@atlaskit/adf-schema 19.3.0 → 20.1.0

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 (106) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/cjs/index.js +366 -360
  3. package/dist/cjs/schema/create-schema.js +7 -4
  4. package/dist/cjs/schema/default-schema.js +8 -14
  5. package/dist/cjs/schema/groups.js +1 -1
  6. package/dist/cjs/schema/index.js +244 -238
  7. package/dist/cjs/schema/jira-schema.js +8 -8
  8. package/dist/cjs/schema/marks/alignment.js +1 -1
  9. package/dist/cjs/schema/marks/annotation.js +1 -1
  10. package/dist/cjs/schema/marks/fragment.js +77 -0
  11. package/dist/cjs/schema/marks/index.js +63 -49
  12. package/dist/cjs/schema/marks/link.js +2 -55
  13. package/dist/cjs/schema/marks/text-color.js +18 -3
  14. package/dist/cjs/schema/marks/unsupported-mark.js +1 -0
  15. package/dist/cjs/schema/nodes/bodied-extension.js +1 -1
  16. package/dist/cjs/schema/nodes/bullet-list.js +1 -1
  17. package/dist/cjs/schema/nodes/caption.js +0 -1
  18. package/dist/cjs/schema/nodes/decision-list.js +1 -1
  19. package/dist/cjs/schema/nodes/doc.js +1 -1
  20. package/dist/cjs/schema/nodes/expand.js +1 -1
  21. package/dist/cjs/schema/nodes/index.js +146 -152
  22. package/dist/cjs/schema/nodes/layout-column.js +1 -1
  23. package/dist/cjs/schema/nodes/media-single.js +1 -1
  24. package/dist/cjs/schema/nodes/media.js +1 -1
  25. package/dist/cjs/schema/nodes/ordered-list.js +1 -1
  26. package/dist/cjs/schema/nodes/panel.js +2 -28
  27. package/dist/cjs/schema/nodes/paragraph.js +168 -25
  28. package/dist/cjs/schema/nodes/tableNodes.js +4 -4
  29. package/dist/cjs/schema/nodes/task-list.js +1 -1
  30. package/dist/cjs/steps/analytics.js +1 -1
  31. package/dist/cjs/steps/table/sort-column.js +1 -1
  32. package/dist/cjs/steps/table/utils/cell-step.js +1 -1
  33. package/dist/cjs/steps/table/utils/table-map.js +2 -2
  34. package/dist/cjs/steps/type-ahead.js +1 -1
  35. package/dist/cjs/steps.js +10 -10
  36. package/dist/cjs/utils/colors.js +4 -4
  37. package/dist/cjs/utils/confluence/emoji.js +1 -1
  38. package/dist/cjs/utils/extensions.js +1 -1
  39. package/dist/cjs/utils/index.js +48 -48
  40. package/dist/cjs/utils/url.js +9 -2
  41. package/dist/cjs/version.json +1 -1
  42. package/dist/es2019/index.js +1 -1
  43. package/dist/es2019/schema/create-schema.js +7 -4
  44. package/dist/es2019/schema/default-schema.js +7 -11
  45. package/dist/es2019/schema/index.js +2 -2
  46. package/dist/es2019/schema/jira-schema.js +1 -1
  47. package/dist/es2019/schema/marks/fragment.js +59 -0
  48. package/dist/es2019/schema/marks/index.js +2 -1
  49. package/dist/es2019/schema/marks/link.js +3 -51
  50. package/dist/es2019/schema/marks/text-color.js +15 -1
  51. package/dist/es2019/schema/marks/unsupported-mark.js +1 -0
  52. package/dist/es2019/schema/nodes/bodied-extension.js +1 -1
  53. package/dist/es2019/schema/nodes/caption.js +0 -1
  54. package/dist/es2019/schema/nodes/doc.js +1 -1
  55. package/dist/es2019/schema/nodes/expand.js +1 -1
  56. package/dist/es2019/schema/nodes/index.js +1 -1
  57. package/dist/es2019/schema/nodes/layout-column.js +1 -1
  58. package/dist/es2019/schema/nodes/media-single.js +1 -1
  59. package/dist/es2019/schema/nodes/panel.js +1 -28
  60. package/dist/es2019/schema/nodes/paragraph.js +163 -25
  61. package/dist/es2019/schema/nodes/tableNodes.js +3 -3
  62. package/dist/es2019/utils/url.js +7 -1
  63. package/dist/es2019/version.json +1 -1
  64. package/dist/esm/index.js +1 -1
  65. package/dist/esm/schema/create-schema.js +7 -4
  66. package/dist/esm/schema/default-schema.js +7 -11
  67. package/dist/esm/schema/index.js +2 -2
  68. package/dist/esm/schema/jira-schema.js +1 -1
  69. package/dist/esm/schema/marks/fragment.js +64 -0
  70. package/dist/esm/schema/marks/index.js +2 -1
  71. package/dist/esm/schema/marks/link.js +3 -55
  72. package/dist/esm/schema/marks/text-color.js +17 -3
  73. package/dist/esm/schema/marks/unsupported-mark.js +1 -0
  74. package/dist/esm/schema/nodes/bodied-extension.js +1 -1
  75. package/dist/esm/schema/nodes/caption.js +0 -1
  76. package/dist/esm/schema/nodes/doc.js +1 -1
  77. package/dist/esm/schema/nodes/expand.js +1 -1
  78. package/dist/esm/schema/nodes/index.js +1 -1
  79. package/dist/esm/schema/nodes/layout-column.js +1 -1
  80. package/dist/esm/schema/nodes/media-single.js +1 -1
  81. package/dist/esm/schema/nodes/panel.js +1 -26
  82. package/dist/esm/schema/nodes/paragraph.js +167 -25
  83. package/dist/esm/schema/nodes/tableNodes.js +3 -3
  84. package/dist/esm/utils/url.js +7 -1
  85. package/dist/esm/version.json +1 -1
  86. package/dist/json-schema/v1/full.json +108 -73
  87. package/dist/json-schema/v1/stage-0.json +63 -26
  88. package/dist/types/index.d.ts +2 -2
  89. package/dist/types/schema/index.d.ts +3 -3
  90. package/dist/types/schema/marks/fragment.d.ts +30 -0
  91. package/dist/types/schema/marks/index.d.ts +2 -0
  92. package/dist/types/schema/marks/link.d.ts +3 -0
  93. package/dist/types/schema/nodes/block-card.d.ts +3 -0
  94. package/dist/types/schema/nodes/bodied-extension.d.ts +7 -5
  95. package/dist/types/schema/nodes/caption.d.ts +0 -1
  96. package/dist/types/schema/nodes/embed-card.d.ts +3 -0
  97. package/dist/types/schema/nodes/extension.d.ts +7 -5
  98. package/dist/types/schema/nodes/index.d.ts +1 -1
  99. package/dist/types/schema/nodes/inline-card.d.ts +0 -9
  100. package/dist/types/schema/nodes/inline-extension.d.ts +7 -5
  101. package/dist/types/schema/nodes/media-single.d.ts +0 -1
  102. package/dist/types/schema/nodes/panel.d.ts +1 -11
  103. package/json-schema/v1/full.json +108 -73
  104. package/json-schema/v1/stage-0.json +63 -26
  105. package/package.json +11 -8
  106. package/test-helpers/schema.ts +1 -0
