mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
improvements
This commit is contained in:
parent
b9632a7814
commit
5fc9f5f3f9
@ -8,7 +8,7 @@ module.exports = () => {
|
|||||||
beccaLoader.load();
|
beccaLoader.load();
|
||||||
|
|
||||||
for (const attr of becca.findAttributes('label','bookmarked')) {
|
for (const attr of becca.findAttributes('label','bookmarked')) {
|
||||||
cloningService.toggleNoteInParent(true, attr.noteId, 'lb_bookmarks');
|
cloningService.toggleNoteInParent(true, attr.noteId, 'lbBookmarks');
|
||||||
|
|
||||||
attr.markAsDeleted("0204__migrate_bookmarks_to_clones");
|
attr.markAsDeleted("0204__migrate_bookmarks_to_clones");
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,10 @@ UPDATE branches SET branchId = 'globalNoteMap' WHERE branchId = 'globalnotemap';
|
|||||||
UPDATE branches SET branchId = 'bulkAction' WHERE branchId = 'bulkaction';
|
UPDATE branches SET branchId = 'bulkAction' WHERE branchId = 'bulkaction';
|
||||||
UPDATE branches SET branchId = 'sqlConsole' WHERE branchId = 'sqlconsole';
|
UPDATE branches SET branchId = 'sqlConsole' WHERE branchId = 'sqlconsole';
|
||||||
|
|
||||||
|
UPDATE branches SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap';
|
||||||
|
UPDATE branches SET noteId = 'bulkAction' WHERE noteId = 'bulkaction';
|
||||||
|
UPDATE branches SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole';
|
||||||
|
|
||||||
UPDATE branches SET parentNoteId = 'globalNoteMap' WHERE parentNoteId = 'globalnotemap';
|
UPDATE branches SET parentNoteId = 'globalNoteMap' WHERE parentNoteId = 'globalnotemap';
|
||||||
UPDATE branches SET parentNoteId = 'bulkAction' WHERE parentNoteId = 'bulkaction';
|
UPDATE branches SET parentNoteId = 'bulkAction' WHERE parentNoteId = 'bulkaction';
|
||||||
UPDATE branches SET parentNoteId = 'sqlConsole' WHERE parentNoteId = 'sqlconsole';
|
UPDATE branches SET parentNoteId = 'sqlConsole' WHERE parentNoteId = 'sqlconsole';
|
||||||
@ -13,3 +17,11 @@ UPDATE branches SET parentNoteId = 'sqlConsole' WHERE parentNoteId = 'sqlconsole
|
|||||||
UPDATE attributes SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap';
|
UPDATE attributes SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap';
|
||||||
UPDATE attributes SET noteId = 'bulkAction' WHERE noteId = 'bulkaction';
|
UPDATE attributes SET noteId = 'bulkAction' WHERE noteId = 'bulkaction';
|
||||||
UPDATE attributes SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole';
|
UPDATE attributes SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole';
|
||||||
|
|
||||||
|
UPDATE attributes SET value = 'globalNoteMap' WHERE type = 'relation' AND value = 'globalnotemap';
|
||||||
|
UPDATE attributes SET value = 'bulkAction' WHERE type = 'relation' AND value = 'bulkaction';
|
||||||
|
UPDATE attributes SET value = 'sqlConsole' WHERE type = 'relation' AND value = 'sqlconsole';
|
||||||
|
|
||||||
|
UPDATE entity_changes SET entityId = 'globalNoteMap' WHERE entityId = 'globalnotemap';
|
||||||
|
UPDATE entity_changes SET entityId = 'bulkAction' WHERE entityId = 'bulkaction';
|
||||||
|
UPDATE entity_changes SET entityId = 'sqlConsole' WHERE entityId = 'sqlconsole';
|
||||||
|
@ -129,7 +129,7 @@ class Branch extends AbstractEntity {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
get isWeak() {
|
get isWeak() {
|
||||||
return ['share', 'lb_bookmarks'].includes(this.parentNoteId);
|
return ['share', 'lbBookmarks'].includes(this.parentNoteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1328,6 +1328,10 @@ class Note extends AbstractEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isLaunchBarConfig() {
|
||||||
|
return this.type === 'launcher' || ['lbRoot', 'lbAvailableShortcuts', 'lbVisibleShortcuts'];
|
||||||
|
}
|
||||||
|
|
||||||
get isDeleted() {
|
get isDeleted() {
|
||||||
return !(this.noteId in this.becca.notes) || this.isBeingDeleted;
|
return !(this.noteId in this.becca.notes) || this.isBeingDeleted;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ export default class RootCommandExecutor extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async showLaunchBarSubtreeCommand() {
|
async showLaunchBarSubtreeCommand() {
|
||||||
await appContext.tabManager.openContextWithNote('lb_root', true, null, 'lb_root');
|
await appContext.tabManager.openContextWithNote('lbRoot', true, null, 'lbRoot');
|
||||||
}
|
}
|
||||||
|
|
||||||
async showShareSubtreeCommand() {
|
async showShareSubtreeCommand() {
|
||||||
|
@ -828,7 +828,7 @@ class NoteShort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isLaunchBarConfig() {
|
isLaunchBarConfig() {
|
||||||
return this.type === 'launcher' || this.noteId.startsWith("lb_");
|
return this.type === 'launcher' || ['lbRoot', 'lbAvailableShortcuts', 'lbVisibleShortcuts'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,13 +27,13 @@ export default class LauncherContextMenu {
|
|||||||
const note = await froca.getNote(this.node.data.noteId);
|
const note = await froca.getNote(this.node.data.noteId);
|
||||||
const parentNoteId = this.node.getParent().data.noteId;
|
const parentNoteId = this.node.getParent().data.noteId;
|
||||||
|
|
||||||
const isVisibleRoot = note.noteId === 'lb_visiblelaunchers';
|
const isVisibleRoot = note.noteId === 'lbVisibleLaunchers';
|
||||||
const isAvailableRoot = note.noteId === 'lb_availablelaunchers';
|
const isAvailableRoot = note.noteId === 'lbAvailableLaunchers';
|
||||||
const isVisibleItem = parentNoteId === 'lb_visiblelaunchers';
|
const isVisibleItem = parentNoteId === 'lbVisibleLaunchers';
|
||||||
const isAvailableItem = parentNoteId === 'lb_availablelaunchers';
|
const isAvailableItem = parentNoteId === 'lbAvailableLaunchers';
|
||||||
const isItem = isVisibleItem || isAvailableItem;
|
const isItem = isVisibleItem || isAvailableItem;
|
||||||
const canBeDeleted = !note.noteId.startsWith("lb_");
|
const canBeDeleted = !note.isLaunchBarConfig();
|
||||||
const canBeReset = note.noteId.startsWith("lb_");
|
const canBeReset = note.isLaunchBarConfig();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
(isVisibleRoot || isAvailableRoot) ? { title: 'Add a note launcher', command: 'addNoteLauncher', uiIcon: "bx bx-plus" } : null,
|
(isVisibleRoot || isAvailableRoot) ? { title: 'Add a note launcher', command: 'addNoteLauncher', uiIcon: "bx bx-plus" } : null,
|
||||||
|
@ -10,7 +10,7 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) {
|
|||||||
branchIdsToMove = filterRootNote(branchIdsToMove);
|
branchIdsToMove = filterRootNote(branchIdsToMove);
|
||||||
branchIdsToMove = filterSearchBranches(branchIdsToMove);
|
branchIdsToMove = filterSearchBranches(branchIdsToMove);
|
||||||
|
|
||||||
if (['root', 'lb_root', 'lb_availablelaunchers', 'lb_visiblelaunchers'].includes(beforeBranchId)) {
|
if (['root', 'lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(beforeBranchId)) {
|
||||||
toastService.showError('Cannot move notes here.');
|
toastService.showError('Cannot move notes here.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -34,9 +34,9 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) {
|
|||||||
const forbiddenNoteIds = [
|
const forbiddenNoteIds = [
|
||||||
'root',
|
'root',
|
||||||
hoistedNoteService.getHoistedNoteId(),
|
hoistedNoteService.getHoistedNoteId(),
|
||||||
'lb_root',
|
'lbRoot',
|
||||||
'lb_availablelaunchers',
|
'lbAvailableLaunchers',
|
||||||
'lb_visiblelaunchers'
|
'lbVisibleLaunchers'
|
||||||
];
|
];
|
||||||
|
|
||||||
if (forbiddenNoteIds.includes(afterNote.noteId)) {
|
if (forbiddenNoteIds.includes(afterNote.noteId)) {
|
||||||
@ -57,7 +57,7 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function moveToParentNote(branchIdsToMove, newParentBranchId) {
|
async function moveToParentNote(branchIdsToMove, newParentBranchId) {
|
||||||
if (newParentBranchId === 'lb_root') {
|
if (newParentBranchId === 'lbRoot') {
|
||||||
toastService.showError('Cannot move notes here.');
|
toastService.showError('Cannot move notes here.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ export default class BookmarkButtons extends FlexContainer {
|
|||||||
this.children = [];
|
this.children = [];
|
||||||
this.noteIds = [];
|
this.noteIds = [];
|
||||||
|
|
||||||
const bookmarkParentNote = await froca.getNote('lb_bookmarks');
|
const bookmarkParentNote = await froca.getNote('lbBookmarks');
|
||||||
|
|
||||||
for (const note of await bookmarkParentNote.getChildNotes()) {
|
for (const note of await bookmarkParentNote.getChildNotes()) {
|
||||||
this.noteIds.push(note.noteId);
|
this.noteIds.push(note.noteId);
|
||||||
@ -37,7 +37,7 @@ export default class BookmarkButtons extends FlexContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entitiesReloadedEvent({loadResults}) {
|
entitiesReloadedEvent({loadResults}) {
|
||||||
if (loadResults.getBranches().find(branch => branch.parentNoteId === 'lb_bookmarks')) {
|
if (loadResults.getBranches().find(branch => branch.parentNoteId === 'lbBookmarks')) {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ export default class BookmarkSwitchWidget extends SwitchWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async toggle(state) {
|
async toggle(state) {
|
||||||
const resp = await server.put(`notes/${this.noteId}/toggle-in-parent/lb_bookmarks/` + !!state);
|
const resp = await server.put(`notes/${this.noteId}/toggle-in-parent/lbBookmarks/` + !!state);
|
||||||
|
|
||||||
if (!resp.success) {
|
if (!resp.success) {
|
||||||
toastService.showError(resp.message);
|
toastService.showError(resp.message);
|
||||||
@ -28,7 +28,7 @@ export default class BookmarkSwitchWidget extends SwitchWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refreshWithNote(note) {
|
refreshWithNote(note) {
|
||||||
const isBookmarked = !!note.getParentBranches().find(b => b.parentNoteId === 'lb_bookmarks');
|
const isBookmarked = !!note.getParentBranches().find(b => b.parentNoteId === 'lbBookmarks');
|
||||||
|
|
||||||
this.$switchOn.toggle(!isBookmarked);
|
this.$switchOn.toggle(!isBookmarked);
|
||||||
this.$switchOff.toggle(isBookmarked);
|
this.$switchOff.toggle(isBookmarked);
|
||||||
|
@ -8,7 +8,7 @@ export default class BackInHistoryButtonWidget extends AbstractHistoryNavigation
|
|||||||
.title("Go to previous note.")
|
.title("Go to previous note.")
|
||||||
.command("backInNoteHistory")
|
.command("backInNoteHistory")
|
||||||
.titlePlacement("right")
|
.titlePlacement("right")
|
||||||
.buttonNoteIdProvider(() => 'lb_backinhistory')
|
.buttonNoteIdProvider(() => 'lbBackInHistory')
|
||||||
.onContextMenu(e => this.showContextMenu(e));
|
.onContextMenu(e => this.showContextMenu(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ export default class ForwardInHistoryButtonWidget extends AbstractHistoryNavigat
|
|||||||
.title("Go to next note.")
|
.title("Go to next note.")
|
||||||
.command("forwardInNoteHistory")
|
.command("forwardInNoteHistory")
|
||||||
.titlePlacement("right")
|
.titlePlacement("right")
|
||||||
.buttonNoteIdProvider(() => 'lb_forwardinhistory')
|
.buttonNoteIdProvider(() => 'lbForwardInHistory')
|
||||||
.onContextMenu(e => this.showContextMenu(e));
|
.onContextMenu(e => this.showContextMenu(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ const TPL = `
|
|||||||
|
|
||||||
export default class NoteActionsWidget extends NoteContextAwareWidget {
|
export default class NoteActionsWidget extends NoteContextAwareWidget {
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
return !this.note?.isLaunchBarConfig();
|
return this.note?.type !== 'launcher';
|
||||||
}
|
}
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
|
@ -17,7 +17,7 @@ export default class LauncherContainer extends FlexContainer {
|
|||||||
async load() {
|
async load() {
|
||||||
this.children = [];
|
this.children = [];
|
||||||
|
|
||||||
const visibleLaunchersRoot = await froca.getNote('lb_visiblelaunchers', true);
|
const visibleLaunchersRoot = await froca.getNote('lbVisibleLaunchers', true);
|
||||||
|
|
||||||
if (!visibleLaunchersRoot) {
|
if (!visibleLaunchersRoot) {
|
||||||
console.log("Visible launchers root note doesn't exist.");
|
console.log("Visible launchers root note doesn't exist.");
|
||||||
@ -61,7 +61,7 @@ export default class LauncherContainer extends FlexContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entitiesReloadedEvent({loadResults}) {
|
entitiesReloadedEvent({loadResults}) {
|
||||||
if (loadResults.getBranches().find(branch => branch.parentNoteId.startsWith("lb_"))) {
|
if (loadResults.getBranches().find(branch => froca.getNoteFromCache(branch.parentNoteId)?.isLaunchBarConfig())) {
|
||||||
// changes in note placement requires reload of all launchers, all other changes are handled by individual
|
// changes in note placement requires reload of all launchers, all other changes are handled by individual
|
||||||
// launchers
|
// launchers
|
||||||
this.load();
|
this.load();
|
||||||
|
@ -58,7 +58,7 @@ const typeWidgetClasses = {
|
|||||||
'canvas': CanvasTypeWidget,
|
'canvas': CanvasTypeWidget,
|
||||||
'protectedSession': ProtectedSessionTypeWidget,
|
'protectedSession': ProtectedSessionTypeWidget,
|
||||||
'book': BookTypeWidget,
|
'book': BookTypeWidget,
|
||||||
'note-map': NoteMapTypeWidget,
|
'noteMap': NoteMapTypeWidget,
|
||||||
'webView': WebViewTypeWidget,
|
'webView': WebViewTypeWidget,
|
||||||
'doc': DocTypeWidget,
|
'doc': DocTypeWidget,
|
||||||
'contentWidget': ContentWidgetTypeWidget
|
'contentWidget': ContentWidgetTypeWidget
|
||||||
|
@ -73,7 +73,7 @@ export default class NoteTitleWidget extends NoteContextAwareWidget {
|
|||||||
this.$noteTitle.val(note.title);
|
this.$noteTitle.val(note.title);
|
||||||
|
|
||||||
this.$noteTitle.prop("readonly", (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable())
|
this.$noteTitle.prop("readonly", (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable())
|
||||||
|| ["lb_root", "lb_availablelaunchers", "lb_visiblelaunchers"].includes(note.noteId));
|
|| ["lbRoot", "lbAvailableLaunchers", "lbVisibleLaunchers"].includes(note.noteId));
|
||||||
|
|
||||||
this.setProtectedStatus(note);
|
this.setProtectedStatus(note);
|
||||||
}
|
}
|
||||||
|
@ -398,7 +398,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
autoExpandMS: 600,
|
autoExpandMS: 600,
|
||||||
preventLazyParents: false,
|
preventLazyParents: false,
|
||||||
dragStart: (node, data) => {
|
dragStart: (node, data) => {
|
||||||
if (['root', 'hidden', 'lb_root', 'lb_availablelaunchers', 'lb_visiblelaunchers'].includes(node.data.noteId)) {
|
if (['root', 'hidden', 'lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(node.data.noteId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +426,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
dragEnter: (node, data) => {
|
dragEnter: (node, data) => {
|
||||||
if (node.data.noteType === 'search') {
|
if (node.data.noteType === 'search') {
|
||||||
return false;
|
return false;
|
||||||
} else if (node.data.noteId === 'lb_root') {
|
} else if (node.data.noteId === 'lbRoot') {
|
||||||
return false;
|
return false;
|
||||||
} else if (node.data.noteType === 'launcher') {
|
} else if (node.data.noteType === 'launcher') {
|
||||||
return ['before', 'after'];
|
return ['before', 'after'];
|
||||||
@ -604,7 +604,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
this.$tree.on('contextmenu', '.fancytree-node', e => {
|
this.$tree.on('contextmenu', '.fancytree-node', e => {
|
||||||
const node = $.ui.fancytree.getNode(e);
|
const node = $.ui.fancytree.getNode(e);
|
||||||
|
|
||||||
if (hoistedNoteService.getHoistedNoteId() === 'lb_root') {
|
if (hoistedNoteService.getHoistedNoteId() === 'lbRoot') {
|
||||||
import("../menus/launcher_context_menu.js").then(({LauncherContextMenu: ShortcutContextMenu}) => {
|
import("../menus/launcher_context_menu.js").then(({LauncherContextMenu: ShortcutContextMenu}) => {
|
||||||
const shortcutContextMenu = new LauncherContextMenu(this, node);
|
const shortcutContextMenu = new LauncherContextMenu(this, node);
|
||||||
shortcutContextMenu.show(e);
|
shortcutContextMenu.show(e);
|
||||||
@ -744,7 +744,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
.map(noteId => froca.notes[noteId])
|
.map(noteId => froca.notes[noteId])
|
||||||
.filter(note => !!note)
|
.filter(note => !!note)
|
||||||
.filter(note =>
|
.filter(note =>
|
||||||
!['share', 'lb_bookmarks'].includes(note.noteId)
|
!['share', 'lbBookmarks'].includes(note.noteId)
|
||||||
&& note.type !== 'search');
|
&& note.type !== 'search');
|
||||||
|
|
||||||
if (realClones.length > 1) {
|
if (realClones.length > 1) {
|
||||||
@ -1554,11 +1554,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
moveShortcutToVisibleCommand({node, selectedOrActiveBranchIds}) {
|
moveShortcutToVisibleCommand({node, selectedOrActiveBranchIds}) {
|
||||||
branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_visiblelaunchers');
|
branchService.moveToParentNote(selectedOrActiveBranchIds, 'lbVisibleLaunchers');
|
||||||
}
|
}
|
||||||
|
|
||||||
moveShortcutToAvailableCommand({node, selectedOrActiveBranchIds}) {
|
moveShortcutToAvailableCommand({node, selectedOrActiveBranchIds}) {
|
||||||
branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_availablelaunchers');
|
branchService.moveToParentNote(selectedOrActiveBranchIds, 'lbAvailableLaunchers');
|
||||||
}
|
}
|
||||||
|
|
||||||
addNoteLauncherCommand({node}) {
|
addNoteLauncherCommand({node}) {
|
||||||
|
@ -47,7 +47,7 @@ export default class OwnedAttributeListWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
getTitle() {
|
getTitle() {
|
||||||
return {
|
return {
|
||||||
show: true,//!this.note.isLaunchBarConfig(),
|
show: !this.note.isLaunchBarConfig(),
|
||||||
title: "Owned attributes",
|
title: "Owned attributes",
|
||||||
icon: "bx bx-list-check"
|
icon: "bx bx-list-check"
|
||||||
};
|
};
|
||||||
|
@ -162,8 +162,6 @@ eventService.subscribe(eventService.ENTITY_CHANGED, ({ entityName, entity }) =>
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const debouncedCreateMissingSpecialNotes = debounce(() => specialNotesService.createMissingSpecialNotes(), 300);
|
|
||||||
|
|
||||||
eventService.subscribe(eventService.ENTITY_DELETED, ({ entityName, entity }) => {
|
eventService.subscribe(eventService.ENTITY_DELETED, ({ entityName, entity }) => {
|
||||||
processInverseRelations(entityName, entity, (definition, note, targetNote) => {
|
processInverseRelations(entityName, entity, (definition, note, targetNote) => {
|
||||||
// if one inverse attribute is deleted then the other should be deleted as well
|
// if one inverse attribute is deleted then the other should be deleted as well
|
||||||
@ -179,13 +177,6 @@ eventService.subscribe(eventService.ENTITY_DELETED, ({ entityName, entity }) =>
|
|||||||
if (entityName === 'branches') {
|
if (entityName === 'branches') {
|
||||||
runAttachedRelations(entity.getNote(), 'runOnBranchDeletion', entity);
|
runAttachedRelations(entity.getNote(), 'runOnBranchDeletion', entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entityName === 'notes') {
|
|
||||||
if (entity.noteId.startsWith("lb_")) {
|
|
||||||
// if user deletes shortcuts, restore them immediately
|
|
||||||
debouncedCreateMissingSpecialNotes();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -114,11 +114,11 @@ function getAndValidateParent(params) {
|
|||||||
throw new Error(`Launchers should not have child notes.`);
|
throw new Error(`Launchers should not have child notes.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!params.ignoreForbiddenParents && ['lb_root'].includes(parentNote.noteId)) {
|
if (!params.ignoreForbiddenParents && ['lbRoot'].includes(parentNote.noteId)) {
|
||||||
throw new Error(`Creating child notes into '${parentNote.noteId}' is not allowed.`);
|
throw new Error(`Creating child notes into '${parentNote.noteId}' is not allowed.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (['lb_availablelaunchers', 'lb_visiblelaunchers'].includes(parentNote.noteId) && params.type !== 'launcher') {
|
if (['lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(parentNote.noteId) && params.type !== 'launcher') {
|
||||||
throw new Error(`Creating child notes into '${parentNote.noteId}' is only possible for type 'launcher'.`);
|
throw new Error(`Creating child notes into '${parentNote.noteId}' is only possible for type 'launcher'.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ const becca = require("../becca/becca");
|
|||||||
const noteService = require("./notes");
|
const noteService = require("./notes");
|
||||||
const cls = require("./cls");
|
const cls = require("./cls");
|
||||||
const dateUtils = require("./date_utils");
|
const dateUtils = require("./date_utils");
|
||||||
|
const log = require("./log.js");
|
||||||
|
|
||||||
const LBTPL_ROOT = "lbtpl_root";
|
const LBTPL_ROOT = "lbtpl_root";
|
||||||
const LBTPL_BASE = "lbtpl_base";
|
const LBTPL_BASE = "lbtpl_base";
|
||||||
@ -253,12 +254,12 @@ function getBulkActionNote() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLaunchBarRoot() {
|
function getLaunchBarRoot() {
|
||||||
let note = becca.getNote('lb_root');
|
let note = becca.getNote('lbRoot');
|
||||||
|
|
||||||
if (!note) {
|
if (!note) {
|
||||||
note = noteService.createNewNote({
|
note = noteService.createNewNote({
|
||||||
branchId: 'lb_root',
|
branchId: 'lbRoot',
|
||||||
noteId: 'lb_root',
|
noteId: 'lbRoot',
|
||||||
title: 'Launch bar',
|
title: 'Launch bar',
|
||||||
type: 'doc',
|
type: 'doc',
|
||||||
content: '',
|
content: '',
|
||||||
@ -273,12 +274,12 @@ function getLaunchBarRoot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLaunchBarAvailableLaunchersRoot() {
|
function getLaunchBarAvailableLaunchersRoot() {
|
||||||
let note = becca.getNote('lb_availablelaunchers');
|
let note = becca.getNote('lbAvailableLaunchers');
|
||||||
|
|
||||||
if (!note) {
|
if (!note) {
|
||||||
note = noteService.createNewNote({
|
note = noteService.createNewNote({
|
||||||
branchId: 'lb_availablelaunchers',
|
branchId: 'lbAvailableLaunchers',
|
||||||
noteId: 'lb_availablelaunchers',
|
noteId: 'lbAvailableLaunchers',
|
||||||
title: 'Available launchers',
|
title: 'Available launchers',
|
||||||
type: 'doc',
|
type: 'doc',
|
||||||
content: '',
|
content: '',
|
||||||
@ -290,7 +291,7 @@ function getLaunchBarAvailableLaunchersRoot() {
|
|||||||
note.addLabel("docName", "launchbar_intro");
|
note.addLabel("docName", "launchbar_intro");
|
||||||
}
|
}
|
||||||
|
|
||||||
const branch = becca.getBranch('lb_availablelaunchers');
|
const branch = becca.getBranch('lbAvailableLaunchers');
|
||||||
if (!branch.isExpanded) {
|
if (!branch.isExpanded) {
|
||||||
branch.isExpanded = true;
|
branch.isExpanded = true;
|
||||||
branch.save();
|
branch.save();
|
||||||
@ -300,12 +301,12 @@ function getLaunchBarAvailableLaunchersRoot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLaunchBarVisibleLaunchersRoot() {
|
function getLaunchBarVisibleLaunchersRoot() {
|
||||||
let note = becca.getNote('lb_visiblelaunchers');
|
let note = becca.getNote('lbVisibleLaunchers');
|
||||||
|
|
||||||
if (!note) {
|
if (!note) {
|
||||||
note = noteService.createNewNote({
|
note = noteService.createNewNote({
|
||||||
branchId: 'lb_visiblelaunchers',
|
branchId: 'lbVisibleLaunchers',
|
||||||
noteId: 'lb_visiblelaunchers',
|
noteId: 'lbVisibleLaunchers',
|
||||||
title: 'Visible launchers',
|
title: 'Visible launchers',
|
||||||
type: 'doc',
|
type: 'doc',
|
||||||
content: '',
|
content: '',
|
||||||
@ -317,7 +318,7 @@ function getLaunchBarVisibleLaunchersRoot() {
|
|||||||
note.addLabel("docName", "launchbar_intro");
|
note.addLabel("docName", "launchbar_intro");
|
||||||
}
|
}
|
||||||
|
|
||||||
const branch = becca.getBranch('lb_visiblelaunchers');
|
const branch = becca.getBranch('lbVisibleLaunchers');
|
||||||
if (!branch.isExpanded) {
|
if (!branch.isExpanded) {
|
||||||
branch.isExpanded = true;
|
branch.isExpanded = true;
|
||||||
branch.save();
|
branch.save();
|
||||||
@ -328,21 +329,21 @@ function getLaunchBarVisibleLaunchersRoot() {
|
|||||||
|
|
||||||
const launchers = [
|
const launchers = [
|
||||||
// visible launchers:
|
// visible launchers:
|
||||||
{ id: 'lb_newnote', command: 'createNoteIntoInbox', title: 'New note', icon: 'bx bx-file-blank', isVisible: true },
|
{ id: 'lbNewNote', command: 'createNoteIntoInbox', title: 'New note', icon: 'bx bx-file-blank', isVisible: true },
|
||||||
{ id: 'lb_search', command: 'searchNotes', title: 'Search notes', icon: 'bx bx-search', isVisible: true },
|
{ id: 'lbSearch', command: 'searchNotes', title: 'Search notes', icon: 'bx bx-search', isVisible: true },
|
||||||
{ id: 'lb_jumpto', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send', isVisible: true },
|
{ id: 'lbJumpTo', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send', isVisible: true },
|
||||||
{ id: 'lb_notemap', targetNoteId: 'globalNotemap', title: 'Note map', icon: 'bx bx-map-alt', isVisible: true },
|
{ id: 'lbNoteMap', targetNoteId: 'globalNotemap', title: 'Note map', icon: 'bx bx-map-alt', isVisible: true },
|
||||||
{ id: 'lb_calendar', builtinWidget: 'calendar', title: 'Calendar', icon: 'bx bx-calendar', isVisible: true },
|
{ id: 'lbCalendar', builtinWidget: 'calendar', title: 'Calendar', icon: 'bx bx-calendar', isVisible: true },
|
||||||
{ id: 'lb_spacer1', builtinWidget: 'spacer', title: 'Spacer', isVisible: true, baseSize: "50", growthFactor: "0" },
|
{ id: 'lbSpacer1', builtinWidget: 'spacer', title: 'Spacer', isVisible: true, baseSize: "50", growthFactor: "0" },
|
||||||
{ id: 'lb_bookmarks', builtinWidget: 'bookmarks', title: 'Bookmarks', icon: 'bx bx-bookmark', isVisible: true },
|
{ id: 'lbBookmarks', builtinWidget: 'bookmarks', title: 'Bookmarks', icon: 'bx bx-bookmark', isVisible: true },
|
||||||
{ id: 'lb_spacer2', builtinWidget: 'spacer', title: 'Spacer', isVisible: true, baseSize: "0", growthFactor: "1" },
|
{ id: 'lbSpacer2', builtinWidget: 'spacer', title: 'Spacer', isVisible: true, baseSize: "0", growthFactor: "1" },
|
||||||
{ id: 'lb_protectedsession', builtinWidget: 'protectedSession', title: 'Protected session', icon: 'bx bx bx-shield-quarter', isVisible: true },
|
{ id: 'lbProtectedSession', builtinWidget: 'protectedSession', title: 'Protected session', icon: 'bx bx bx-shield-quarter', isVisible: true },
|
||||||
{ id: 'lb_syncstatus', builtinWidget: 'syncStatus', title: 'Sync status', icon: 'bx bx-wifi', isVisible: true },
|
{ id: 'lbSyncStatus', builtinWidget: 'syncStatus', title: 'Sync status', icon: 'bx bx-wifi', isVisible: true },
|
||||||
|
|
||||||
// available launchers:
|
// available launchers:
|
||||||
{ id: 'lb_recentchanges', command: 'showRecentChanges', title: 'Recent changes', icon: 'bx bx-history', isVisible: false },
|
{ id: 'lbRecentChanges', command: 'showRecentChanges', title: 'Recent changes', icon: 'bx bx-history', isVisible: false },
|
||||||
{ id: 'lb_backinhistory', builtinWidget: 'backInHistoryButton', title: 'Back in history', icon: 'bx bxs-left-arrow-square', isVisible: false },
|
{ id: 'lbBackInHistory', builtinWidget: 'backInHistoryButton', title: 'Back in history', icon: 'bx bxs-left-arrow-square', isVisible: false },
|
||||||
{ id: 'lb_forwardinhistory', builtinWidget: 'forwardInHistoryButton', title: 'Forward in history', icon: 'bx bxs-right-arrow-square', isVisible: false },
|
{ id: 'lbForwardInHistory', builtinWidget: 'forwardInHistoryButton', title: 'Forward in history', icon: 'bx bxs-right-arrow-square', isVisible: false },
|
||||||
];
|
];
|
||||||
|
|
||||||
function createLaunchers() {
|
function createLaunchers() {
|
||||||
@ -628,11 +629,11 @@ function createMissingSpecialNotes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resetLauncher(noteId) {
|
function resetLauncher(noteId) {
|
||||||
if (noteId.startsWith('lb_')) {
|
const note = becca.getNote(noteId);
|
||||||
const note = becca.getNote(noteId);
|
|
||||||
|
|
||||||
|
if (note.isLauncherConfig()) {
|
||||||
if (note) {
|
if (note) {
|
||||||
if (noteId === 'lb_root') {
|
if (noteId === 'lbRoot') {
|
||||||
// deleting hoisted notes are not allowed, so we just reset the children
|
// deleting hoisted notes are not allowed, so we just reset the children
|
||||||
for (const childNote of note.getChildNotes()) {
|
for (const childNote of note.getChildNotes()) {
|
||||||
childNote.deleteNote();
|
childNote.deleteNote();
|
||||||
|
@ -30,7 +30,7 @@ function getNotes(noteIds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validateParentChild(parentNoteId, childNoteId, branchId = null) {
|
function validateParentChild(parentNoteId, childNoteId, branchId = null) {
|
||||||
if (['root', 'hidden', 'share', 'lb_root', 'lb_availablelaunchers', 'lb_visiblelaunchers'].includes(childNoteId)) {
|
if (['root', 'hidden', 'share', 'lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(childNoteId)) {
|
||||||
return { success: false, message: `Cannot change this note's location.`};
|
return { success: false, message: `Cannot change this note's location.`};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentNoteId !== 'lb_bookmarks' && becca.getNote(parentNoteId).type === 'launcher') {
|
if (parentNoteId !== 'lbBookmarks' && becca.getNote(parentNoteId).type === 'launcher') {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: 'Launcher note cannot have any children.'
|
message: 'Launcher note cannot have any children.'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user