All files / app/assets/javascripts/content_editor/extensions details_content.js

100% Statements 5/5
100% Branches 0/0
100% Functions 5/5
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                  99x           15x       99x 1x 1x        
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'),
    };
  },
});