@@ -6,8 +6,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
6
6
 
7
7
  import { Schema } from 'prosemirror-model';
8
8
  import { COLOR, FONT_STYLE, SEARCH_QUERY, LINK } from './groups';
9
- import { link, em, strong, textColor, strike, subsup, underline, code, typeAheadQuery, confluenceInlineComment, breakout, alignment, indentation, annotation, unsupportedMark, unsupportedNodeAttribute, dataConsumer } from './marks';
10
- import { confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, doc, paragraph, text, bulletList, orderedList, listItem, heading, blockquote, codeBlock, panel, rule, image, mention, media, mediaInline, mediaGroup, mediaSingle, hardBreak, emoji, table, tableCell, tableHeader, tableRow, decisionList, decisionItem, taskList, taskItem, unknownBlock, extension, inlineExtension, bodiedExtension, date, placeholder, layoutSection, layoutColumn, inlineCard, blockCard, unsupportedBlock, unsupportedInline, status, expand, nestedExpand, embedCard, caption } from './nodes';
9
+ import { link, em, strong, textColor, strike, subsup, underline, code, typeAheadQuery, confluenceInlineComment, breakout, alignment, indentation, annotation, unsupportedMark, unsupportedNodeAttribute, dataConsumer, fragment } from './marks';
10
+ import { confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, doc, paragraph, text, bulletList, orderedList, listItem, heading, blockquote, codeBlock, panel, rule, image, mention, media, mediaInline, mediaGroup, mediaSingleWithCaption, hardBreak, emoji, table, tableCell, tableHeader, tableRow, decisionList, decisionItem, taskList, taskItem, unknownBlock, extension, inlineExtension, bodiedExtension, date, placeholder, layoutSection, layoutColumn, inlineCard, blockCard, unsupportedBlock, unsupportedInline, status, expand, nestedExpand, embedCard, caption } from './nodes';
11
11
 
