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
rename "widget" type to "content-widget"
zadam012fb1f50bd6
diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.jsindex d1580ab418..46307bbf07 100644--- a/src/public/app/entities/note_short.js+++ b/src/public/app/entities/note_short.js@@ -22,7 +22,8 @@ const NOTE_TYPE_ICONS = {"canvas": "bx bx-pen","web-view": "bx bx-globe-alt","launcher": "bx bx-link",- "doc": "bx bxs-file-doc"+ "doc": "bx bxs-file-doc",+ "content-widget": "bx bxs-widget"};/**diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.jsindex f52f665f8b..090d0be5c1 100644--- a/src/public/app/widgets/note_detail.js+++ b/src/public/app/widgets/note_detail.js@@ -26,7 +26,7 @@ import NoneTypeWidget from "./type_widgets/none.js";import NoteMapTypeWidget from "./type_widgets/note_map.js";import WebViewTypeWidget from "./type_widgets/web_view.js";import DocTypeWidget from "./type_widgets/doc.js";-import WidgetTypeWidget from "./type_widgets/widget.js";+import ContentWidgetTypeWidget from "./type_widgets/widget.js";const TPL = `<div class="note-detail">@@ -61,7 +61,7 @@ const typeWidgetClasses = {'note-map': NoteMapTypeWidget,'web-view': WebViewTypeWidget,'doc': DocTypeWidget,- 'widget': WidgetTypeWidget+ 'content-widget': ContentWidgetTypeWidget};export default class NoteDetailWidget extends NoteContextAwareWidget {@@ -130,6 +130,10 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {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);diff --git a/src/public/app/widgets/note_type.js b/src/public/app/widgets/note_type.jsindex 6cbd9667d0..f40a193105 100644--- a/src/public/app/widgets/note_type.js+++ b/src/public/app/widgets/note_type.js@@ -10,7 +10,7 @@ const NOTE_TYPES = [{ type: "note-map", mime: '', title: "Note Map", selectable: false },{ type: "launcher", mime: '', title: "Launcher", selectable: false },{ type: "doc", mime: '', title: "Doc", selectable: false },- { type: "widget", mime: '', title: "Widget", selectable: false },+ { type: "content-widget", mime: '', title: "Widget", selectable: false },{ type: "text", mime: "text/html", title: "Text", selectable: true },{ type: "relation-map", mime: "application/json", title: "Relation Map", selectable: true },diff --git a/src/public/app/widgets/type_widgets/widget.js b/src/public/app/widgets/type_widgets/widget.jsindex 88c0b15c8b..9cac124380 100644--- a/src/public/app/widgets/type_widgets/widget.js+++ b/src/public/app/widgets/type_widgets/widget.js@@ -2,8 +2,8 @@ import TypeWidget from "./type_widget.js";const TPL = `<div class="note-detail-widget note-detail-printable"></div>`;-export default class WidgetTypeWidget extends TypeWidget {- static getType() { return "widget"; }+export default class ContentWidgetTypeWidget extends TypeWidget {+ static getType() { return "content-widget"; }doRender() {this.$widget = $(TPL);@@ -12,12 +12,12 @@ export default class WidgetTypeWidget extends TypeWidget {}async doRefresh(note) {- const widgetName = note.getLabelValue('widget');+ const contentWidget = note.getLabelValue('contentWidget');- if (widgetName === 'optionsAppearance') {+ if (contentWidget === 'optionsAppearance') {this.$widget.empty().append("HI!");} else {- this.$widget.empty().append(`Unknown widget of type "${widgetName}"`);+ this.$widget.empty().append(`Unknown widget of type "${contentWidget}"`);}}}diff --git a/src/services/note_types.js b/src/services/note_types.jsindex 2f52f21106..ef20b95d5a 100644--- a/src/services/note_types.js+++ b/src/services/note_types.js@@ -13,5 +13,5 @@ module.exports = ['web-view','launcher','doc',- 'widget'+ 'content-widget'];diff --git a/src/services/special_notes.js b/src/services/special_notes.jsindex f285c58474..15bf85cdbc 100644--- a/src/services/special_notes.js+++ b/src/services/special_notes.js@@ -593,12 +593,12 @@ function createOptionNotes() {branchId: OPTIONS_APPEARANCE,noteId: OPTIONS_APPEARANCE,title: 'Appearance',- type: 'widget',+ type: 'content-widget',content: '',parentNoteId: OPTIONS_ROOT}).note;- note.addLabel('widget', 'optionsAppearance');+ note.addLabel('contentWidget', 'optionsAppearance');}}