Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
refactor(react/type_widgets): bring back cut to note
Elian Doran156b4101a545
diff --git a/apps/client/src/widgets/note_detail.ts.bak b/apps/client/src/widgets/note_detail.ts.bakindex ae01997be8..2dabdf8df0 100644--- a/apps/client/src/widgets/note_detail.ts.bak+++ b/apps/client/src/widgets/note_detail.ts.bak@@ -13,49 +13,6 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {appContext.addBeforeUnloadListener(this);}- isEnabled() {- return true;- }-- async refresh() {- this.type = await this.getWidgetType();- this.mime = this.note?.mime;-- if (!(this.type in this.typeWidgets)) {- const clazz = typeWidgetClasses[this.type];-- if (!clazz) {- throw new Error(`Cannot find type widget for type '${this.type}'`);- }-- const typeWidget = (this.typeWidgets[this.type] = new clazz());- typeWidget.spacedUpdate = this.spacedUpdate;- typeWidget.setParent(this);-- if (this.noteContext) {- typeWidget.setNoteContextEvent({ noteContext: this.noteContext });- }- const $renderedWidget = typeWidget.render();- keyboardActionsService.updateDisplayedShortcuts($renderedWidget);-- this.$widget.append($renderedWidget);-- if (this.noteContext) {- await typeWidget.handleEvent("setNoteContext", { noteContext: this.noteContext });- }-- // this is happening in update(), so note has been already set, and we need to reflect this- if (this.noteContext) {- await typeWidget.handleEvent("noteSwitched", {- noteContext: this.noteContext,- notePath: this.noteContext.notePath- });- }-- this.child(typeWidget);- }- }-/*** sets full height of container that contains note content for a subset of note-types*/@@ -109,12 +66,6 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {landscape: this.note.hasAttribute("label", "printLandscape")});}-- hoistedNoteChangedEvent({ ntxId }: EventData<"hoistedNoteChanged">) {- if (this.isNoteContext(ntxId)) {- this.refresh();- }- }beforeUnloadEvent() {return this.spacedUpdate.isAllSavedAndTriggerUpdate();@@ -136,29 +87,6 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {callback(this);}- async cutIntoNoteCommand() {- const note = appContext.tabManager.getActiveContextNote();-- if (!note) {- return;- }-- // without await as this otherwise causes deadlock through component mutex- const parentNotePath = appContext.tabManager.getActiveContextNotePath();- if (this.noteContext && parentNotePath) {- noteCreateService.createNote(parentNotePath, {- isProtected: note.isProtected,- saveSelection: true,- textEditor: await this.noteContext.getTextEditor()- });- }- }-- // used by cutToNote in CKEditor build- async saveNoteDetailNowCommand() {- await this.spacedUpdate.updateNowIfNecessary();- }-renderActiveNoteEvent() {if (this.noteContext?.isActive()) {this.refresh();diff --git a/apps/client/src/widgets/type_widgets/text/EditableText.tsx b/apps/client/src/widgets/type_widgets/text/EditableText.tsxindex f3209c0112..a4c1c0087b 100644--- a/apps/client/src/widgets/type_widgets/text/EditableText.tsx+++ b/apps/client/src/widgets/type_widgets/text/EditableText.tsx@@ -137,6 +137,24 @@ export default function EditableText({ note, parentComponent, ntxId, noteContext} else {window.open(selectedLinkUrl, "_blank");}+ },+ async cutIntoNoteCommand() {+ const note = appContext.tabManager.getActiveContextNote();+ if (!note) return;++ // without await as this otherwise causes deadlock through component mutex+ const parentNotePath = appContext.tabManager.getActiveContextNotePath();+ if (noteContext && parentNotePath) {+ note_create.createNote(parentNotePath, {+ isProtected: note.isProtected,+ saveSelection: true,+ textEditor: await noteContext?.getTextEditor()+ });+ }+ },+ async saveNoteDetailNowCommand() {+ // used by cutToNote in CKEditor build+ spacedUpdate.updateNowIfNecessary();}});