Skip to content

Build your personal knowledge base with Trilium Notes

renamed notefull to notecomplement

zadamf6f7836b8e88
diff --git a/package-lock.json b/package-lock.json
index 274ab3f297..d6b9d0a3d8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -7268,9 +7268,9 @@
"integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k="
},
"open": {
- "version": "7.0.1",
- "resolved": "https://registry.npmjs.org/open/-/open-7.0.1.tgz",
- "integrity": "sha512-/fVm742AZt6bZ3NpbmBzGpZksDiGbo+xz8RylegKSAnTCgT5u5tvJe0cre3QxICphqHhJHc0OFtFyvU7rNx8+Q==",
+ "version": "7.0.2",
+ "resolved": "https://registry.npmjs.org/open/-/open-7.0.2.tgz",
+ "integrity": "sha512-70E/pFTPr7nZ9nLDPNTcj3IVqnNvKuP4VsBmoKV9YGTnChe0mlS3C4qM7qKarhZ8rGaHKLfo+vBTHXDp6ZSyLQ==",
"requires": {
"is-docker": "^2.0.0",
"is-wsl": "^2.1.1"
diff --git a/package.json b/package.json
index fceb08aae6..371af27e24 100644
--- a/package.json
+++ b/package.json
@@ -54,7 +54,7 @@
"mime-types": "2.1.26",
"multer": "1.4.2",
"node-abi": "2.13.0",
- "open": "7.0.1",
+ "open": "7.0.2",
"pngjs": "3.4.0",
"portscanner": "2.2.0",
"rand-token": "0.4.0",
diff --git a/src/public/javascripts/dialogs/note_info.js b/src/public/javascripts/dialogs/note_info.js
index 886415440c..4eceb3daee 100644
--- a/src/public/javascripts/dialogs/note_info.js
+++ b/src/public/javascripts/dialogs/note_info.js
@@ -16,11 +16,11 @@ export function showDialog() {
$dialog.modal();
- const {note, noteFull} = appContext.getActiveTabContext();
+ const {note, noteComplement} = appContext.getActiveTabContext();
$noteId.text(note.noteId);
- $dateCreated.text(noteFull.dateCreated);
- $dateModified.text(noteFull.dateModified);
+ $dateCreated.text(noteComplement.dateCreated);
+ $dateModified.text(noteComplement.dateModified);
$type.text(note.type);
$mime.text(note.mime);
}
diff --git a/src/public/javascripts/entities/note_full.js b/src/public/javascripts/entities/note_complement.js
similarity index 68%
rename from src/public/javascripts/entities/note_full.js
rename to src/public/javascripts/entities/note_complement.js
index d1b667f51b..4c75021bd6 100644
--- a/src/public/javascripts/entities/note_full.js
+++ b/src/public/javascripts/entities/note_complement.js
@@ -1,10 +1,11 @@
-import NoteShort from './note_short.js';
-
/**
- * Represents full note, specifically including note's content.
+ * Complements the NoteShort with the main note content and other extra attributes
*/
-class NoteFull {
+class NoteComplement {
constructor(row) {
+ /** @param {string} */
+ this.noteId = row.noteId;
+
/** @param {string} */
this.content = row.content;
@@ -22,4 +23,4 @@ class NoteFull {
}
}
-export default NoteFull;
\ No newline at end of file
+export default NoteComplement;
\ No newline at end of file
diff --git a/src/public/javascripts/services/app_context.js b/src/public/javascripts/services/app_context.js
index 2412d4b9a8..bd5c6e0cb1 100644
--- a/src/public/javascripts/services/app_context.js
+++ b/src/public/javascripts/services/app_context.js
@@ -171,7 +171,7 @@ class AppContext {
return activeContext ? activeContext.notePath : null;
}
- /** @return {NoteFull} */
+ /** @return {NoteShort} */
getActiveTabNote() {
const activeContext = this.getActiveTabContext();
return activeContext ? activeContext.note : null;
diff --git a/src/public/javascripts/services/frontend_script_api.js b/src/public/javascripts/services/frontend_script_api.js
index cc3d300cd2..357084159e 100644
--- a/src/public/javascripts/services/frontend_script_api.js
+++ b/src/public/javascripts/services/frontend_script_api.js
@@ -289,7 +289,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
/**
* @method
- * @returns {NoteFull} active note (loaded into right pane)
+ * @returns {NoteShort} active note (loaded into right pane)
*/
this.getActiveTabNote = appContext.getActiveTabNote;
diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.js
index f167441572..7548a12dc4 100644
--- a/src/public/javascripts/services/note_detail.js
+++ b/src/public/javascripts/services/note_detail.js
@@ -1,7 +1,7 @@
import server from './server.js';
import ws from "./ws.js";
import treeCache from "./tree_cache.js";
-import NoteFull from "../entities/note_full.js";
+import NoteComplement from "../entities/note_full.js";
import appContext from "./app_context.js";
function getActiveEditor() {
@@ -15,10 +15,10 @@ function getActiveEditor() {
}
}
-async function loadNoteFull(noteId) {
+async function loadNoteComplement(noteId) {
const row = await server.get('notes/' + noteId);
- return new NoteFull(row);
+ return new NoteComplement(row);
}
function focusOnTitle() {
@@ -45,7 +45,7 @@ $(window).on('beforeunload', () => {
});
export default {
- loadNoteFull,
+ loadNoteComplement,
focusOnTitle,
focusAndSelectTitle,
getActiveEditor,
diff --git a/src/public/javascripts/services/note_tooltip.js b/src/public/javascripts/services/note_tooltip.js
index 37b6e34e8f..48b698e1aa 100644
--- a/src/public/javascripts/services/note_tooltip.js
+++ b/src/public/javascripts/services/note_tooltip.js
@@ -44,9 +44,9 @@ async function mouseEnterHandler() {
const noteId = treeService.getNoteIdFromNotePath(notePath);
const note = await treeCache.getNote(noteId);
- const noteFull = await noteDetailService.loadNoteFull(noteId);
+ const noteComplement = await noteDetailService.loadNoteComplement(noteId);
- const html = await renderTooltip(note, noteFull);
+ const html = await renderTooltip(note, noteComplement);
// we need to check if we're still hovering over the element
// since the operation to get tooltip content was async, it is possible that
@@ -71,7 +71,7 @@ function mouseLeaveHandler() {
$(this).tooltip('dispose');
}
-async function renderTooltip(note, noteFull) {
+async function renderTooltip(note, noteComplement) {
const attributes = await note.getAttributes();
let content = '';
@@ -117,11 +117,11 @@ async function renderTooltip(note, noteFull) {
if (note.type === 'text') {
// surround with <div> for a case when note's content is pure text (e.g. "[protected]") which
// then fails the jquery non-empty text test
- content += '<div>' + noteFull.content + '</div>';
+ content += '<div>' + noteComplement.content + '</div>';
}
else if (note.type === 'code') {
content += $("<pre>")
- .text(noteFull.content)
+ .text(noteComplement.content)
.prop('outerHTML');
}
else if (note.type === 'image') {
diff --git a/src/public/javascripts/services/tab_context.js b/src/public/javascripts/services/tab_context.js
index 0f7a985947..6ae5a06ac4 100644
--- a/src/public/javascripts/services/tab_context.js
+++ b/src/public/javascripts/services/tab_context.js
@@ -51,8 +51,8 @@ class TabContext extends Component {
/** @property {NoteShort} */
this.note = await treeCache.getNote(noteId);
- /** @property {NoteFull} */
- this.noteFull = await noteDetailService.loadNoteFull(noteId);
+ /** @property {NoteComplement} */
+ this.noteComplement = await noteDetailService.loadNoteComplement(noteId);
//this.cleanup(); // esp. on windows autocomplete is not getting closed automatically
diff --git a/src/public/javascripts/widgets/component.js b/src/public/javascripts/widgets/component.js
index ce813c0a44..d193547674 100644
--- a/src/public/javascripts/widgets/component.js
+++ b/src/public/javascripts/widgets/component.js
@@ -1,7 +1,9 @@
+import utils from '../services/utils.js';
+
export default class Component {
/** @param {AppContext} appContext */
constructor(appContext) {
- this.componentId = `component-${this.constructor.name}`;
+ this.componentId = `comp-${this.constructor.name}-` + utils.randomString(10);
this.appContext = appContext;
/** @type Component[] */
this.children = [];
diff --git a/src/public/javascripts/widgets/note_detail.js b/src/public/javascripts/widgets/note_detail.js
index dadb9d09f3..b0e3de14c1 100644
--- a/src/public/javascripts/widgets/note_detail.js
+++ b/src/public/javascripts/widgets/note_detail.js
@@ -37,18 +37,17 @@ export default class NoteDetailWidget extends TabAwareWidget {
this.typeWidgetPromises = {};
this.spacedUpdate = new SpacedUpdate(async () => {
- const {noteFull, note} = this.tabContext;
+ const {noteComplement, note} = this.tabContext;
const {noteId} = note;
// FIXME hack
const dto = note.dto;
- dto.content = noteFull.content = this.getTypeWidget().getContent();
+ dto.content = noteComplement.content = this.getTypeWidget().getContent();
const resp = await server.put('notes/' + noteId, dto, this.componentId);
- // FIXME: minor - does not propagate to other tab contexts with this note though
- noteFull.dateModified = resp.dateModified;
- noteFull.utcDateModified = resp.utcDateModified;
+ noteComplement.dateModified = resp.dateModified;
+ noteComplement.utcDateModified = resp.utcDateModified;
this.trigger('noteChangesSaved', {noteId})
});
@@ -161,7 +160,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
let type = note.type;
if (type === 'text' && !disableAutoBook
- && utils.isHtmlEmpty(this.tabContext.noteFull.content)
+ && utils.isHtmlEmpty(this.tabContext.noteComplement.content)
&& note.hasChildren()) {
type = 'book';
@@ -223,9 +222,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
async entitiesReloadedListener({loadResults}) {
if (loadResults.isNoteContentReloaded(this.noteId, this.componentId)) {
- this.tabContext.noteFull = await noteDetailService.loadNoteFull(this.noteId);
-
- console.log("Reloaded", this.tabContext.noteFull);
+ this.tabContext.noteComplement = await noteDetailService.loadNoteComplement(this.noteId);
this.refreshWithNote(this.note, this.notePath);
}
diff --git a/src/public/javascripts/widgets/note_info.js b/src/public/javascripts/widgets/note_info.js
index 4d87caac4a..1825076ccd 100644
--- a/src/public/javascripts/widgets/note_info.js
+++ b/src/public/javascripts/widgets/note_info.js
@@ -49,16 +49,16 @@ class NoteInfoWidget extends StandardWidget {
const $type = this.$body.find(".note-info-type");
const $mime = this.$body.find(".note-info-mime");
- const {noteFull} = this.tabContext;
+ const {noteComplement} = this.tabContext;
$noteId.text(note.noteId);
$dateCreated
- .text(noteFull.dateCreated)
- .attr("title", noteFull.dateCreated);
+ .text(noteComplement.dateCreated)
+ .attr("title", noteComplement.dateCreated);
$dateModified
- .text(noteFull.dateModified)
- .attr("title", noteFull.dateCreated);
+ .text(noteComplement.dateModified)
+ .attr("title", noteComplement.dateCreated);
$type.text(note.type);
diff --git a/src/public/javascripts/widgets/type_widgets/code.js b/src/public/javascripts/widgets/type_widgets/code.js
index ce791579de..157821b991 100644
--- a/src/public/javascripts/widgets/type_widgets/code.js
+++ b/src/public/javascripts/widgets/type_widgets/code.js
@@ -75,7 +75,7 @@ export default class CodeTypeWidget extends TypeWidget {
this.spacedUpdate.allowUpdateWithoutChange(() => {
// CodeMirror breaks pretty badly on null so even though it shouldn't happen (guarded by consistency check)
// we provide fallback
- this.codeEditor.setValue(this.tabContext.noteFull.content || "");
+ this.codeEditor.setValue(this.tabContext.noteComplement.content || "");
const info = CodeMirror.findModeByMIME(note.mime);
diff --git a/src/public/javascripts/widgets/type_widgets/file.js b/src/public/javascripts/widgets/type_widgets/file.js
index c539e5032f..953fb21ac2 100644
--- a/src/public/javascripts/widgets/type_widgets/file.js
+++ b/src/public/javascripts/widgets/type_widgets/file.js
@@ -128,9 +128,9 @@ export default class FileTypeWidget extends TypeWidget {
this.$fileSize.text(note.contentLength + " bytes");
this.$fileType.text(note.mime);
- if (this.tabContext.noteFull.content) {
+ if (this.tabContext.noteComplement.content) {
this.$previewContent.show();
- this.$previewContent.text(this.tabContext.noteFull.content);
+ this.$previewContent.text(this.tabContext.noteComplement.content);
}
else {
this.$previewContent.empty().hide();
diff --git a/src/public/javascripts/widgets/type_widgets/image.js b/src/public/javascripts/widgets/type_widgets/image.js
index bfe59aa536..12a01c241b 100644
--- a/src/public/javascripts/widgets/type_widgets/image.js
+++ b/src/public/javascripts/widgets/type_widgets/image.js
@@ -132,7 +132,7 @@ class NoteDetailImage extends TypeWidget {
this.$fileSize.text(note.contentLength + " bytes");
this.$fileType.text(note.mime);
- const imageHash = this.tabContext.noteFull.utcDateModified.replace(" ", "_");
+ const imageHash = this.tabContext.noteComplement.utcDateModified.replace(" ", "_");
this.$imageView.prop("src", `api/images/${note.noteId}/${note.title}?${imageHash}`);
}
diff --git a/src/public/javascripts/widgets/type_widgets/relation_map.js b/src/public/javascripts/widgets/type_widgets/relation_map.js
index f876b19470..0079221044 100644
--- a/src/public/javascripts/widgets/type_widgets/relation_map.js
+++ b/src/public/javascripts/widgets/type_widgets/relation_map.js
@@ -254,9 +254,9 @@ export default class RelationMapTypeWidget extends TypeWidget {
}
};
- if (this.tabContext.noteFull.content) {
+ if (this.tabContext.noteComplement.content) {
try {
- this.mapData = JSON.parse(this.tabContext.noteFull.content);
+ this.mapData = JSON.parse(this.tabContext.noteComplement.content);
} catch (e) {
console.log("Could not parse content: ", e);
}
diff --git a/src/public/javascripts/widgets/type_widgets/search.js b/src/public/javascripts/widgets/type_widgets/search.js
index 1abb1eaa77..7f8be075d1 100644
--- a/src/public/javascripts/widgets/type_widgets/search.js
+++ b/src/public/javascripts/widgets/type_widgets/search.js
@@ -45,7 +45,7 @@ export default class SearchTypeWidget extends TypeWidget {
this.$component.show();
try {
- const json = JSON.parse(this.tabContext.noteFull.content);
+ const json = JSON.parse(this.tabContext.noteComplement.content);
this.$searchString.val(json.searchString);
}
diff --git a/src/public/javascripts/widgets/type_widgets/text.js b/src/public/javascripts/widgets/type_widgets/text.js
index 71198656aa..11e4edfaba 100644
--- a/src/public/javascripts/widgets/type_widgets/text.js
+++ b/src/public/javascripts/widgets/type_widgets/text.js
@@ -140,7 +140,7 @@ export default class TextTypeWidget extends TypeWidget {
this.textEditor.isReadOnly = await note.hasLabel('readOnly');
this.spacedUpdate.allowUpdateWithoutChange(() => {
- this.textEditor.setData(this.tabContext.noteFull.content);
+ this.textEditor.setData(this.tabContext.noteComplement.content);
});
}
diff --git a/src/routes/routes.js b/src/routes/routes.js
index bf9596685c..1e6c0ce744 100644
--- a/src/routes/routes.js
+++ b/src/routes/routes.js
@@ -1,5 +1,3 @@
-import * as syncService from "../services/sync.js";
-
const setupRoute = require('./setup');
const loginRoute = require('./login');
const indexRoute = require('./index');
@@ -46,7 +44,7 @@ const auth = require('../services/auth');
const cls = require('../services/cls');
const sql = require('../services/sql');
const protectedSessionService = require('../services/protected_session');
-const syncTableService = require('../services/sync_table');
+const syncService = require('../services/sync');
const csurf = require('csurf');
const csrfMiddleware = csurf({