a7e77e10fe
The schema is built on top of the default schema and Node and Mark classes provided by tiptap-extensions. prosemirror-model is used to parse HTML/DOM into a prosemirror document, and prosemirror-markdown is used to serialize this document to (GitLab Flavored) Markdown.
27 lines
581 B
JavaScript
27 lines
581 B
JavaScript
/* eslint-disable class-methods-use-this */
|
|
|
|
import { Node } from 'tiptap';
|
|
|
|
// Transforms generated HTML back to GFM for Banzai::Filter::MarkdownFilter
|
|
export default class Summary extends Node {
|
|
get name() {
|
|
return 'summary';
|
|
}
|
|
|
|
get schema() {
|
|
return {
|
|
content: 'text*',
|
|
marks: '',
|
|
defining: true,
|
|
parseDOM: [{ tag: 'summary' }],
|
|
toDOM: () => ['summary', 0],
|
|
};
|
|
}
|
|
|
|
toMarkdown(state, node) {
|
|
state.write('<summary>');
|
|
state.text(node.textContent, false);
|
|
state.write('</summary>');
|
|
state.closeBlock(node);
|
|
}
|
|
}
|