mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
create note from template WIP
This commit is contained in:
parent
98b579524c
commit
b204014a11
@ -43,7 +43,8 @@ async function createNote(parentNotePath, options = {}) {
|
|||||||
content: options.content || "",
|
content: options.content || "",
|
||||||
isProtected: options.isProtected,
|
isProtected: options.isProtected,
|
||||||
type: options.type,
|
type: options.type,
|
||||||
mime: options.mime
|
mime: options.mime,
|
||||||
|
templateNoteId: options.templateNoteId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (options.saveSelection && utils.isCKEditorInitialized()) {
|
if (options.saveSelection && utils.isCKEditorInitialized()) {
|
||||||
|
@ -48,7 +48,10 @@ class TreeContextMenu {
|
|||||||
for (const templateNote of templateNotes) {
|
for (const templateNote of templateNotes) {
|
||||||
items.push({
|
items.push({
|
||||||
title: templateNote.title,
|
title: templateNote.title,
|
||||||
uiIcon: templateNote.getIcon()
|
uiIcon: templateNote.getIcon(),
|
||||||
|
command: command,
|
||||||
|
type: templateNote.type,
|
||||||
|
templateNoteId: templateNote.noteId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,7 +130,7 @@ class TreeContextMenu {
|
|||||||
].filter(row => row !== null);
|
].filter(row => row !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectMenuItemHandler({command, type}) {
|
async selectMenuItemHandler({command, type, templateNoteId}) {
|
||||||
const notePath = treeService.getNotePath(this.node);
|
const notePath = treeService.getNotePath(this.node);
|
||||||
|
|
||||||
if (command === 'openInTab') {
|
if (command === 'openInTab') {
|
||||||
@ -141,7 +144,8 @@ class TreeContextMenu {
|
|||||||
target: 'after',
|
target: 'after',
|
||||||
targetBranchId: this.node.data.branchId,
|
targetBranchId: this.node.data.branchId,
|
||||||
type: type,
|
type: type,
|
||||||
isProtected: isProtected
|
isProtected: isProtected,
|
||||||
|
templateNoteId: templateNoteId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (command === "insertChildNote") {
|
else if (command === "insertChildNote") {
|
||||||
@ -149,7 +153,8 @@ class TreeContextMenu {
|
|||||||
|
|
||||||
noteCreateService.createNote(parentNotePath, {
|
noteCreateService.createNote(parentNotePath, {
|
||||||
type: type,
|
type: type,
|
||||||
isProtected: this.node.data.isProtected
|
isProtected: this.node.data.isProtected,
|
||||||
|
templateNoteId: templateNoteId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (command === 'openNoteInSplit') {
|
else if (command === 'openNoteInSplit') {
|
||||||
|
@ -155,6 +155,14 @@ function createNewNote(params) {
|
|||||||
|
|
||||||
scanForLinks(note);
|
scanForLinks(note);
|
||||||
|
|
||||||
|
if (params.templateNoteId) {
|
||||||
|
if (!becca.getNote(params.templateNoteId)) {
|
||||||
|
throw new Error(`Template note '${params.templateNoteId}' does not exist.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
note.addRelation('template', params.templateNoteId);
|
||||||
|
}
|
||||||
|
|
||||||
copyChildAttributes(parentNote, note);
|
copyChildAttributes(parentNote, note);
|
||||||
|
|
||||||
triggerNoteTitleChanged(note);
|
triggerNoteTitleChanged(note);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user