mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixes
This commit is contained in:
parent
46d3160da4
commit
3e189d5c10
BIN
db/demo.zip
BIN
db/demo.zip
Binary file not shown.
@ -50,28 +50,28 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
/**
|
/**
|
||||||
* @method
|
* @method
|
||||||
* @param {string} noteId
|
* @param {string} noteId
|
||||||
* @returns {Promise<Note|null>}
|
* @returns {Note|null}
|
||||||
*/
|
*/
|
||||||
this.getNote = repository.getNote;
|
this.getNote = repository.getNote;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method
|
* @method
|
||||||
* @param {string} branchId
|
* @param {string} branchId
|
||||||
* @returns {Promise<Branch|null>}
|
* @returns {Branch|null}
|
||||||
*/
|
*/
|
||||||
this.getBranch = repository.getBranch;
|
this.getBranch = repository.getBranch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method
|
* @method
|
||||||
* @param {string} attributeId
|
* @param {string} attributeId
|
||||||
* @returns {Promise<Attribute|null>}
|
* @returns {Attribute|null}
|
||||||
*/
|
*/
|
||||||
this.getAttribute = repository.getAttribute;
|
this.getAttribute = repository.getAttribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method
|
* @method
|
||||||
* @param {string} imageId
|
* @param {string} imageId
|
||||||
* @returns {Promise<Image|null>}
|
* @returns {Image|null}
|
||||||
*/
|
*/
|
||||||
this.getImage = repository.getImage;
|
this.getImage = repository.getImage;
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* @method
|
* @method
|
||||||
* @param {string} SQL query
|
* @param {string} SQL query
|
||||||
* @param {Array.<?>} array of params
|
* @param {Array.<?>} array of params
|
||||||
* @returns {Promise<Entity|null>}
|
* @returns {Entity|null}
|
||||||
*/
|
*/
|
||||||
this.getEntity = repository.getEntity;
|
this.getEntity = repository.getEntity;
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* @method
|
* @method
|
||||||
* @param {string} SQL query
|
* @param {string} SQL query
|
||||||
* @param {Array.<?>} array of params
|
* @param {Array.<?>} array of params
|
||||||
* @returns {Promise<Entity[]>}
|
* @returns {Entity[]}
|
||||||
*/
|
*/
|
||||||
this.getEntities = repository.getEntities;
|
this.getEntities = repository.getEntities;
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
* @param {string} searchString
|
* @param {string} searchString
|
||||||
* @returns {Promise<Note|null>}
|
* @returns {Note|null}
|
||||||
*/
|
*/
|
||||||
this.searchForNote = searchString => {
|
this.searchForNote = searchString => {
|
||||||
const notes = searchService.searchNoteEntities(searchString);
|
const notes = searchService.searchNoteEntities(searchString);
|
||||||
@ -123,7 +123,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* @method
|
* @method
|
||||||
* @param {string} name - attribute name
|
* @param {string} name - attribute name
|
||||||
* @param {string} [value] - attribute value
|
* @param {string} [value] - attribute value
|
||||||
* @returns {Promise<Note[]>}
|
* @returns {Note[]}
|
||||||
*/
|
*/
|
||||||
this.getNotesWithLabel = attributeService.getNotesWithLabel;
|
this.getNotesWithLabel = attributeService.getNotesWithLabel;
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* @method
|
* @method
|
||||||
* @param {string} name - attribute name
|
* @param {string} name - attribute name
|
||||||
* @param {string} [value] - attribute value
|
* @param {string} [value] - attribute value
|
||||||
* @returns {Promise<Note|null>}
|
* @returns {Note|null}
|
||||||
*/
|
*/
|
||||||
this.getNoteWithLabel = attributeService.getNoteWithLabel;
|
this.getNoteWithLabel = attributeService.getNoteWithLabel;
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* @param {string} noteId
|
* @param {string} noteId
|
||||||
* @param {string} parentNoteId
|
* @param {string} parentNoteId
|
||||||
* @param {string} prefix - if branch will be create between note and parent note, set this prefix
|
* @param {string} prefix - if branch will be create between note and parent note, set this prefix
|
||||||
* @returns {Promise<void>}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
this.ensureNoteIsPresentInParent = cloningService.ensureNoteIsPresentInParent;
|
this.ensureNoteIsPresentInParent = cloningService.ensureNoteIsPresentInParent;
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* @method
|
* @method
|
||||||
* @param {string} noteId
|
* @param {string} noteId
|
||||||
* @param {string} parentNoteId
|
* @param {string} parentNoteId
|
||||||
* @returns {Promise<void>}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
this.ensureNoteIsAbsentFromParent = cloningService.ensureNoteIsAbsentFromParent;
|
this.ensureNoteIsAbsentFromParent = cloningService.ensureNoteIsAbsentFromParent;
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* @param {string} noteId
|
* @param {string} noteId
|
||||||
* @param {string} parentNoteId
|
* @param {string} parentNoteId
|
||||||
* @param {string} prefix - if branch will be create between note and parent note, set this prefix
|
* @param {string} prefix - if branch will be create between note and parent note, set this prefix
|
||||||
* @returns {Promise<void>}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
this.toggleNoteInParent = cloningService.toggleNoteInParent;
|
this.toggleNoteInParent = cloningService.toggleNoteInParent;
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* @param {string} parentNoteId
|
* @param {string} parentNoteId
|
||||||
* @param {string} title
|
* @param {string} title
|
||||||
* @param {string} content
|
* @param {string} content
|
||||||
* @return {Promise<{note: Note, branch: Branch}>}
|
* @return {{note: Note, branch: Branch}}
|
||||||
*/
|
*/
|
||||||
this.createTextNote = (parentNoteId, title, content = '') => noteService.createNewNote({
|
this.createTextNote = (parentNoteId, title, content = '') => noteService.createNewNote({
|
||||||
parentNoteId,
|
parentNoteId,
|
||||||
@ -199,7 +199,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* @param {string} parentNoteId
|
* @param {string} parentNoteId
|
||||||
* @param {string} title
|
* @param {string} title
|
||||||
* @param {object} content
|
* @param {object} content
|
||||||
* @return {Promise<{note: Note, branch: Branch}>}
|
* @return {{note: Note, branch: Branch}}
|
||||||
*/
|
*/
|
||||||
this.createDataNote = (parentNoteId, title, content = {}) => noteService.createNewNote({
|
this.createDataNote = (parentNoteId, title, content = {}) => noteService.createNewNote({
|
||||||
parentNoteId,
|
parentNoteId,
|
||||||
@ -226,7 +226,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* @method
|
* @method
|
||||||
*
|
*
|
||||||
* @param {CreateNewNoteParams} [params]
|
* @param {CreateNewNoteParams} [params]
|
||||||
* @returns {Promise<{note: Note, branch: Branch}>} object contains newly created entities note and branch
|
* @returns {{note: Note, branch: Branch}} object contains newly created entities note and branch
|
||||||
*/
|
*/
|
||||||
this.createNewNote = noteService.createNewNote;
|
this.createNewNote = noteService.createNewNote;
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* @param {string} title
|
* @param {string} title
|
||||||
* @param {string} [content=""]
|
* @param {string} [content=""]
|
||||||
* @param {CreateNoteExtraOptions} [extraOptions={}]
|
* @param {CreateNoteExtraOptions} [extraOptions={}]
|
||||||
* @returns {Promise<{note: Note, branch: Branch}>} object contains newly created entities note and branch
|
* @returns {{note: Note, branch: Branch}} object contains newly created entities note and branch
|
||||||
*/
|
*/
|
||||||
this.createNote = (parentNoteId, title, content = "", extraOptions= {}) => {
|
this.createNote = (parentNoteId, title, content = "", extraOptions= {}) => {
|
||||||
extraOptions.parentNoteId = parentNoteId;
|
extraOptions.parentNoteId = parentNoteId;
|
||||||
@ -301,7 +301,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* Returns root note of the calendar.
|
* Returns root note of the calendar.
|
||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
* @returns {Promise<Note|null>}
|
* @returns {Note|null}
|
||||||
*/
|
*/
|
||||||
this.getRootCalendarNote = dateNoteService.getRootCalendarNote;
|
this.getRootCalendarNote = dateNoteService.getRootCalendarNote;
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
* @param {string} date in YYYY-MM-DD format
|
* @param {string} date in YYYY-MM-DD format
|
||||||
* @returns {Promise<Note|null>}
|
* @returns {Note|null}
|
||||||
*/
|
*/
|
||||||
this.getDateNote = dateNoteService.getDateNote;
|
this.getDateNote = dateNoteService.getDateNote;
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* Returns today's day note. If such note doesn't exist, it is created.
|
* Returns today's day note. If such note doesn't exist, it is created.
|
||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
* @returns {Promise<Note|null>}
|
* @returns {Note|null}
|
||||||
*/
|
*/
|
||||||
this.getTodayNote = dateNoteService.getTodayNote;
|
this.getTodayNote = dateNoteService.getTodayNote;
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
* @method
|
* @method
|
||||||
* @param {string} date in YYYY-MM-DD format
|
* @param {string} date in YYYY-MM-DD format
|
||||||
* @param {object} options - "startOfTheWeek" - either "monday" (default) or "sunday"
|
* @param {object} options - "startOfTheWeek" - either "monday" (default) or "sunday"
|
||||||
* @returns {Promise<Note|null>}
|
* @returns {Note|null}
|
||||||
*/
|
*/
|
||||||
this.getWeekNote = dateNoteService.getWeekNote;
|
this.getWeekNote = dateNoteService.getWeekNote;
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
* @param {string} date in YYYY-MM format
|
* @param {string} date in YYYY-MM format
|
||||||
* @returns {Promise<Note|null>}
|
* @returns {Note|null}
|
||||||
*/
|
*/
|
||||||
this.getMonthNote = dateNoteService.getMonthNote;
|
this.getMonthNote = dateNoteService.getMonthNote;
|
||||||
|
|
||||||
@ -346,14 +346,13 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
* @param {string} year in YYYY format
|
* @param {string} year in YYYY format
|
||||||
* @returns {Promise<Note|null>}
|
* @returns {Note|null}
|
||||||
*/
|
*/
|
||||||
this.getYearNote = dateNoteService.getYearNote;
|
this.getYearNote = dateNoteService.getYearNote;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method
|
* @method
|
||||||
* @param {string} parentNoteId - this note's child notes will be sorted
|
* @param {string} parentNoteId - this note's child notes will be sorted
|
||||||
* @returns Promise<void>
|
|
||||||
*/
|
*/
|
||||||
this.sortNotesAlphabetically = treeService.sortNotesAlphabetically;
|
this.sortNotesAlphabetically = treeService.sortNotesAlphabetically;
|
||||||
|
|
||||||
@ -380,7 +379,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
* @param {function} func
|
* @param {function} func
|
||||||
* @returns {Promise<?>} result of func callback
|
* @returns {?} result of func callback
|
||||||
*/
|
*/
|
||||||
this.transactional = sql.transactional;
|
this.transactional = sql.transactional;
|
||||||
|
|
||||||
|
@ -30,20 +30,20 @@ function getNoteStartingWith(parentNoteId, startsWith) {
|
|||||||
AND branches.isDeleted = 0`, [parentNoteId]);
|
AND branches.isDeleted = 0`, [parentNoteId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {Promise<Note>} */
|
/** @return {Note} */
|
||||||
function getRootCalendarNote() {
|
function getRootCalendarNote() {
|
||||||
// some caching here could be useful (e.g. in CLS)
|
// some caching here could be useful (e.g. in CLS)
|
||||||
let rootNote = attributeService.getNoteWithLabel(CALENDAR_ROOT_LABEL);
|
let rootNote = attributeService.getNoteWithLabel(CALENDAR_ROOT_LABEL);
|
||||||
|
|
||||||
if (!rootNote) {
|
if (!rootNote) {
|
||||||
rootNote = (noteService.createNewNote({
|
rootNote = noteService.createNewNote({
|
||||||
parentNoteId: 'root',
|
parentNoteId: 'root',
|
||||||
title: 'Calendar',
|
title: 'Calendar',
|
||||||
target: 'into',
|
target: 'into',
|
||||||
isProtected: false,
|
isProtected: false,
|
||||||
type: 'text',
|
type: 'text',
|
||||||
content: ''
|
content: ''
|
||||||
})).note;
|
}).note;
|
||||||
|
|
||||||
attributeService.createLabel(rootNote.noteId, CALENDAR_ROOT_LABEL);
|
attributeService.createLabel(rootNote.noteId, CALENDAR_ROOT_LABEL);
|
||||||
attributeService.createLabel(rootNote.noteId, 'sorted');
|
attributeService.createLabel(rootNote.noteId, 'sorted');
|
||||||
@ -52,7 +52,7 @@ function getRootCalendarNote() {
|
|||||||
return rootNote;
|
return rootNote;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {Promise<Note>} */
|
/** @return {Note} */
|
||||||
function getYearNote(dateStr, rootNote) {
|
function getYearNote(dateStr, rootNote) {
|
||||||
if (!rootNote) {
|
if (!rootNote) {
|
||||||
rootNote = getRootCalendarNote();
|
rootNote = getRootCalendarNote();
|
||||||
@ -91,7 +91,7 @@ function getMonthNoteTitle(rootNote, monthNumber, dateObj) {
|
|||||||
.replace(/{month}/g, monthName);
|
.replace(/{month}/g, monthName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {Promise<Note>} */
|
/** @return {Note} */
|
||||||
function getMonthNote(dateStr, rootNote) {
|
function getMonthNote(dateStr, rootNote) {
|
||||||
if (!rootNote) {
|
if (!rootNote) {
|
||||||
rootNote = getRootCalendarNote();
|
rootNote = getRootCalendarNote();
|
||||||
@ -139,7 +139,7 @@ function getDateNoteTitle(rootNote, dayNumber, dateObj) {
|
|||||||
.replace(/{weekDay2}/g, weekDay.substr(0, 2));
|
.replace(/{weekDay2}/g, weekDay.substr(0, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {Promise<Note>} */
|
/** @return {Note} */
|
||||||
function getDateNote(dateStr) {
|
function getDateNote(dateStr) {
|
||||||
const rootNote = getRootCalendarNote();
|
const rootNote = getRootCalendarNote();
|
||||||
|
|
||||||
|
@ -330,6 +330,17 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type === 'text' && noteMeta) {
|
||||||
|
const includeNoteLinks = (noteMeta.attributes || [])
|
||||||
|
.filter(attr => attr.type === 'relation' && attr.name === 'includeNoteLink');
|
||||||
|
|
||||||
|
// this will replace relation map links
|
||||||
|
for (const link of includeNoteLinks) {
|
||||||
|
// no need to escape the regexp find string since it's a noteId which doesn't contain any special characters
|
||||||
|
content = content.replace(new RegExp(link.value, "g"), getNewNoteId(link.value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let note = repository.getNote(noteId);
|
let note = repository.getNote(noteId);
|
||||||
|
|
||||||
if (note) {
|
if (note) {
|
||||||
|
@ -44,12 +44,12 @@ function getCachedEntity(entityName, entityId, query) {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise<Note|null>} */
|
/** @returns {Note|null} */
|
||||||
function getNote(noteId) {
|
function getNote(noteId) {
|
||||||
return getCachedEntity('notes', noteId, "SELECT * FROM notes WHERE noteId = ?");
|
return getCachedEntity('notes', noteId, "SELECT * FROM notes WHERE noteId = ?");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise<Note[]>} */
|
/** @returns {Note[]} */
|
||||||
function getNotes(noteIds) {
|
function getNotes(noteIds) {
|
||||||
// this note might be optimised, but remember that it must keep the existing order of noteIds
|
// this note might be optimised, but remember that it must keep the existing order of noteIds
|
||||||
// (important e.g. for @orderBy in search)
|
// (important e.g. for @orderBy in search)
|
||||||
@ -64,22 +64,22 @@ function getNotes(noteIds) {
|
|||||||
return notes;
|
return notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise<NoteRevision|null>} */
|
/** @returns {NoteRevision|null} */
|
||||||
function getNoteRevision(noteRevisionId) {
|
function getNoteRevision(noteRevisionId) {
|
||||||
return getCachedEntity('note_revisions', noteRevisionId, "SELECT * FROM note_revisions WHERE noteRevisionId = ?");
|
return getCachedEntity('note_revisions', noteRevisionId, "SELECT * FROM note_revisions WHERE noteRevisionId = ?");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise<Branch|null>} */
|
/** @returns {Branch|null} */
|
||||||
function getBranch(branchId) {
|
function getBranch(branchId) {
|
||||||
return getCachedEntity('branches', branchId, "SELECT * FROM branches WHERE branchId = ?", [branchId]);
|
return getCachedEntity('branches', branchId, "SELECT * FROM branches WHERE branchId = ?", [branchId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise<Attribute|null>} */
|
/** @returns {Attribute|null} */
|
||||||
function getAttribute(attributeId) {
|
function getAttribute(attributeId) {
|
||||||
return getCachedEntity('attributes', attributeId, "SELECT * FROM attributes WHERE attributeId = ?");
|
return getCachedEntity('attributes', attributeId, "SELECT * FROM attributes WHERE attributeId = ?");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise<Option|null>} */
|
/** @returns {Option|null} */
|
||||||
function getOption(name) {
|
function getOption(name) {
|
||||||
return getEntity("SELECT * FROM options WHERE name = ?", [name]);
|
return getEntity("SELECT * FROM options WHERE name = ?", [name]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user