Molodetz blogrol volgens DPP-template
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
export class EditorPreview {
|
||||
constructor() {
|
||||
this.source = document.querySelector("[data-preview-source]");
|
||||
this.target = document.querySelector("[data-preview-target]");
|
||||
if (!this.source || !this.target) {
|
||||
return;
|
||||
}
|
||||
this.timer = null;
|
||||
this.source.addEventListener("input", () => this.schedule());
|
||||
customElements.whenDefined("dp-content").then(() => this.update());
|
||||
}
|
||||
|
||||
schedule() {
|
||||
clearTimeout(this.timer);
|
||||
this.timer = setTimeout(() => this.update(), 150);
|
||||
}
|
||||
|
||||
update() {
|
||||
this.target.markdown = this.source.value;
|
||||
}
|
||||
}
|
||||
|
||||
window.editorPreview = new EditorPreview();
|
||||
Reference in New Issue
Block a user