debian-mirror-gitlab/app/assets/javascripts/behaviors/markdown/nodes/heading.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
682 B
JavaScript
Raw Normal View History

2022-04-04 11:22:00 +05:30
import { defaultMarkdownSerializer } from '~/lib/prosemirror_markdown_serializer';
2019-03-02 22:35:43 +05:30
// Transforms generated HTML back to GFM for Banzai::Filter::MarkdownFilter
2022-05-07 20:08:51 +05:30
export default ({ levels = [1, 2, 3, 4, 5, 6] } = {}) => ({
name: 'heading',
schema: {
attrs: {
level: {
default: 1,
},
},
content: 'inline*',
group: 'block',
defining: true,
draggable: false,
parseDOM: levels.map((level) => ({
tag: `h${level}`,
attrs: { level },
})),
toDOM: (node) => [`h${node.attrs.level}`, 0],
},
2019-03-02 22:35:43 +05:30
toMarkdown(state, node) {
if (!node.childCount) return;
defaultMarkdownSerializer.nodes.heading(state, node);
2022-05-07 20:08:51 +05:30
},
});