mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
appearance options as a special note
This commit is contained in:
parent
74fdaad032
commit
aec2c2d5cd
@ -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');
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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 {
|
||||
|
@ -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 },
|
||||
|
23
src/public/app/widgets/type_widgets/widget.js
Normal file
23
src/public/app/widgets/type_widgets/widget.js
Normal file
@ -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}"`);
|
||||
}
|
||||
}
|
||||
}
|
@ -12,5 +12,6 @@ module.exports = [
|
||||
'canvas',
|
||||
'web-view',
|
||||
'launcher',
|
||||
'doc'
|
||||
'doc',
|
||||
'widget'
|
||||
];
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user