mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-27 00:06:30 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			138 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			138 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!DOCTYPE html>
 | |
| <html lang="en">
 | |
| <head>
 | |
|     <meta charset="utf-8">
 | |
|     <title>JSDoc: Source: entities/note_short.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/note_short.js</h1>
 | |
| 
 | |
|     
 | |
| 
 | |
| 
 | |
| 
 | |
|     
 | |
|     <section>
 | |
|         <article>
 | |
|             <pre class="prettyprint source linenums"><code>/**
 | |
|  * This note's representation is used in note tree and is kept in TreeCache.
 | |
|  * Its notable omission is the note content.
 | |
|  */
 | |
| class NoteShort {
 | |
|     constructor(treeCache, row) {
 | |
|         this.treeCache = treeCache;
 | |
|         /** @param {string} */
 | |
|         this.noteId = row.noteId;
 | |
|         /** @param {string} */
 | |
|         this.title = row.title;
 | |
|         /** @param {boolean} */
 | |
|         this.isProtected = row.isProtected;
 | |
|         /** @param {string} one of 'text', 'code', 'file' or 'render' */
 | |
|         this.type = row.type;
 | |
|         /** @param {string} content-type, e.g. "application/json" */
 | |
|         this.mime = row.mime;
 | |
|         /** @param {boolean} */
 | |
|         this.archived = row.archived;
 | |
|         this.cssClass = row.cssClass;
 | |
|     }
 | |
| 
 | |
|     /** @returns {boolean} */
 | |
|     isJson() {
 | |
|         return this.mime === "application/json";
 | |
|     }
 | |
| 
 | |
|     /** @returns {Promise<Branch[]>} */
 | |
|     async getBranches() {
 | |
|         const branchIds = this.treeCache.parents[this.noteId].map(
 | |
|             parentNoteId => this.treeCache.getBranchIdByChildParent(this.noteId, parentNoteId));
 | |
| 
 | |
|         return this.treeCache.getBranches(branchIds);
 | |
|     }
 | |
| 
 | |
|     /** @returns {boolean} */
 | |
|     hasChildren() {
 | |
|         return this.treeCache.children[this.noteId]
 | |
|             && this.treeCache.children[this.noteId].length > 0;
 | |
|     }
 | |
| 
 | |
|     /** @returns {Promise<Branch[]>} */
 | |
|     async getChildBranches() {
 | |
|         if (!this.treeCache.children[this.noteId]) {
 | |
|             return [];
 | |
|         }
 | |
| 
 | |
|         const branchIds = this.treeCache.children[this.noteId].map(
 | |
|             childNoteId => this.treeCache.getBranchIdByChildParent(childNoteId, this.noteId));
 | |
| 
 | |
|         return await this.treeCache.getBranches(branchIds);
 | |
|     }
 | |
| 
 | |
|     /** @returns {string[]} */
 | |
|     getParentNoteIds() {
 | |
|         return this.treeCache.parents[this.noteId] || [];
 | |
|     }
 | |
| 
 | |
|     /** @returns {Promise<NoteShort[]>} */
 | |
|     async getParentNotes() {
 | |
|         return await this.treeCache.getNotes(this.getParentNoteIds());
 | |
|     }
 | |
| 
 | |
|     /** @returns {string[]} */
 | |
|     getChildNoteIds() {
 | |
|         return this.treeCache.children[this.noteId] || [];
 | |
|     }
 | |
| 
 | |
|     /** @returns {Promise<NoteShort[]>} */
 | |
|     async getChildNotes() {
 | |
|         return await this.treeCache.getNotes(this.getChildNoteIds());
 | |
|     }
 | |
| 
 | |
|     get toString() {
 | |
|         return `Note(noteId=${this.noteId}, title=${this.title})`;
 | |
|     }
 | |
| 
 | |
|     get dto() {
 | |
|         const dto = Object.assign({}, this);
 | |
|         delete dto.treeCache;
 | |
|         delete dto.archived;
 | |
| 
 | |
|         return dto;
 | |
|     }
 | |
| }
 | |
| 
 | |
| export default NoteShort;</code></pre>
 | |
|         </article>
 | |
|     </section>
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| </div>
 | |
| 
 | |
| <nav>
 | |
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteFull.html">NoteFull</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3>
 | |
| </nav>
 | |
| 
 | |
| <br class="clear">
 | |
| 
 | |
| <footer>
 | |
|     Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Oct 07 2018 16:27:00 GMT+0200 (CEST)
 | |
| </footer>
 | |
| 
 | |
| <script> prettyPrint(); </script>
 | |
| <script src="scripts/linenumber.js"> </script>
 | |
| </body>
 | |
| </html>
 |