@atlaskit/adf-schema 49.0.6 → 50.0.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 (190) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/index.js +132 -0
  3. package/dist/cjs/next-schema/generated/nodeTypes.js +140 -1
  4. package/dist/cjs/next-schema/nodes/blockCard.js +15 -0
  5. package/dist/cjs/next-schema/nodes/blockquote.js +16 -2
  6. package/dist/cjs/next-schema/nodes/caption.js +7 -0
  7. package/dist/cjs/next-schema/nodes/codeBlock.js +5 -0
  8. package/dist/cjs/next-schema/nodes/date.js +5 -0
  9. package/dist/cjs/next-schema/nodes/embedCard.js +5 -0
  10. package/dist/cjs/next-schema/nodes/emoji.js +5 -0
  11. package/dist/cjs/next-schema/nodes/expand.js +5 -0
  12. package/dist/cjs/next-schema/nodes/hardBreak.js +5 -0
  13. package/dist/cjs/next-schema/nodes/inlineCard.js +10 -0
  14. package/dist/cjs/next-schema/nodes/layoutColumn.js +5 -0
  15. package/dist/cjs/next-schema/nodes/layoutSection.js +12 -0
  16. package/dist/cjs/next-schema/nodes/list.js +20 -1
  17. package/dist/cjs/next-schema/nodes/media.js +10 -0
  18. package/dist/cjs/next-schema/nodes/mediaInline.js +5 -0
  19. package/dist/cjs/next-schema/nodes/mediaSingle.js +10 -0
  20. package/dist/cjs/next-schema/nodes/nestedExpand.js +5 -0
  21. package/dist/cjs/next-schema/nodes/panel.js +5 -0
  22. package/dist/cjs/next-schema/nodes/placeholder.js +5 -0
  23. package/dist/cjs/next-schema/nodes/rule.js +9 -1
  24. package/dist/cjs/next-schema/nodes/tableNodes.js +17 -0
  25. package/dist/cjs/schema/index.js +138 -0
  26. package/dist/cjs/schema/nodes/block-card.js +48 -1
  27. package/dist/cjs/schema/nodes/blockquote.js +20 -2
  28. package/dist/cjs/schema/nodes/bullet-list.js +20 -1
  29. package/dist/cjs/schema/nodes/caption.js +20 -1
  30. package/dist/cjs/schema/nodes/code-block.js +72 -2
  31. package/dist/cjs/schema/nodes/date.js +22 -1
  32. package/dist/cjs/schema/nodes/embed-card.js +36 -1
  33. package/dist/cjs/schema/nodes/emoji.js +73 -1
  34. package/dist/cjs/schema/nodes/expand.js +56 -1
  35. package/dist/cjs/schema/nodes/hard-break.js +18 -1
  36. package/dist/cjs/schema/nodes/index.js +138 -0
  37. package/dist/cjs/schema/nodes/inline-card.js +46 -1
  38. package/dist/cjs/schema/nodes/layout-column.js +37 -1
  39. package/dist/cjs/schema/nodes/layout-section.js +31 -1
  40. package/dist/cjs/schema/nodes/list-item.js +34 -1
  41. package/dist/cjs/schema/nodes/media-inline.js +12 -2
  42. package/dist/cjs/schema/nodes/media-single.js +22 -2
  43. package/dist/cjs/schema/nodes/media.js +21 -4
  44. package/dist/cjs/schema/nodes/nested-expand.js +34 -7
  45. package/dist/cjs/schema/nodes/ordered-list.js +54 -3
  46. package/dist/cjs/schema/nodes/panel.js +13 -5
  47. package/dist/cjs/schema/nodes/placeholder.js +24 -1
  48. package/dist/cjs/schema/nodes/rule.js +18 -1
  49. package/dist/cjs/schema/nodes/tableNodes.js +69 -6
  50. package/dist/cjs/validator-schema/generated/validatorSpec.js +159 -0
  51. package/dist/es2019/index.js +2 -2
  52. package/dist/es2019/next-schema/generated/nodeTypes.js +140 -1
  53. package/dist/es2019/next-schema/nodes/blockCard.js +15 -0
  54. package/dist/es2019/next-schema/nodes/blockquote.js +16 -2
  55. package/dist/es2019/next-schema/nodes/caption.js +7 -0
  56. package/dist/es2019/next-schema/nodes/codeBlock.js +5 -0
  57. package/dist/es2019/next-schema/nodes/date.js +5 -0
  58. package/dist/es2019/next-schema/nodes/embedCard.js +5 -0
  59. package/dist/es2019/next-schema/nodes/emoji.js +5 -0
  60. package/dist/es2019/next-schema/nodes/expand.js +5 -0
  61. package/dist/es2019/next-schema/nodes/hardBreak.js +5 -0
  62. package/dist/es2019/next-schema/nodes/inlineCard.js +10 -0
  63. package/dist/es2019/next-schema/nodes/layoutColumn.js +5 -0
  64. package/dist/es2019/next-schema/nodes/layoutSection.js +12 -0
  65. package/dist/es2019/next-schema/nodes/list.js +20 -1
  66. package/dist/es2019/next-schema/nodes/media.js +10 -0
  67. package/dist/es2019/next-schema/nodes/mediaInline.js +5 -0
  68. package/dist/es2019/next-schema/nodes/mediaSingle.js +10 -0
  69. package/dist/es2019/next-schema/nodes/nestedExpand.js +5 -0
  70. package/dist/es2019/next-schema/nodes/panel.js +5 -0
  71. package/dist/es2019/next-schema/nodes/placeholder.js +5 -0
  72. package/dist/es2019/next-schema/nodes/rule.js +9 -1
  73. package/dist/es2019/next-schema/nodes/tableNodes.js +17 -0
  74. package/dist/es2019/schema/default-schema.js +1 -1
  75. package/dist/es2019/schema/index.js +1 -1
  76. package/dist/es2019/schema/nodes/block-card.js +50 -0
  77. package/dist/es2019/schema/nodes/blockquote.js +19 -1
  78. package/dist/es2019/schema/nodes/bullet-list.js +19 -0
  79. package/dist/es2019/schema/nodes/caption.js +19 -0
  80. package/dist/es2019/schema/nodes/code-block.js +68 -0
  81. package/dist/es2019/schema/nodes/date.js +19 -0
  82. package/dist/es2019/schema/nodes/embed-card.js +34 -0
  83. package/dist/es2019/schema/nodes/emoji.js +71 -0
  84. package/dist/es2019/schema/nodes/expand.js +59 -0
  85. package/dist/es2019/schema/nodes/hard-break.js +15 -0
  86. package/dist/es2019/schema/nodes/index.js +20 -20
  87. package/dist/es2019/schema/nodes/inline-card.js +45 -0
  88. package/dist/es2019/schema/nodes/layout-column.js +38 -0
  89. package/dist/es2019/schema/nodes/layout-section.js +32 -0
  90. package/dist/es2019/schema/nodes/list-item.js +29 -0
  91. package/dist/es2019/schema/nodes/media-inline.js +8 -1
  92. package/dist/es2019/schema/nodes/media-single.js +20 -1
  93. package/dist/es2019/schema/nodes/media.js +17 -4
  94. package/dist/es2019/schema/nodes/nested-expand.js +21 -6
  95. package/dist/es2019/schema/nodes/ordered-list.js +51 -2
  96. package/dist/es2019/schema/nodes/panel.js +11 -5
  97. package/dist/es2019/schema/nodes/placeholder.js +23 -0
  98. package/dist/es2019/schema/nodes/rule.js +15 -0
  99. package/dist/es2019/schema/nodes/tableNodes.js +59 -3
  100. package/dist/es2019/validator-schema/generated/validatorSpec.js +159 -0
  101. package/dist/esm/index.js +2 -2
  102. package/dist/esm/next-schema/generated/nodeTypes.js +140 -1
  103. package/dist/esm/next-schema/nodes/blockCard.js +15 -0
  104. package/dist/esm/next-schema/nodes/blockquote.js +16 -2
  105. package/dist/esm/next-schema/nodes/caption.js +7 -0
  106. package/dist/esm/next-schema/nodes/codeBlock.js +5 -0
  107. package/dist/esm/next-schema/nodes/date.js +5 -0
  108. package/dist/esm/next-schema/nodes/embedCard.js +5 -0
  109. package/dist/esm/next-schema/nodes/emoji.js +5 -0
  110. package/dist/esm/next-schema/nodes/expand.js +5 -0
  111. package/dist/esm/next-schema/nodes/hardBreak.js +5 -0
  112. package/dist/esm/next-schema/nodes/inlineCard.js +10 -0
  113. package/dist/esm/next-schema/nodes/layoutColumn.js +5 -0
  114. package/dist/esm/next-schema/nodes/layoutSection.js +12 -0
  115. package/dist/esm/next-schema/nodes/list.js +20 -1
  116. package/dist/esm/next-schema/nodes/media.js +10 -0
  117. package/dist/esm/next-schema/nodes/mediaInline.js +5 -0
  118. package/dist/esm/next-schema/nodes/mediaSingle.js +10 -0
  119. package/dist/esm/next-schema/nodes/nestedExpand.js +5 -0
  120. package/dist/esm/next-schema/nodes/panel.js +5 -0
  121. package/dist/esm/next-schema/nodes/placeholder.js +5 -0
  122. package/dist/esm/next-schema/nodes/rule.js +9 -1
  123. package/dist/esm/next-schema/nodes/tableNodes.js +17 -0
  124. package/dist/esm/schema/default-schema.js +1 -1
  125. package/dist/esm/schema/index.js +1 -1
  126. package/dist/esm/schema/nodes/block-card.js +47 -0
  127. package/dist/esm/schema/nodes/blockquote.js +19 -1
  128. package/dist/esm/schema/nodes/bullet-list.js +19 -0
  129. package/dist/esm/schema/nodes/caption.js +19 -0
  130. package/dist/esm/schema/nodes/code-block.js +71 -1
  131. package/dist/esm/schema/nodes/date.js +21 -0
  132. package/dist/esm/schema/nodes/embed-card.js +35 -0
  133. package/dist/esm/schema/nodes/emoji.js +71 -0
  134. package/dist/esm/schema/nodes/expand.js +55 -0
  135. package/dist/esm/schema/nodes/hard-break.js +17 -0
  136. package/dist/esm/schema/nodes/index.js +20 -20
  137. package/dist/esm/schema/nodes/inline-card.js +45 -0
  138. package/dist/esm/schema/nodes/layout-column.js +36 -0
  139. package/dist/esm/schema/nodes/layout-section.js +30 -0
  140. package/dist/esm/schema/nodes/list-item.js +33 -0
  141. package/dist/esm/schema/nodes/media-inline.js +10 -1
  142. package/dist/esm/schema/nodes/media-single.js +21 -1
  143. package/dist/esm/schema/nodes/media.js +19 -3
  144. package/dist/esm/schema/nodes/nested-expand.js +32 -6
  145. package/dist/esm/schema/nodes/ordered-list.js +53 -2
  146. package/dist/esm/schema/nodes/panel.js +12 -4
  147. package/dist/esm/schema/nodes/placeholder.js +23 -0
  148. package/dist/esm/schema/nodes/rule.js +17 -0
  149. package/dist/esm/schema/nodes/tableNodes.js +68 -5
  150. package/dist/esm/validator-schema/generated/validatorSpec.js +159 -0
  151. package/dist/json-schema/v1/full.json +140 -2
  152. package/dist/json-schema/v1/stage-0.json +152 -2
  153. package/dist/types/index.d.ts +2 -2
  154. package/dist/types/next-schema/generated/nodeTypes.d.ts +72 -0
  155. package/dist/types/next-schema/groups/nonNestableBlockContentGroup.d.ts +7 -0
  156. package/dist/types/next-schema/groups/tableCellContentPseudoGroup.d.ts +7 -0
  157. package/dist/types/next-schema/nodes/blockquote.d.ts +7 -0
  158. package/dist/types/next-schema/nodes/layoutSection.d.ts +5 -0
  159. package/dist/types/schema/index.d.ts +1 -1
  160. package/dist/types/schema/nodes/block-card.d.ts +4 -0
  161. package/dist/types/schema/nodes/blockquote.d.ts +4 -0
  162. package/dist/types/schema/nodes/bullet-list.d.ts +1 -0
  163. package/dist/types/schema/nodes/caption.d.ts +4 -0
  164. package/dist/types/schema/nodes/code-block.d.ts +2 -0
  165. package/dist/types/schema/nodes/date.d.ts +2 -0
  166. package/dist/types/schema/nodes/embed-card.d.ts +2 -0
  167. package/dist/types/schema/nodes/emoji.d.ts +2 -0
  168. package/dist/types/schema/nodes/expand.d.ts +2 -0
  169. package/dist/types/schema/nodes/hard-break.d.ts +2 -0
  170. package/dist/types/schema/nodes/index.d.ts +20 -20
  171. package/dist/types/schema/nodes/inline-card.d.ts +1 -0
  172. package/dist/types/schema/nodes/layout-column.d.ts +2 -0
  173. package/dist/types/schema/nodes/layout-section.d.ts +4 -0
  174. package/dist/types/schema/nodes/list-item.d.ts +2 -0
  175. package/dist/types/schema/nodes/media-inline.d.ts +1 -0
  176. package/dist/types/schema/nodes/media-single.d.ts +3 -1
  177. package/dist/types/schema/nodes/media.d.ts +3 -1
  178. package/dist/types/schema/nodes/nested-expand.d.ts +2 -0
  179. package/dist/types/schema/nodes/ordered-list.d.ts +2 -0
  180. package/dist/types/schema/nodes/panel.d.ts +2 -0
  181. package/dist/types/schema/nodes/placeholder.d.ts +2 -0
  182. package/dist/types/schema/nodes/rule.d.ts +4 -0
  183. package/dist/types/schema/nodes/tableNodes.d.ts +6 -0
  184. package/dist/types/schema/nodes/types/list.d.ts +7 -0
  185. package/dist/types/schema/nodes/types/rich-media-common.d.ts +1 -0
  186. package/dist/types/validator-schema/generated/validatorSpec.d.ts +159 -0
  187. package/json-schema/v1/full.json +140 -2
  188. package/json-schema/v1/stage-0.json +152 -2
  189. package/package.json +2 -2
  190. package/schema-generators/__tests__/unit/adfToValidatorSpec.unit.ts +1 -0
