@atlaskit/adf-schema 21.0.0 → 22.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/cjs/json-schema/index.js +23 -0
  3. package/dist/cjs/schema/nodes/bodied-extension.js +1 -1
  4. package/dist/cjs/schema/nodes/doc.js +1 -1
  5. package/dist/cjs/schema/nodes/expand.js +1 -1
  6. package/dist/cjs/schema/nodes/layout-column.js +1 -1
  7. package/dist/cjs/schema/nodes/list-item.js +1 -1
  8. package/dist/cjs/schema/nodes/media-group.js +1 -1
  9. package/dist/cjs/schema/nodes/nested-expand.js +1 -1
  10. package/dist/cjs/schema/nodes/paragraph.js +24 -145
  11. package/dist/cjs/schema/nodes/tableNodes.js +2 -2
  12. package/dist/cjs/version.json +1 -1
  13. package/dist/es2019/json-schema/index.js +2 -0
  14. package/dist/es2019/schema/marks/data-consumer.js +8 -1
  15. package/dist/es2019/schema/nodes/bodied-extension.js +1 -1
  16. package/dist/es2019/schema/nodes/doc.js +1 -1
  17. package/dist/es2019/schema/nodes/expand.js +1 -1
  18. package/dist/es2019/schema/nodes/layout-column.js +1 -1
  19. package/dist/es2019/schema/nodes/list-item.js +1 -1
  20. package/dist/es2019/schema/nodes/media-group.js +1 -1
  21. package/dist/es2019/schema/nodes/nested-expand.js +1 -1
  22. package/dist/es2019/schema/nodes/paragraph.js +24 -142
  23. package/dist/es2019/schema/nodes/tableNodes.js +2 -2
  24. package/dist/es2019/version.json +1 -1
  25. package/dist/esm/json-schema/index.js +2 -0
  26. package/dist/esm/schema/marks/data-consumer.js +8 -1
  27. package/dist/esm/schema/nodes/bodied-extension.js +1 -1
  28. package/dist/esm/schema/nodes/doc.js +1 -1
  29. package/dist/esm/schema/nodes/expand.js +1 -1
  30. package/dist/esm/schema/nodes/layout-column.js +1 -1
  31. package/dist/esm/schema/nodes/list-item.js +1 -1
  32. package/dist/esm/schema/nodes/media-group.js +1 -1
  33. package/dist/esm/schema/nodes/nested-expand.js +1 -1
  34. package/dist/esm/schema/nodes/paragraph.js +24 -144
  35. package/dist/esm/schema/nodes/tableNodes.js +2 -2
  36. package/dist/esm/version.json +1 -1
  37. package/dist/json-schema/package.json +7 -0
  38. package/dist/types/json-schema/index.d.ts +2 -0
  39. package/dist/types/schema/marks/data-consumer.d.ts +8 -1
  40. package/dist/types/schema/nodes/media.d.ts +1 -1
  41. package/json-schema/package.json +7 -0
  42. package/package.json +10 -3
  43. package/schema/package.json +7 -0
  44. package/url/package.json +7 -0
  45. package/test-helpers/html-helpers.ts +0 -40
  46. package/test-helpers/matches.ts +0 -8
  47. package/test-helpers/schema-builder.ts +0 -329
  48. package/test-helpers/schema.ts +0 -80
package/CHANGELOG.md CHANGED
@@ -1,5 +1,79 @@
1
1
  # @atlaskit/adf-schema
2
2
 
