@atlaskit/adf-schema 49.0.5 → 49.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.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/index.js +114 -0
- package/dist/cjs/next-schema/generated/nodeTypes.js +118 -1
- package/dist/cjs/next-schema/nodes/blockCard.js +15 -0
- package/dist/cjs/next-schema/nodes/blockquote.js +16 -2
- package/dist/cjs/next-schema/nodes/caption.js +7 -0
- package/dist/cjs/next-schema/nodes/codeBlock.js +5 -0
- package/dist/cjs/next-schema/nodes/date.js +5 -0
- package/dist/cjs/next-schema/nodes/embedCard.js +5 -0
- package/dist/cjs/next-schema/nodes/emoji.js +5 -0
- package/dist/cjs/next-schema/nodes/expand.js +5 -0
- package/dist/cjs/next-schema/nodes/hardBreak.js +5 -0
- package/dist/cjs/next-schema/nodes/inlineCard.js +10 -0
- package/dist/cjs/next-schema/nodes/layoutColumn.js +5 -0
- package/dist/cjs/next-schema/nodes/layoutSection.js +12 -0
- package/dist/cjs/next-schema/nodes/list.js +20 -1
- package/dist/cjs/next-schema/nodes/media.js +10 -0
- package/dist/cjs/next-schema/nodes/mediaInline.js +5 -0
- package/dist/cjs/next-schema/nodes/mediaSingle.js +10 -0
- package/dist/cjs/next-schema/nodes/nestedExpand.js +5 -0
- package/dist/cjs/next-schema/nodes/panel.js +5 -0
- package/dist/cjs/next-schema/nodes/placeholder.js +5 -0
- package/dist/cjs/next-schema/nodes/rule.js +9 -1
- package/dist/cjs/schema/index.js +120 -0
- package/dist/cjs/schema/marks/background-color.js +9 -9
- package/dist/cjs/schema/nodes/block-card.js +48 -1
- package/dist/cjs/schema/nodes/blockquote.js +20 -2
- package/dist/cjs/schema/nodes/bullet-list.js +20 -1
- package/dist/cjs/schema/nodes/caption.js +20 -1
- package/dist/cjs/schema/nodes/code-block.js +72 -2
- package/dist/cjs/schema/nodes/date.js +22 -1
- package/dist/cjs/schema/nodes/embed-card.js +36 -1
- package/dist/cjs/schema/nodes/emoji.js +73 -1
- package/dist/cjs/schema/nodes/expand.js +56 -1
- package/dist/cjs/schema/nodes/hard-break.js +18 -1
- package/dist/cjs/schema/nodes/index.js +120 -0
- package/dist/cjs/schema/nodes/inline-card.js +46 -1
- package/dist/cjs/schema/nodes/layout-column.js +37 -1
- package/dist/cjs/schema/nodes/layout-section.js +31 -1
- package/dist/cjs/schema/nodes/list-item.js +34 -1
- package/dist/cjs/schema/nodes/media-inline.js +12 -2
- package/dist/cjs/schema/nodes/media-single.js +22 -2
- package/dist/cjs/schema/nodes/media.js +21 -4
- package/dist/cjs/schema/nodes/nested-expand.js +34 -7
- package/dist/cjs/schema/nodes/ordered-list.js +54 -3
- package/dist/cjs/schema/nodes/panel.js +13 -5
- package/dist/cjs/schema/nodes/placeholder.js +24 -1
- package/dist/cjs/schema/nodes/rule.js +18 -1
- package/dist/cjs/validator-schema/generated/validatorSpec.js +142 -0
- package/dist/es2019/index.js +2 -2
- package/dist/es2019/next-schema/generated/nodeTypes.js +118 -1
- package/dist/es2019/next-schema/nodes/blockCard.js +15 -0
- package/dist/es2019/next-schema/nodes/blockquote.js +16 -2
- package/dist/es2019/next-schema/nodes/caption.js +7 -0
- package/dist/es2019/next-schema/nodes/codeBlock.js +5 -0
- package/dist/es2019/next-schema/nodes/date.js +5 -0
- package/dist/es2019/next-schema/nodes/embedCard.js +5 -0
- package/dist/es2019/next-schema/nodes/emoji.js +5 -0
- package/dist/es2019/next-schema/nodes/expand.js +5 -0
- package/dist/es2019/next-schema/nodes/hardBreak.js +5 -0
- package/dist/es2019/next-schema/nodes/inlineCard.js +10 -0
- package/dist/es2019/next-schema/nodes/layoutColumn.js +5 -0
- package/dist/es2019/next-schema/nodes/layoutSection.js +12 -0
- package/dist/es2019/next-schema/nodes/list.js +20 -1
- package/dist/es2019/next-schema/nodes/media.js +10 -0
- package/dist/es2019/next-schema/nodes/mediaInline.js +5 -0
- package/dist/es2019/next-schema/nodes/mediaSingle.js +10 -0
- package/dist/es2019/next-schema/nodes/nestedExpand.js +5 -0
- package/dist/es2019/next-schema/nodes/panel.js +5 -0
- package/dist/es2019/next-schema/nodes/placeholder.js +5 -0
- package/dist/es2019/next-schema/nodes/rule.js +9 -1
- package/dist/es2019/schema/index.js +1 -1
- package/dist/es2019/schema/marks/background-color.js +9 -9
- package/dist/es2019/schema/nodes/block-card.js +50 -0
- package/dist/es2019/schema/nodes/blockquote.js +19 -1
- package/dist/es2019/schema/nodes/bullet-list.js +19 -0
- package/dist/es2019/schema/nodes/caption.js +19 -0
- package/dist/es2019/schema/nodes/code-block.js +68 -0
- package/dist/es2019/schema/nodes/date.js +19 -0
- package/dist/es2019/schema/nodes/embed-card.js +34 -0
- package/dist/es2019/schema/nodes/emoji.js +71 -0
- package/dist/es2019/schema/nodes/expand.js +59 -0
- package/dist/es2019/schema/nodes/hard-break.js +15 -0
- package/dist/es2019/schema/nodes/index.js +19 -19
- package/dist/es2019/schema/nodes/inline-card.js +45 -0
- package/dist/es2019/schema/nodes/layout-column.js +38 -0
- package/dist/es2019/schema/nodes/layout-section.js +32 -0
- package/dist/es2019/schema/nodes/list-item.js +29 -0
- package/dist/es2019/schema/nodes/media-inline.js +8 -1
- package/dist/es2019/schema/nodes/media-single.js +20 -1
- package/dist/es2019/schema/nodes/media.js +17 -4
- package/dist/es2019/schema/nodes/nested-expand.js +21 -6
- package/dist/es2019/schema/nodes/ordered-list.js +51 -2
- package/dist/es2019/schema/nodes/panel.js +11 -5
- package/dist/es2019/schema/nodes/placeholder.js +23 -0
- package/dist/es2019/schema/nodes/rule.js +15 -0
- package/dist/es2019/validator-schema/generated/validatorSpec.js +142 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/next-schema/generated/nodeTypes.js +118 -1
- package/dist/esm/next-schema/nodes/blockCard.js +15 -0
- package/dist/esm/next-schema/nodes/blockquote.js +16 -2
- package/dist/esm/next-schema/nodes/caption.js +7 -0
- package/dist/esm/next-schema/nodes/codeBlock.js +5 -0
- package/dist/esm/next-schema/nodes/date.js +5 -0
- package/dist/esm/next-schema/nodes/embedCard.js +5 -0
- package/dist/esm/next-schema/nodes/emoji.js +5 -0
- package/dist/esm/next-schema/nodes/expand.js +5 -0
- package/dist/esm/next-schema/nodes/hardBreak.js +5 -0
- package/dist/esm/next-schema/nodes/inlineCard.js +10 -0
- package/dist/esm/next-schema/nodes/layoutColumn.js +5 -0
- package/dist/esm/next-schema/nodes/layoutSection.js +12 -0
- package/dist/esm/next-schema/nodes/list.js +20 -1
- package/dist/esm/next-schema/nodes/media.js +10 -0
- package/dist/esm/next-schema/nodes/mediaInline.js +5 -0
- package/dist/esm/next-schema/nodes/mediaSingle.js +10 -0
- package/dist/esm/next-schema/nodes/nestedExpand.js +5 -0
- package/dist/esm/next-schema/nodes/panel.js +5 -0
- package/dist/esm/next-schema/nodes/placeholder.js +5 -0
- package/dist/esm/next-schema/nodes/rule.js +9 -1
- package/dist/esm/schema/index.js +1 -1
- package/dist/esm/schema/marks/background-color.js +9 -9
- package/dist/esm/schema/nodes/block-card.js +47 -0
- package/dist/esm/schema/nodes/blockquote.js +19 -1
- package/dist/esm/schema/nodes/bullet-list.js +19 -0
- package/dist/esm/schema/nodes/caption.js +19 -0
- package/dist/esm/schema/nodes/code-block.js +71 -1
- package/dist/esm/schema/nodes/date.js +21 -0
- package/dist/esm/schema/nodes/embed-card.js +35 -0
- package/dist/esm/schema/nodes/emoji.js +71 -0
- package/dist/esm/schema/nodes/expand.js +55 -0
- package/dist/esm/schema/nodes/hard-break.js +17 -0
- package/dist/esm/schema/nodes/index.js +19 -19
- package/dist/esm/schema/nodes/inline-card.js +45 -0
- package/dist/esm/schema/nodes/layout-column.js +36 -0
- package/dist/esm/schema/nodes/layout-section.js +30 -0
- package/dist/esm/schema/nodes/list-item.js +33 -0
- package/dist/esm/schema/nodes/media-inline.js +10 -1
- package/dist/esm/schema/nodes/media-single.js +21 -1
- package/dist/esm/schema/nodes/media.js +19 -3
- package/dist/esm/schema/nodes/nested-expand.js +32 -6
- package/dist/esm/schema/nodes/ordered-list.js +53 -2
- package/dist/esm/schema/nodes/panel.js +12 -4
- package/dist/esm/schema/nodes/placeholder.js +23 -0
- package/dist/esm/schema/nodes/rule.js +17 -0
- package/dist/esm/validator-schema/generated/validatorSpec.js +142 -0
- package/dist/json-schema/v1/full.json +125 -2
- package/dist/json-schema/v1/stage-0.json +137 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/next-schema/generated/nodeTypes.d.ts +62 -0
- package/dist/types/next-schema/groups/nonNestableBlockContentGroup.d.ts +7 -0
- package/dist/types/next-schema/groups/tableCellContentPseudoGroup.d.ts +7 -0
- package/dist/types/next-schema/nodes/blockquote.d.ts +7 -0
- package/dist/types/next-schema/nodes/layoutSection.d.ts +5 -0
- package/dist/types/schema/index.d.ts +1 -1
- package/dist/types/schema/nodes/block-card.d.ts +4 -0
- package/dist/types/schema/nodes/blockquote.d.ts +4 -0
- package/dist/types/schema/nodes/bullet-list.d.ts +1 -0
- package/dist/types/schema/nodes/caption.d.ts +4 -0
- package/dist/types/schema/nodes/code-block.d.ts +2 -0
- package/dist/types/schema/nodes/date.d.ts +2 -0
- package/dist/types/schema/nodes/embed-card.d.ts +2 -0
- package/dist/types/schema/nodes/emoji.d.ts +2 -0
- package/dist/types/schema/nodes/expand.d.ts +2 -0
- package/dist/types/schema/nodes/hard-break.d.ts +2 -0
- package/dist/types/schema/nodes/index.d.ts +19 -19
- package/dist/types/schema/nodes/inline-card.d.ts +1 -0
- package/dist/types/schema/nodes/layout-column.d.ts +2 -0
- package/dist/types/schema/nodes/layout-section.d.ts +4 -0
- package/dist/types/schema/nodes/list-item.d.ts +2 -0
- package/dist/types/schema/nodes/media-inline.d.ts +1 -0
- package/dist/types/schema/nodes/media-single.d.ts +3 -1
- package/dist/types/schema/nodes/media.d.ts +3 -1
- package/dist/types/schema/nodes/nested-expand.d.ts +2 -0
- package/dist/types/schema/nodes/ordered-list.d.ts +2 -0
- package/dist/types/schema/nodes/panel.d.ts +2 -0
- package/dist/types/schema/nodes/placeholder.d.ts +2 -0
- package/dist/types/schema/nodes/rule.d.ts +4 -0
- package/dist/types/schema/nodes/types/list.d.ts +7 -0
- package/dist/types/schema/nodes/types/rich-media-common.d.ts +1 -0
- package/dist/types/validator-schema/generated/validatorSpec.d.ts +142 -0
- package/json-schema/v1/full.json +125 -2
- package/json-schema/v1/stage-0.json +137 -2
- package/package.json +2 -2
- package/schema-generators/__tests__/unit/adfToValidatorSpec.unit.ts +1 -0
@@ -1,5 +1,6 @@
|
|
1
1
|
import { acNameToEmoji, acShortcutToEmoji } from '../../utils/confluence/emoji';
|
2
2
|
import { emoji as emojiFactory } from '../../next-schema/generated/nodeTypes';
|
3
|
+
import { uuid } from '../../utils/uuid';
|
3
4
|
|
4
5
|
/**
|
5
6
|
* @name emoji_node
|
@@ -58,4 +59,74 @@ export const emoji = emojiFactory({
|
|
58
59
|
};
|
59
60
|
return ['span', attrs, text];
|
60
61
|
}
|
62
|
+
});
|
63
|
+
export const emojiWithLocalId = emojiFactory({
|
64
|
+
parseDOM: [
|
65
|
+
// Handle copy/paste beautiful panel from renderer />
|
66
|
+
{
|
67
|
+
tag: 'div.ak-editor-panel__icon span',
|
68
|
+
ignore: true
|
69
|
+
}, {
|
70
|
+
tag: 'span[data-emoji-short-name]',
|
71
|
+
getAttrs: domNode => {
|
72
|
+
const dom = domNode;
|
73
|
+
return {
|
74
|
+
shortName: dom.getAttribute('data-emoji-short-name') || emoji.attrs.shortName.default,
|
75
|
+
id: dom.getAttribute('data-emoji-id') || emoji.attrs.id.default,
|
76
|
+
text: dom.getAttribute('data-emoji-text') || emoji.attrs.text.default,
|
77
|
+
localId: uuid.generate()
|
78
|
+
};
|
79
|
+
}
|
80
|
+
},
|
81
|
+
// Handle copy/paste from old <ac:emoticon />
|
82
|
+
{
|
83
|
+
tag: 'img[data-emoticon-name]',
|
84
|
+
getAttrs: dom => {
|
85
|
+
const attrs = acNameToEmoji(dom.getAttribute('data-emoticon-name'));
|
86
|
+
return {
|
87
|
+
...attrs,
|
88
|
+
localId: uuid.generate()
|
89
|
+
};
|
90
|
+
}
|
91
|
+
},
|
92
|
+
// Handle copy/paste from old <ac:hipchat-emoticons />
|
93
|
+
{
|
94
|
+
tag: 'img[data-hipchat-emoticon]',
|
95
|
+
getAttrs: dom => {
|
96
|
+
const attrs = acShortcutToEmoji(dom.getAttribute('data-hipchat-emoticon'));
|
97
|
+
return {
|
98
|
+
...attrs,
|
99
|
+
localId: uuid.generate()
|
100
|
+
};
|
101
|
+
}
|
102
|
+
},
|
103
|
+
// Handle copy/paste from bitbucket's <img class="emoji" />
|
104
|
+
{
|
105
|
+
tag: 'img.emoji[data-emoji-short-name]',
|
106
|
+
getAttrs: domNode => {
|
107
|
+
const dom = domNode;
|
108
|
+
return {
|
109
|
+
shortName: dom.getAttribute('data-emoji-short-name') || emoji.attrs.shortName.default,
|
110
|
+
id: dom.getAttribute('data-emoji-id') || emoji.attrs.id.default,
|
111
|
+
text: dom.getAttribute('data-emoji-text') || emoji.attrs.text.default,
|
112
|
+
localId: uuid.generate()
|
113
|
+
};
|
114
|
+
}
|
115
|
+
}],
|
116
|
+
toDOM(node) {
|
117
|
+
var _node$attrs;
|
118
|
+
const {
|
119
|
+
shortName,
|
120
|
+
id,
|
121
|
+
text
|
122
|
+
} = node.attrs;
|
123
|
+
const attrs = {
|
124
|
+
'data-emoji-short-name': shortName,
|
125
|
+
'data-emoji-id': id,
|
126
|
+
'data-emoji-text': text,
|
127
|
+
contenteditable: 'false',
|
128
|
+
'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
|
129
|
+
};
|
130
|
+
return ['span', attrs, text];
|
131
|
+
}
|
61
132
|
});
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { expand as expandFactory } from '../../next-schema/generated/nodeTypes';
|
2
|
+
import { uuid } from '../../utils/uuid';
|
2
3
|
|
3
4
|
/**
|
4
5
|
* @name expand_node
|
@@ -52,6 +53,64 @@ const nodeSpecOptions = {
|
|
52
53
|
}
|
53
54
|
};
|
54
55
|
export const expandWithNestedExpand = expandFactory(nodeSpecOptions);
|
56
|
+
export const expandWithNestedExpandLocalId = expandFactory({
|
57
|
+
parseDOM: [{
|
58
|
+
context: 'table//',
|
59
|
+
tag: 'div[data-node-type="expand"]',
|
60
|
+
getAttrs: dom => {
|
61
|
+
const attrs = getExpandAttrs(dom);
|
62
|
+
return {
|
63
|
+
...attrs,
|
64
|
+
localId: uuid.generate()
|
65
|
+
};
|
66
|
+
}
|
67
|
+
}, {
|
68
|
+
context: 'expand//',
|
69
|
+
tag: '[data-node-type="expand"]',
|
70
|
+
getAttrs: dom => {
|
71
|
+
const attrs = getExpandAttrs(dom);
|
72
|
+
return {
|
73
|
+
...attrs,
|
74
|
+
localId: uuid.generate()
|
75
|
+
};
|
76
|
+
}
|
77
|
+
}, {
|
78
|
+
context: 'nestedExpand//',
|
79
|
+
tag: '[data-node-type="expand"]',
|
80
|
+
getAttrs: dom => {
|
81
|
+
const attrs = getExpandAttrs(dom);
|
82
|
+
return {
|
83
|
+
...attrs,
|
84
|
+
localId: uuid.generate()
|
85
|
+
};
|
86
|
+
}
|
87
|
+
}, {
|
88
|
+
tag: '[data-node-type="nestedExpand"] button',
|
89
|
+
ignore: true
|
90
|
+
}, {
|
91
|
+
tag: '[data-node-type="expand"] button',
|
92
|
+
ignore: true
|
93
|
+
}, {
|
94
|
+
tag: 'div[data-node-type="expand"]',
|
95
|
+
getAttrs: dom => {
|
96
|
+
const attrs = getExpandAttrs(dom);
|
97
|
+
return {
|
98
|
+
...attrs,
|
99
|
+
localId: uuid.generate()
|
100
|
+
};
|
101
|
+
}
|
102
|
+
}],
|
103
|
+
toDOM(node) {
|
104
|
+
var _node$attrs;
|
105
|
+
const attrs = {
|
106
|
+
'data-node-type': 'expand',
|
107
|
+
'data-title': node.attrs.title,
|
108
|
+
'data-expanded': node.attrs.__expanded,
|
109
|
+
'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
|
110
|
+
};
|
111
|
+
return ['div', attrs, 0];
|
112
|
+
}
|
113
|
+
});
|
55
114
|
export const toJSON = node => ({
|
56
115
|
attrs: Object.keys(node.attrs).filter(key => !key.startsWith('__')).reduce((obj, key) => {
|
57
116
|
return {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { uuid } from '../../utils/uuid';
|
1
2
|
import { hardBreak as hardBreakFactory } from '../../next-schema/generated/nodeTypes';
|
2
3
|
|
3
4
|
/**
|
@@ -11,4 +12,18 @@ export const hardBreak = hardBreakFactory({
|
|
11
12
|
toDOM() {
|
12
13
|
return ['br'];
|
13
14
|
}
|
15
|
+
});
|
16
|
+
export const hardBreakWithLocalId = hardBreakFactory({
|
17
|
+
parseDOM: [{
|
18
|
+
tag: 'br',
|
19
|
+
getAttrs: () => ({
|
20
|
+
localId: uuid.generate()
|
21
|
+
})
|
22
|
+
}],
|
23
|
+
toDOM(node) {
|
24
|
+
var _node$attrs;
|
25
|
+
return ['br', {
|
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
|
+
}
|
14
29
|
});
|
@@ -1,44 +1,44 @@
|
|
1
|
-
export { expandWithNestedExpand, toJSON as expandToJSON } from './expand';
|
1
|
+
export { expandWithNestedExpand, expandWithNestedExpandLocalId, toJSON as expandToJSON } from './expand';
|
2
2
|
export { confluenceJiraIssue } from './confluence-jira-issue';
|
3
3
|
export { confluenceUnsupportedBlock } from './confluence-unsupported-block';
|
4
4
|
export { confluenceUnsupportedInline } from './confluence-unsupported-inline';
|
5
5
|
export { doc } from './doc';
|
6
|
-
export { blockquote, extendedBlockquote } from './blockquote';
|
7
|
-
export { bulletList, bulletListSelector } from './bullet-list';
|
8
|
-
export { codeBlock, toJSON as codeBlockToJSON } from './code-block';
|
9
|
-
export { hardBreak } from './hard-break';
|
6
|
+
export { blockquote, extendedBlockquote, extendedBlockquoteWithLocalId } from './blockquote';
|
7
|
+
export { bulletList, bulletListSelector, bulletListWithLocalId } from './bullet-list';
|
8
|
+
export { codeBlock, codeBlockWithLocalId, toJSON as codeBlockToJSON } from './code-block';
|
9
|
+
export { hardBreak, hardBreakWithLocalId } from './hard-break';
|
10
10
|
export { heading } from './heading';
|
11
|
-
export { rule } from './rule';
|
12
|
-
export { orderedList, orderedListSelector, orderedListWithOrder } from './ordered-list';
|
11
|
+
export { rule, ruleWithLocalId } from './rule';
|
12
|
+
export { orderedList, orderedListSelector, orderedListWithLocalId, orderedListWithOrder, orderedListWithOrderAndLocalId } from './ordered-list';
|
13
13
|
export { paragraph } from './paragraph';
|
14
|
-
export { emoji } from './emoji';
|
14
|
+
export { emoji, emojiWithLocalId } from './emoji';
|
15
15
|
export { image } from './image';
|
16
16
|
export { mention, toJSON as mentionToJSON } from './mention';
|
17
17
|
export { listItem, listItemWithDecisionStage0 } from './list-item';
|
18
|
-
export { extendedPanel, PanelType } from './panel';
|
18
|
+
export { extendedPanel, extendedPanelWithLocalId, PanelType } from './panel';
|
19
19
|
export { text } from './text';
|
20
20
|
export { default as unknownBlock } from './unknown-block';
|
21
|
-
export { caption } from './caption';
|
21
|
+
export { caption, captionWithLocalId } from './caption';
|
22
22
|
export { media, copyPrivateAttributes as copyPrivateMediaAttributes, toJSON as mediaToJSON } from './media';
|
23
23
|
export { mediaGroup } from './media-group';
|
24
24
|
export { mediaInline } from './media-inline';
|
25
|
-
export { mediaSingle, mediaSingleSpec, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, toJSON as mediaSingleToJSON } from './media-single';
|
25
|
+
export { mediaSingle, mediaSingleSpec, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleFullWithLocalId, toJSON as mediaSingleToJSON } from './media-single';
|
26
26
|
export { table, tableWithNestedTable, tableRowWithNestedTable, tableCellWithNestedTable, tableHeaderWithNestedTable, tableStage0, tableWithCustomWidth, tableToJSON, tableCell, toJSONTableCell, tableHeader, toJSONTableHeader, tableRow, tableBackgroundColorPalette, tableBackgroundBorderColor, tableBackgroundColorNames, getCellAttrs, getCellDomAttrs, tablePrefixSelector, tableCellSelector, tableHeaderSelector, tableCellContentWrapperSelector, tableCellContentDomSelector } from './tableNodes';
|
27
27
|
export { decisionList, decisionListSelector } from './decision-list';
|
28
28
|
export { decisionItem } from './decision-item';
|
29
29
|
export { taskList, taskListSelector } from './task-list';
|
30
30
|
export { taskItem } from './task-item';
|
31
|
-
export { date } from './date';
|
32
|
-
export { placeholder } from './placeholder';
|
33
|
-
export { layoutSection, layoutSectionWithSingleColumn } from './layout-section';
|
34
|
-
export { layoutColumn } from './layout-column';
|
35
|
-
export { inlineCard } from './inline-card';
|
36
|
-
export { blockCard } from './block-card';
|
31
|
+
export { date, dateWithLocalId } from './date';
|
32
|
+
export { placeholder, placeholderWithLocalId } from './placeholder';
|
33
|
+
export { layoutSection, layoutSectionWithSingleColumn, layoutSectionWithSingleColumnLocalId } from './layout-section';
|
34
|
+
export { layoutColumn, layoutColumnWithLocalId } from './layout-column';
|
35
|
+
export { inlineCard, inlineCardWithLocalId } from './inline-card';
|
36
|
+
export { blockCard, blockCardWithLocalId } from './block-card';
|
37
37
|
export { unsupportedBlock } from './unsupported-block';
|
38
38
|
export { unsupportedInline } from './unsupported-inline';
|
39
39
|
export { status } from './status';
|
40
|
-
export { nestedExpand } from './nested-expand';
|
41
|
-
export { embedCard } from './embed-card';
|
40
|
+
export { nestedExpand, nestedExpandWithLocalId } from './nested-expand';
|
41
|
+
export { embedCard, embedCardWithLocalId } from './embed-card';
|
42
42
|
// Extensions
|
43
43
|
export { extension } from './extension';
|
44
44
|
export { inlineExtension } from './inline-extension';
|
@@ -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
|
-
|
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
|
+
});
|