1 import {htmlToDoc, docToHtml} from "./util";
3 import parser from "./markdown-parser";
4 import serializer from "./markdown-serializer";
7 constructor(target, content) {
8 // Build DOM from content
9 const htmlDoc = htmlToDoc(content);
10 const markdown = serializer.serialize(htmlDoc);
12 this.textarea = target.appendChild(document.createElement("textarea"))
13 this.textarea.value = markdown;
17 const markdown = this.textarea.value;
18 const doc = parser.parse(markdown);
19 return docToHtml(doc);
22 focus() { this.textarea.focus() }
23 destroy() { this.textarea.remove() }
26 export default MarkdownView;