Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
cssClass is correctly filled for new note
azivner792039227f9a
diff --git a/src/entities/note.js b/src/entities/note.jsindex 09bfb34827..4c2c09aec8 100644--- a/src/entities/note.js+++ b/src/entities/note.js@@ -99,23 +99,37 @@ class Note extends Entity {return await repository.getEntities(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ?`, [this.noteId]);}- /** @returns {Promise<Attribute[]>} all note's attributes, including inherited ones */- async getAttributes() {+ /**+ * @param {string} [name] - attribute name to filter+ * @returns {Promise<Attribute[]>} all note's attributes, including inherited ones+ */+ async getAttributes(name) {if (!this.__attributeCache) {await this.loadAttributesToCache();}- return this.__attributeCache;+ if (name) {+ return this.__attributeCache.filter(attr => attr.name === name);+ }+ else {+ return this.__attributeCache;+ }}- /** @returns {Promise<Attribute[]>} all note's labels (attributes with type label), including inherited ones */- async getLabels() {- return (await this.getAttributes()).filter(attr => attr.type === LABEL);+ /**+ * @param {string} [name] - label name to filter+ * @returns {Promise<Attribute[]>} all note's labels (attributes with type label), including inherited ones+ */+ async getLabels(name) {+ return (await this.getAttributes(name)).filter(attr => attr.type === LABEL);}- /** @returns {Promise<Attribute[]>} all note's relations (attributes with type relation), including inherited ones */- async getRelations() {- return (await this.getAttributes()).filter(attr => attr.type === RELATION);+ /**+ * @param {string} [name] - relation name to filter+ * @returns {Promise<Attribute[]>} all note's relations (attributes with type relation), including inherited ones+ */+ async getRelations(name) {+ return (await this.getAttributes(name)).filter(attr => attr.type === RELATION);}/**diff --git a/src/public/javascripts/services/protected_session.js b/src/public/javascripts/services/protected_session.jsindex 60a91e65a2..d8924e1e83 100644--- a/src/public/javascripts/services/protected_session.js+++ b/src/public/javascripts/services/protected_session.js@@ -89,6 +89,8 @@ async function setupProtectedSession() {$protectedSessionOnButton.addClass('active');$protectedSessionOffButton.removeClass('active');}++ infoService.showMessage("Protected session has been started.");}function ensureDialogIsClosed() {diff --git a/src/routes/api/notes.js b/src/routes/api/notes.jsindex 97cddb8bd4..ccb5f75b63 100644--- a/src/routes/api/notes.js+++ b/src/routes/api/notes.js@@ -26,6 +26,8 @@ async function createNote(req) {const { note, branch } = await noteService.createNewNote(parentNoteId, newNote, req);+ note.cssClass = (await note.getLabels("cssClass")).map(label => label.value).join(" ");+return {note,branchdiff --git a/src/services/notes.js b/src/services/notes.jsindex 3b79712fa9..62c2b52ee7 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -81,6 +81,8 @@ async function createNewNote(parentNoteId, noteData) {position: attr.position,isInheritable: attr.isInheritable}).save();++ note.invalidateAttributeCache();}}