3
+ ## 22.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`03930b9f4c7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/03930b9f4c7) - ED-14253: fixed infinite transaction loop after uploading a file to the editor.
8
+
9
+ - updated ADF for MediaBaseAttributes.\_\_contextId to allow for null value
10
+ - fixed Editor example page 2-comment-jira-bento
11
+
12
+ ## 22.0.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [`c7a3ccf95cd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c7a3ccf95cd) - Patching versions to no longer reference localid from adf or smart-cards
17
+
18
+ ## 22.0.0
19
+
20
+ ### Major Changes
21
+
22
+ - [`439cf07029a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/439cf07029a) - ED-13881 Move @atlaskit/adf-schema test helpers to @atlaskit/editor-test-helpers
23
+
24
+ A new entry point for @atlaskit/editor-test-helpers/adf-schema has been
25
+ introduced. All test helpers that previously lived under @atlaskit/adf-schema
26
+ have been moved there instead.
27
+
28
+ Imports inside @atlaskit/adf-schema that previously relied on relative paths, or
29
+ imports from other packages that referred to @atlaskit/adf-schema/test-helpers,
30
+ should be updated to reference @atlaskit/editor-test-helpers/adf-schema instead.
31
+
32
+ Old usages:
33
+
34
+ ```
35
+ import { schema } from '../relative/path/to/test-helpers';
36
+ import { schema } from '@atlaskit/adf-schema/test-helpers';
37
+ ```
38
+
39
+ New usage:
40
+
41
+ ```
42
+ import { schema } from '@atlaskit/editor-test-helpers/adf-schema';
43
+ ```
44
+
45
+ - [`a86ac5fa763`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a86ac5fa763) - ED-13881 Migrate @atlaskit/adf-schema to declarative entry points
46
+
47
+ We are now explicitly declaring entry points as public API. Since some consumers
48
+ may have previously relied on file-based entry points for the generated JSON
49
+ schema outputs, this is considered a breaking change.
50
+
51
+ Old usage:
52
+
53
+ ```
54
+ import * as fullSchema from '@atlaskit/adf-schema/json-schema/v1/full.json';
55
+ import * as stageZeroSchema from '@atlaskit/adf-schema/json-schema/v1/stage-0.json';
56
+ ```
57
+
58
+ New usage:
59
+
60
+ ```
61
+ import { fullSchema } from '@atlaskit/adf-schema/json-schema';
62
+ import { stageZeroSchema } from '@atlaskit/adf-schema/json-schema';
63
+ ```
64
+
65
+ - [`304351e4b1e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/304351e4b1e) - CETI-241 - Added additional panel ADF attributes (panelIconId, panelIconText) to uniquely identify custom panel emojis. The change has been categorised as major since it is a change to the full-schema ADF. However, the custom panel feature is behind a feature flag, has not yet been released to production, and is only currently planned for release to Confluence. See ADF change #61 for further details.
66
+ - [`3b49ff824ec`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3b49ff824ec) - ED-14043 update prosemirror schema to only allow link mark on children of paragraph and mediaSingle
67
+
68
+ ### Minor Changes
69
+
70
+ - [`e9aea0f4191`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e9aea0f4191) - CETI-243 Handling Duplicate Emoji Issue When Copying From Renderer
71
+
72
+ ### Patch Changes
73
+
74
+ - [`7f8be1a6a30`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7f8be1a6a30) - clean stage0 artefacts from dataConsumer mark
75
+ - [`783bda0d683`](https://bitbucket.org/atlassian/atlassian-frontend/commits/783bda0d683) - Extra information added to analytics for toolbar change view options
76
+
3
77
  ## 21.0.0
4
78
 
5
79
  ### Major Changes
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "fullSchema", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _full.default;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "stageZeroSchema", {
15
+ enumerable: true,
16
+ get: function get() {
17
+ return _stage.default;
18
+ }
19
+ });
20
+
21
+ var _full = _interopRequireDefault(require("../../json-schema/v1/full.json"));
22
+
23
+ var _stage = _interopRequireDefault(require("../../json-schema/v1/stage-0.json"));
@@ -11,7 +11,7 @@ var createBodiedExtensionNodeSpec = function createBodiedExtensionNodeSpec() {
11
11
  var nodeSpec = {
12
12
  inline: false,
13
13
  group: 'block',
14
- marks: 'link dataConsumer fragment',
14
+ marks: 'dataConsumer fragment',
15
15
  content: '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaGroup | mediaSingle | decisionList | taskList | table | blockCard | extension | unsupportedBlock | embedCard)+',
16
16
  defining: true,
17
17
  selectable: true,
@@ -10,6 +10,6 @@ exports.doc = void 0;
10
10
  */
11
11
  var doc = {
12
12
  content: '(block|layoutSection)+',
13
- marks: 'alignment breakout dataConsumer fragment indentation link unsupportedMark unsupportedNodeAttribute'
13
+ marks: 'alignment breakout dataConsumer fragment indentation unsupportedMark unsupportedNodeAttribute'
14
14
  };
15
15
  exports.doc = doc;
@@ -27,7 +27,7 @@ function getExpandAttrs(domNode) {
27
27
  var expand = {
28
28
  inline: false,
29
29
  group: 'block',
30
- marks: 'link dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
30
+ marks: 'dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
31
31
  content: '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaGroup | mediaSingle | decisionList | taskList | table | blockCard | embedCard | extension | unsupportedBlock)+',
32
32
  isolating: true,
33
33
  selectable: true,
@@ -11,7 +11,7 @@ exports.layoutColumn = void 0;
11
11
  var layoutColumn = {
12
12
  content: '(block|unsupportedBlock)+',
13
13
  isolating: true,
14
- marks: 'link alignment indentation dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
14
+ marks: 'alignment indentation dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
15
15
  selectable: false,
16
16
  attrs: {
17
17
  width: {
@@ -12,7 +12,7 @@ exports.listItem = void 0;
12
12
  */
13
13
  var listItem = {
14
14
  content: '(paragraph | mediaSingle | codeBlock) (paragraph | bulletList | orderedList | mediaSingle | codeBlock)*',
15
- marks: 'link unsupportedMark unsupportedNodeAttribute',
15
+ marks: 'unsupportedMark unsupportedNodeAttribute',
16
16
  defining: true,
17
17
  selectable: false,
18
18
  parseDOM: [{
@@ -13,7 +13,7 @@ var mediaGroup = {
13
13
  group: 'block',
14
14
  content: '(media|unsupportedBlock)+',
15
15
  attrs: {},
16
- marks: 'unsupportedMark unsupportedNodeAttribute link',
16
+ marks: 'unsupportedMark unsupportedNodeAttribute',
17
17
  selectable: false,
18
18
  parseDOM: [{
19
19
  tag: 'div[data-node-type="mediaGroup"]'
@@ -20,7 +20,7 @@ exports.nestedExpand = void 0;
20
20
  */
21
21
  var nestedExpand = {
22
22
  inline: false,
23
- marks: 'link unsupportedMark unsupportedNodeAttribute',
23
+ marks: 'unsupportedMark unsupportedNodeAttribute',
24
24
  content: '(paragraph | heading | mediaSingle | mediaGroup | unsupportedBlock)+',
25
25
  isolating: true,
26
26
  selectable: true,
@@ -5,72 +5,30 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.paragraph = void 0;
7
7
 
8
- var _prosemirrorModel = require("prosemirror-model");
9
-
10
- var _url = require("../../utils/url");
11
-
12
- var getLinkContent = function getLinkContent(node, schema) {
13
- if (!(node instanceof HTMLAnchorElement)) {
14
- return _prosemirrorModel.Fragment.empty;
15
- }
16
-
17
- var href = node.getAttribute('href') || '';
18
- var text = node.innerText;
19
-
20
- if (!text || text.length === 0) {
21
- return _prosemirrorModel.Fragment.empty;
22
- }
23
-
24
- var marks = (0, _url.isSafeUrl)(href) ? [schema.marks.link.create({
25
- href: href
26
- })] : [];
27
- var textNode = schema.text(text, marks);
28
- return _prosemirrorModel.Fragment.from(textNode);
29
- };
30
-
31
- var blockTags = {
32
- address: true,
33
- article: true,
34
- aside: true,
35
- blockquote: true,
36
- canvas: true,
37
- dd: true,
38
- div: true,
39
- dl: true,
40
- fieldset: true,
41
- figcaption: true,
42
- figure: true,
43
- footer: true,
44
- form: true,
45
- h1: true,
46
- h2: true,
47
- h3: true,
48
- h4: true,
49
- h5: true,
50
- h6: true,
51
- header: true,
52
- hgroup: true,
53
- hr: true,
54
- li: true,
55
- noscript: true,
56
- ol: true,
57
- output: true,
58
- p: true,
59
- pre: true,
60
- section: true,
61
- table: true,
62
- tfoot: true,
63
- ul: true
64
- };
65
-
66
- var isListItemNode = function isListItemNode(node) {
67
- return Boolean(node && node.nodeName.toLowerCase() === 'li');
68
- };
69
-
70
- var isTextNode = function isTextNode(node) {
71
- return Boolean(node && node.nodeType === Node.TEXT_NODE);
72
- };
73
-
8
+ /**
9
+ * @name paragraph_node
10
+ */
11
+
12
+ /**
13
+ * @name paragraph_with_no_marks_node
14
+ */
15
+
16
+ /**
17
+ * NOTE: Need this because TS is too smart and inline everything.
18
+ * So we need to give them separate identity.
19
+ * Probably there's a way to solve it but that will need time and exploration.
20
+ * // http://bit.ly/2raXFX5
21
+ * type T1 = X | Y
22
+ * type T2 = A | T1 | B // T2 = A | X | Y | B
23
+ */
24
+
25
+ /**
26
+ * @name paragraph_with_alignment_node
27
+ */
28
+
29
+ /**
30
+ * @name paragraph_with_indentation_node
31
+ */
74
32
  var isImageNode = function isImageNode(node) {
75
33
  return Boolean(node && node.nodeName.toLowerCase() === 'img');
76
34
  };
@@ -93,21 +51,6 @@ var hasInlineImage = function hasInlineImage(node) {
93
51
  });
94
52
  };
95
53
 
96
- var hasWhiteSpacePre = function hasWhiteSpacePre(node) {
97
- return Boolean(node instanceof HTMLElement && node.style.whiteSpace === 'pre');
98
- };
99
-
100
- var hasFontFamilyMonospace = function hasFontFamilyMonospace(node) {
101
- return Boolean(node instanceof HTMLElement && node.style.fontFamily.includes('monospace'));
102
- };
103
-
104
- var isBlockLevelNode = function isBlockLevelNode(node) {
105
- return Boolean(node && blockTags.hasOwnProperty(node.nodeName.toLowerCase()));
106
- };
107
-
108
- var NOT_INTERNAL_LINKS = [':not([data-inline-card])', ':not([data-block-card])', ':not([data-block-link])', ':not([data-skip-paste])'].join('');
109
- var ANCHOR_LINK = "a[href]".concat(NOT_INTERNAL_LINKS);
110
- var NOT_INTERNAL_ELEMENTS = [':not(.code-block)', ':not([data-node-type])', ':not([data-embed-card])', ':not([data-layout-section])', ':not([data-task-local-id])', ':not([data-task-state])', ':not([data-pm-slice])', ':not([data-mark-type])', ':not([data-layout-content])', ':not([data-panel-content])'].join('');
111
54
  var pDOM = ['p', 0];
112
55
  var paragraph = {
113
56
  selectable: false,
@@ -116,70 +59,6 @@ var paragraph = {
116
59
  marks: 'strong code em link strike subsup textColor typeAheadQuery underline confluenceInlineComment action annotation unsupportedMark unsupportedNodeAttribute dataConsumer fragment',
117
60
  parseDOM: [{
118
61
  tag: 'p'
119
- }, {
120
- tag: "div".concat(NOT_INTERNAL_ELEMENTS, ", li:not([data-pm-slice])"),
121
- priority: 100,
122
- getAttrs: function getAttrs(node) {
123
- if (!(node instanceof Node)) {
124
- return false;
125
- }
126
-
127
- var isCodeBlock = hasWhiteSpacePre(node) || hasFontFamilyMonospace(node);
128
-
129
- if (isCodeBlock || !node.hasChildNodes()) {
130
- return false;
131
- }
132
-
133
- var hasInlineChildren = Array.from(node.childNodes).every(function (child) {
134
- return !isBlockLevelNode(child) && // IMG is considered block for mediaSingle
135
- !isImageNode(child);
136
- });
137
-
138
- if (!hasInlineChildren) {
139
- return false;
140
- }
141
-
142
- if ( // We can skip this rule for pure list items
143
- isListItemNode(node) && Array.from(node.childNodes).every(isTextNode)) {
144
- return false;
145
- }
146
-
147
- return null;
148
- }
149
- }, {
150
- tag: ":not(span) + ".concat(ANCHOR_LINK),
151
- priority: 100,
152
- getContent: getLinkContent
153
- }, {
154
- tag: ":not(span) > ".concat(ANCHOR_LINK, ":first-child"),
155
- getAttrs: function getAttrs(node) {
156
- if (!(node instanceof Node)) {
157
- return false;
158
- }
159
-
160
- if (isBlockLevelNode(node.firstChild)) {
161
- return null;
162
- }
163
-
164
- if (hasInlineImage(node)) {
165
- return false;
166
- }
167
-
168
- var isNextSiblingValid = node.nextSibling === null || node.nextSibling instanceof Text && (node.nextSibling.textContent || '').trim().length === 0;
169
-
170
- if (isNextSiblingValid) {
171
- return null;
172
- } // This rule should not match when there is any sibling after the anchor
173
-
174
-
175
- if (!isBlockLevelNode(node.nextSibling)) {
176
- return false;
177
- }
178
-
179
- return null;
180
- },
181
- priority: 100,
182
- getContent: getLinkContent
183
62
  }],
184
63
  toDOM: function toDOM() {
185
64
  return pDOM;
@@ -221,7 +221,7 @@ var tableCell = {
221
221
  content: '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaSingle | mediaGroup | decisionList | taskList | blockCard | embedCard | extension | nestedExpand | unsupportedBlock)+',
222
222
  attrs: cellAttrs,
223
223
  tableRole: 'cell',
224
- marks: 'link alignment dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
224
+ marks: 'alignment dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
225
225
  isolating: true,
226
226
  parseDOM: [// Ignore number cell copied from renderer
227
227
  {
@@ -258,7 +258,7 @@ var tableHeader = {
258
258
  attrs: cellAttrs,
259
259
  tableRole: 'header_cell',
260
260
  isolating: true,
261
- marks: 'link alignment dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
261
+ marks: 'alignment dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
262
262
  parseDOM: [{
263
263
  tag: 'th',
264
264
  getAttrs: function getAttrs(dom) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "21.0.0",
3
+ "version": "22.0.2",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,2 @@
1
+ export { default as fullSchema } from '../../json-schema/v1/full.json';
2
+ export { default as stageZeroSchema } from '../../json-schema/v1/stage-0.json';
@@ -1,6 +1,13 @@
1
1
  import { isDOMElement } from '../../utils/parseDOM';
2
2
  /**
3
- * @minLength 1
3
+ * This annotation is purely for reference, & does _nothing_ given annotating
4
+ * `minLength` on an array of strings is not supported with our schema+spec
5
+ * generator.
6
+ *
7
+ * We're keeping it to signal that data consumer `sources` shouldn't be empty
8
+ * strings
9
+ *
10
+ * // @minLength 1
4
11
  */
5
12
 
6
13
  const parseDataConsumer = maybeValue => {
@@ -4,7 +4,7 @@ const createBodiedExtensionNodeSpec = () => {
4
4
  const nodeSpec = {
5
5
  inline: false,
6
6
  group: 'block',
7
- marks: 'link dataConsumer fragment',
7
+ marks: 'dataConsumer fragment',
8
8
  content: '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaGroup | mediaSingle | decisionList | taskList | table | blockCard | extension | unsupportedBlock | embedCard)+',
9
9
  defining: true,
10
10
  selectable: true,
@@ -3,5 +3,5 @@
3
3
  */
4
4
  export const doc = {
5
5
  content: '(block|layoutSection)+',
6
- marks: 'alignment breakout dataConsumer fragment indentation link unsupportedMark unsupportedNodeAttribute'
6
+ marks: 'alignment breakout dataConsumer fragment indentation unsupportedMark unsupportedNodeAttribute'
7
7
  };
@@ -20,7 +20,7 @@ function getExpandAttrs(domNode) {
20
20
  export const expand = {
21
21
  inline: false,
22
22
  group: 'block',
23
- marks: 'link dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
23
+ marks: 'dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
24
24
  content: '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaGroup | mediaSingle | decisionList | taskList | table | blockCard | embedCard | extension | unsupportedBlock)+',
25
25
  isolating: true,
26
26
  selectable: true,
@@ -4,7 +4,7 @@
4
4
  export const layoutColumn = {
5
5
  content: '(block|unsupportedBlock)+',
6
6
  isolating: true,
7
- marks: 'link alignment indentation dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
7
+ marks: 'alignment indentation dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
8
8
  selectable: false,
9
9
  attrs: {
10
10
  width: {
@@ -6,7 +6,7 @@
6
6
  */
7
7
  export const listItem = {
8
8
  content: '(paragraph | mediaSingle | codeBlock) (paragraph | bulletList | orderedList | mediaSingle | codeBlock)*',
9
- marks: 'link unsupportedMark unsupportedNodeAttribute',
9
+ marks: 'unsupportedMark unsupportedNodeAttribute',
10
10
  defining: true,
11
11
  selectable: false,
12
12
  parseDOM: [{
@@ -6,7 +6,7 @@ export const mediaGroup = {
6
6
  group: 'block',
7
7
  content: '(media|unsupportedBlock)+',
8
8
  attrs: {},
9
- marks: 'unsupportedMark unsupportedNodeAttribute link',
9
+ marks: 'unsupportedMark unsupportedNodeAttribute',
10
10
  selectable: false,
11
11
  parseDOM: [{
12
12
  tag: 'div[data-node-type="mediaGroup"]'
@@ -13,7 +13,7 @@
13
13
  */
14
14
  export const nestedExpand = {
15
15
  inline: false,
16
- marks: 'link unsupportedMark unsupportedNodeAttribute',
16
+ marks: 'unsupportedMark unsupportedNodeAttribute',
17
17
  content: '(paragraph | heading | mediaSingle | mediaGroup | unsupportedBlock)+',
18
18
  isolating: true,
19
19
  selectable: true,
@@ -1,68 +1,27 @@
1
- import { Fragment } from 'prosemirror-model';
2
- import { isSafeUrl } from '../../utils/url';
3
-
4
- const getLinkContent = (node, schema) => {
5
- if (!(node instanceof HTMLAnchorElement)) {
6
- return Fragment.empty;
7
- }
8
-
9
- const href = node.getAttribute('href') || '';
10
- const text = node.innerText;
11
-
12
- if (!text || text.length === 0) {
13
- return Fragment.empty;
14
- }
15
-
16
- const marks = isSafeUrl(href) ? [schema.marks.link.create({
17
- href
18
- })] : [];
19
- const textNode = schema.text(text, marks);
20
- return Fragment.from(textNode);
21
- };
22
-
23
- const blockTags = {
24
- address: true,
25
- article: true,
26
- aside: true,
27
- blockquote: true,
28
- canvas: true,
29
- dd: true,
30
- div: true,
31
- dl: true,
32
- fieldset: true,
33
- figcaption: true,
34
- figure: true,
35
- footer: true,
36
- form: true,
37
- h1: true,
38
- h2: true,
39
- h3: true,
40
- h4: true,
41
- h5: true,
42
- h6: true,
43
- header: true,
44
- hgroup: true,
45
- hr: true,
46
- li: true,
47
- noscript: true,
48
- ol: true,
49
- output: true,
50
- p: true,
51
- pre: true,
52
- section: true,
53
- table: true,
54
- tfoot: true,
55
- ul: true
56
- };
57
-
58
- const isListItemNode = node => {
59
- return Boolean(node && node.nodeName.toLowerCase() === 'li');
60
- };
61
-
62
- const isTextNode = node => {
63
- return Boolean(node && node.nodeType === Node.TEXT_NODE);
64
- };
65
-
1
+ /**
2
+ * @name paragraph_node
3
+ */
4
+
5
+ /**
6
+ * @name paragraph_with_no_marks_node
7
+ */
8
+
9
+ /**
10
+ * NOTE: Need this because TS is too smart and inline everything.
11
+ * So we need to give them separate identity.
12
+ * Probably there's a way to solve it but that will need time and exploration.
13
+ * // http://bit.ly/2raXFX5
14
+ * type T1 = X | Y
15
+ * type T2 = A | T1 | B // T2 = A | X | Y | B
16
+ */
17
+
18
+ /**
19
+ * @name paragraph_with_alignment_node
20
+ */
21
+
22
+ /**
23
+ * @name paragraph_with_indentation_node
24
+ */
66
25
  const isImageNode = node => {
67
26
  return Boolean(node && node.nodeName.toLowerCase() === 'img');
68
27
  };
@@ -83,21 +42,6 @@ const hasInlineImage = node => {
83
42
  });
84
43
  };
85
44
 
86
- const hasWhiteSpacePre = node => {
87
- return Boolean(node instanceof HTMLElement && node.style.whiteSpace === 'pre');
88
- };
89
-
90
- const hasFontFamilyMonospace = node => {
91
- return Boolean(node instanceof HTMLElement && node.style.fontFamily.includes('monospace'));
92
- };
93
-
94
- const isBlockLevelNode = node => {
95
- return Boolean(node && blockTags.hasOwnProperty(node.nodeName.toLowerCase()));
96
- };
97
-
98
- const NOT_INTERNAL_LINKS = [':not([data-inline-card])', ':not([data-block-card])', ':not([data-block-link])', ':not([data-skip-paste])'].join('');
99
- const ANCHOR_LINK = `a[href]${NOT_INTERNAL_LINKS}`;
100
- const NOT_INTERNAL_ELEMENTS = [':not(.code-block)', ':not([data-node-type])', ':not([data-embed-card])', ':not([data-layout-section])', ':not([data-task-local-id])', ':not([data-task-state])', ':not([data-pm-slice])', ':not([data-mark-type])', ':not([data-layout-content])', ':not([data-panel-content])'].join('');
101
45
  const pDOM = ['p', 0];
102
46
  export const paragraph = {
103
47
  selectable: false,
@@ -106,68 +50,6 @@ export const paragraph = {
106
50
  marks: 'strong code em link strike subsup textColor typeAheadQuery underline confluenceInlineComment action annotation unsupportedMark unsupportedNodeAttribute dataConsumer fragment',
107
51
  parseDOM: [{
108
52
  tag: 'p'
109
- }, {
110
- tag: `div${NOT_INTERNAL_ELEMENTS}, li:not([data-pm-slice])`,
111
- priority: 100,
112
- getAttrs: node => {
113
- if (!(node instanceof Node)) {
114
- return false;
115
- }
116
-
117
- const isCodeBlock = hasWhiteSpacePre(node) || hasFontFamilyMonospace(node);
118
-
119
- if (isCodeBlock || !node.hasChildNodes()) {
120
- return false;
121
- }
122
-
123
- const hasInlineChildren = Array.from(node.childNodes).every(child => !isBlockLevelNode(child) && // IMG is considered block for mediaSingle
124
- !isImageNode(child));
125
-
126
- if (!hasInlineChildren) {
127
- return false;
128
- }
129
-
130
- if ( // We can skip this rule for pure list items
131
- isListItemNode(node) && Array.from(node.childNodes).every(isTextNode)) {
132
- return false;
133
- }
134
-
135
- return null;
136
- }
137
- }, {
138
- tag: `:not(span) + ${ANCHOR_LINK}`,
139
- priority: 100,
140
- getContent: getLinkContent
141
- }, {
142
- tag: `:not(span) > ${ANCHOR_LINK}:first-child`,
143
- getAttrs: node => {
144
- if (!(node instanceof Node)) {
145
- return false;
146
- }
147
-
148
- if (isBlockLevelNode(node.firstChild)) {
149
- return null;
150
- }
151
-
152
- if (hasInlineImage(node)) {
153
- return false;
154
- }
155
-
156
- const isNextSiblingValid = node.nextSibling === null || node.nextSibling instanceof Text && (node.nextSibling.textContent || '').trim().length === 0;
157
-
158
- if (isNextSiblingValid) {
159
- return null;
160
- } // This rule should not match when there is any sibling after the anchor
161
-
162
-
163
- if (!isBlockLevelNode(node.nextSibling)) {
164
- return false;
165
- }
166
-
167
- return null;
168
- },
169
- priority: 100,
170
- getContent: getLinkContent
171
53
  }],
172
54
 
173
55
  toDOM() {