BookStack/resources/js/editor/markdown-serializer.js
Dan Brown a8f48185b5
Got underline working in editor
Major step, since this is the first inline HTML element which needed
advanced parsing out on the markdown side, since not commonmark
supported.
2022-01-10 13:38:32 +00:00

25 lines
No EOL
618 B
JavaScript

import {MarkdownSerializer, defaultMarkdownSerializer} from "prosemirror-markdown";
import {docToHtml} from "./util";
const nodes = defaultMarkdownSerializer.nodes;
const marks = defaultMarkdownSerializer.marks;
nodes.callout = function(state, node) {
writeNodeAsHtml(state, node);
};
marks.underline = {
open: '<span style="text-decoration: underline;">',
close: '</span>',
};
function writeNodeAsHtml(state, node) {
const html = docToHtml({ content: [node] });
state.write(html);
state.closeBlock();
}
const serializer = new MarkdownSerializer(nodes, marks);
export default serializer;