1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-06-29 04:01:49 +03:00
Files
bookstack/resources/js/editor.js
Dan Brown 0fb8ba00a5 Attempted adding tricky custom block
Attempted adding callouts, which have the challenge of being shown via
HTML within markdown content. Got stuck on parsing back to the state
from markdown.
2022-01-07 16:37:36 +00:00

17 lines
608 B
JavaScript

import MarkdownView from "./editor/MarkdownView";
import ProseMirrorView from "./editor/ProseMirrorView";
const place = document.querySelector("#editor");
let view = new ProseMirrorView(place, document.getElementById('content').innerHTML);
const markdownToggle = document.getElementById('markdown-toggle');
markdownToggle.addEventListener('change', event => {
const View = markdownToggle.checked ? MarkdownView : ProseMirrorView;
if (view instanceof View) return
const content = view.content
console.log(content);
view.destroy()
view = new View(place, content)
view.focus()
});