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

87.5% Statements 7/8
75% Branches 3/4
100% Functions 5/5
85.71% Lines 6/7

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 27 28 29 30 31 32      7x 7x                     629x     7x           90x       7x      
import { Node } from '@tiptap/core';
import { PARSE_HTML_PRIORITY_LOWEST } from '../constants';
 
const getDiv = (element) => {
  Eif (element.nodeName === 'DIV') return element;
  return element.querySelector('div');
};
 
export default Node.create({
  name: 'division',
  content: 'block*',
  group: 'block',
  defining: true,
 
  addAttributes() {
    return {
      className: {
        default: null,
        parseHTML: (element) => getDiv(element).className || null,
      },
    };
  },
 
  parseHTML() {
    return [{ tag: 'div', priority: PARSE_HTML_PRIORITY_LOWEST }];
  },
 
  renderHTML({ HTMLAttributes }) {
    return ['div', HTMLAttributes, 0];
  },
});