@@ -1,4 +1,5 @@
1
1
  import { inlineCard as inlineCardFactory } from '../../next-schema/generated/nodeTypes';
2
+ import { uuid } from '../../utils/uuid';
2
3
 
3
4
  /**
4
5
  * @name inlineCard_node
@@ -44,4 +45,48 @@ export const inlineCard = inlineCardFactory({
44
45
  return ['a', attrs];
45
46
  }
46
47
  }
48
+ });
49
+ export const inlineCardWithLocalId = inlineCardFactory({
50
+ parseDOM: [{
51
+ tag: 'a[data-inline-card], span[data-inline-card]',
52
+ // bump priority higher than hyperlink
53
+ priority: 100,
54
+ getAttrs: dom => {
55
+ const anchor = dom;
56
+ const data = anchor.getAttribute('data-card-data');
57
+
58
+ /* Support attrs from Editor and Renderer */
59
+ return {
60
+ url: anchor.getAttribute('href') || anchor.getAttribute('data-card-url') || null,
61
+ data: data ? JSON.parse(data) : null
62
+ };
63
+ }
64
+ },
65
+ // for renderer
66
+ {
67
+ tag: 'div[data-inline-card]',
68
+ getAttrs: dom => {
69
+ const anchor = dom;
70
+ const data = anchor.getAttribute('data-card-data');
71
+ return {
72
+ url: anchor.getAttribute('data-card-url'),
73
+ data: data ? JSON.parse(data) : null,
74
+ localId: uuid.generate()
75
+ };
76
+ }
77
+ }],
78
+ toDOM(node) {
79
+ var _node$attrs;
80
+ const attrs = {
81
+ 'data-inline-card': '',
82
+ href: node.attrs.url || '',
83
+ 'data-card-data': node.attrs.data ? JSON.stringify(node.attrs.data) : '',
84
+ 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) || undefined
85
+ };
86
+ if (node.attrs.url) {
87
+ return ['a', attrs, node.attrs.url];
88
+ } else {
89
+ return ['a', attrs];
90
+ }
91
+ }
47
92
  });
