def saveTags(self) -> None: if not self.note: return self.note.tags = self.mw.col.tags.split(self.tags.text()) if not self.addMode: self.note.flush() gui_hooks.editor_did_update_tags(self.note)
def saveTags(self) -> None: if not self.note: return tagsTxt = unicodedata.normalize("NFC", self.tags.text()) self.note.tags = self.mw.col.tags.canonify(self.mw.col.tags.split(tagsTxt)) self.tags.setText(self.mw.col.tags.join(self.note.tags).strip()) if not self.addMode: self.note.flush() gui_hooks.editor_did_update_tags(self.note)
def on_tag_focus_lost(self) -> None: self.note.tags = self.mw.col.tags.split(self.tags.text()) gui_hooks.editor_did_update_tags(self.note) if not self.addMode: self._save_current_note()
def onBridgeCmd(self, cmd: str) -> Any: if not self.note: # shutdown return # focus lost or key/button pressed? if cmd.startswith("blur") or cmd.startswith("key"): (type, ord_str, nid_str, txt) = cmd.split(":", 3) ord = int(ord_str) try: nid = int(nid_str) except ValueError: nid = 0 if nid != self.note.id: print("ignored late blur") return try: self.note.fields[ord] = self.mungeHTML(txt) except IndexError: print("ignored late blur after notetype change") return if not self.addMode: self._save_current_note() if type == "blur": self.currentField = None # run any filters if gui_hooks.editor_did_unfocus_field(False, self.note, ord): # something updated the note; update it after a subsequent focus # event has had time to fire self.mw.progress.timer(100, self.loadNoteKeepingFocus, False) else: self._check_and_update_duplicate_display_async() else: gui_hooks.editor_did_fire_typing_timer(self.note) self._check_and_update_duplicate_display_async() # focused into field? elif cmd.startswith("focus"): (type, num) = cmd.split(":", 1) self.last_field_index = self.currentField = int(num) gui_hooks.editor_did_focus_field(self.note, self.currentField) elif cmd.startswith("toggleStickyAll"): model = self.note.note_type() flds = model["flds"] any_sticky = any([fld["sticky"] for fld in flds]) result = [] for fld in flds: if not any_sticky or fld["sticky"]: fld["sticky"] = not fld["sticky"] result.append(fld["sticky"]) update_notetype_legacy( parent=self.mw, notetype=model).run_in_background(initiator=self) return result elif cmd.startswith("toggleSticky"): (type, num) = cmd.split(":", 1) ord = int(num) model = self.note.note_type() fld = model["flds"][ord] new_state = not fld["sticky"] fld["sticky"] = new_state update_notetype_legacy( parent=self.mw, notetype=model).run_in_background(initiator=self) return new_state elif cmd.startswith("lastTextColor"): (_, textColor) = cmd.split(":", 1) self.mw.pm.profile["lastTextColor"] = textColor elif cmd.startswith("lastHighlightColor"): (_, highlightColor) = cmd.split(":", 1) self.mw.pm.profile["lastHighlightColor"] = highlightColor elif cmd.startswith("saveTags"): (type, tagsJson) = cmd.split(":", 1) self.note.tags = json.loads(tagsJson) gui_hooks.editor_did_update_tags(self.note) if not self.addMode: self._save_current_note() elif cmd in self._links: self._links[cmd](self) else: print("uncaught cmd", cmd)