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
appearance options as a special note
zadamaec2c2d5cdce
diff --git a/src/public/app/components/root_command_executor.js b/src/public/app/components/root_command_executor.jsindex 0e96e70c57..6eca67a08b 100644--- a/src/public/app/components/root_command_executor.js+++ b/src/public/app/components/root_command_executor.js@@ -83,4 +83,8 @@ export default class RootCommandExecutor extends Component {async showHiddenSubtreeCommand() {await appContext.tabManager.openContextWithNote('hidden', true, null, 'hidden');}++ async showOptionsInHiddenCommand() {+ await appContext.tabManager.openContextWithNote('opt_root', true, null, 'opt_root');+ }}diff --git a/src/public/app/widgets/buttons/global_menu.js b/src/public/app/widgets/buttons/global_menu.jsindex 80ddaabf9d..a62caa9514 100644--- a/src/public/app/widgets/buttons/global_menu.js+++ b/src/public/app/widgets/buttons/global_menu.js@@ -83,10 +83,15 @@ const TPL = `</button><ul class="dropdown-menu dropdown-menu-right">- <li class="dropdown-item options-button" data-trigger-command="showOptions">+ <li class="dropdown-item" data-trigger-command="showOptions"><span class="bx bx-slider"></span>Options</li>++ <li class="dropdown-item" data-trigger-command="showOptionsInHidden">+ <span class="bx bx-slider"></span>+ Options in hidden+ </li><li class="dropdown-item" data-trigger-command="openNewWindow"><span class="bx bx-window-open"></span>diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.jsindex ff45fe55ab..f52f665f8b 100644--- a/src/public/app/widgets/note_detail.js+++ b/src/public/app/widgets/note_detail.js@@ -26,6 +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";const TPL = `<div class="note-detail">@@ -59,7 +60,8 @@ const typeWidgetClasses = {'book': BookTypeWidget,'note-map': NoteMapTypeWidget,'web-view': WebViewTypeWidget,- 'doc': DocTypeWidget+ 'doc': DocTypeWidget,+ 'widget': WidgetTypeWidget};export default class NoteDetailWidget extends NoteContextAwareWidget {diff --git a/src/public/app/widgets/note_type.js b/src/public/app/widgets/note_type.jsindex 1cbf6777bb..6cbd9667d0 100644--- a/src/public/app/widgets/note_type.js+++ b/src/public/app/widgets/note_type.js@@ -10,6 +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: "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.jsnew file mode 100644index 0000000000..88c0b15c8b--- /dev/null+++ b/src/public/app/widgets/type_widgets/widget.js@@ -0,0 +1,23 @@+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"; }++ doRender() {+ this.$widget = $(TPL);++ super.doRender();+ }++ async doRefresh(note) {+ const widgetName = note.getLabelValue('widget');++ if (widgetName === 'optionsAppearance') {+ this.$widget.empty().append("HI!");+ } else {+ this.$widget.empty().append(`Unknown widget of type "${widgetName}"`);+ }+ }+}diff --git a/src/services/note_types.js b/src/services/note_types.jsindex c057ca30ef..2f52f21106 100644--- a/src/services/note_types.js+++ b/src/services/note_types.js@@ -12,5 +12,6 @@ module.exports = ['canvas','web-view','launcher',- 'doc'+ 'doc',+ 'widget'];diff --git a/src/services/special_notes.js b/src/services/special_notes.jsindex 8fd8fbfa55..f285c58474 100644--- a/src/services/special_notes.js+++ b/src/services/special_notes.js@@ -58,10 +58,6 @@ function getHiddenRoot() {hidden.addLabel('iconClass', "bx bx-chip", false);}- if (!hidden.hasOwnedLabel("docName")) {- hidden.addLabel("docName", "hidden");- }-const MAX_POS = 999_999_999;const branch = hidden.getBranches()[0];@@ -349,16 +345,7 @@ const launchers = [{ id: 'lb_forwardinhistory', builtinWidget: 'forwardInHistoryButton', title: 'Forward in history', icon: 'bx bxs-right-arrow-square', isVisible: false },];-function createMissingSpecialNotes() {- getSqlConsoleRoot();- getGlobalNoteMap();- getBulkActionNote();- createLauncherTemplates();- getLaunchBarRoot();- getLaunchBarAvailableLaunchersRoot();- getLaunchBarVisibleLaunchersRoot();- getShareRoot();-+function createLaunchers() {for (const launcher of launchers) {let note = becca.getNote(launcher.id);@@ -402,14 +389,6 @@ function createMissingSpecialNotes() {throw new Error(`No action defined for launcher ${JSON.stringify(launcher)}`);}}-- // share root is not automatically created since it's visible in the tree and many won't need it/use it-- const hidden = getHiddenRoot();-- if (!hidden.hasOwnedLabel('excludeFromNoteMap')) {- hidden.addLabel('excludeFromNoteMap', "", true);- }}function createLauncher(parentNoteId, launcherType) {@@ -461,6 +440,18 @@ function createLauncher(parentNoteId, launcherType) {};}+function initHiddenRoot() {+ const hidden = getHiddenRoot();++ if (!hidden.hasOwnedLabel("docName")) {+ hidden.addLabel("docName", "hidden");+ }++ if (!hidden.hasOwnedLabel('excludeFromNoteMap')) {+ hidden.addLabel('excludeFromNoteMap', "", true);+ }+}+function createLauncherTemplates() {if (!(LBTPL_ROOT in becca.notes)) {noteService.createNewNote({@@ -582,6 +573,49 @@ function createLauncherTemplates() {}}+const OPTIONS_ROOT = "opt_root";+const OPTIONS_APPEARANCE = "opt_appearance";++function createOptionNotes() {+ if (!(OPTIONS_ROOT in becca.notes)) {+ noteService.createNewNote({+ branchId: OPTIONS_ROOT,+ noteId: OPTIONS_ROOT,+ title: 'Options',+ type: 'doc',+ content: '',+ parentNoteId: getHiddenRoot().noteId+ });+ }++ if (!(OPTIONS_APPEARANCE in becca.notes)) {+ const note = noteService.createNewNote({+ branchId: OPTIONS_APPEARANCE,+ noteId: OPTIONS_APPEARANCE,+ title: 'Appearance',+ type: 'widget',+ content: '',+ parentNoteId: OPTIONS_ROOT+ }).note;++ note.addLabel('widget', 'optionsAppearance');+ }+}++function createMissingSpecialNotes() {+ initHiddenRoot();+ getSqlConsoleRoot();+ getGlobalNoteMap();+ getBulkActionNote();+ createLauncherTemplates();+ getLaunchBarRoot();+ getLaunchBarAvailableLaunchersRoot();+ getLaunchBarVisibleLaunchersRoot();+ createLaunchers();+ createOptionNotes();+ getShareRoot();+}+function resetLauncher(noteId) {if (noteId.startsWith('lb_')) {const note = becca.getNote(noteId);