@@ -1,4 +1,5 @@
1
1
  import { layoutColumn as layoutColumnFactory } from '../../next-schema/generated/nodeTypes';
2
+ import { uuid } from '../../utils/uuid';
2
3
 
3
4
  /**
4
5
  * @name layoutColumn_node
@@ -30,6 +31,43 @@ export const layoutColumn = layoutColumnFactory({
30
31
  attrs['data-column-width'] = `${width}`;
31
32
  }
32
33
 
34
+ // We need to apply a attribute to the inner most child to help
35
+ // ProseMirror identify its boundaries better.
36
+ const contentAttrs = {
37
+ 'data-layout-content': 'true'
38
+ };
39
+ return ['div', attrs, ['div', contentAttrs, 0]];
40
+ }
41
+ });
42
+ export const layoutColumnWithLocalId = layoutColumnFactory({
43
+ parseDOM: [{
44
+ context: 'layoutColumn//',
45
+ tag: 'div[data-layout-column]',
46
+ skip: true
47
+ }, {
48
+ tag: 'div[data-layout-column]',
49
+ getAttrs: domNode => {
50
+ const dom = domNode;
51
+ return {
52
+ width: Number(dom.getAttribute('data-column-width')) || undefined,
53
+ localId: uuid.generate()
54
+ };
55
+ }
56
+ }],
57
+ toDOM(node) {
58
+ var _node$attrs;
59
+ const attrs = {
60
+ 'data-layout-column': 'true',
61
+ 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) || undefined
62
+ };
63
+ const {
64
+ width
65
+ } = node.attrs;
66
+ if (width) {
67
+ attrs['style'] = `flex-basis: ${width}%`;
68
+ attrs['data-column-width'] = `${width}`;
69
+ }
70
+
33
71
  // We need to apply a attribute to the inner most child to help
34
72
  // ProseMirror identify its boundaries better.
35
73
  const contentAttrs = {
@@ -1,5 +1,6 @@
1
1
  import { layoutSection as layoutSectionFactory, layoutSectionWithSingleColumnStage0 as layoutSectionWithSingleColumnStage0Factory } from '../../next-schema/generated/nodeTypes';
2
2
  import { layoutSectionFull as layoutSectionFullFactory } from '../../next-schema/generated/nodeTypes';
3
+ import { uuid } from '../../utils/uuid';
3
4
 
4
5
  /**
5
6
  * @name layoutSection_node
@@ -74,4 +75,35 @@ export const layoutSectionWithSingleColumn = layoutSectionWithSingleColumnStage0
74
75
  };
75
76
  return ['div', attrs, 0];
76
77
  }
78
+ });
79
+ export const layoutSectionWithSingleColumnLocalId = layoutSectionWithSingleColumnStage0Factory({
80
+ parseDOM: [{
81
+ context: 'layoutSection//|layoutColumn//',
82
+ tag: 'div[data-layout-section]',
83
+ skip: true
84
+ }, {
85
+ tag: 'div[data-layout-section]',
86
+ getAttrs: dom => {
87
+ const columnRuleStyle = dom.getAttribute('data-column-rule-style');
88
+ const localId = uuid.generate();
89
+ return columnRuleStyle ? {
90
+ columnRuleStyle,
91
+ localId
92
+ } : {
93
+ localId
94
+ };
95
+ }
96
+ }],
97
+ toDOM(node) {
98
+ var _node$attrs;
99
+ const {
100
+ columnRuleStyle
101
+ } = node.attrs;
102
+ const attrs = {
103
+ 'data-layout-section': 'true',
104
+ 'data-column-rule-style': columnRuleStyle || undefined,
105
+ 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) || undefined
106
+ };
107
+ return ['div', attrs, 0];
108
+ }
77
109
  });
@@ -1,3 +1,4 @@
1
+ import { uuid } from '../../utils';
1
2
  import { listItem as listItemFactory, listItemWithNestedDecisionStage0 as listItemWithNestedDecisionStage0Factory } from '../../next-schema/generated/nodeTypes';
2
3
 
3
4
  /**
@@ -12,6 +13,20 @@ export const listItem = listItemFactory({
12
13
  return ['li', 0];
13
14
  }
14
15
  });
16
+ export const listItemWithLocalId = listItemFactory({
17
+ parseDOM: [{
18
+ tag: 'li',
19
+ getAttrs: () => ({
20
+ localId: uuid.generate()
21
+ })
22
+ }],
23
+ toDOM(node) {
24
+ var _node$attrs;
25
+ return ['li', {
26
+ 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) || undefined
27
+ }, 0];
28
+ }
29
+ });
15
30
 
16
31
  /**
17
32
  * @name list_item_with_decision_stage0
@@ -24,4 +39,18 @@ export const listItemWithDecisionStage0 = listItemWithNestedDecisionStage0Factor
24
39
  toDOM() {
25
40
  return ['li', 0];
26
41
  }
42
+ });
43
+ export const listItemWithNestedDecisionAndLocalIdStage0 = listItemWithNestedDecisionStage0Factory({
44
+ parseDOM: [{
45
+ tag: 'li',
46
+ getAttrs: () => ({
47
+ localId: uuid.generate()
48
+ })
49
+ }],
50
+ toDOM(node) {
51
+ var _node$attrs2;
52
+ return ['li', {
53
+ 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId) || undefined
54
+ }, 0];
55
+ }
27
56
  });
@@ -1,8 +1,15 @@
1
1
  import { createMediaSpec } from './media';
2
+ import { uuid } from '../../utils/uuid';
2
3
  import { mediaInline as mediaInlineFactory } from '../../next-schema/generated/nodeTypes';
3
4
 
4
5
  /**
5
6
  * @name mediaInline_node
6
7
  */
