summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/content_editor/extensions/sourcemap.js
blob: f9de71f601b61c1202943e82880fa5ccc7dac621 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { Extension } from '@tiptap/core';
import Blockquote from './blockquote';
import Bold from './bold';
import BulletList from './bullet_list';
import Code from './code';
import CodeBlockHighlight from './code_block_highlight';
import FootnoteReference from './footnote_reference';
import FootnoteDefinition from './footnote_definition';
import Frontmatter from './frontmatter';
import Heading from './heading';
import HardBreak from './hard_break';
import HorizontalRule from './horizontal_rule';
import HTMLNodes from './html_nodes';
import Image from './image';
import Italic from './italic';
import Link from './link';
import ListItem from './list_item';
import OrderedList from './ordered_list';
import Paragraph from './paragraph';
import ReferenceDefinition from './reference_definition';
import Strike from './strike';
import TaskList from './task_list';
import TaskItem from './task_item';
import Table from './table';
import TableCell from './table_cell';
import TableHeader from './table_header';
import TableRow from './table_row';

export default Extension.create({
  addGlobalAttributes() {
    return [
      {
        types: [
          Bold.name,
          Blockquote.name,
          BulletList.name,
          Code.name,
          CodeBlockHighlight.name,
          FootnoteReference.name,
          FootnoteDefinition.name,
          Frontmatter.name,
          HardBreak.name,
          Heading.name,
          HorizontalRule.name,
          Image.name,
          Italic.name,
          Link.name,
          ListItem.name,
          OrderedList.name,
          Paragraph.name,
          ReferenceDefinition.name,
          Strike.name,
          TaskList.name,
          TaskItem.name,
          Table.name,
          TableCell.name,
          TableHeader.name,
          TableRow.name,
          ...HTMLNodes.map((htmlNode) => htmlNode.name),
        ],
        attributes: {
          /**
           * The reason to add a function that returns an empty
           * string in these attributes is indicate that these
           * attributes shouldn’t be rendered in the ProseMirror
           * view.
           */
          sourceMarkdown: {
            default: null,
            renderHTML: () => '',
          },
          sourceMapKey: {
            default: null,
            renderHTML: () => '',
          },
        },
      },
    ];
  },
});