2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								<!DOCTYPE html>  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< html  lang = "en" >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< head >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < meta  charset = "utf-8" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < title > JSDoc: Source: entities/fnote.js< / title > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < script  src = "scripts/prettify/prettify.js" >  < / script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < script  src = "scripts/prettify/lang-css.js" >  < / script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    <!-- [if lt IE 9]>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < script  src = "//html5shiv.googlecode.com/svn/trunk/html5.js" > < / script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    <![endif]--> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < link  type = "text/css"  rel = "stylesheet"  href = "styles/prettify-tomorrow.css" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < link  type = "text/css"  rel = "stylesheet"  href = "styles/jsdoc-default.css" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / head >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< body >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< div  id = "main" >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < h1  class = "page-title" > Source: entities/fnote.js< / h1 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < section > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < article > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < pre  class = "prettyprint source linenums" > < code > import server from '../services/server.js';
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import noteAttributeCache from "../services/note_attribute_cache.js";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import ws from "../services/ws.js";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import froca from "../services/froca.js";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import protectedSessionHolder from "../services/protected_session_holder.js";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import cssClassManager from "../services/css_class_manager.js";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const LABEL = 'label';
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const RELATION = 'relation';
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const NOTE_TYPE_ICONS = {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "file": "bx bx-file",
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "image": "bx bx-image",
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "code": "bx bx-code",
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "render": "bx bx-extension",
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "search": "bx bx-file-find",
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 20:30:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "relationMap": "bx bxs-network-chart",
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    "book": "bx bx-book",
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 20:30:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "noteMap": "bx bxs-network-chart",
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    "mermaid": "bx bx-selection",
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "canvas": "bx bx-pen",
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "webView": "bx bx-globe-alt",
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "launcher": "bx bx-link",
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "doc": "bx bxs-file-doc",
							 
						 
					
						
							
								
									
										
										
										
											2024-12-11 18:31:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "contentWidget": "bx bxs-widget",
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "mindMap": "bx bx-sitemap"
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 04:17:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * There are many different Note types, some of which are entirely opaque to the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * end user. Those types should be used only for checking against, they are
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * not for direct use.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * @typedef {"file" | "image" | "search" | "noteMap" | "launcher" | "doc" | "contentWidget" | "text" | "relationMap" | "render" | "canvas" | "mermaid" | "book" | "webView" | "code"} NoteType
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * @typedef {Object} NotePathRecord
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * @property {boolean} isArchived
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * @property {boolean} isInHoistedSubTree
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * @property {boolean} isSearch
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * @property {Array< string>} notePath
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * @property {boolean} isHidden
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * Note is the main node and concept in Trilium.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								class FNote {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {Froca} froca
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {Object.< string, Object>} row
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    constructor(froca, row) {
							 
						 
					
						
							
								
									
										
										
										
											2023-07-27 23:22:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        /** @type {Froca} */
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        this.froca = froca;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        /** @type {string[]} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.attributes = [];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        /** @type {string[]} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.targetRelations = [];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        /** @type {string[]} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.parents = [];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        /** @type {string[]} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.children = [];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        /** @type {Object.< string, string>} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.parentToBranch = {};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        /** @type {Object.< string, string>} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.childToBranch = {};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        /** @type {FAttachment[]|null} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.attachments = null; // lazy loaded
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        this.update(row);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    update(row) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        /** @type {string} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.noteId = row.noteId;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        /** @type {string} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.title = row.title;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        /** @type {boolean} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.isProtected = !!row.isProtected;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        /**
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 04:17:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								         * See {@see NoteType} for info on values.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         * @type {NoteType}
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								         */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.type = row.type;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         * content-type, e.g. "application/json"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         * @type {string}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.mime = row.mime;
							 
						 
					
						
							
								
									
										
										
										
											2023-11-21 20:46:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // the main use case to keep this is to detect content change which should trigger refresh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.blobId = row.blobId;
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    addParent(parentNoteId, branchId, sort = true) {
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        if (parentNoteId === 'none') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (!this.parents.includes(parentNoteId)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this.parents.push(parentNoteId);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.parentToBranch[parentNoteId] = branchId;
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (sort) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this.sortParents();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    addChild(childNoteId, branchId, sort = true) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (!(childNoteId in this.childToBranch)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this.children.push(childNoteId);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.childToBranch[childNoteId] = branchId;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (sort) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this.sortChildren();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    sortChildren() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const branchIdPos = {};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for (const branchId of Object.values(this.childToBranch)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            branchIdPos[branchId] = this.froca.getBranch(branchId).notePosition;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 12:23:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this.children.sort((a, b) => branchIdPos[this.childToBranch[a]] - branchIdPos[this.childToBranch[b]]);
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /** @returns {boolean} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isJson() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.mime === "application/json";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async getContent() {
							 
						 
					
						
							
								
									
										
										
										
											2023-09-05 22:48:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const blob = await this.getBlob();
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-05 22:48:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return blob?.content;
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async getJsonContent() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const content = await this.getContent();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        try {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return JSON.parse(content);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        catch (e) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            console.log(`Cannot parse content of note '${this.noteId}': `, e.message);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return null;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {string[]}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getParentBranchIds() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return Object.values(this.parentToBranch);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {string[]}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @deprecated use getParentBranchIds() instead
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getBranchIds() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.getParentBranchIds();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FBranch[]}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getParentBranches() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const branchIds = Object.values(this.parentToBranch);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.froca.getBranches(branchIds);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FBranch[]}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @deprecated use getParentBranches() instead
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getBranches() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.getParentBranches();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /** @returns {boolean} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hasChildren() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.children.length > 0;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /** @returns {FBranch[]} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getChildBranches() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // don't use Object.values() to guarantee order
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const branchIds = this.children.map(childNoteId => this.childToBranch[childNoteId]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.froca.getBranches(branchIds);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /** @returns {string[]} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getParentNoteIds() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.parents;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /** @returns {FNote[]} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getParentNotes() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.froca.getNotesFromCache(this.parents);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // will sort the parents so that non-search &  non-archived are first and archived at the end
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // this is done so that non-search &  non-archived paths are always explored as first when looking for a note path
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    sortParents() {
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        this.parents.sort((aNoteId, bNoteId) => {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const aBranchId = this.parentToBranch[aNoteId];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if (aBranchId & &  aBranchId.startsWith('virt-')) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return 1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const aNote = this.froca.getNoteFromCache(aNoteId);
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if (aNote.isArchived || aNote.isHiddenCompletely()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return 1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 12:23:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return aNoteId <  bNoteId ? -1 : 1;
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    get isArchived() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.hasAttribute('label', 'archived');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /** @returns {string[]} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getChildNoteIds() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.children;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /** @returns {Promise< FNote[]>} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async getChildNotes() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return await this.froca.getNotes(this.children);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /** @returns {Promise< FAttachment[]>} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async getAttachments() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (!this.attachments) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this.attachments = await this.froca.getAttachmentsForNote(this.noteId);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.attachments;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 23:11:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /** @returns {Promise< FAttachment[]>} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async getAttachmentsByRole(role) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return (await this.getAttachments())
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            .filter(attachment => attachment.role === role);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /** @returns {Promise< FAttachment>} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async getAttachmentById(attachmentId) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const attachments = await this.getAttachments();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return attachments.find(att => att.attachmentId === attachmentId);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isEligibleForConversionToAttachment() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (this.type !== 'image' || !this.isContentAvailable() || this.hasChildren() || this.getParentBranches().length !== 1) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const targetRelations = this.getTargetRelations().filter(relation => relation.name === 'imageLink');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (targetRelations.length > 1) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const parentNote = this.getParentNotes()[0]; // at this point note can have only one parent
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const referencingNote = targetRelations[0]?.getNote();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (referencingNote & &  referencingNote !== parentNote) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } else if (parentNote.type !== 'text' || !parentNote.isContentAvailable()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} [type] - (optional) attribute type to filter
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} [name] - (optional) attribute name to filter
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FAttribute[]} all note's attributes, including inherited ones
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getOwnedAttributes(type, name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const attrs = this.attributes
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            .map(attributeId => this.froca.attributes[attributeId])
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            .filter(Boolean); // filter out nulls;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.__filterAttrs(attrs, type, name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} [type] - (optional) attribute type to filter
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} [name] - (optional) attribute name to filter
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FAttribute[]} all note's attributes, including inherited ones
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getAttributes(type, name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.__filterAttrs(this.__getCachedAttributes([]), type, name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string[]} path
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @return {FAttribute[]}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @private
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    __getCachedAttributes(path) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // notes/clones cannot form tree cycles, it is possible to create attribute inheritance cycle via templates
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // when template instance is a parent of template itself
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (path.includes(this.noteId)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return [];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (!(this.noteId in noteAttributeCache.attributes)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const newPath = [...path, this.noteId];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const attrArrs = [ this.getOwnedAttributes() ];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // inheritable attrs on root are typically not intended to be applied to hidden subtree #3537
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if (this.noteId !== 'root' & &  this.noteId !== '_hidden') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                for (const parentNote of this.getParentNotes()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    // these virtual parent-child relationships are also loaded into froca
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if (parentNote.type !== 'search') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        attrArrs.push(parentNote.__getInheritableAttributes(newPath));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            for (const templateAttr of attrArrs.flat().filter(attr => attr.type === 'relation' & &  ['template', 'inherit'].includes(attr.name))) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                const templateNote = this.froca.notes[templateAttr.value];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if (templateNote & &  templateNote.noteId !== this.noteId) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    attrArrs.push(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        templateNote.__getCachedAttributes(newPath)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            // template attr is used as a marker for templates, but it's not meant to be inherited
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            .filter(attr => !(attr.type === 'label' & &  (attr.name === 'template' || attr.name === 'workspacetemplate')))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    );
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            noteAttributeCache.attributes[this.noteId] = [];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const addedAttributeIds = new Set();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            for (const attr of attrArrs.flat()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if (!addedAttributeIds.has(attr.attributeId)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    addedAttributeIds.add(attr.attributeId);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    noteAttributeCache.attributes[this.noteId].push(attr);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return noteAttributeCache.attributes[this.noteId];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isRoot() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.noteId === 'root';
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * Gives all possible note paths leading to this note. Paths containing search note are ignored (could form cycles)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {string[][]} - array of notePaths (each represented by array of noteIds constituting the particular note path)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getAllNotePaths() {
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        if (this.noteId === 'root') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return [['root']];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const parentNotes = this.getParentNotes().filter(note => note.type !== 'search');
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const notePaths = parentNotes.length === 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ? parentNotes[0].getAllNotePaths() // optimization for the most common case
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            : parentNotes.flatMap(parentNote => parentNote.getAllNotePaths());
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for (const notePath of notePaths) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            notePath.push(this.noteId);
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return notePaths;
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} [hoistedNoteId='root']
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 04:17:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @return {Array< NotePathRecord>}
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getSortedNotePathRecords(hoistedNoteId = 'root') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const isHoistedRoot = hoistedNoteId === 'root';
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        const notePaths = this.getAllNotePaths().map(path => ({
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            notePath: path,
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            isInHoistedSubTree: isHoistedRoot || path.includes(hoistedNoteId),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            isArchived: path.some(noteId => froca.notes[noteId].isArchived),
							 
						 
					
						
							
								
									
										
										
										
											2023-07-15 12:07:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            isSearch: path.find(noteId => froca.notes[noteId].type === 'search'),
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            isHidden: path.includes('_hidden')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        notePaths.sort((a, b) => {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if (a.isInHoistedSubTree !== b.isInHoistedSubTree) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return a.isInHoistedSubTree ? -1 : 1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } else if (a.isArchived !== b.isArchived) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return a.isArchived ? 1 : -1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } else if (a.isHidden !== b.isHidden) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return a.isHidden ? 1 : -1;
							 
						 
					
						
							
								
									
										
										
										
											2023-07-15 12:07:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } else if (a.isSearch !== b.isSearch) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return a.isSearch ? 1 : -1;
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            } else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return a.notePath.length - b.notePath.length;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return notePaths;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * Returns the note path considered to be the "best"
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     *
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} [hoistedNoteId='root']
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @return {string[]} array of noteIds constituting the particular note path
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getBestNotePath(hoistedNoteId = 'root') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.getSortedNotePathRecords(hoistedNoteId)[0]?.notePath;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * Returns the note path considered to be the "best"
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     *
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} [hoistedNoteId='root']
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @return {string} serialized note path (e.g. 'root/a1h315/js725h')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getBestNotePathString(hoistedNoteId = 'root') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const notePath = this.getBestNotePath(hoistedNoteId);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return notePath?.join("/");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @return boolean - true if there's no non-hidden path, note is not cloned to the visible tree
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isHiddenCompletely() {
							 
						 
					
						
							
								
									
										
										
										
											2023-07-15 12:07:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if (this.noteId === '_hidden') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } else if (this.noteId === 'root') {
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for (const parentNote of this.getParentNotes()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if (parentNote.noteId === 'root') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return false;
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } else if (parentNote.noteId === '_hidden' || parentNote.type === 'search') {
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                continue;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if (!parentNote.isHiddenCompletely()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {FAttribute[]} attributes
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 04:17:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @param {AttributeType} type
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @param {string} name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @return {FAttribute[]}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @private
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    __filterAttrs(attributes, type, name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this.__validateTypeName(type, name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (!type & &  !name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return attributes;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } else if (type & &  name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return attributes.filter(attr => attr.name === name & &  attr.type === type);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } else if (type) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return attributes.filter(attr => attr.type === type);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } else if (name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return attributes.filter(attr => attr.name === name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    __getInheritableAttributes(path) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const attrs = this.__getCachedAttributes(path);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return attrs.filter(attr => attr.isInheritable);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    __validateTypeName(type, name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (type & &  type !== 'label' & &  type !== 'relation') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            throw new Error(`Unrecognized attribute type '${type}'. Only 'label' and 'relation' are possible values.`);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const firstLetter = name.charAt(0);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if (firstLetter === '#' || firstLetter === '~') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                throw new Error(`Detect '#' or '~' in the attribute's name. In the API, attribute names should be set without these characters.`);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} [name] - label name to filter
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FAttribute[]} all note's labels (attributes with type label), including inherited ones
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getOwnedLabels(name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.getOwnedAttributes(LABEL, name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} [name] - label name to filter
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FAttribute[]} all note's labels (attributes with type label), including inherited ones
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getLabels(name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.getAttributes(LABEL, name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getIcon() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const iconClassLabels = this.getLabels('iconClass');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const workspaceIconClass = this.getWorkspaceIconClass();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (iconClassLabels.length > 0) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return iconClassLabels[0].value;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else if (workspaceIconClass) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return workspaceIconClass;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else if (this.noteId === 'root') {
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 20:30:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return "bx bx-home-alt-2";
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (this.noteId === '_share') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return "bx bx-share-alt";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else if (this.type === 'text') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if (this.isFolder()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return "bx bx-folder";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return "bx bx-note";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else if (this.type === 'code' & &  this.mime.startsWith('text/x-sql')) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return "bx bx-data";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return NOTE_TYPE_ICONS[this.type];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getColorClass() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const color = this.getLabelValue("color");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return cssClassManager.createClassForColor(color);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isFolder() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.type === 'search'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            || this.getFilteredChildBranches().length > 0;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getFilteredChildBranches() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let childBranches = this.getChildBranches();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (!childBranches) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ws.logError(`No children for '${this.noteId}'. This shouldn't happen.`);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // we're not checking hideArchivedNotes since that would mean we need to lazy load the child notes
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // which would seriously slow down everything.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // we check this flag only once user chooses to expand the parent. This has the negative consequence that
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // note may appear as a folder but not contain any children when all of them are archived
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return childBranches;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} [name] - relation name to filter
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FAttribute[]} all note's relations (attributes with type relation), including inherited ones
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getOwnedRelations(name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.getOwnedAttributes(RELATION, name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} [name] - relation name to filter
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FAttribute[]} all note's relations (attributes with type relation), including inherited ones
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getRelations(name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.getAttributes(RELATION, name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 04:17:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @param {AttributeType} type - attribute type (label, relation, etc.)
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - attribute name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {boolean} true if note has an attribute with given type and name (including inherited)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hasAttribute(type, name) {
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const attributes = this.getAttributes();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return attributes.some(attr => attr.name === name & &  attr.type === type);
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 04:17:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @param {AttributeType} type - attribute type (label, relation, etc.)
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - attribute name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {boolean} true if note has an attribute with given type and name (including inherited)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hasOwnedAttribute(type, name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return !!this.getOwnedAttribute(type, name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 04:17:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @param {AttributeType} type - attribute type (label, relation, etc.)
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - attribute name
							 
						 
					
						
							
								
									
										
										
										
											2023-07-15 12:07:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @returns {FAttribute} attribute of the given type and name. If there are more such attributes, first is returned. Returns null if there's no such attribute belonging to this note.
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getOwnedAttribute(type, name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const attributes = this.getOwnedAttributes();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return attributes.find(attr => attr.name === name & &  attr.type === type);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 04:17:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @param {AttributeType} type - attribute type (label, relation, etc.)
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - attribute name
							 
						 
					
						
							
								
									
										
										
										
											2023-07-15 12:07:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @returns {FAttribute} attribute of the given type and name. If there are more such attributes, first is returned. Returns null if there's no such attribute belonging to this note.
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getAttribute(type, name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const attributes = this.getAttributes();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return attributes.find(attr => attr.name === name & &  attr.type === type);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 04:17:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @param {AttributeType} type - attribute type (label, relation, etc.)
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - attribute name
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @returns {string} attribute value of the given type and name or null if no such attribute exists.
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getOwnedAttributeValue(type, name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const attr = this.getOwnedAttribute(type, name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return attr ? attr.value : null;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 04:17:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @param {AttributeType} type - attribute type (label, relation, etc.)
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - attribute name
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @returns {string} attribute value of the given type and name or null if no such attribute exists.
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getAttributeValue(type, name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const attr = this.getAttribute(type, name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return attr ? attr.value : null;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - label name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {boolean} true if label exists (excluding inherited)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hasOwnedLabel(name) { return this.hasOwnedAttribute(LABEL, name); }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - label name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {boolean} true if label exists (including inherited)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hasLabel(name) { return this.hasAttribute(LABEL, name); }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - label name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {boolean} true if label exists (including inherited) and does not have "false" value.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isLabelTruthy(name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const label = this.getLabel(name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (!label) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return label & &  label.value !== 'false';
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - relation name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {boolean} true if relation exists (excluding inherited)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hasOwnedRelation(name) { return this.hasOwnedAttribute(RELATION, name); }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - relation name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {boolean} true if relation exists (including inherited)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hasRelation(name) { return this.hasAttribute(RELATION, name); }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - label name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FAttribute} label if it exists, null otherwise
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getOwnedLabel(name) { return this.getOwnedAttribute(LABEL, name); }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - label name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FAttribute} label if it exists, null otherwise
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getLabel(name) { return this.getAttribute(LABEL, name); }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - relation name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FAttribute} relation if it exists, null otherwise
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getOwnedRelation(name) { return this.getOwnedAttribute(RELATION, name); }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - relation name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FAttribute} relation if it exists, null otherwise
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getRelation(name) { return this.getAttribute(RELATION, name); }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - label name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {string} label value if label exists, null otherwise
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getOwnedLabelValue(name) { return this.getOwnedAttributeValue(LABEL, name); }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - label name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {string} label value if label exists, null otherwise
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getLabelValue(name) { return this.getAttributeValue(LABEL, name); }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - relation name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {string} relation value if relation exists, null otherwise
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getOwnedRelationValue(name) { return this.getOwnedAttributeValue(RELATION, name); }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name - relation name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {string} relation value if relation exists, null otherwise
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getRelationValue(name) { return this.getAttributeValue(RELATION, name); }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {Promise< FNote>|null} target note of the relation or null (if target is empty or note was not found)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async getRelationTarget(name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const targets = await this.getRelationTargets(name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return targets.length > 0 ? targets[0] : null;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @param {string} [name] - relation name to filter
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {Promise< FNote[]>}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async getRelationTargets(name) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const relations = this.getRelations(name);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const targets = [];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for (const relation of relations) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            targets.push(await this.froca.getNote(relation.value));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return targets;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FNote[]}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getNotesToInheritAttributesFrom() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const relations = [
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ...this.getRelations('template'),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ...this.getRelations('inherit')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return relations.map(rel => this.froca.notes[rel.value]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getPromotedDefinitionAttributes() {
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if (this.isLabelTruthy('hidePromotedAttributes')) {
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            return [];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const promotedAttrs = this.getAttributes()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            .filter(attr => attr.isDefinition())
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            .filter(attr => {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                const def = attr.getDefinition();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return def & &  def.isPromoted;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // attrs are not resorted if position changes after the initial load
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 14:35:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        promotedAttrs.sort((a, b) => {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if (a.noteId === b.noteId) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return a.position <  b.position ? -1 : 1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // inherited promoted attributes should stay grouped: https://github.com/zadam/trilium/issues/3761
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return a.noteId <  b.noteId ? -1 : 1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        });
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return promotedAttrs;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hasAncestor(ancestorNoteId, followTemplates = false, visitedNoteIds = null) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (this.noteId === ancestorNoteId) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (!visitedNoteIds) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            visitedNoteIds = new Set();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } else if (visitedNoteIds.has(this.noteId)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // to avoid infinite cycle when template is descendent of the instance
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        visitedNoteIds.add(this.noteId);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (followTemplates) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            for (const templateNote of this.getNotesToInheritAttributesFrom()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if (templateNote.hasAncestor(ancestorNoteId, followTemplates, visitedNoteIds)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for (const parentNote of this.getParentNotes()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if (parentNote.hasAncestor(ancestorNoteId, followTemplates, visitedNoteIds)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isInHiddenSubtree() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.noteId === '_hidden' || this.hasAncestor('_hidden');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @deprecated NOOP
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    invalidateAttributeCache() {}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * Get relations which target this note
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {FAttribute[]}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getTargetRelations() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.targetRelations
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            .map(attributeId => this.froca.attributes[attributeId]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * Get relations which target this note
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @returns {Promise< FNote[]>}
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async getTargetRelationSourceNotes() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const targetRelations = this.getTargetRelations();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return await this.froca.getNotes(targetRelations.map(tr => tr.noteId));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * @deprecated use getBlob() instead
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @return {Promise< FBlob>}
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async getNoteComplement() {
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 20:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return this.getBlob();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-27 23:22:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /** @return {Promise< FBlob>} */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async getBlob() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return await this.froca.getBlob('notes', this.noteId);
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    toString() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return `Note(noteId=${this.noteId}, title=${this.title})`;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    get dto() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const dto = Object.assign({}, this);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        delete dto.froca;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return dto;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getCssClass() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const labels = this.getLabels('cssClass');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return labels.map(l => l.value).join(' ');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getWorkspaceIconClass() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const labels = this.getLabels('workspaceIconClass');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return labels.length > 0 ? labels[0].value : "";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getWorkspaceTabBackgroundColor() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const labels = this.getLabels('workspaceTabBackgroundColor');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return labels.length > 0 ? labels[0].value : "";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /** @returns {boolean} true if this note is JavaScript (code or file) */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isJavaScript() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return (this.type === "code" || this.type === "file" || this.type === 'launcher')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  (this.mime.startsWith("application/javascript")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                || this.mime === "application/x-javascript"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                || this.mime === "text/javascript");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /** @returns {boolean} true if this note is HTML */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isHtml() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return (this.type === "code" || this.type === "file" || this.type === "render") & &  this.mime === "text/html";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /** @returns {string|null} JS script environment - either "frontend" or "backend" */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getScriptEnv() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (this.isHtml() || (this.isJavaScript() & &  this.mime.endsWith('env=frontend'))) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return "frontend";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (this.type === 'render') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return "frontend";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (this.isJavaScript() & &  this.mime.endsWith('env=backend')) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return "backend";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return null;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async executeScript() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (!this.isJavaScript()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            throw new Error(`Note ${this.noteId} is of type ${this.type} and mime ${this.mime} and thus cannot be executed`);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const env = this.getScriptEnv();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if (env === "frontend") {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const bundleService = (await import("../services/bundle.js")).default;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return await bundleService.getAndExecuteBundle(this.noteId);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else if (env === "backend") {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const resp = await server.post(`script/run/${this.noteId}`);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            throw new Error(`Unrecognized env type ${env} for note ${this.noteId}`);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isShared() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for (const parentNoteId of this.parents) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if (parentNoteId === 'root' || parentNoteId === 'none') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                continue;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const parentNote = froca.notes[parentNoteId];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if (!parentNote || parentNote.type === 'search') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                continue;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if (parentNote.noteId === '_share' || parentNote.isShared()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isContentAvailable() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return !this.isProtected || protectedSessionHolder.isProtectedSessionAvailable()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isLaunchBarConfig() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.type === 'launcher' || ['_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(this.noteId);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isOptions() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return this.noteId.startsWith("_options");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
									
										
										
										
											2023-09-06 23:05:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * Provides note's date metadata.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * @returns {Promise< {dateCreated: string, utcDateCreated: string, dateModified: string, utcDateModified: string}>}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async getMetadata() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return await server.get(`notes/${this.noteId}/metadata`);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								export default FNote;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / code > < / pre >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < / article > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < / section > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / div >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< nav >  
						 
					
						
							
								
									
										
										
										
											2023-09-25 23:11:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < h2 > < a  href = "index.html" > Home< / a > < / h2 > < h3 > Classes< / h3 > < ul > < li > < a  href = "BasicWidget.html" > BasicWidget< / a > < / li > < li > < a  href = "FAttachment.html" > FAttachment< / a > < / li > < li > < a  href = "FAttribute.html" > FAttribute< / a > < / li > < li > < a  href = "FBranch.html" > FBranch< / a > < / li > < li > < a  href = "FNote.html" > FNote< / a > < / li > < li > < a  href = "FrontendScriptApi.html" > FrontendScriptApi< / a > < / li > < li > < a  href = "NoteContextAwareWidget.html" > NoteContextAwareWidget< / a > < / li > < li > < a  href = "RightPanelWidget.html" > RightPanelWidget< / a > < / li > < / ul > < h3 > Global< / h3 > < ul > < li > < a  href = "global.html#api" > api< / a > < / li > < li > < a  href = "global.html#getJsonContent" > getJsonContent< / a > < / li > < li > < a  href = "global.html#getJsonContentSafely" > getJsonContentSafely< / a > < / li > < / ul > 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< / nav >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< br  class = "clear" >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< footer >  
						 
					
						
							
								
									
										
										
										
											2024-12-15 10:44:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Documentation generated by < a  href = "https://github.com/jsdoc/jsdoc" > JSDoc 4.0.4< / a > 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 16:30:14 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< / footer >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< script >  prettyPrint ( ) ;  < / script >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< script  src = "scripts/linenumber.js" >  < / script >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / body >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / html >