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

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

  addOptions() {
    return {
      HTMLAttributes: {
        dir: 'auto',
      },
    };
  },

  parseHTML() {
    return [{ tag: 'figure' }];
  },

  renderHTML({ HTMLAttributes }) {
    return ['figure', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
  },
});