diff options
Diffstat (limited to 'src/nodes/Table.js')
-rw-r--r-- | src/nodes/Table.js | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/nodes/Table.js b/src/nodes/Table.js index 02441aacf..a4d93ed85 100644 --- a/src/nodes/Table.js +++ b/src/nodes/Table.js @@ -1,8 +1,41 @@ import { Table } from '@tiptap/extension-table' -import { mergeAttributes } from '@tiptap/core' +import { Node, mergeAttributes } from '@tiptap/core' + +/* + * Markdown tables do not include captions. + * We still need to parse them though + * because otherwise tiptap will try to insert their text content + * and put it in the top row of the table. + */ +const tableCaption = Node.create({ + name: 'tableCaption', + content: 'inline*', + addAttributes() { + return {} + }, + + renderHTML() { + return ['caption'] + }, + + toMarkdown(state, node) { + }, + + parseHTML() { + return [ + { tag: 'table caption', priority: 90 }, + ] + }, +}) export default Table.extend({ - content: 'tableHead tableBody', + content: 'tableCaption? tableHead tableBody', + + addExtensions() { + return [ + tableCaption, + ] + }, renderHTML({ HTMLAttributes }) { return ['table', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0] |