12
12
  function addItems(builtInItems, config) {
13
13
  var customSpecs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
@@ -93,7 +93,7 @@ var nodesInOrder = [{
93
93
  spec: codeBlock
94
94
  }, {
95
95
  name: 'panel',
96
- spec: panel
96
+ spec: panel(true)
97
97
  }, {
98
98
  name: 'rule',
99
99
  spec: rule
@@ -114,7 +114,7 @@ var nodesInOrder = [{
114
114
  spec: mediaGroup
115
115
  }, {
116
116
  name: 'mediaSingle',
117
- spec: mediaSingle
117
+ spec: mediaSingleWithCaption
118
118
  }, {
119
119
  name: 'mediaInline',
120
120
  spec: mediaInline
@@ -248,6 +248,9 @@ var marksInOrder = [{
248
248
  }, {
249
249
  name: 'dataConsumer',
250
250
  spec: dataConsumer
251
+ }, {
252
+ name: 'fragment',
253
+ spec: fragment
251
254
  }, {
252
255
  name: 'indentation',
253
256
  spec: indentation
@@ -1,12 +1,10 @@
1
- import { customPanel } from './nodes/panel';
2
- import { layoutSectionWithSingleColumn } from './nodes/layout-section';
3
- import { dataConsumer } from './marks/data-consumer';
4
- import { allowCustomPanel, createSchema } from './create-schema';
5
- import { mediaSingleWithCaption } from './nodes';
1
+ import { layoutSectionWithSingleColumn } from './nodes';
2
+ import { dataConsumer, fragment } from './marks';
3
+ import { createSchema } from './create-schema';
6
4
 
7
5
  var getDefaultSchemaConfig = function getDefaultSchemaConfig() {
8
6
  var defaultSchemaConfig = {
9
- nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'panel', 'rule', 'image', 'mention', 'media', 'mediaGroup', 'mediaSingle', 'mediaInline', 'confluenceUnsupportedBlock', 'confluenceUnsupportedInline', 'confluenceJiraIssue', 'expand', 'nestedExpand', 'extension', 'inlineExtension', 'bodiedExtension', 'hardBreak', 'emoji', 'table', 'tableCell', 'tableHeader', 'tableRow', 'decisionList', 'decisionItem', 'taskList', 'taskItem', 'unknownBlock', 'date', 'status', 'placeholder', 'layoutSection', 'layoutColumn', 'inlineCard', 'blockCard', 'embedCard', 'unsupportedBlock', 'unsupportedInline'],
7
+ nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'panel', 'rule', 'image', 'caption', 'mention', 'media', 'mediaGroup', 'mediaSingle', 'mediaInline', 'confluenceUnsupportedBlock', 'confluenceUnsupportedInline', 'confluenceJiraIssue', 'expand', 'nestedExpand', 'extension', 'inlineExtension', 'bodiedExtension', 'hardBreak', 'emoji', 'table', 'tableCell', 'tableHeader', 'tableRow', 'decisionList', 'decisionItem', 'taskList', 'taskItem', 'unknownBlock', 'date', 'status', 'placeholder', 'layoutSection', 'layoutColumn', 'inlineCard', 'blockCard', 'embedCard', 'unsupportedBlock', 'unsupportedInline'],
10
8
  marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'confluenceInlineComment', 'breakout', 'alignment', 'indentation', 'annotation', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery' // https://product-fabric.atlassian.net/browse/ED-10214,
11
9
  ]
12
10
  };
@@ -16,18 +14,16 @@ var getDefaultSchemaConfig = function getDefaultSchemaConfig() {
16
14
  export var defaultSchemaConfig = getDefaultSchemaConfig();
17
15
  export var getSchemaBasedOnStage = function getSchemaBasedOnStage() {
18
16
  var stage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'final';
19
- var defaultSchemaConfig = getDefaultSchemaConfig(); // TODO: ED-10445 remove stage0 check after panels with emoji are on full schema AND image captions are on full schema
17
+ var defaultSchemaConfig = getDefaultSchemaConfig();
20
18
 
21
19
  if (stage === 'stage0') {
22
20
  defaultSchemaConfig.customNodeSpecs = {
23
- panel: customPanel(allowCustomPanel),
24
- mediaSingle: mediaSingleWithCaption,
25
21
  layoutSection: layoutSectionWithSingleColumn
26
22
  };
27
23
  defaultSchemaConfig.customMarkSpecs = {
28
- dataConsumer: dataConsumer
24
+ dataConsumer: dataConsumer,
25
+ fragment: fragment
29
26
  };
30
- defaultSchemaConfig.nodes.push('caption');
31
27
  defaultSchemaConfig.nodes.push('mediaInline');
32
28
  }
33
29
 
@@ -1,5 +1,5 @@
1
- export { PanelType, blockCard, blockquote, bodiedExtension, bulletList, bulletListSelector, caption, codeBlock, codeBlockToJSON, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, date, decisionItem, decisionList, decisionListSelector, doc, embedCard, emoji, expand, expandToJSON, extension, hardBreak, heading, image, inlineCard, inlineExtension, layoutColumn, layoutSection, layoutSectionWithSingleColumn, listItem, media, mediaGroup, mediaSingle, mediaInline, mediaSingleWithCaption, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, panel, customPanel, paragraph, placeholder, rule, getCellAttrs, getCellDomAttrs, status, table, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, taskList, taskListSelector, text, toJSONTableCell, toJSONTableHeader, unknownBlock, unsupportedBlock, unsupportedInline } from './nodes';
2
- export { AnnotationTypes, alignment, alignmentPositionMap, annotation, breakout, code, colorPalette, colorPaletteExtended, confluenceInlineComment, dataConsumer, dataConsumerToJSON, em, indentation, link, linkToJSON, strike, strong, subsup, textColor, typeAheadQuery, underline, buildAnnotationMarkDataAttributes, AnnotationMarkStates, unsupportedMark, unsupportedNodeAttribute } from './marks';
1
+ export { PanelType, blockCard, blockquote, bodiedExtension, bulletList, bulletListSelector, caption, codeBlock, codeBlockToJSON, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, date, decisionItem, decisionList, decisionListSelector, doc, embedCard, emoji, expand, expandToJSON, extension, hardBreak, heading, image, inlineCard, inlineExtension, layoutColumn, layoutSection, layoutSectionWithSingleColumn, listItem, media, mediaGroup, mediaSingle, mediaInline, mediaSingleWithCaption, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, panel, paragraph, placeholder, rule, getCellAttrs, getCellDomAttrs, status, table, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, taskList, taskListSelector, text, toJSONTableCell, toJSONTableHeader, unknownBlock, unsupportedBlock, unsupportedInline } from './nodes';
2
+ export { AnnotationTypes, alignment, alignmentPositionMap, annotation, breakout, code, colorPalette, colorPaletteExtended, confluenceInlineComment, dataConsumer, dataConsumerToJSON, em, fragment, fragmentToJSON, indentation, link, linkToJSON, strike, strong, subsup, textColor, typeAheadQuery, underline, buildAnnotationMarkDataAttributes, AnnotationMarkStates, unsupportedMark, unsupportedNodeAttribute } from './marks';
3
3
  export { unsupportedNodeTypesForMediaCards } from './unsupported';
4
4
  export { inlineNodes } from './inline-nodes';
5
5
  export { sanitizeNodes, createSchema } from './create-schema';
@@ -37,7 +37,7 @@ export default function makeSchema(config) {
37
37
  }
38
38
 
39
39
  if (config.allowMedia) {
40
- nodes.push('mediaGroup', 'mediaSingle', 'media');
40
+ nodes.push('mediaGroup', 'mediaSingle', 'media', 'caption');
41
41
  }
42
42
 
43
43
  if (config.allowTextColor) {
@@ -0,0 +1,64 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+
7
+ import { isDOMElement } from '../../utils/parseDOM';
8
+
9
+ var parseFragment = function parseFragment(maybeValue) {
10
+ var _maybeValue$getAttrib;
11
+
12
+ if (!isDOMElement(maybeValue)) {
13
+ return false;
14
+ }
15
+
16
+ var name = (_maybeValue$getAttrib = maybeValue.getAttribute('data-name')) !== null && _maybeValue$getAttrib !== void 0 ? _maybeValue$getAttrib : undefined;
17
+ var localId = maybeValue.getAttribute('data-localId');
18
+
19
+ if (!localId) {
20
+ return false;
21
+ }
22
+
23
+ return {
24
+ localId: localId,
25
+ name: name
26
+ };
27
+ };
28
+
29
+ export var fragment = {
30
+ inclusive: false,
31
+ excludes: '',
32
+ attrs: {
33
+ localId: {
34
+ default: ''
35
+ },
36
+ name: {
37
+ default: null
38
+ }
39
+ },
40
+ parseDOM: [{
41
+ tag: '[data-mark-type="fragment"]',
42
+ getAttrs: function getAttrs(maybeValue) {
43
+ return parseFragment(maybeValue);
44
+ }
45
+ }],
46
+ toDOM: function toDOM(mark, inline) {
47
+ var wrapperStyle = inline ? 'span' : 'div';
48
+ return [wrapperStyle, {
49
+ 'data-mark-type': 'fragment',
50
+ 'data-name': mark.attrs.name,
51
+ 'data-localId': mark.attrs.localId
52
+ }];
53
+ }
54
+ };
55
+ export var toJSON = function toJSON(mark) {
56
+ return {
57
+ type: mark.type.name,
58
+ attrs: _objectSpread({
59
+ localId: mark.attrs.localId
60
+ }, mark.attrs.name ? {
61
+ name: mark.attrs.name
62
+ } : {})
63
+ };
64
+ };
@@ -14,4 +14,5 @@ export { indentation } from './indentation';
14
14
  export { annotation, AnnotationMarkStates, buildDataAttributes as buildAnnotationMarkDataAttributes, AnnotationTypes } from './annotation';
15
15
  export { unsupportedMark } from './unsupported-mark';
16
16
  export { unsupportedNodeAttribute } from './unsupported-node-attributes';
17
- export { dataConsumer, toJSON as dataConsumerToJSON } from './data-consumer';
17
+ export { dataConsumer, toJSON as dataConsumerToJSON } from './data-consumer';
18
+ export { fragment, toJSON as fragmentToJSON } from './fragment';
@@ -4,8 +4,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
4
4
 
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
6
 
7
- import { Fragment } from 'prosemirror-model';
8
- import { LINK, COLOR } from '../groups';
7
+ import { LINK } from '../groups';
9
8
  import { isSafeUrl, normalizeUrl } from '../../utils/url';
10
9
 
11
10
  var getLinkAttrs = function getLinkAttrs(attribute) {
@@ -26,34 +25,8 @@ var getLinkAttrs = function getLinkAttrs(attribute) {
26
25
  };
27
26
  };
28
27
 
29
- var getLinkAttrsWithCheck = function getLinkAttrsWithCheck(attribute) {
30
- return function (domNode) {
31
- var dom = domNode;
32
- var hasTextOnlyChildren = Array.from(dom.childNodes).every(function (node) {
33
- return node.nodeType === Node.TEXT_NODE || node.nodeName === 'SPAN';
34
- });
35
-
36
- if (hasTextOnlyChildren) {
37
- var href = dom.getAttribute(attribute) || '';
38
- var attrs = {
39
- __confluenceMetadata: dom.hasAttribute('__confluenceMetadata') ? JSON.parse(dom.getAttribute('__confluenceMetadata') || '') : undefined
40
- };
41
-
42
- if (isSafeUrl(href)) {
43
- attrs.href = normalizeUrl(href);
44
- } else {
45
- return false;
46
- }
47
-
48
- return attrs;
49
- }
50
-
51
- return false;
52
- };
53
- };
54
-
55
28
  export var link = {
56
- excludes: "".concat(LINK, " ").concat(COLOR),
29
+ excludes: "".concat(LINK),
57
30
  // ED-5844 No multiple links in media node
58
31
  group: LINK,
59
32
  attrs: {
@@ -69,39 +42,14 @@ export var link = {
69
42
  contentElement: function contentElement(node) {
70
43
  var clone = node.cloneNode(true);
71
44
  clone.removeAttribute('data-block-link');
45
+ clone.setAttribute('data-skip-paste', 'true');
72
46
  var wrapper = document.createElement('div');
73
47
  wrapper.appendChild(clone);
74
48
  return wrapper;
75
49
  }
76
50
  }, {
77
51
  tag: 'a[href]',
78
- context: 'mediaSingle/|taskItem/|decisionItem/',
79
52
  getAttrs: getLinkAttrs('href')
80
- }, {
81
- tag: 'a[href]',
82
- getAttrs: getLinkAttrsWithCheck('href')
83
- }, {
84
- /**
85
- * When links aren't wrapped in a paragraph and due to
86
- * the odd nature of how our schema is set up, prosemirror will
87
- * add the link to the paragraph node itself where it should be on
88
- * the text node, this satisfies our schema because link is allowed
89
- * in many places (e.g. listitem)
90
- * This change comes through via prosemirror-model@1.9.1
91
- */
92
- tag: 'a[href]',
93
- getAttrs: getLinkAttrsWithCheck('href'),
94
- getContent: function getContent(node, schema) {
95
- if (node instanceof HTMLAnchorElement) {
96
- var href = node.getAttribute('href');
97
- var text = node.innerText;
98
- return Fragment.from(schema.nodes.paragraph.createChecked(undefined, schema.text(text, [schema.marks.link.create({
99
- href: href
100
- })])));
101
- }
102
-
103
- return Fragment.empty;
104
- }
105
53
  }],
106
54
  toDOM: function toDOM(node, isInline) {
107
55
  var attrs = Object.keys(node.attrs).reduce(function (attrs, key) {
@@ -1,3 +1,4 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import { COLOR } from '../groups';
3
4
  import { rgbToHex, N0, N80, P50, P300, P500, T75, T300, T500, G75, G300, G500, R75, R300, R500, Y75, Y200, Y400, B75, B100, B500 } from '../../utils/colors';
@@ -65,14 +66,27 @@ export var textColor = {
65
66
  } // else handle other colour formats
66
67
 
67
68
 
69
+ return hexColor && (colorPalette.has(hexColor) || colorPaletteExtended.has(hexColor)) ? {
70
+ color: hexColor
71
+ } : false;
72
+ }
73
+ }, {
74
+ tag: '.fabric-text-color-mark',
75
+ getAttrs: function getAttrs(maybeElement) {
76
+ if (!(maybeElement instanceof HTMLElement)) {
77
+ return false;
78
+ }
79
+
80
+ var hexColor = maybeElement.dataset.textCustomColor;
68
81
  return hexColor && (colorPalette.has(hexColor) || colorPaletteExtended.has(hexColor)) ? {
69
82
  color: hexColor
70
83
  } : false;
71
84
  }
72
85
  }],
73
86
  toDOM: function toDOM(mark) {
74
- return ['span', {
75
- style: "color: ".concat(mark.attrs.color)
76
- }];
87
+ return ['span', _defineProperty({
88
+ class: 'fabric-text-color-mark',
89
+ style: "--custom-text-color: ".concat(mark.attrs.color)
90
+ }, 'data-text-custom-color', mark.attrs.color)];
77
91
  }
78
92
  };
@@ -2,6 +2,7 @@ export var unsupportedMark = {
2
2
  toDOM: function toDOM() {
3
3
  return ['span'];
4
4
  },
5
+ excludes: '',
5
6
  attrs: {
6
7
  originalValue: {}
7
8
  }
@@ -4,7 +4,7 @@ var createBodiedExtensionNodeSpec = function createBodiedExtensionNodeSpec() {
4
4
  var nodeSpec = {
5
5
  inline: false,
6
6
  group: 'block',
7
- marks: 'link dataConsumer',
7
+ marks: 'link 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,
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @stage 0
3
2
  * @name caption_node
4
3
  */
5
4
  export var caption = {
@@ -3,5 +3,5 @@
3
3
  */
4
4
  export var doc = {
5
5
  content: '(block|layoutSection)+',
6
- marks: 'alignment breakout dataConsumer indentation link unsupportedMark unsupportedNodeAttribute'
6
+ marks: 'alignment breakout dataConsumer fragment indentation link unsupportedMark unsupportedNodeAttribute'
7
7
  };
@@ -20,7 +20,7 @@ function getExpandAttrs(domNode) {
20
20
  export var expand = {
21
21
  inline: false,
22
22
  group: 'block',
23
- marks: 'link dataConsumer unsupportedMark unsupportedNodeAttribute',
23
+ marks: 'link 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,
@@ -15,7 +15,7 @@ export { emoji } from './emoji';
15
15
  export { image } from './image';
16
16
  export { mention, toJSON as mentionToJSON } from './mention';
17
17
  export { listItem } from './list-item';
18
- export { panel, customPanel, PanelType } from './panel';
18
+ export { panel, PanelType } from './panel';
19
19
  export { text } from './text';
20
20
  export { default as unknownBlock } from './unknown-block';
21
21
  export { caption } from './caption';
@@ -4,7 +4,7 @@
4
4
  export var layoutColumn = {
5
5
  content: '(block|unsupportedBlock)+',
6
6
  isolating: true,
7
- marks: 'link alignment indentation dataConsumer unsupportedMark unsupportedNodeAttribute',
7
+ marks: 'link alignment indentation dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
8
8
  selectable: false,
9
9
  attrs: {
10
10
  width: {
@@ -23,7 +23,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
23
23
 
24
24
  /**
25
25
  * @name mediaSingle_caption_node
26
- * @stage 0
27
26
  */
28
27
  export var defaultAttrs = {
29
28
  width: {
@@ -69,6 +68,7 @@ export var mediaSingle = {
69
68
  }
70
69
  };
71
70
  export var mediaSingleWithCaption = _objectSpread(_objectSpread({}, mediaSingle), {}, {
71
+ atom: false,
72
72
  content: 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*'
73
73
  });
74
74
  export var toJSON = function toJSON(node) {
@@ -57,7 +57,7 @@ var getParseDOMAttrs = function getParseDOMAttrs(allowCustomPanel, dom) {
57
57
  return parseDOMAttrs;
58
58
  };
59
59
 
60
- export var customPanel = function customPanel(allowCustomPanel) {
60
+ export var panel = function panel(allowCustomPanel) {
61
61
  var panelNodeSpec = {
62
62
  group: 'block',
63
63
  content: '(paragraph | heading | bulletList | orderedList | blockCard | unsupportedBlock)+',
@@ -75,29 +75,4 @@ export var customPanel = function customPanel(allowCustomPanel) {
75
75
  }
76
76
  };
77
77
  return panelNodeSpec;
78
- };
79
- export var panel = {
80
- group: 'block',
81
- content: '(paragraph | heading | bulletList | orderedList | blockCard | unsupportedBlock)+',
82
- marks: 'unsupportedMark unsupportedNodeAttribute',
83
- attrs: {
84
- panelType: {
85
- default: 'info'
86
- }
87
- },
88
- parseDOM: [{
89
- tag: 'div[data-panel-type]',
90
- getAttrs: function getAttrs(dom) {
91
- return {
92
- panelType: dom.getAttribute('data-panel-type')
93
- };
94
- }
95
- }],
96
- toDOM: function toDOM(node) {
97
- var panelType = node.attrs.panelType;
98
- var attrs = {
99
- 'data-panel-type': panelType
100
- };
101
- return ['div', attrs, ['div', {}, 0]];
102
- }
103
78
  };
@@ -1,35 +1,177 @@
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
- */
1
+ import { Fragment } from 'prosemirror-model';
2
+ import { isSafeUrl } from '../../utils/url';
3
+
4
+ var getLinkContent = function getLinkContent(node, schema) {
5
+ if (!(node instanceof HTMLAnchorElement)) {
6
+ return Fragment.empty;
7
+ }
8
+
9
+ var href = node.getAttribute('href') || '';
10
+ var text = node.innerText;
11
+
12
+ if (!text || text.length === 0) {
13
+ return Fragment.empty;
14
+ }
15
+
16
+ var marks = isSafeUrl(href) ? [schema.marks.link.create({
17
+ href: href
18
+ })] : [];
19
+ var textNode = schema.text(text, marks);
20
+ return Fragment.from(textNode);
21
+ };
22
+
23
+ var 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
+ var isListItemNode = function isListItemNode(node) {
59
+ return Boolean(node && node.nodeName.toLowerCase() === 'li');
60
+ };
61
+
62
+ var isTextNode = function isTextNode(node) {
63
+ return Boolean(node && node.nodeType === Node.TEXT_NODE);
64
+ };
65
+
66
+ var isImageNode = function isImageNode(node) {
67
+ return Boolean(node && node.nodeName.toLowerCase() === 'img');
68
+ };
69
+
70
+ var hasInlineImage = function hasInlineImage(node) {
71
+ if (!node) {
72
+ return false;
73
+ }
74
+
75
+ return Array.from(node.childNodes).some(function (child) {
76
+ var isImage = isImageNode(child);
77
+
78
+ if (!isImage && child.childNodes) {
79
+ return Array.from(node.childNodes).some(function (node) {
80
+ return hasInlineImage(node);
81
+ });
82
+ }
83
+
84
+ return isImage;
85
+ });
86
+ };
87
+
88
+ var hasWhiteSpacePre = function hasWhiteSpacePre(node) {
89
+ return Boolean(node instanceof HTMLElement && node.style.whiteSpace === 'pre');
90
+ };
91
+
92
+ var hasFontFamilyMonospace = function hasFontFamilyMonospace(node) {
93
+ return Boolean(node instanceof HTMLElement && node.style.fontFamily.includes('monospace'));
94
+ };
95
+
96
+ var isBlockLevelNode = function isBlockLevelNode(node) {
97
+ return Boolean(node && blockTags.hasOwnProperty(node.nodeName.toLowerCase()));
98
+ };
99
+
100
+ var NOT_INTERNAL_LINKS = [':not([data-inline-card])', ':not([data-block-card])', ':not([data-block-link])', ':not([data-skip-paste])'].join('');
101
+ var ANCHOR_LINK = "a[href]".concat(NOT_INTERNAL_LINKS);
102
+ 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])'].join('');
25
103
  var pDOM = ['p', 0];
26
104
  export var paragraph = {
27
105
  selectable: false,
28
106
  content: 'inline*',
29
107
  group: 'block',
30
- marks: 'strong code em link strike subsup textColor typeAheadQuery underline confluenceInlineComment action annotation unsupportedMark unsupportedNodeAttribute dataConsumer',
108
+ marks: 'strong code em link strike subsup textColor typeAheadQuery underline confluenceInlineComment action annotation unsupportedMark unsupportedNodeAttribute dataConsumer fragment',
31
109
  parseDOM: [{
32
110
  tag: 'p'
111
+ }, {
112
+ tag: "div".concat(NOT_INTERNAL_ELEMENTS, ", li:not([data-pm-slice])"),
113
+ priority: 100,
114
+ getAttrs: function getAttrs(node) {
115
+ if (!(node instanceof Node)) {
116
+ return false;
117
+ }
118
+
119
+ var isCodeBlock = hasWhiteSpacePre(node) || hasFontFamilyMonospace(node);
120
+
121
+ if (isCodeBlock || !node.hasChildNodes()) {
122
+ return false;
123
+ }
124
+
125
+ var hasInlineChildren = Array.from(node.childNodes).every(function (child) {
126
+ return !isBlockLevelNode(child) && // IMG is considered block for mediaSingle
127
+ !isImageNode(child);
128
+ });
129
+
130
+ if (!hasInlineChildren) {
131
+ return false;
132
+ }
133
+
134
+ if ( // We can skip this rule for pure list items
135
+ isListItemNode(node) && Array.from(node.childNodes).every(isTextNode)) {
136
+ return false;
137
+ }
138
+
139
+ return null;
140
+ }
141
+ }, {
142
+ tag: ":not(span) + ".concat(ANCHOR_LINK),
143
+ priority: 100,
144
+ getContent: getLinkContent
145
+ }, {
146
+ tag: ":not(span) > ".concat(ANCHOR_LINK, ":first-child"),
147
+ getAttrs: function getAttrs(node) {
148
+ if (!(node instanceof Node)) {
149
+ return false;
150
+ }
151
+
152
+ if (isBlockLevelNode(node.firstChild)) {
153
+ return null;
154
+ }
155
+
156
+ if (hasInlineImage(node)) {
157
+ return false;
158
+ }
159
+
160
+ var isNextSiblingValid = node.nextSibling === null || node.nextSibling instanceof Text && (node.nextSibling.textContent || '').trim().length === 0;
161
+
162
+ if (isNextSiblingValid) {
163
+ return null;
164
+ } // This rule should not match when there is any sibling after the anchor
165
+
166
+
167
+ if (!isBlockLevelNode(node.nextSibling)) {
168
+ return false;
169
+ }
170
+
171
+ return null;
172
+ },
173
+ priority: 100,
174
+ getContent: getLinkContent
33
175
  }],
34
176
  toDOM: function toDOM() {
35
177
  return pDOM;
@@ -107,7 +107,7 @@ var createTableSpec = function createTableSpec() {
107
107
  var tableNodeSpec = {
108
108
  content: 'tableRow+',
109
109
  attrs: attrs,
110
- marks: 'unsupportedMark unsupportedNodeAttribute',
110
+ marks: 'fragment unsupportedMark unsupportedNodeAttribute',
111
111
  tableRole: 'table',
112
112
  isolating: true,
113
113
  selectable: false,
@@ -189,7 +189,7 @@ export var tableCell = {
189
189
  content: '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaSingle | mediaGroup | decisionList | taskList | blockCard | embedCard | extension | nestedExpand | unsupportedBlock)+',
190
190
  attrs: cellAttrs,
191
191
  tableRole: 'cell',
192
- marks: 'link alignment dataConsumer unsupportedMark unsupportedNodeAttribute',
192
+ marks: 'link alignment dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
193
193
  isolating: true,
194
194
  parseDOM: [// Ignore number cell copied from renderer
195
195
  {
@@ -222,7 +222,7 @@ export var tableHeader = {
222
222
  attrs: cellAttrs,
223
223
  tableRole: 'header_cell',
224
224
  isolating: true,
225
- marks: 'link alignment dataConsumer unsupportedMark unsupportedNodeAttribute',
225
+ marks: 'link alignment dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
226
226
  parseDOM: [{
227
227
  tag: 'th',
228
228
  getAttrs: function getAttrs(dom) {