7
8
 
8
- export const mediaInline = createMediaSpec(mediaInlineFactory({}).attrs, true);
9
+ export const mediaInline = createMediaSpec(mediaInlineFactory({}).attrs, true);
10
+ export const mediaInlineWithLocalId = createMediaSpec({
11
+ ...mediaInlineFactory({}).attrs,
12
+ localId: {
13
+ default: uuid.generate()
14
+ }
15
+ }, true, true);
@@ -1,6 +1,7 @@
1
1
  import { WidthType } from './types/rich-media-common';
2
2
  import { isDOMElement } from '../../utils/parseDOM';
3
3
  import { mediaSingle as mediaSingleFactory, mediaSingleCaption as mediaSingleCaptionFactory, mediaSingleFull as mediaSingleFullFactory, mediaSingleWidthType as mediaSingleWidthTypeFactory } from '../../next-schema/generated/nodeTypes';
4
+ import { uuid } from '../../utils/uuid';
4
5
 
5
6
  /**
6
7
  * @name mediaSingle_node
@@ -34,7 +35,8 @@ export const defaultAttrs = {
34
35
  };
35
36
  export const mediaSingleSpec = ({
36
37
  withCaption = false,
37
- withExtendedWidthTypes = false
38
+ withExtendedWidthTypes = false,
39
+ generateLocalId = false
38
40
  }) => {
39
41
  const getAttrs = dom => {
40
42
  if (!isDOMElement(dom)) {
@@ -46,6 +48,14 @@ export const mediaSingleSpec = ({
46
48
  const layout = dom.getAttribute('data-layout') || 'center';
47
49
  const width = Number(dom.getAttribute('data-width')) || null;
48
50
  const widthType = dom.getAttribute('data-width-type');
51
+ if (generateLocalId) {
52
+ return {
53
+ layout,
54
+ width,
55
+ widthType,
56
+ localId: uuid.generate()
57
+ };
58
+ }
49
59
  if (withExtendedWidthTypes) {
50
60
  return {
51
61
  layout,
@@ -75,6 +85,10 @@ export const mediaSingleSpec = ({
75
85
  'data-layout': layout,
76
86
  'data-width': ''
77
87
  };
88
+ if (generateLocalId) {
89
+ var _node$attrs;
90
+ attrs['data-local-id'] = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) || undefined;
91
+ }
78
92
  if (width) {
79
93
  attrs['data-width'] = isFinite(width) && Math.floor(width) === width ? width : width.toFixed(2);
80
94
  }
@@ -148,6 +162,11 @@ export const mediaSingleFull = mediaSingleSpec({
148
162
  withCaption: true,
149
163
  withExtendedWidthTypes: true
150
164
  });
165
+ export const mediaSingleFullWithLocalId = mediaSingleSpec({
166
+ withCaption: true,
167
+ withExtendedWidthTypes: true,
168
+ generateLocalId: true
169
+ });
151
170
  export const toJSON = node => ({
152
171
  attrs: Object.keys(node.attrs).reduce((obj, key) => {
153
172
  if (node.attrs[key] !== null) {
@@ -1,13 +1,14 @@
1
1
  import { N30 } from '../../utils/colors';
2
2
  import { media as mediaFactory } from '../../next-schema/generated/nodeTypes';
3
3
  import { mediaInline as mediaInlineFactory } from '../../next-schema/generated/nodeTypes';
4
+ import { uuid } from '../../utils/uuid';
4
5
 
5
6
  /**
6
7
  * @name media_node
7
8
  */
