mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 10:22:29 +08:00
fix(mermaid): refresh when editing
This commit is contained in:
parent
67ab91267d
commit
e0a8b64b4d
@ -6,6 +6,8 @@ import AbstractSplitTypeWidget from "./abstract_split_type_widget.js";
|
||||
*
|
||||
* This adds the following functionality:
|
||||
*
|
||||
* - Automatic handling of the preview when content or the note changes.
|
||||
*
|
||||
*/
|
||||
export default abstract class AbstractSvgSplitTypeWidget extends AbstractSplitTypeWidget {
|
||||
|
||||
@ -20,11 +22,24 @@ export default abstract class AbstractSvgSplitTypeWidget extends AbstractSplitTy
|
||||
async doRefresh(note: FNote | null | undefined) {
|
||||
super.doRefresh(note);
|
||||
|
||||
if (note) {
|
||||
const blob = await note.getBlob();
|
||||
const content = blob?.content || "";
|
||||
console.log(content);
|
||||
const blob = await note?.getBlob();
|
||||
const content = blob?.content || "";
|
||||
this.refreshPreview(content);
|
||||
}
|
||||
|
||||
getData(): { content: string; } {
|
||||
const data = super.getData();
|
||||
this.refreshPreview(data.content);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers an update of the preview pane with the provided content.
|
||||
*
|
||||
* @param content the content that will be passed to `renderSvg` for rendering. It is not the SVG content.
|
||||
*/
|
||||
async refreshPreview(content: string) {
|
||||
if (this.note) {
|
||||
const svg = await this.renderSvg(content);
|
||||
this.$renderContainer.html(svg);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user