Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
backend API note creation updates
zadam19206d1e0d3c
diff --git a/config-sample.ini b/config-sample.iniindex 3292540d88..36d546ebe3 100644--- a/config-sample.ini+++ b/config-sample.ini@@ -2,6 +2,9 @@# Instance name can be used to distinguish between different instancesinstanceName=+# Disable automatically generating desktop icon+# noDesktopIcon=true+[Network]# host setting is relevant only for web deployments - set the host on which the server will listen# host=0.0.0.0diff --git a/src/services/backend_script_api.js b/src/services/backend_script_api.jsindex 2e1f639fe0..36bb247ae9 100644--- a/src/services/backend_script_api.js+++ b/src/services/backend_script_api.js@@ -177,19 +177,55 @@ function BackendScriptApi(currentNote, apiParams) {* @property {string} [value] - attribute value*/+ /**+ * Create text note. See also createNote() for more options.+ *+ * @param {string} parentNoteId+ * @param {string} title+ * @param {string} content+ * @return {Promise<{note: Note, branch: Branch}>}+ */+ this.createTextNote = async (parentNoteId, title, content = '') => await noteService.createNewNote({+ parentNoteId,+ title,+ content,+ type: 'text'+ });++ /**+ * Create data note - data in this context means object serializable to JSON. Created note will be of type 'code' and+ * JSON MIME type. See also createNote() for more options.+ *+ * @param {string} parentNoteId+ * @param {string} title+ * @param {object} content+ * @return {Promise<{note: Note, branch: Branch}>}+ */+ this.createDataNote = async (parentNoteId, title, content = {}) => await noteService.createNewNote({+ parentNoteId,+ title,+ content: JSON.stringify(content),+ type: 'code',+ mime: 'application/json'+ });+/*** @typedef {object} CreateNoteParams- * @property {boolean} [json=false] - should the note be JSON- * @property {boolean} [isProtected=false] - should the note be protected- * @property {string} [type='text'] - note type- * @property {string} [mime='text/html'] - MIME type of the note- * @property {CreateNoteAttribute[]} [attributes=[]] - attributes to be created for this note+ * @property {string} parentNoteId - MANDATORY+ * @property {string} title - MANDATORY+ * @property {string|buffer} content - MANDATORY+ * @property {string} type - text, code, file, image, search, book, relation-map - MANDATORY+ * @property {string} mime - value is derived from default mimes for type+ * @property {boolean} isProtected - default is false+ * @property {boolean} isExpanded - default is false+ * @property {string} prefix - default is empty string+ * @property {int} notePosition - default is last existing notePosition in a parent + 10*//*** @method*- * @param {CreateNoteParams} [extraOptions={}]+ * @param {CreateNoteParams} [params]* @returns {Promise<{note: Note, branch: Branch}>} object contains newly created entities note and branch*/this.createNote = noteService.createNewNote;