8
9
 
9
10
  export const defaultAttrs = mediaFactory({}).attrs;
10
- export const createMediaSpec = (attributes, inline = false) => {
11
+ export const createMediaSpec = (attributes, inline = false, generateLocalId = false) => {
11
12
  const domNodeType = inline ? 'span' : 'div';
12
13
  const nodeName = inline ? 'mediaInline' : 'media';
13
14
  const parseDOM = [{
@@ -45,6 +46,7 @@ export const createMediaSpec = (attributes, inline = false) => {
45
46
  ignore: true
46
47
  }];
47
48
  const toDOM = node => {
49
+ var _node$attrs;
48
50
  const attrs = {
49
51
  'data-id': node.attrs.id,
50
52
  'data-node-type': `${nodeName}`,
@@ -61,7 +63,8 @@ export const createMediaSpec = (attributes, inline = false) => {
61
63
  title: 'Attachment',
62
64
  // Manually kept in sync with the style of media cards. The goal is to render a plain gray
63
65
  // rectangle that provides an affordance for media.
64
- style: `display: inline-block; border-radius: 3px; background: ${N30}; box-shadow: 0 1px 1px rgba(9, 30, 66, 0.2), 0 0 1px 0 rgba(9, 30, 66, 0.24);`
66
+ style: `display: inline-block; border-radius: 3px; background: ${N30}; box-shadow: 0 1px 1px rgba(9, 30, 66, 0.2), 0 0 1px 0 rgba(9, 30, 66, 0.24);`,
67
+ 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) || undefined
65
68
  };
66
69
  copyPrivateAttributes(node.attrs, attrs, key => `data-${camelCaseToKebabCase(key.slice(2))}`);
67
70
  return [`${domNodeType}`, attrs];
@@ -79,17 +82,27 @@ export const createMediaSpec = (attributes, inline = false) => {
79
82
  // https://product-fabric.atlassian.net/browse/EDM-2996
80
83
  tag: 'img:not(.smart-link-icon)',
81
84
  getAttrs: dom => {
82
- return {
85
+ const attrs = {
83
86
  type: 'external',
84
87
  url: dom.getAttribute('src') || '',
85
88
  alt: dom.getAttribute('alt') || ''
86
89
  };
90
+ if (generateLocalId) {
91
+ attrs.localId = uuid.generate();
92
+ }
93
+ return attrs;
87
94
  }
88
95
  }],
89
96
  toDOM
90
97
  });
91
98
  };
92
- export const media = createMediaSpec(defaultAttrs, false);
99
+ export const media = createMediaSpec(defaultAttrs, false, false);
100
+ export const mediaWithLocalId = createMediaSpec({
101
+ ...defaultAttrs,
102
+ localId: {
103
+ default: uuid.generate()
104
+ }
105
+ }, false, true);
93
106
  export const camelCaseToKebabCase = str => str.replace(/([^A-Z]+)([A-Z])/g, (_, x, y) => `${x}-${y.toLowerCase()}`);
94
107
  export const copyPrivateAttributes = (from, to, map) => {
95
108
  if (media.attrs) {
@@ -1,4 +1,5 @@
1
1
  import { nestedExpand as nestedExpandFactory } from '../../next-schema/generated/nodeTypes';
2
+ import { uuid } from '../../utils/uuid';
2
3
 
3
4
  /**
4
5
  * @name nestedExpand_content
@@ -14,18 +15,19 @@ import { nestedExpand as nestedExpandFactory } from '../../next-schema/generated
14
15
  * @name nestedExpand_with_no_marks_node
15
16
  */
16
17
 
17
- function getExpandAttrs(domNode) {
18
+ function getExpandAttrs(domNode, generateLocalId) {
18
19
  const dom = domNode;
19
20
  return {
20
21
  title: dom.getAttribute('data-title'),
21
- __expanded: true
22
+ __expanded: true,
23
+ localId: generateLocalId ? uuid.generate() : undefined
22
24
  };
23
25
  }
24
26
  const nestedExpandFactoryOptions = {
25
27
  parseDOM: [{
26
28
  context: 'nestedExpand//',
27
29
  tag: '[data-node-type="nestedExpand"]',
28
- getAttrs: getExpandAttrs
30
+ getAttrs: domNode => getExpandAttrs(domNode, false)
29
31
  }, {
30
32
  tag: '[data-node-type="nestedExpand"] button',
31
33
  ignore: true
@@ -34,13 +36,15 @@ const nestedExpandFactoryOptions = {
34
36
  ignore: true
35
37
  }, {
36
38
  tag: 'div[data-node-type="nestedExpand"]',
37
- getAttrs: getExpandAttrs
39
+ getAttrs: domNode => getExpandAttrs(domNode, false)
38
40
  }],
39
41
  toDOM(node) {
42
+ var _node$attrs;
40
43
  const attrs = {
41
44
  'data-node-type': 'nestedExpand',
42
45
  'data-title': node.attrs.title,
43
- 'data-expanded': node.attrs.__expanded
46
+ 'data-expanded': node.attrs.__expanded,
47
+ 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) || undefined
44
48
  };
45
49
  return ['div', attrs, 0];
46
50
  }
@@ -50,4 +54,15 @@ const nestedExpandFactoryOptions = {
50
54
  * @name nestedExpand
51
55
  * @description an expand that can be nested (eg. inside table, layout).
52
56
  */
53
- export const nestedExpand = nestedExpandFactory(nestedExpandFactoryOptions);
57
+ export const nestedExpand = nestedExpandFactory(nestedExpandFactoryOptions);
58
+ export const nestedExpandWithLocalId = nestedExpandFactory({
59
+ ...nestedExpandFactoryOptions,
60
+ parseDOM: [...nestedExpandFactoryOptions.parseDOM, {
61
+ context: 'nestedExpand//',
62
+ tag: '[data-node-type="nestedExpand"]',
63
+ getAttrs: domNode => getExpandAttrs(domNode, true)
64
+ }, {
65
+ tag: '[data-node-type="nestedExpand"]',
66
+ getAttrs: domNode => getExpandAttrs(domNode, true)
67
+ }]
68
+ });
@@ -1,3 +1,4 @@
1
+ import { uuid } from '../../utils';
1
2
  import { orderedList as orderedListFactory } from '../../next-schema/generated/nodeTypes';
2
3
  export const orderedListSelector = '.ak-ol';
3
4
  export const orderedList = orderedListFactory({
@@ -11,6 +12,22 @@ export const orderedList = orderedListFactory({
11
12
  return ['ol', attrs, 0];
12
13
  }
13
14
  });
15
+ export const orderedListWithLocalId = orderedListFactory({
16
+ parseDOM: [{
17
+ tag: 'ol',
18
+ getAttrs: () => ({
19
+ localId: uuid.generate()
20
+ })
21
+ }],
22
+ toDOM(node) {
23
+ var _node$attrs;
24
+ const attrs = {
25
+ class: orderedListSelector.substr(1),
26
+ 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) || undefined
27
+ };
28
+ return ['ol', attrs, 0];
29
+ }
30
+ });
14
31
 
15
32
  // resolve "start" to a safe, 0+ integer, otherwise return undefined
16
33
  // Note: Any changes to this function should also be made to "resolveOrder"
@@ -43,12 +60,44 @@ export const orderedListWithOrder = orderedListFactory({
43
60
  }
44
61
  }],
45
62
  toDOM(node) {
46
- var _node$attrs;
47
- const start = resolveStart(node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.order);
63
+ var _node$attrs2;
64
+ const start = resolveStart(node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.order);
48
65
  const attrs = {
49
66
  start: typeof start === 'number' ? String(start) : undefined,
50
67
  class: orderedListSelector.substr(1)
51
68
  };
52
69
  return ['ol', attrs, 0];
53
70
  }
71
+ });
72
+ export const orderedListWithOrderAndLocalId = orderedListFactory({
73
+ parseDOM: [{
74
+ tag: 'ol',
75
+ getAttrs: domNode => {
76
+ const dom = domNode;
77
+ const startDOMAttr = dom.getAttribute('start');
78
+ const localId = uuid.generate();
79
+ if (startDOMAttr) {
80
+ const start = resolveStart(startDOMAttr);
81
+ if (typeof start === 'number') {
82
+ return {
83
+ order: start,
84
+ localId
85
+ };
86
+ }
87
+ }
88
+ return {
89
+ localId
90
+ };
91
+ }
92
+ }],
93
+ toDOM(node) {
94
+ var _node$attrs3, _node$attrs4;
95
+ const start = resolveStart(node === null || node === void 0 ? void 0 : (_node$attrs3 = node.attrs) === null || _node$attrs3 === void 0 ? void 0 : _node$attrs3.order);
96
+ const attrs = {
97
+ start: typeof start === 'number' ? String(start) : undefined,
98
+ class: orderedListSelector.substr(1),
99
+ 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs4 = node.attrs) === null || _node$attrs4 === void 0 ? void 0 : _node$attrs4.localId) || undefined
100
+ };
101
+ return ['ol', attrs, 0];
102
+ }
54
103
  });
@@ -1,4 +1,5 @@
1
1
  import { panel as panelFactory } from '../../next-schema/generated/nodeTypes';
2
+ import { uuid } from '../../utils/uuid';
2
3
  export let PanelType = /*#__PURE__*/function (PanelType) {
3
4
  PanelType["INFO"] = "info";
4
5
  PanelType["NOTE"] = "note";
@@ -20,14 +21,18 @@ const getDomAttrs = nodeAttrs => {
20
21
  'data-panel-icon': nodeAttrs.panelIcon,
21
22
  'data-panel-icon-id': nodeAttrs.panelIconId,
22
23
  'data-panel-icon-text': nodeAttrs.panelIconText,
23
- 'data-panel-color': nodeAttrs.panelColor
24
+ 'data-panel-color': nodeAttrs.panelColor,
25
+ 'data-local-id': (nodeAttrs === null || nodeAttrs === void 0 ? void 0 : nodeAttrs.localId) || undefined
24
26
  };
25
27
  return attrs;
26
28
  };
27
- const getParseDOMAttrs = (allowCustomPanel, dom) => {
29
+ const getParseDOMAttrs = (allowCustomPanel, dom, generateLocalId) => {
28
30
  let parseDOMAttrs = {
29
31
  panelType: dom.getAttribute('data-panel-type')
30
32
  };
33
+ if (generateLocalId) {
34
+ parseDOMAttrs.localId = uuid.generate();
35
+ }
31
36
  if (allowCustomPanel) {
32
37
  parseDOMAttrs = {
33
38
  ...parseDOMAttrs,
@@ -41,10 +46,10 @@ const getParseDOMAttrs = (allowCustomPanel, dom) => {
41
46
  }
42
47
  return parseDOMAttrs;
43
48
  };
44
- const createPanelNodeSpecOptions = allowCustomPanel => ({
49
+ const createPanelNodeSpecOptions = (allowCustomPanel, generateLocalId) => ({
45
50
  parseDOM: [{
46
51
  tag: 'div[data-panel-type]',
47
- getAttrs: dom => getParseDOMAttrs(allowCustomPanel, dom)
52
+ getAttrs: dom => getParseDOMAttrs(allowCustomPanel, dom, generateLocalId)
48
53
  }],
49
54
  toDOM(node) {
50
55
  const attrs = getDomAttrs(node.attrs);
@@ -61,4 +66,5 @@ const createPanelNodeSpecOptions = allowCustomPanel => ({
61
66
  * Specifically, it allows Media, action, code-block, rule and decision nodes in
62
67
  * addition to content allowed inside panel
63
68
  */
64
- export const extendedPanel = allowCustomPanel => panelFactory(createPanelNodeSpecOptions(allowCustomPanel));
69
+ export const extendedPanel = allowCustomPanel => panelFactory(createPanelNodeSpecOptions(allowCustomPanel));
70
+ export const extendedPanelWithLocalId = allowCustomPanel => panelFactory(createPanelNodeSpecOptions(allowCustomPanel, true));
@@ -1,4 +1,5 @@
1
1
  import { placeholder as placeholderFactory } from '../../next-schema/generated/nodeTypes';
2
+ import { uuid } from '../../utils/uuid';
2
3
 
3
4
  /**
4
5
  * @name placeholder_node
@@ -22,4 +23,26 @@ export const placeholder = placeholderFactory({
22
23
  };
23
24
  return ['span', attrs, text];
24
25
  }
26
+ });
27
+ export const placeholderWithLocalId = placeholderFactory({
28
+ parseDOM: [{
29
+ tag: 'span[data-placeholder]',
30
+ getAttrs: dom => ({
31
+ text: dom.getAttribute('data-placeholder') || placeholder.attrs.text.default,
32
+ localId: uuid.generate()
33
+ })
34
+ }],
35
+ toDOM(node) {
36
+ var _node$attrs;
37
+ const {
38
+ text
39
+ } = node.attrs;
40
+ const attrs = {
41
+ 'data-placeholder': text,
42
+ // Needs to be edtiable for mobile to not close keyboard
43
+ contenteditable: 'true',
44
+ 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) || undefined
45
+ };
46
+ return ['span', attrs, text];
47
+ }
25
48
  });
@@ -1,4 +1,5 @@
1
1
  import { rule as ruleFactory } from '../../next-schema/generated/nodeTypes';
2
+ import { uuid } from '../../utils/uuid';
2
3
 
3
4
  /**
4
5
  * @name rule_node
@@ -12,4 +13,18 @@ export const rule = ruleFactory({
12
13
  toDOM() {
13
14
  return hrDOM;
14
15
  }
16
+ });
17
+ export const ruleWithLocalId = ruleFactory({
18
+ parseDOM: [{
19
+ tag: 'hr',
20
+ getAttrs: () => ({
21
+ localId: uuid.generate()
22
+ })
23
+ }],
24
+ toDOM(node) {
25
+ var _node$attrs;
26
+ return ['hr', {
27
+ 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) || undefined
28
+ }];
29
+ }
15
30
  });
@@ -39,11 +39,15 @@ export const getCellAttrs = (dom, defaultValues = {}) => {
39
39
  }
40
40
  }
41
41
  const backgroundHexCode = dataCellBackgroundHexCode || (backgroundColor && backgroundColor !== defaultValues['background'] ? backgroundColor : null);
42
+ const localId = dom.getAttribute('data-local-id') || defaultValues.localId;
42
43
  return {
43
44
  colspan,
44
45
  rowspan: Number(dom.getAttribute('rowspan') || 1),
45
46
  colwidth: width && width.length === colspan ? width : null,
46
- background: backgroundHexCode
47
+ background: backgroundHexCode,
48
+ ...(localId && {
49
+ localId
50
+ })
47
51
  };
48
52
  };
49
53
  // these are for test only
@@ -76,6 +80,7 @@ const cssVariablePattern = /^var\(--.*\)$/;
76
80
  * @returns CellDomAttrs
77
81
  */
78
82
  export const getCellDomAttrs = node => {
83
+ var _node$attrs;
79
84
  const attrs = {};
80
85
  const nodeType = node.type.name;
81
86
  if (node.attrs.colspan !== 1) {
@@ -166,6 +171,9 @@ export const getCellDomAttrs = node => {
166
171
  } else {
167
172
  attrs.class = tableCellSelector;
168
173
  }
174
+ if (node !== null && node !== void 0 && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.localId) {
175
+ attrs['data-local-id'] = node.attrs.localId;
176
+ }
169
177
  return attrs;
170
178
  };
171
179
  export const tableBackgroundColorPalette = new Map();
@@ -271,6 +279,10 @@ const cellAttrs = {
271
279
  },
272
280
  background: {
273
281
  default: null
282
+ },
283
+ localId: {
284
+ default: null,
285
+ optional: true
274
286
  }
275
287
  };
276
288
  const tableCellNodeSpecOptions = {
@@ -288,7 +300,8 @@ const tableCellNodeSpecOptions = {
288
300
  export const tableCell = tableCellFactory(tableCellNodeSpecOptions);
289
301
  export const toJSONTableCell = node => ({
290
302
  attrs: Object.keys(node.attrs).reduce((obj, key) => {
291
- if (cellAttrs[key].default !== node.attrs[key]) {
303
+ // Only process keys that are defined in cellAttrs
304
+ if (cellAttrs[key] && cellAttrs[key].default !== node.attrs[key]) {
292
305
  obj[key] = node.attrs[key];
293
306
  }
294
307
  return obj;
@@ -310,4 +323,47 @@ export const toJSONTableHeader = toJSONTableCell;
310
323
  export const tableWithNestedTable = tableWithNestedTableFactory(tableNodeSpecOptions);
311
324
  export const tableRowWithNestedTable = tableRowWithNestedTableFactory(tableRowNodeSpecOptions);
312
325
  export const tableCellWithNestedTable = tableCellWithNestedTableFactory(tableCellNodeSpecOptions);
313
- export const tableHeaderWithNestedTable = tableHeaderWithNestedTableFactory(tableHeaderNodeSpecOptions);
326
+ export const tableHeaderWithNestedTable = tableHeaderWithNestedTableFactory(tableHeaderNodeSpecOptions);
327
+
328
+ // table nodes with localId support
329
+ const tableRowNodeSpecOptionsWithLocalId = {
330
+ parseDOM: [{
331
+ tag: 'tr',
332
+ getAttrs: () => ({
333
+ localId: uuid.generate()
334
+ })
335
+ }],
336
+ toDOM(node) {
337
+ var _node$attrs2;
338
+ return ['tr', {
339
+ 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId) || undefined
340
+ }, 0];
341
+ }
342
+ };
343
+ export const tableRowWithLocalId = tableRowFactory(tableRowNodeSpecOptionsWithLocalId);
344
+ const tableCellNodeSpecOptionsWithLocalId = {
345
+ parseDOM: [{
346
+ tag: 'td',
347
+ getAttrs: () => ({
348
+ localId: uuid.generate()
349
+ })
350
+ }],
351
+ toDOM(node) {
352
+ var _node$attrs3;
353
+ return ['td', {
354
+ 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs3 = node.attrs) === null || _node$attrs3 === void 0 ? void 0 : _node$attrs3.localId) || undefined
355
+ }, 0];
356
+ }
357
+ };
358
+ export const tableCellWithLocalId = tableCellFactory(tableCellNodeSpecOptionsWithLocalId);
359
+ const tableHeaderNodeSpecOptionsWithLocalId = {
360
+ parseDOM: [{
361
+ tag: 'th',
362
+ getAttrs: dom => getCellAttrs(dom, {
363
+ background: DEFAULT_TABLE_HEADER_CELL_BACKGROUND,
364
+ localId: uuid.generate()
365
+ })
366
+ }],
367
+ toDOM: node => ['th', getCellDomAttrs(node), 0]
368
+ };
369
+ export const tableHeaderWithLocalId = tableHeaderFactory(tableHeaderNodeSpecOptionsWithLocalId);