Skip to content

Build your personal knowledge base with Trilium Notes

Merge remote-tracking branch 'origin/better-sqlite3'

zadama7d9870846dd
diff --cc package.json
index a955eebfee,3dc3fe8681..bd7c15283b
--- a/package.json
+++ b/package.json
@@@ -80,16 -79,13 +81,16 @@@
"yazl": "^2.5.1"
},
"devDependencies": {
+ "cross-env": "^7.0.2",
- "electron": "9.0.2",
+ "electron": "9.0.4",
- "electron-builder": "22.6.0",
+ "electron-builder": "22.7.0",
"electron-packager": "14.2.1",
- "electron-rebuild": "1.10.1",
+ "electron-rebuild": "1.11.0",
+ "esm": "^3.2.25",
+ "jasmine": "^3.5.0",
"jsdoc": "3.6.4",
"lorem-ipsum": "2.0.3",
- "webpack": "5.0.0-beta.16",
+ "webpack": "5.0.0-beta.17",
"webpack-cli": "4.0.0-beta.8"
},
"optionalDependencies": {
diff --cc src/entities/attribute.js
index 14b7c8a879,0e36921db3..d9c6317e27
--- a/src/entities/attribute.js
+++ b/src/entities/attribute.js
@@@ -105,10 -105,10 +105,10 @@@ class Attribute extends Entity
// cannot be static!
updatePojo(pojo) {
- delete pojo.__note;
+ delete pojo.__note; // FIXME: probably note necessary anymore
}
- createClone(type, name, value) {
+ createClone(type, name, value, isInheritable) {
return new Attribute({
noteId: this.noteId,
type: type,
diff --cc src/public/app/services/tree.js
index 736cab6ead,fd22f1bd80..ec9e0a1db7
--- a/src/public/app/services/tree.js
+++ b/src/public/app/services/tree.js
@@@ -66,12 -66,16 +66,16 @@@ async function getRunPath(notePath, log
}
if (!parents.some(p => p.noteId === parentNoteId)) {
- console.debug(utils.now(), "Did not find parent " + parentNoteId + " for child " + childNoteId);
+ if (logErrors) {
+ console.log(utils.now(), "Did not find parent " + parentNoteId + " for child " + childNoteId);
+ }
if (parents.length > 0) {
- console.debug(utils.now(), "Available parents:", parents);
+ if (logErrors) {
+ console.log(utils.now(), "Available parents:", parents);
+ }
- const someNotePath = await getSomeNotePath(parents[0]);
+ const someNotePath = getSomeNotePath(parents[0]);
if (someNotePath) { // in case it's root the path may be empty
const pathToRoot = someNotePath.split("/").reverse();
diff --cc src/public/app/widgets/type_widgets/editable_text.js
index 2190931a87,1a4f8a1e00..d7923cc662
--- a/src/public/app/widgets/type_widgets/editable_text.js
+++ b/src/public/app/widgets/type_widgets/editable_text.js
@@@ -259,19 -258,7 +259,23 @@@ export default class EditableTextTypeWi
} );
}
+ async createNoteForReferenceLink(title) {
+ const {parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(this.notePath);
+
+ const {note} = await noteCreateService.createNote(parentNoteId, {
+ activate: false,
+ title: title,
+ target: 'after',
+ targetBranchId: await treeCache.getBranchId(parentNoteId, this.noteId),
+ type: 'text'
+ });
+
+ const notePath = treeService.getSomeNotePath(note);
+
+ return notePath;
+ }
++
+ async refreshIncludedNoteEvent({noteId}) {
+ this.refreshIncludedNote(this.$editor, noteId);
+ }
}
diff --cc src/services/utils.js
index ff71e6d398,5a13950348..e41779b44d
--- a/src/services/utils.js
+++ b/src/services/utils.js
@@@ -210,29 -217,24 +218,47 @@@ function formatDownloadTitle(filename,
}
}
+function removeTextFileExtension(filePath) {
+ const extension = path.extname(filePath).toLowerCase();
+
+ if (extension === '.md' || extension === '.markdown' || extension === '.html') {
+ return filePath.substr(0, filePath.length - extension.length);
+ }
+ else {
+ return filePath;
+ }
+}
+
+function getNoteTitle(filePath, replaceUnderscoresWithSpaces, noteMeta) {
+ if (noteMeta) {
+ return noteMeta.title;
+ } else {
+ const basename = path.basename(removeTextFileExtension(filePath));
+ if(replaceUnderscoresWithSpaces) {
+ return basename.replace(/_/g, ' ').trim();
+ }
+ return basename;
+ }
+}
+
+ function timeLimit(promise, limitMs) {
+ return new Promise((res, rej) => {
+ let resolved = false;
+
+ promise.then(result => {
+ resolved = true;
+
+ res(result);
+ });
+
+ setTimeout(() => {
+ if (!resolved) {
+ rej(new Error('Process exceeded time limit ' + limitMs));
+ }
+ }, limitMs);
+ });
+ }
+
module.exports = {
randomSecureToken,
randomString,
@@@ -261,7 -263,6 +287,8 @@@
isStringNote,
quoteRegex,
replaceAll,
- formatDownloadTitle,
+ getNoteTitle,
+ removeTextFileExtension,
+ formatDownloadTitle,
+ timeLimit
};