Welcome to mirror list, hosted at ThFree Co, Russian Federation.

division.js « extensions « content_editor « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 566ed85acf37519ddc6859d4cf0a5ac084ce5dd4 (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
import { Node } from '@tiptap/core';
import { PARSE_HTML_PRIORITY_LOWEST } from '../constants';

const getDiv = (element) => {
  if (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];
  },
});