mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
it should not be possible to add note after hoisted note
This commit is contained in:
parent
ecdc5865a6
commit
c85979b66b
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "trilium",
|
"name": "trilium",
|
||||||
"version": "0.27.0-beta",
|
"version": "0.27.1-beta",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -649,11 +649,15 @@ messagingService.subscribeToSyncMessages(syncData => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
utils.bindShortcut('ctrl+o', () => {
|
utils.bindShortcut('ctrl+o', async () => {
|
||||||
const node = getCurrentNode();
|
const node = getCurrentNode();
|
||||||
const parentNoteId = node.data.parentNoteId;
|
const parentNoteId = node.data.parentNoteId;
|
||||||
const isProtected = treeUtils.getParentProtectedStatus(node);
|
const isProtected = treeUtils.getParentProtectedStatus(node);
|
||||||
|
|
||||||
|
if (node.data.noteId === 'root' || node.data.noteId === await hoistedNoteService.getHoistedNoteId()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
createNote(node, parentNoteId, 'after', isProtected, true);
|
createNote(node, parentNoteId, 'after', isProtected, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -13,8 +13,6 @@ import syncService from "./sync.js";
|
|||||||
import hoistedNoteService from './hoisted_note.js';
|
import hoistedNoteService from './hoisted_note.js';
|
||||||
import ContextMenuItemsContainer from './context_menu_items_container.js';
|
import ContextMenuItemsContainer from './context_menu_items_container.js';
|
||||||
|
|
||||||
const $tree = $("#tree");
|
|
||||||
|
|
||||||
let clipboardIds = [];
|
let clipboardIds = [];
|
||||||
let clipboardMode = null;
|
let clipboardMode = null;
|
||||||
|
|
||||||
@ -110,11 +108,12 @@ async function getContextMenuItems(event) {
|
|||||||
const note = await treeCache.getNote(node.data.noteId);
|
const note = await treeCache.getNote(node.data.noteId);
|
||||||
const parentNote = await treeCache.getNote(branch.parentNoteId);
|
const parentNote = await treeCache.getNote(branch.parentNoteId);
|
||||||
const isNotRoot = note.noteId !== 'root';
|
const isNotRoot = note.noteId !== 'root';
|
||||||
|
const isHoisted = note.noteId === await hoistedNoteService.getHoistedNoteId();
|
||||||
|
|
||||||
const itemsContainer = new ContextMenuItemsContainer(contextMenuItems);
|
const itemsContainer = new ContextMenuItemsContainer(contextMenuItems);
|
||||||
|
|
||||||
// Modify menu entries depending on node status
|
// Modify menu entries depending on node status
|
||||||
itemsContainer.enableItem("insertNoteAfter", isNotRoot && parentNote.type !== 'search');
|
itemsContainer.enableItem("insertNoteAfter", isNotRoot && !isHoisted && parentNote.type !== 'search');
|
||||||
itemsContainer.enableItem("insertChildNote", note.type !== 'search');
|
itemsContainer.enableItem("insertChildNote", note.type !== 'search');
|
||||||
itemsContainer.enableItem("delete", isNotRoot && parentNote.type !== 'search');
|
itemsContainer.enableItem("delete", isNotRoot && parentNote.type !== 'search');
|
||||||
itemsContainer.enableItem("copy", isNotRoot);
|
itemsContainer.enableItem("copy", isNotRoot);
|
||||||
@ -125,10 +124,8 @@ async function getContextMenuItems(event) {
|
|||||||
itemsContainer.enableItem("export", note.type !== 'search');
|
itemsContainer.enableItem("export", note.type !== 'search');
|
||||||
itemsContainer.enableItem("editBranchPrefix", isNotRoot && parentNote.type !== 'search');
|
itemsContainer.enableItem("editBranchPrefix", isNotRoot && parentNote.type !== 'search');
|
||||||
|
|
||||||
const hoistedNoteId = await hoistedNoteService.getHoistedNoteId();
|
itemsContainer.hideItem("hoist", isHoisted);
|
||||||
|
itemsContainer.hideItem("unhoist", !isHoisted || !isNotRoot);
|
||||||
itemsContainer.hideItem("hoist", note.noteId === hoistedNoteId);
|
|
||||||
itemsContainer.hideItem("unhoist", note.noteId !== hoistedNoteId || !isNotRoot);
|
|
||||||
|
|
||||||
// Activate node on right-click
|
// Activate node on right-click
|
||||||
node.setActive();
|
node.setActive();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user