summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/content_editor/extensions/details_content.js
blob: fb6c49d91aa5dfd5e38ea116999753282a53cc2e (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
import { Node } from '@tiptap/core';
import { PARSE_HTML_PRIORITY_HIGHEST } from '../constants';

export default Node.create({
  name: 'detailsContent',
  content: 'block+',
  defining: true,

  parseHTML() {
    return [
      { tag: '*', consuming: false, context: 'details/', priority: PARSE_HTML_PRIORITY_HIGHEST },
    ];
  },

  renderHTML({ HTMLAttributes }) {
    return ['li', HTMLAttributes, 0];
  },

  addKeyboardShortcuts() {
    return {
      Enter: () => this.editor.commands.splitListItem('detailsContent'),
      'Shift-Tab': () => this.editor.commands.liftListItem('detailsContent'),
    };
  },
});