summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/components/rich_content_editor/services/renderers/mock_data.js
blob: 660c21281fde574f727174b8cd6f52af8f29d018 (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
// Node spec helpers

export const buildMockTextNode = literal => {
  return {
    firstChild: null,
    literal,
    type: 'text',
  };
};

export const normalTextNode = buildMockTextNode('This is just normal text.');

// Token spec helpers

const buildMockUneditableOpenToken = type => {
  return {
    type: 'openTag',
    tagName: type,
    attributes: { contenteditable: false },
    classNames: [
      'gl-px-4 gl-py-2 gl-my-5 gl-opacity-5 gl-bg-gray-100 gl-user-select-none gl-cursor-not-allowed',
    ],
  };
};

const buildMockUneditableCloseToken = type => {
  return { type: 'closeTag', tagName: type };
};

export const originToken = {
  type: 'text',
  tagName: null,
  content: '{:.no_toc .hidden-md .hidden-lg}',
};
export const uneditableCloseToken = buildMockUneditableCloseToken('div');
export const uneditableOpenTokens = [buildMockUneditableOpenToken('div'), originToken];
export const uneditableCloseTokens = [originToken, uneditableCloseToken];
export const uneditableTokens = [...uneditableOpenTokens, uneditableCloseToken];

export const originInlineToken = {
  type: 'text',
  content: '<i>Inline</i> content',
};
export const uneditableInlineTokens = [
  buildMockUneditableOpenToken('a'),
  originInlineToken,
  buildMockUneditableCloseToken('a'),
];

export const uneditableBlockTokens = [
  buildMockUneditableOpenToken('div'),
  {
    type: 'text',
    tagName: null,
    content: '<div><h1>Some header</h1><p>Some paragraph</p></div>',
  },
  buildMockUneditableCloseToken('div'),
];