Merge remote-tracking branch 'origin/master' into dev

# Conflicts:
#	package-lock.json
#	src/public/app/widgets/mermaid.js
This commit is contained in:
zadam 2023-02-15 23:47:41 +01:00
commit 42e08284b0
5 changed files with 48 additions and 40 deletions

View File

@ -2,7 +2,7 @@
"name": "trilium",
"productName": "Trilium Notes",
"description": "Trilium Notes",
"version": "0.58.7",
"version": "0.58.8",
"license": "AGPL-3.0-only",
"main": "electron.js",
"bin": {

View File

@ -85,6 +85,7 @@ const TPL = `
font-size: 90%;
position: relative;
left: 0;
top: 5px;
}
</style>

View File

@ -75,44 +75,45 @@ export default class MermaidWidget extends NoteContextAwareWidget {
const wheelZoomLoaded = libraryLoader.requireLibrary(libraryLoader.WHEEL_ZOOM);
try {
const renderedSvg = await this.renderSvg();
this.$display.html(renderedSvg);
await this.renderSvg(async renderedSvg => {
this.$display.html(renderedSvg);
// not awaiting intentionally
// this is pretty hacky since we update ancillary on render
// but if nothing changed this should not trigger DB write and sync
server.put(`notes/${note.noteId}/ancillaries/mermaidSvg`, {
mime: 'image/svg+xml',
content: renderedSvg
// not awaiting intentionally
// this is pretty hacky since we update ancillary on render
// but if nothing changed this should not trigger DB write and sync
server.put(`notes/${note.noteId}/ancillaries/mermaidSvg`, {
mime: 'image/svg+xml',
content: renderedSvg
});
await wheelZoomLoaded;
this.$display.attr("id", `mermaid-render-${idCounter}`);
WZoom.create(`#mermaid-render-${idCounter}`, {
type: 'html',
maxScale: 10,
speed: 20,
zoomOnClick: false
});
this.$errorContainer.hide();
});
await wheelZoomLoaded;
this.$display.attr("id", `mermaid-render-${idCounter}`);
WZoom.create(`#mermaid-render-${idCounter}`, {
type: 'html',
maxScale: 10,
speed: 20,
zoomOnClick: false
});
this.$errorContainer.hide();
} catch (e) {
this.$errorMessage.text(e.message);
this.$errorContainer.show();
}
}
renderSvg() {
return new Promise(async res => {
idCounter++;
async renderSvg(cb) {
idCounter++;
const noteComplement = await froca.getNoteComplement(this.noteId);
const content = noteComplement.content || "";
const noteComplement = await froca.getNoteComplement(this.noteId);
const content = noteComplement.content || "";
mermaid.mermaidAPI.render(`mermaid-graph-${idCounter}`, content, res);
});
// this can't be promisified since in case of error this both calls callback with error SVG and throws exception
// with error details
mermaid.mermaidAPI.render(`mermaid-graph-${idCounter}`, content, cb);
}
async entitiesReloadedEvent({loadResults}) {
@ -126,9 +127,9 @@ export default class MermaidWidget extends NoteContextAwareWidget {
return;
}
const renderedSvg = await this.renderSvg();
this.download(`${this.note.title}.svg`, renderedSvg);
await this.renderSvg(renderedSvg => {
this.download(`${this.note.title}.svg`, renderedSvg);
});
}
download(filename, text) {

View File

@ -154,6 +154,19 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
}
});
this.watchdog.setCreator(async (elementOrData, editorConfig) => {
const editor = await BalloonEditor.create(elementOrData, editorConfig);
editor.model.document.on('change:data', () => this.spacedUpdate.scheduleUpdate());
if (glob.isDev && ENABLE_INSPECTOR) {
await import(/* webpackIgnore: true */'../../../libraries/ckeditor/inspector.js');
CKEditorInspector.attach(editor);
}
return editor;
});
await this.watchdog.create(this.$editor[0], {
placeholder: "Type the content of your note here ...",
mention: mentionSetup,
@ -168,13 +181,6 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
enablePreview: true // Enable preview view
}
});
this.watchdog.editor.model.document.on('change:data', () => this.spacedUpdate.scheduleUpdate());
if (glob.isDev && ENABLE_INSPECTOR) {
await import(/* webpackIgnore: true */'../../../libraries/ckeditor/inspector.js');
CKEditorInspector.attach(this.watchdog.editor);
}
}
async doRefresh(note) {

View File

@ -1 +1 @@
module.exports = { buildDate:"2023-01-17T23:14:58+01:00", buildRevision: "a3149aecf41bac3c559ebbd1865e916264985ac3" };
module.exports = { buildDate:"2023-02-13T21:50:54+01:00", buildRevision: "17085e5578d2a20a77a6ade058f74e6d5b798ecc" };