mirror of https://github.com/TriliumNext/Notes
refactor(client/ts): start implementing experimental split type view for mermaid
parent
7a16774cdc
commit
56da5f7761
@ -0,0 +1,53 @@
|
||||
import type { EventData } from "../../components/app_context.js";
|
||||
import type FNote from "../../entities/fnote.js";
|
||||
import EditableCodeTypeWidget from "./editable_code.js";
|
||||
import TypeWidget from "./type_widget.js";
|
||||
|
||||
const TPL = `\
|
||||
<div class="note-detail-split-editor note-detail-printable">
|
||||
<div class="note-detail-split-preview">
|
||||
</div>
|
||||
|
||||
<div class="note-detail-split-editor">
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
export default class SplitTypeEditor extends TypeWidget {
|
||||
|
||||
private $preview!: JQuery<HTMLElement>;
|
||||
private $editor!: JQuery<HTMLElement>;
|
||||
private editorTypeWidget: EditableCodeTypeWidget;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.editorTypeWidget = new EditableCodeTypeWidget();
|
||||
this.editorTypeWidget.isEnabled = () => true;
|
||||
}
|
||||
|
||||
doRender(): void {
|
||||
console.log("Render");
|
||||
this.$widget = $(TPL);
|
||||
|
||||
this.$preview = this.$widget.find(".note-detail-split-preview");
|
||||
this.$editor = this.$widget.find(".note-detail-split-editor");
|
||||
this.$editor.append(this.editorTypeWidget.render());
|
||||
|
||||
super.doRender();
|
||||
}
|
||||
|
||||
async doRefresh(note: FNote | null | undefined) {
|
||||
await this.editorTypeWidget.initialized;
|
||||
|
||||
if (note) {
|
||||
console.log("Refresh with ", note);
|
||||
this.editorTypeWidget.noteContext = this.noteContext;
|
||||
this.editorTypeWidget.spacedUpdate = this.spacedUpdate;
|
||||
this.editorTypeWidget.doRefresh(note);
|
||||
}
|
||||
}
|
||||
|
||||
getData() {
|
||||
return this.editorTypeWidget.getData();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
import SplitTypeEditor from "./abstract_split_type_widget.js";
|
||||
|
||||
export class MermaidTypeWidget extends SplitTypeEditor {
|
||||
|
||||
static getType() {
|
||||
return "mermaid";
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue