diff --git a/db/migrations/0184__NOOP.js b/db/migrations/0184__NOOP.js
new file mode 100644
index 000000000..9ad8902db
--- /dev/null
+++ b/db/migrations/0184__NOOP.js
@@ -0,0 +1 @@
+module.exports = () => console.log("NOOP, moved to migration 0189");
diff --git a/db/migrations/0187__add_changeId_to_entity_changes.sql b/db/migrations/0187__add_changeId_to_entity_changes.sql
index e897b58da..e2350594b 100644
--- a/db/migrations/0187__add_changeId_to_entity_changes.sql
+++ b/db/migrations/0187__add_changeId_to_entity_changes.sql
@@ -1,3 +1,13 @@
+-- delete duplicates https://github.com/zadam/trilium/issues/2534
+DELETE FROM entity_changes WHERE isErased = 0 AND id IN (
+ SELECT id FROM entity_changes ec
+ WHERE (
+ SELECT COUNT(*) FROM entity_changes
+ WHERE ec.entityName = entity_changes.entityName
+ AND ec.entityId = entity_changes.entityId
+ ) > 1
+);
+
CREATE TABLE IF NOT EXISTS "mig_entity_changes" (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`entityName` TEXT NOT NULL,
@@ -10,8 +20,8 @@ CREATE TABLE IF NOT EXISTS "mig_entity_changes" (
`utcDateChanged` TEXT NOT NULL
);
-INSERT INTO mig_entity_changes (entityName, entityId, hash, isErased, changeId, sourceId, isSynced, utcDateChanged)
- SELECT entityName, entityId, hash, isErased, '', sourceId, isSynced, utcDateChanged FROM entity_changes;
+INSERT INTO mig_entity_changes (id, entityName, entityId, hash, isErased, changeId, sourceId, isSynced, utcDateChanged)
+ SELECT id, entityName, entityId, hash, isErased, '', sourceId, isSynced, utcDateChanged FROM entity_changes;
DROP TABLE entity_changes;
diff --git a/db/migrations/0184__add_excludeFromNoteMap_to_journal.js b/db/migrations/0189__add_excludeFromNoteMap_to_journal.js
similarity index 100%
rename from db/migrations/0184__add_excludeFromNoteMap_to_journal.js
rename to db/migrations/0189__add_excludeFromNoteMap_to_journal.js
diff --git a/docs/backend_api/ApiToken.html b/docs/backend_api/ApiToken.html
index fd85e3d53..d9539104c 100644
--- a/docs/backend_api/ApiToken.html
+++ b/docs/backend_api/ApiToken.html
@@ -363,7 +363,9 @@
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/Attribute.html b/docs/backend_api/Attribute.html
index f0dd9a7ec..5da2f4475 100644
--- a/docs/backend_api/Attribute.html
+++ b/docs/backend_api/Attribute.html
@@ -1020,7 +1020,9 @@ and relation (representing named relationship between source and target note)
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/BackendScriptApi.html b/docs/backend_api/BackendScriptApi.html
index cf1a18ddb..ac1229dcf 100644
--- a/docs/backend_api/BackendScriptApi.html
+++ b/docs/backend_api/BackendScriptApi.html
@@ -614,7 +614,7 @@
-module:sql
+module:sql
@@ -5493,7 +5493,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
- if branch will be create between note and parent note, set this prefix
+ if branch will be created between note and parent note, set this prefix
@@ -5913,7 +5913,9 @@ exists, then we'll use that transaction.
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/Branch.html b/docs/backend_api/Branch.html
index d29b8e361..b1de020b2 100644
--- a/docs/backend_api/Branch.html
+++ b/docs/backend_api/Branch.html
@@ -252,7 +252,7 @@ parents.
Source:
@@ -514,7 +514,7 @@ parents.
Source:
@@ -752,7 +752,9 @@ parents.
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/Note.html b/docs/backend_api/Note.html
index cb9c0307f..06bbc8a9d 100644
--- a/docs/backend_api/Note.html
+++ b/docs/backend_api/Note.html
@@ -1517,7 +1517,7 @@
Source:
@@ -1619,7 +1619,7 @@
Source:
@@ -1721,7 +1721,7 @@
Source:
@@ -1827,7 +1827,7 @@
Source:
@@ -2001,7 +2001,7 @@
Source:
@@ -2201,7 +2201,7 @@
Source:
@@ -2379,7 +2379,7 @@
Source:
@@ -2476,6 +2476,8 @@
+ Deprecated: use getParentBranches() instead
+
@@ -2488,7 +2490,7 @@
Source:
@@ -2590,7 +2592,7 @@
Source:
@@ -2692,7 +2694,7 @@
Source:
@@ -2794,7 +2796,7 @@
Source:
@@ -2896,7 +2898,7 @@
Source:
@@ -3004,7 +3006,7 @@
Source:
@@ -3110,7 +3112,7 @@
Source:
@@ -3261,7 +3263,7 @@
Source:
@@ -3431,7 +3433,7 @@
Source:
@@ -3586,7 +3588,7 @@
Source:
@@ -3756,7 +3758,7 @@
Source:
@@ -3862,7 +3864,7 @@
Source:
@@ -4064,7 +4066,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -4242,7 +4244,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -4400,7 +4402,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -4570,7 +4572,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -4725,7 +4727,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -4895,7 +4897,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -5050,7 +5052,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -5220,7 +5222,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -5375,7 +5377,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -5586,7 +5588,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -5737,7 +5739,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -5907,7 +5909,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6062,7 +6064,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6171,7 +6173,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6280,7 +6282,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6382,7 +6384,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6484,7 +6486,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6586,7 +6588,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6693,7 +6695,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6795,7 +6797,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6946,7 +6948,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7124,7 +7126,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7279,7 +7281,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7434,7 +7436,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7589,7 +7591,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7739,7 +7741,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7845,7 +7847,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7951,7 +7953,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8057,7 +8059,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8163,7 +8165,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8269,7 +8271,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8502,7 +8504,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8682,7 +8684,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8862,7 +8864,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9073,7 +9075,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9253,7 +9255,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9413,7 +9415,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9655,7 +9657,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9866,7 +9868,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -10077,7 +10079,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -10123,7 +10125,9 @@ This method can be significantly faster than the getAttribute()
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/NoteRevision.html b/docs/backend_api/NoteRevision.html
index 4c5ba9ca9..800f9985c 100644
--- a/docs/backend_api/NoteRevision.html
+++ b/docs/backend_api/NoteRevision.html
@@ -1290,7 +1290,9 @@ It's used for seamless note versioning.
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/Option.html b/docs/backend_api/Option.html
index f0f20a329..d90875d9f 100644
--- a/docs/backend_api/Option.html
+++ b/docs/backend_api/Option.html
@@ -431,7 +431,9 @@
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/RecentNote.html b/docs/backend_api/RecentNote.html
index a03691ba7..31106a6b5 100644
--- a/docs/backend_api/RecentNote.html
+++ b/docs/backend_api/RecentNote.html
@@ -363,7 +363,9 @@
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/becca_entities_api_token.js.html b/docs/backend_api/becca_entities_api_token.js.html
index 62e869de9..a6436cbca 100644
--- a/docs/backend_api/becca_entities_api_token.js.html
+++ b/docs/backend_api/becca_entities_api_token.js.html
@@ -70,7 +70,9 @@ module.exports = ApiToken;
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/becca_entities_attribute.js.html b/docs/backend_api/becca_entities_attribute.js.html
index 2fe091dbd..569206094 100644
--- a/docs/backend_api/becca_entities_attribute.js.html
+++ b/docs/backend_api/becca_entities_attribute.js.html
@@ -245,7 +245,9 @@ module.exports = Attribute;
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/becca_entities_branch.js.html b/docs/backend_api/becca_entities_branch.js.html
index 860191014..474c07967 100644
--- a/docs/backend_api/becca_entities_branch.js.html
+++ b/docs/backend_api/becca_entities_branch.js.html
@@ -86,6 +86,12 @@ class Branch extends AbstractEntity {
}
init() {
+ if (this.branchId) {
+ this.becca.branches[this.branchId] = this;
+ }
+
+ this.becca.childParentToBranch[`${this.noteId}-${this.parentNoteId}`] = this;
+
if (this.branchId === 'root') {
return;
}
@@ -104,15 +110,12 @@ class Branch extends AbstractEntity {
if (!parentNote.children.includes(childNote)) {
parentNote.children.push(childNote);
}
-
- this.becca.branches[this.branchId] = this;
- this.becca.childParentToBranch[`${this.noteId}-${this.parentNoteId}`] = this;
}
/** @returns {Note} */
get childNote() {
if (!(this.noteId in this.becca.notes)) {
- // entities can come out of order in sync, create skeleton which will be filled later
+ // entities can come out of order in sync/import, create skeleton which will be filled later
this.becca.addNote(this.noteId, new Note({noteId: this.noteId}));
}
@@ -126,7 +129,7 @@ class Branch extends AbstractEntity {
/** @returns {Note} */
get parentNote() {
if (!(this.parentNoteId in this.becca.notes)) {
- // entities can come out of order in sync, create skeleton which will be filled later
+ // entities can come out of order in sync/import, create skeleton which will be filled later
this.becca.addNote(this.parentNoteId, new Note({noteId: this.parentNoteId}));
}
@@ -164,9 +167,7 @@ class Branch extends AbstractEntity {
notePosition: this.notePosition,
isExpanded: this.isExpanded,
isDeleted: false,
- utcDateModified: this.utcDateModified,
- // not used for anything, will be later dropped
- utcDateCreated: dateUtils.utcNowDateTime()
+ utcDateModified: this.utcDateModified
};
}
@@ -192,7 +193,9 @@ module.exports = Branch;
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/becca_entities_note.js.html b/docs/backend_api/becca_entities_note.js.html
index a16635153..64d0a4539 100644
--- a/docs/backend_api/becca_entities_note.js.html
+++ b/docs/backend_api/becca_entities_note.js.html
@@ -164,7 +164,10 @@ class Note extends AbstractEntity {
return this.parentBranches;
}
- /** @returns {Branch[]} */
+ /**
+ * @returns {Branch[]}
+ * @deprecated use getParentBranches() instead
+ */
getBranches() {
return this.parentBranches;
}
@@ -1139,7 +1142,7 @@ class Note extends AbstractEntity {
const branch = this.becca.getNote(parentNoteId).getParentBranches()[0];
- return cloningService.cloneNoteToParent(this.noteId, branch.branchId);
+ return cloningService.cloneNoteToBranch(this.noteId, branch.branchId);
}
decrypt() {
@@ -1211,7 +1214,9 @@ module.exports = Note;
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/becca_entities_note_revision.js.html b/docs/backend_api/becca_entities_note_revision.js.html
index cd16ba839..6bea60bb8 100644
--- a/docs/backend_api/becca_entities_note_revision.js.html
+++ b/docs/backend_api/becca_entities_note_revision.js.html
@@ -230,7 +230,9 @@ module.exports = NoteRevision;
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/becca_entities_option.js.html b/docs/backend_api/becca_entities_option.js.html
index c9cc7ae32..5c315cf47 100644
--- a/docs/backend_api/becca_entities_option.js.html
+++ b/docs/backend_api/becca_entities_option.js.html
@@ -65,9 +65,7 @@ class Option extends AbstractEntity {
name: this.name,
value: this.value,
isSynced: this.isSynced,
- utcDateModified: this.utcDateModified,
- // utcDateCreated is scheduled for removal so the value does not matter
- utcDateCreated: dateUtils.utcNowDateTime()
+ utcDateModified: this.utcDateModified
}
}
}
@@ -83,7 +81,9 @@ module.exports = Option;
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/becca_entities_recent_note.js.html b/docs/backend_api/becca_entities_recent_note.js.html
index 627f16937..fdf0f598c 100644
--- a/docs/backend_api/becca_entities_recent_note.js.html
+++ b/docs/backend_api/becca_entities_recent_note.js.html
@@ -69,7 +69,9 @@ module.exports = RecentNote;
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/global.html b/docs/backend_api/global.html
index aa443d260..f38d479fe 100644
--- a/docs/backend_api/global.html
+++ b/docs/backend_api/global.html
@@ -1083,7 +1083,9 @@
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/index.html b/docs/backend_api/index.html
index 9c94014d0..6da54a46a 100644
--- a/docs/backend_api/index.html
+++ b/docs/backend_api/index.html
@@ -50,7 +50,9 @@
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/module-sql.html b/docs/backend_api/module-sql.html
deleted file mode 100644
index 1f457e4ce..000000000
--- a/docs/backend_api/module-sql.html
+++ /dev/null
@@ -1,1267 +0,0 @@
-
-
-
-
- JSDoc: Module: sql
-
-
-
-
-
-
-
-
-
-
-
-
-
Module: sql
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Methods
-
-
-
-
-
-
-
- (static) execute(query, paramsopt )
-
-
-
-
-
-
-
- Execute SQL
-
-
-
-
-
-
-
-
-
-
- Parameters:
-
-
-
-
-
-
- Name
-
-
- Type
-
-
- Attributes
-
-
-
-
- Description
-
-
-
-
-
-
-
-
- query
-
-
-
-
-
-string
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SQL query with ? used as parameter placeholder
-
-
-
-
-
-
- params
-
-
-
-
-
-Array.<object>
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
- array of params if needed
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Source:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (static) getColumn(query, paramsopt ) → {Array.<object>}
-
-
-
-
-
-
-
- Get a first column in an array.
-
-
-
-
-
-
-
-
-
-
- Parameters:
-
-
-
-
-
-
- Name
-
-
- Type
-
-
- Attributes
-
-
-
-
- Description
-
-
-
-
-
-
-
-
- query
-
-
-
-
-
-string
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SQL query with ? used as parameter placeholder
-
-
-
-
-
-
- params
-
-
-
-
-
-Array.<object>
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
- array of params if needed
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Source:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Returns:
-
-
-
- - array of first column of all returned rows
-
-
-
-
-
-
- Type
-
-
-
-Array.<object>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (static) getMap(query, paramsopt ) → {object}
-
-
-
-
-
-
-
- Get a map of first column mapping to second column.
-
-
-
-
-
-
-
-
-
-
- Parameters:
-
-
-
-
-
-
- Name
-
-
- Type
-
-
- Attributes
-
-
-
-
- Description
-
-
-
-
-
-
-
-
- query
-
-
-
-
-
-string
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SQL query with ? used as parameter placeholder
-
-
-
-
-
-
- params
-
-
-
-
-
-Array.<object>
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
- array of params if needed
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Source:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Returns:
-
-
-
- - map of first column to second column
-
-
-
-
-
-
- Type
-
-
-
-object
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (static) getRow(query, paramsopt ) → {object}
-
-
-
-
-
-
-
- Get first returned row.
-
-
-
-
-
-
-
-
-
-
- Parameters:
-
-
-
-
-
-
- Name
-
-
- Type
-
-
- Attributes
-
-
-
-
- Description
-
-
-
-
-
-
-
-
- query
-
-
-
-
-
-string
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SQL query with ? used as parameter placeholder
-
-
-
-
-
-
- params
-
-
-
-
-
-Array.<object>
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
- array of params if needed
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Source:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Returns:
-
-
-
- - map of column name to column value
-
-
-
-
-
-
- Type
-
-
-
-object
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (static) getRows(query, paramsopt ) → {Array.<object>}
-
-
-
-
-
-
-
- Get all returned rows.
-
-
-
-
-
-
-
-
-
-
- Parameters:
-
-
-
-
-
-
- Name
-
-
- Type
-
-
- Attributes
-
-
-
-
- Description
-
-
-
-
-
-
-
-
- query
-
-
-
-
-
-string
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SQL query with ? used as parameter placeholder
-
-
-
-
-
-
- params
-
-
-
-
-
-Array.<object>
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
- array of params if needed
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Source:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Returns:
-
-
-
- - array of all rows, each row is a map of column name to column value
-
-
-
-
-
-
- Type
-
-
-
-Array.<object>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (static) getValue(query, paramsopt )
-
-
-
-
-
-
-
- Get single value from the given query - first column from first returned row.
-
-
-
-
-
-
-
-
-
-
- Parameters:
-
-
-
-
-
-
- Name
-
-
- Type
-
-
- Attributes
-
-
-
-
- Description
-
-
-
-
-
-
-
-
- query
-
-
-
-
-
-string
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SQL query with ? used as parameter placeholder
-
-
-
-
-
-
- params
-
-
-
-
-
-Array.<object>
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
- array of params if needed
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Source:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Returns:
-
-
-
- [object] - single value
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Modules Classes
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/backend_api/services_backend_script_api.js.html b/docs/backend_api/services_backend_script_api.js.html
index 9c72d1736..59e64a6b0 100644
--- a/docs/backend_api/services_backend_script_api.js.html
+++ b/docs/backend_api/services_backend_script_api.js.html
@@ -189,7 +189,7 @@ function BackendScriptApi(currentNote, apiParams) {
* @param {boolean} present - true if we want the branch to exist, false if we want it gone
* @param {string} noteId
* @param {string} parentNoteId
- * @param {string} prefix - if branch will be create between note and parent note, set this prefix
+ * @param {string} prefix - if branch will be created between note and parent note, set this prefix
* @returns {void}
*/
this.toggleNoteInParent = cloningService.toggleNoteInParent;
@@ -457,7 +457,9 @@ module.exports = BackendScriptApi;
- Modules Classes
+ Modules Classes
diff --git a/docs/backend_api/services_sql.js.html b/docs/backend_api/services_sql.js.html
index 9576eb954..b17d24343 100644
--- a/docs/backend_api/services_sql.js.html
+++ b/docs/backend_api/services_sql.js.html
@@ -30,6 +30,8 @@
/**
* @module sql
+ *
+ * TODO: some methods (like getValue()) could use raw rows
*/
const log = require('./log');
@@ -117,13 +119,7 @@ function getRowOrNull(query, params = []) {
}
function getValue(query, params = []) {
- const row = getRowOrNull(query, params);
-
- if (!row) {
- return null;
- }
-
- return row[Object.keys(row)[0]];
+ return wrap(query, s => s.pluck().get(params));
}
// smaller values can result in better performance due to better usage of statement cache
@@ -172,32 +168,17 @@ function iterateRows(query, params = []) {
function getMap(query, params = []) {
const map = {};
- const results = getRows(query, params);
+ const results = getRawRows(query, params);
for (const row of results) {
- const keys = Object.keys(row);
-
- map[row[keys[0]]] = row[keys[1]];
+ map[row[0]] = row[1];
}
return map;
}
function getColumn(query, params = []) {
- const list = [];
- const result = getRows(query, params);
-
- if (result.length === 0) {
- return list;
- }
-
- const key = Object.keys(result[0])[0];
-
- for (const row of result) {
- list.push(row[key]);
- }
-
- return list;
+ return wrap(query, s => s.pluck().all(params));
}
function execute(query, params = []) {
@@ -395,7 +376,9 @@ module.exports = {
- Modules Classes
+ Modules Classes
diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.html
index bc614f7d5..f4e98b4ac 100644
--- a/docs/frontend_api/FrontendScriptApi.html
+++ b/docs/frontend_api/FrontendScriptApi.html
@@ -1772,7 +1772,7 @@
Source:
@@ -1928,7 +1928,7 @@
Source:
@@ -2172,6 +2172,45 @@
+
+
+
+ showNoteIcon
+
+
+
+
+
+boolean
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+ show also note icon before the title
+
+
+
@@ -2249,7 +2288,7 @@
Source:
@@ -2488,7 +2527,7 @@
Source:
@@ -2594,7 +2633,7 @@
Source:
@@ -2748,7 +2787,7 @@
Source:
@@ -2885,7 +2924,7 @@
Source:
@@ -3147,7 +3186,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3610,7 +3649,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -3765,7 +3804,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -3920,7 +3959,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4357,7 +4396,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4513,7 +4552,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4669,7 +4708,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4806,7 +4845,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4960,7 +4999,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5901,7 +5940,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -6052,7 +6091,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -6418,7 +6457,7 @@ Typical use case is when new note has been created, we should wait until it is s
Source:
diff --git a/docs/frontend_api/NoteShort.html b/docs/frontend_api/NoteShort.html
index be44835e5..178d41f85 100644
--- a/docs/frontend_api/NoteShort.html
+++ b/docs/frontend_api/NoteShort.html
@@ -1103,7 +1103,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1303,7 +1303,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1481,7 +1481,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1575,6 +1575,8 @@ This note's representation is used in note tree and is kept in Froca.
+ Deprecated: use getParentBranches() instead
+
@@ -1587,7 +1589,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1677,6 +1679,8 @@ This note's representation is used in note tree and is kept in Froca.
+ Deprecated: use getParentBranchIds() instead
+
@@ -1689,7 +1693,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1791,7 +1795,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1893,7 +1897,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1995,7 +1999,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2146,7 +2150,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2313,7 +2317,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2468,7 +2472,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2578,7 +2582,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2752,7 +2756,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2952,7 +2956,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3130,7 +3134,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3285,7 +3289,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3452,7 +3456,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3607,7 +3611,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3762,7 +3766,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3929,7 +3933,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4084,7 +4088,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4142,6 +4146,210 @@ This note's representation is used in note tree and is kept in Froca.
+ getParentBranches() → {Array.<Branch >}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+
+
+
+ Type
+
+
+
+Array.<Branch >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ getParentBranchIds() → {Array.<string>}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+
+
+
+ Type
+
+
+
+Array.<string>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
getParentNoteIds() → {Array.<string>}
@@ -4190,7 +4398,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4292,7 +4500,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4443,7 +4651,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4610,7 +4818,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4765,7 +4973,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4935,7 +5143,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5086,7 +5294,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5192,7 +5400,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5305,7 +5513,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5411,7 +5619,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5513,7 +5721,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5687,7 +5895,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5793,7 +6001,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5944,7 +6152,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6122,7 +6330,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6277,7 +6485,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6432,7 +6640,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6587,7 +6795,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6695,7 +6903,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6779,7 +6987,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6885,7 +7093,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
diff --git a/docs/frontend_api/entities_note_short.js.html b/docs/frontend_api/entities_note_short.js.html
index 5e3f31250..f794709cf 100644
--- a/docs/frontend_api/entities_note_short.js.html
+++ b/docs/frontend_api/entities_note_short.js.html
@@ -158,18 +158,38 @@ class NoteShort {
}
}
- /** @returns {string[]} */
- getBranchIds() {
+ /**
+ * @returns {string[]}
+ */
+ getParentBranchIds() {
return Object.values(this.parentToBranch);
}
- /** @returns {Branch[]} */
- getBranches() {
+ /**
+ * @returns {string[]}
+ * @deprecated use getParentBranchIds() instead
+ */
+ getBranchIds() {
+ return this.getParentBranchIds();
+ }
+
+ /**
+ * @returns {Branch[]}
+ */
+ getParentBranches() {
const branchIds = Object.values(this.parentToBranch);
return this.froca.getBranches(branchIds);
}
+ /**
+ * @returns {Branch[]}
+ * @deprecated use getParentBranches() instead
+ */
+ getBranches() {
+ return this.getParentBranches();
+ }
+
/** @returns {boolean} */
hasChildren() {
return this.children.length > 0;
@@ -406,6 +426,9 @@ class NoteShort {
else if (this.noteId === 'root') {
return "bx bx-chevrons-right";
}
+ if (this.noteId === 'share') {
+ return "bx bx-share-alt";
+ }
else if (this.type === 'text') {
if (this.isFolder()) {
return "bx bx-folder";
@@ -648,8 +671,8 @@ class NoteShort {
});
}
- hasAncestor(ancestorNote, visitedNoteIds = null) {
- if (this.noteId === ancestorNote.noteId) {
+ hasAncestor(ancestorNoteId, visitedNoteIds = null) {
+ if (this.noteId === ancestorNoteId) {
return true;
}
@@ -663,13 +686,13 @@ class NoteShort {
visitedNoteIds.add(this.noteId);
for (const templateNote of this.getTemplateNotes()) {
- if (templateNote.hasAncestor(ancestorNote, visitedNoteIds)) {
+ if (templateNote.hasAncestor(ancestorNoteId, visitedNoteIds)) {
return true;
}
}
for (const parentNote of this.getParentNotes()) {
- if (parentNote.hasAncestor(ancestorNote, visitedNoteIds)) {
+ if (parentNote.hasAncestor(ancestorNoteId, visitedNoteIds)) {
return true;
}
}
@@ -786,6 +809,26 @@ class NoteShort {
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) {
+ continue;
+ }
+
+ if (parentNote.noteId === 'share' || parentNote.isShared()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
export default NoteShort;
diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html
index 36c0f90d8..04d0bea25 100644
--- a/docs/frontend_api/services_frontend_script_api.js.html
+++ b/docs/frontend_api/services_frontend_script_api.js.html
@@ -341,6 +341,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
* @param {object} [params]
* @param {boolean} [params.showTooltip=true] - enable/disable tooltip on the link
* @param {boolean} [params.showNotePath=false] - show also whole note's path as part of the link
+ * @param {boolean} [params.showNoteIcon=false] - show also note icon before the title
* @param {string} [title=] - custom link tile with note's title as default
*/
this.createNoteLink = linkService.createNoteLink;
diff --git a/package.json b/package.json
index 8c9aa9263..1a7714c42 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "trilium",
"productName": "Trilium Notes",
"description": "Trilium Notes",
- "version": "0.49.2-beta",
+ "version": "0.49.3",
"license": "AGPL-3.0-only",
"main": "electron.js",
"bin": {
diff --git a/src/becca/becca_service.js b/src/becca/becca_service.js
index 92037178b..b27e985f5 100644
--- a/src/becca/becca_service.js
+++ b/src/becca/becca_service.js
@@ -71,14 +71,7 @@ function getNoteTitle(childNoteId, parentNoteId) {
return "[error fetching title]";
}
- let title;
-
- if (childNote.isProtected) {
- title = protectedSessionService.isProtectedSessionAvailable() ? childNote.title : '[protected]';
- }
- else {
- title = childNote.title;
- }
+ const title = childNote.getTitleOrProtected();
const branch = parentNote ? becca.getBranchFromChildAndParent(childNote.noteId, parentNote.noteId) : null;
diff --git a/src/becca/entities/note.js b/src/becca/entities/note.js
index bf4779bf0..2410d7a7f 100644
--- a/src/becca/entities/note.js
+++ b/src/becca/entities/note.js
@@ -131,6 +131,10 @@ class Note extends AbstractEntity {
|| protectedSessionService.isProtectedSessionAvailable()
}
+ getTitleOrProtected() {
+ return this.isContentAvailable() ? this.title : '[protected]';
+ }
+
/** @returns {Branch[]} */
getParentBranches() {
return this.parentBranches;
diff --git a/src/routes/api/note_map.js b/src/routes/api/note_map.js
index 4455aebe7..4458797a9 100644
--- a/src/routes/api/note_map.js
+++ b/src/routes/api/note_map.js
@@ -98,7 +98,7 @@ function getLinkMap(req) {
return [
note.noteId,
- note.isContentAvailable() ? note.title : '[protected]',
+ note.getTitleOrProtected(),
note.type
];
});
@@ -158,7 +158,7 @@ function getTreeMap(req) {
.concat(...mapRootNote.getParentNotes())
.map(note => [
note.noteId,
- note.isContentAvailable() ? note.title : '[protected]',
+ note.getTitleOrProtected(),
note.type
]);
diff --git a/src/routes/api/tree.js b/src/routes/api/tree.js
index 0503c4202..3894fbce3 100644
--- a/src/routes/api/tree.js
+++ b/src/routes/api/tree.js
@@ -54,7 +54,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {
notes.push({
noteId: note.noteId,
- title: note.isDecrypted ? note.title : '[protected]',
+ title: note.getTitleOrProtected(),
isProtected: note.isProtected,
type: note.type,
mime: note.mime
diff --git a/src/services/build.js b/src/services/build.js
index eba226397..e96a03068 100644
--- a/src/services/build.js
+++ b/src/services/build.js
@@ -1 +1 @@
-module.exports = { buildDate:"2022-01-02T22:43:30+01:00", buildRevision: "feffd57f240438d107c1ed1c1772545611a97dee" };
+module.exports = { buildDate:"2022-01-06T23:09:17+01:00", buildRevision: "590eea11830531699643b381d06a6a59dd7704bb" };
diff --git a/src/services/export/zip.js b/src/services/export/zip.js
index ffed0f5d9..3e8e3ad4a 100644
--- a/src/services/export/zip.js
+++ b/src/services/export/zip.js
@@ -97,7 +97,8 @@ function exportToZip(taskContext, branch, format, res) {
return;
}
- const completeTitle = branch.prefix ? (branch.prefix + ' - ' + note.title) : note.title;
+ const title = note.getTitleOrProtected();
+ const completeTitle = branch.prefix ? (branch.prefix + ' - ' + title) : title;
let baseFileName = sanitize(completeTitle);
if (baseFileName.length > 200) { // actual limit is 256 bytes(!) but let's be conservative
@@ -113,7 +114,7 @@ function exportToZip(taskContext, branch, format, res) {
isClone: true,
noteId: note.noteId,
notePath: notePath,
- title: note.title,
+ title: note.getTitleOrProtected(),
prefix: branch.prefix,
dataFileName: fileName,
type: 'text', // export will have text description,
@@ -125,7 +126,7 @@ function exportToZip(taskContext, branch, format, res) {
isClone: false,
noteId: note.noteId,
notePath: notePath,
- title: note.title,
+ title: note.getTitleOrProtected(),
notePosition: branch.notePosition,
prefix: branch.prefix,
isExpanded: branch.isExpanded,
@@ -445,7 +446,7 @@ ${content}
}
const note = branch.getNote();
- const zipFileName = (branch.prefix ? `${branch.prefix} - ` : "") + note.title + ".zip";
+ const zipFileName = (branch.prefix ? `${branch.prefix} - ` : "") + note.getTitleOrProtected() + ".zip";
res.setHeader('Content-Disposition', utils.getContentDisposition(zipFileName));
res.setHeader('Content-Type', 'application/zip');
diff --git a/src/services/notes.js b/src/services/notes.js
index f35706a2f..304b406dc 100644
--- a/src/services/notes.js
+++ b/src/services/notes.js
@@ -104,8 +104,9 @@ function createNewNote(params) {
throw new Error(`Parent note "${params.parentNoteId}" not found.`);
}
- if (!params.title || params.title.trim().length === 0) {
- throw new Error(`Note title must not be empty`);
+ if (params.title === null || params.title === undefined) {
+ // empty title is allowed since it's possible to create such in the UI
+ throw new Error(`Note title must be set`);
}
if (params.content === null || params.content === undefined) {
diff --git a/src/services/script.js b/src/services/script.js
index 0ab45b537..1079fe5a1 100644
--- a/src/services/script.js
+++ b/src/services/script.js
@@ -5,7 +5,7 @@ const becca = require("../becca/becca");
function executeNote(note, apiParams) {
if (!note.isJavaScript() || note.getScriptEnv() !== 'backend' || !note.isContentAvailable()) {
- log.info(`Cannot execute note ${note.noteId} "${note.title}", note must be of type "Code: JS frontend"`);
+ log.info(`Cannot execute note ${note.noteId} "${note.title}", note must be of type "Code: JS backend"`);
return;
}
diff --git a/src/views/share/page.ejs b/src/views/share/page.ejs
index cefd35b96..b7506b853 100644
--- a/src/views/share/page.ejs
+++ b/src/views/share/page.ejs
@@ -29,7 +29,7 @@
<% if (note.parents[0].noteId !== 'share' && note.parents.length !== 0) { %>
- parent: <%= note.parents[0].title %>
<% } %>
@@ -40,10 +40,7 @@
<% } %>
- <% if (note.type === 'book') { %>
- <% } else if (isEmpty) { %>
-
This note has no content.
- <% } else { %>
+ <% if (!isEmpty) { %>
<%- content %>
@@ -52,20 +49,21 @@
<% if (note.hasChildren()) { %>
<% if (!isEmpty) { %>
-
<% } %>
+
+ <% } else if (isEmpty) { %>
+
This note has no content.
<% } %>