blob: 9a2e2c032134972b06fa3c64113d99ac0804e7b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/* eslint-disable class-methods-use-this */
import { Node } from 'tiptap';
import { __ } from '~/locale';
// Transforms generated HTML back to GFM for Banzai::Filter::TableOfContentsFilter
export default class TableOfContents extends Node {
get name() {
return 'table_of_contents';
}
get schema() {
return {
group: 'block',
atom: true,
parseDOM: [
{
tag: 'ul.section-nav',
priority: 51,
},
{
tag: 'p.table-of-contents',
priority: 51,
},
],
toDOM: () => ['p', { class: 'table-of-contents' }, __('Table of Contents')],
};
}
toMarkdown(state, node) {
state.write('[[_TOC_]]');
state.closeBlock(node);
}
}
|