@atlaskit/adf-schema 25.1.0 → 25.2.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 +14 -0
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/json-schema/index.js +0 -3
- package/dist/cjs/schema/bitbucket-schema.js +0 -2
- package/dist/cjs/schema/confluence-schema.js +1 -4
- package/dist/cjs/schema/create-schema.js +12 -38
- package/dist/cjs/schema/default-schema.js +3 -16
- package/dist/cjs/schema/groups.js +13 -6
- package/dist/cjs/schema/index.js +0 -5
- package/dist/cjs/schema/inline-nodes.js +0 -5
- package/dist/cjs/schema/jira-schema.js +0 -36
- package/dist/cjs/schema/marks/alignment.js +0 -2
- package/dist/cjs/schema/marks/annotation.js +2 -14
- package/dist/cjs/schema/marks/code.js +0 -5
- package/dist/cjs/schema/marks/confluence-inline-comment.js +1 -1
- package/dist/cjs/schema/marks/data-consumer.js +2 -7
- package/dist/cjs/schema/marks/em.js +0 -2
- package/dist/cjs/schema/marks/fragment.js +0 -13
- package/dist/cjs/schema/marks/indentation.js +0 -2
- package/dist/cjs/schema/marks/index.js +0 -18
- package/dist/cjs/schema/marks/link.js +0 -17
- package/dist/cjs/schema/marks/strike.js +0 -2
- package/dist/cjs/schema/marks/strong.js +2 -3
- package/dist/cjs/schema/marks/subsup.js +0 -5
- package/dist/cjs/schema/marks/text-color.js +46 -37
- package/dist/cjs/schema/marks/type-ahead-query.js +0 -3
- package/dist/cjs/schema/marks/underline.js +0 -2
- package/dist/cjs/schema/nodes/block-card.js +1 -2
- package/dist/cjs/schema/nodes/blockquote.js +1 -1
- package/dist/cjs/schema/nodes/bodied-extension.js +0 -3
- package/dist/cjs/schema/nodes/caption.js +1 -1
- package/dist/cjs/schema/nodes/code-block.js +11 -29
- package/dist/cjs/schema/nodes/date.js +1 -1
- package/dist/cjs/schema/nodes/decision-item.js +2 -4
- package/dist/cjs/schema/nodes/decision-list.js +0 -2
- package/dist/cjs/schema/nodes/doc.js +1 -1
- package/dist/cjs/schema/nodes/embed-card.js +6 -6
- package/dist/cjs/schema/nodes/emoji.js +11 -9
- package/dist/cjs/schema/nodes/expand.js +1 -4
- package/dist/cjs/schema/nodes/extension.js +0 -3
- package/dist/cjs/schema/nodes/hard-break.js +1 -1
- package/dist/cjs/schema/nodes/heading.js +2 -2
- package/dist/cjs/schema/nodes/index.js +0 -45
- package/dist/cjs/schema/nodes/inline-card.js +4 -4
- package/dist/cjs/schema/nodes/inline-extension.js +0 -3
- package/dist/cjs/schema/nodes/layout-column.js +4 -5
- package/dist/cjs/schema/nodes/layout-section.js +1 -1
- package/dist/cjs/schema/nodes/media-group.js +1 -1
- package/dist/cjs/schema/nodes/media-inline.js +0 -2
- package/dist/cjs/schema/nodes/media-single.js +3 -14
- package/dist/cjs/schema/nodes/media.js +10 -28
- package/dist/cjs/schema/nodes/mention.js +4 -14
- package/dist/cjs/schema/nodes/nested-expand.js +1 -1
- package/dist/cjs/schema/nodes/ordered-list.js +3 -17
- package/dist/cjs/schema/nodes/panel.js +1 -13
- package/dist/cjs/schema/nodes/paragraph.js +1 -6
- package/dist/cjs/schema/nodes/placeholder.js +1 -1
- package/dist/cjs/schema/nodes/rule.js +1 -1
- package/dist/cjs/schema/nodes/status.js +4 -6
- package/dist/cjs/schema/nodes/tableNodes.js +12 -39
- package/dist/cjs/schema/nodes/task-item.js +2 -4
- package/dist/cjs/schema/nodes/task-list.js +0 -2
- package/dist/cjs/schema/nodes/text.js +1 -1
- package/dist/cjs/steps/analytics.js +4 -38
- package/dist/cjs/steps/set-attrs.js +0 -26
- package/dist/cjs/steps/table/add-column.js +33 -105
- package/dist/cjs/steps/table/constants.js +0 -1
- package/dist/cjs/steps/table/sort-column.js +0 -19
- package/dist/cjs/steps/table/utils/cell-step.js +18 -49
- package/dist/cjs/steps/table/utils/cells-at-column.js +2 -21
- package/dist/cjs/steps/table/utils/find-column.js +13 -17
- package/dist/cjs/steps/table/utils/get-table-rect-from-doc.js +6 -8
- package/dist/cjs/steps/table/utils/side-effects/rows.js +23 -78
- package/dist/cjs/steps/table/utils/side-effects/side-effects.js +0 -23
- package/dist/cjs/steps/table/utils/side-effects/table.js +2 -18
- package/dist/cjs/steps/table/utils/table-map.js +0 -6
- package/dist/cjs/steps/type-ahead.js +5 -25
- package/dist/cjs/steps.js +0 -6
- package/dist/cjs/utils/colors.js +13 -36
- package/dist/cjs/utils/confluence/emoji.js +6 -13
- package/dist/cjs/utils/extensions.js +0 -8
- package/dist/cjs/utils/index.js +0 -4
- package/dist/cjs/utils/parseDOM.js +0 -2
- package/dist/cjs/utils/url.js +3 -20
- package/dist/cjs/utils/uuid.js +0 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/index.js +1 -2
- package/dist/es2019/schema/bitbucket-schema.js +1 -1
- package/dist/es2019/schema/confluence-schema.js +1 -2
- package/dist/es2019/schema/create-schema.js +12 -25
- package/dist/es2019/schema/default-schema.js +3 -11
- package/dist/es2019/schema/groups.js +13 -6
- package/dist/es2019/schema/index.js +1 -2
- package/dist/es2019/schema/jira-schema.js +0 -24
- package/dist/es2019/schema/marks/alignment.js +1 -3
- package/dist/es2019/schema/marks/annotation.js +3 -9
- package/dist/es2019/schema/marks/breakout.js +0 -4
- package/dist/es2019/schema/marks/code.js +1 -5
- package/dist/es2019/schema/marks/confluence-inline-comment.js +1 -2
- package/dist/es2019/schema/marks/data-consumer.js +3 -5
- package/dist/es2019/schema/marks/em.js +1 -2
- package/dist/es2019/schema/marks/fragment.js +0 -8
- package/dist/es2019/schema/marks/indentation.js +0 -4
- package/dist/es2019/schema/marks/link.js +2 -11
- package/dist/es2019/schema/marks/strike.js +1 -2
- package/dist/es2019/schema/marks/strong.js +3 -7
- package/dist/es2019/schema/marks/subsup.js +0 -6
- package/dist/es2019/schema/marks/text-color.js +44 -29
- package/dist/es2019/schema/marks/type-ahead-query.js +0 -2
- package/dist/es2019/schema/marks/underline.js +1 -2
- package/dist/es2019/schema/marks/unsupported-mark.js +0 -1
- package/dist/es2019/schema/marks/unsupported-node-attributes.js +0 -1
- package/dist/es2019/schema/nodes/block-card.js +1 -3
- package/dist/es2019/schema/nodes/blockquote.js +1 -2
- package/dist/es2019/schema/nodes/bodied-extension.js +0 -4
- package/dist/es2019/schema/nodes/bullet-list.js +0 -2
- package/dist/es2019/schema/nodes/caption.js +1 -2
- package/dist/es2019/schema/nodes/code-block.js +11 -28
- package/dist/es2019/schema/nodes/confluence-jira-issue.js +0 -2
- package/dist/es2019/schema/nodes/confluence-unsupported-block.js +0 -4
- package/dist/es2019/schema/nodes/confluence-unsupported-inline.js +0 -4
- package/dist/es2019/schema/nodes/date.js +1 -2
- package/dist/es2019/schema/nodes/decision-item.js +0 -2
- package/dist/es2019/schema/nodes/decision-list.js +1 -2
- package/dist/es2019/schema/nodes/doc.js +1 -0
- package/dist/es2019/schema/nodes/embed-card.js +1 -2
- package/dist/es2019/schema/nodes/emoji.js +9 -6
- package/dist/es2019/schema/nodes/expand.js +1 -3
- package/dist/es2019/schema/nodes/extension.js +0 -4
- package/dist/es2019/schema/nodes/hard-break.js +1 -2
- package/dist/es2019/schema/nodes/heading.js +2 -3
- package/dist/es2019/schema/nodes/image.js +0 -4
- package/dist/es2019/schema/nodes/inline-card.js +4 -5
- package/dist/es2019/schema/nodes/inline-extension.js +0 -4
- package/dist/es2019/schema/nodes/layout-column.js +4 -6
- package/dist/es2019/schema/nodes/layout-section.js +1 -4
- package/dist/es2019/schema/nodes/list-item.js +0 -2
- package/dist/es2019/schema/nodes/media-group.js +1 -2
- package/dist/es2019/schema/nodes/media-single.js +3 -6
- package/dist/es2019/schema/nodes/media.js +10 -20
- package/dist/es2019/schema/nodes/mention.js +0 -11
- package/dist/es2019/schema/nodes/nested-expand.js +1 -2
- package/dist/es2019/schema/nodes/ordered-list.js +4 -14
- package/dist/es2019/schema/nodes/panel.js +3 -10
- package/dist/es2019/schema/nodes/paragraph.js +1 -7
- package/dist/es2019/schema/nodes/placeholder.js +1 -2
- package/dist/es2019/schema/nodes/rule.js +1 -2
- package/dist/es2019/schema/nodes/status.js +1 -2
- package/dist/es2019/schema/nodes/tableNodes.js +10 -26
- package/dist/es2019/schema/nodes/task-item.js +0 -2
- package/dist/es2019/schema/nodes/task-list.js +0 -2
- package/dist/es2019/schema/nodes/text.js +1 -0
- package/dist/es2019/schema/nodes/unknown-block.js +0 -2
- package/dist/es2019/schema/nodes/unsupported-block.js +0 -2
- package/dist/es2019/schema/nodes/unsupported-inline.js +0 -2
- package/dist/es2019/steps/analytics.js +13 -30
- package/dist/es2019/steps/set-attrs.js +3 -12
- package/dist/es2019/steps/table/add-column.js +33 -76
- package/dist/es2019/steps/table/constants.js +0 -1
- package/dist/es2019/steps/table/sort-column.js +1 -8
- package/dist/es2019/steps/table/utils/cell-step.js +15 -32
- package/dist/es2019/steps/table/utils/cells-at-column.js +6 -11
- package/dist/es2019/steps/table/utils/find-column.js +12 -15
- package/dist/es2019/steps/table/utils/get-table-rect-from-doc.js +7 -6
- package/dist/es2019/steps/table/utils/side-effects/rows.js +19 -59
- package/dist/es2019/steps/table/utils/side-effects/side-effects.js +0 -21
- package/dist/es2019/steps/table/utils/side-effects/table.js +0 -17
- package/dist/es2019/steps/type-ahead.js +3 -15
- package/dist/es2019/utils/colors.js +8 -18
- package/dist/es2019/utils/confluence/emoji.js +5 -8
- package/dist/es2019/utils/extensions.js +0 -4
- package/dist/es2019/utils/url.js +2 -12
- package/dist/es2019/utils/uuid.js +0 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/schema/bitbucket-schema.js +1 -1
- package/dist/esm/schema/confluence-schema.js +1 -2
- package/dist/esm/schema/create-schema.js +12 -31
- package/dist/esm/schema/default-schema.js +3 -11
- package/dist/esm/schema/groups.js +13 -6
- package/dist/esm/schema/index.js +1 -2
- package/dist/esm/schema/jira-schema.js +0 -24
- package/dist/esm/schema/marks/alignment.js +1 -1
- package/dist/esm/schema/marks/annotation.js +3 -11
- package/dist/esm/schema/marks/code.js +1 -3
- package/dist/esm/schema/marks/confluence-inline-comment.js +1 -0
- package/dist/esm/schema/marks/data-consumer.js +3 -3
- package/dist/esm/schema/marks/em.js +1 -0
- package/dist/esm/schema/marks/fragment.js +0 -9
- package/dist/esm/schema/marks/link.js +0 -12
- package/dist/esm/schema/marks/strike.js +1 -0
- package/dist/esm/schema/marks/strong.js +3 -1
- package/dist/esm/schema/marks/subsup.js +0 -4
- package/dist/esm/schema/marks/text-color.js +46 -30
- package/dist/esm/schema/marks/underline.js +1 -0
- package/dist/esm/schema/nodes/block-card.js +1 -1
- package/dist/esm/schema/nodes/blockquote.js +1 -0
- package/dist/esm/schema/nodes/bodied-extension.js +0 -2
- package/dist/esm/schema/nodes/caption.js +1 -0
- package/dist/esm/schema/nodes/code-block.js +11 -26
- package/dist/esm/schema/nodes/date.js +1 -0
- package/dist/esm/schema/nodes/decision-item.js +2 -2
- package/dist/esm/schema/nodes/decision-list.js +1 -0
- package/dist/esm/schema/nodes/doc.js +1 -0
- package/dist/esm/schema/nodes/embed-card.js +6 -5
- package/dist/esm/schema/nodes/emoji.js +12 -7
- package/dist/esm/schema/nodes/expand.js +1 -1
- package/dist/esm/schema/nodes/extension.js +0 -2
- package/dist/esm/schema/nodes/hard-break.js +1 -0
- package/dist/esm/schema/nodes/heading.js +2 -1
- package/dist/esm/schema/nodes/inline-card.js +4 -3
- package/dist/esm/schema/nodes/inline-extension.js +0 -2
- package/dist/esm/schema/nodes/layout-column.js +4 -4
- package/dist/esm/schema/nodes/layout-section.js +1 -0
- package/dist/esm/schema/nodes/media-group.js +1 -0
- package/dist/esm/schema/nodes/media-single.js +3 -8
- package/dist/esm/schema/nodes/media.js +10 -18
- package/dist/esm/schema/nodes/mention.js +4 -13
- package/dist/esm/schema/nodes/nested-expand.js +1 -0
- package/dist/esm/schema/nodes/ordered-list.js +3 -13
- package/dist/esm/schema/nodes/panel.js +1 -10
- package/dist/esm/schema/nodes/paragraph.js +1 -5
- package/dist/esm/schema/nodes/placeholder.js +1 -0
- package/dist/esm/schema/nodes/rule.js +1 -0
- package/dist/esm/schema/nodes/status.js +5 -4
- package/dist/esm/schema/nodes/tableNodes.js +12 -25
- package/dist/esm/schema/nodes/task-item.js +2 -2
- package/dist/esm/schema/nodes/text.js +1 -0
- package/dist/esm/steps/analytics.js +5 -31
- package/dist/esm/steps/set-attrs.js +1 -17
- package/dist/esm/steps/table/add-column.js +33 -91
- package/dist/esm/steps/table/constants.js +0 -1
- package/dist/esm/steps/table/sort-column.js +1 -10
- package/dist/esm/steps/table/utils/cell-step.js +18 -42
- package/dist/esm/steps/table/utils/cells-at-column.js +2 -18
- package/dist/esm/steps/table/utils/find-column.js +13 -16
- package/dist/esm/steps/table/utils/get-table-rect-from-doc.js +7 -6
- package/dist/esm/steps/table/utils/side-effects/rows.js +23 -76
- package/dist/esm/steps/table/utils/side-effects/side-effects.js +0 -18
- package/dist/esm/steps/table/utils/side-effects/table.js +2 -13
- package/dist/esm/steps/type-ahead.js +6 -18
- package/dist/esm/utils/colors.js +12 -23
- package/dist/esm/utils/confluence/emoji.js +6 -10
- package/dist/esm/utils/extensions.js +0 -4
- package/dist/esm/utils/url.js +2 -12
- package/dist/esm/version.json +1 -1
- package/dist/types/schema/default-schema.d.ts +1 -1
- package/dist/types/utils/colors.d.ts +1 -1
- package/package.json +2 -2
@@ -1,6 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* @name layoutColumn_node
|
3
3
|
*/
|
4
|
+
|
4
5
|
export const layoutColumn = {
|
5
6
|
content: '(block|unsupportedBlock)+',
|
6
7
|
isolating: true,
|
@@ -24,7 +25,6 @@ export const layoutColumn = {
|
|
24
25
|
};
|
25
26
|
}
|
26
27
|
}],
|
27
|
-
|
28
28
|
toDOM(node) {
|
29
29
|
const attrs = {
|
30
30
|
'data-layout-column': 'true'
|
@@ -32,18 +32,16 @@ export const layoutColumn = {
|
|
32
32
|
const {
|
33
33
|
width
|
34
34
|
} = node.attrs;
|
35
|
-
|
36
35
|
if (width) {
|
37
36
|
attrs['style'] = `flex-basis: ${width}%`;
|
38
37
|
attrs['data-column-width'] = width;
|
39
|
-
}
|
40
|
-
// ProseMirror identify its boundaries better.
|
41
|
-
|
38
|
+
}
|
42
39
|
|
40
|
+
// We need to apply a attribute to the inner most child to help
|
41
|
+
// ProseMirror identify its boundaries better.
|
43
42
|
const contentAttrs = {
|
44
43
|
'data-layout-content': 'true'
|
45
44
|
};
|
46
45
|
return ['div', attrs, ['div', contentAttrs, 0]];
|
47
46
|
}
|
48
|
-
|
49
47
|
};
|
@@ -14,6 +14,7 @@
|
|
14
14
|
* @stage 0
|
15
15
|
* @name layoutSection_with_single_column_node
|
16
16
|
*/
|
17
|
+
|
17
18
|
export const layoutSection = {
|
18
19
|
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock* | unsupportedBlock+',
|
19
20
|
marks: 'unsupportedMark unsupportedNodeAttribute',
|
@@ -25,14 +26,12 @@ export const layoutSection = {
|
|
25
26
|
}, {
|
26
27
|
tag: 'div[data-layout-section]'
|
27
28
|
}],
|
28
|
-
|
29
29
|
toDOM() {
|
30
30
|
const attrs = {
|
31
31
|
'data-layout-section': 'true'
|
32
32
|
};
|
33
33
|
return ['div', attrs, 0];
|
34
34
|
}
|
35
|
-
|
36
35
|
};
|
37
36
|
export const layoutSectionWithSingleColumn = {
|
38
37
|
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock* | unsupportedBlock+',
|
@@ -45,12 +44,10 @@ export const layoutSectionWithSingleColumn = {
|
|
45
44
|
}, {
|
46
45
|
tag: 'div[data-layout-section]'
|
47
46
|
}],
|
48
|
-
|
49
47
|
toDOM() {
|
50
48
|
const attrs = {
|
51
49
|
'data-layout-section': 'true'
|
52
50
|
};
|
53
51
|
return ['div', attrs, 0];
|
54
52
|
}
|
55
|
-
|
56
53
|
};
|
@@ -1,6 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* @name mediaGroup_node
|
3
3
|
*/
|
4
|
+
|
4
5
|
export const mediaGroup = {
|
5
6
|
inline: false,
|
6
7
|
group: 'block',
|
@@ -13,11 +14,9 @@ export const mediaGroup = {
|
|
13
14
|
}, {
|
14
15
|
tag: 'div[class="MediaGroup"]'
|
15
16
|
}],
|
16
|
-
|
17
17
|
toDOM() {
|
18
18
|
return ['div', {
|
19
19
|
'data-node-type': 'mediaGroup'
|
20
20
|
}, 0];
|
21
21
|
}
|
22
|
-
|
23
22
|
};
|
@@ -18,6 +18,7 @@
|
|
18
18
|
/**
|
19
19
|
* @name mediaSingle_caption_node
|
20
20
|
*/
|
21
|
+
|
21
22
|
export const defaultAttrs = {
|
22
23
|
width: {
|
23
24
|
default: null
|
@@ -42,7 +43,6 @@ export const mediaSingle = {
|
|
42
43
|
width: Number(dom.getAttribute('data-width')) || null
|
43
44
|
})
|
44
45
|
}],
|
45
|
-
|
46
46
|
toDOM(node) {
|
47
47
|
const {
|
48
48
|
layout,
|
@@ -53,16 +53,14 @@ export const mediaSingle = {
|
|
53
53
|
'data-layout': layout,
|
54
54
|
'data-width': ''
|
55
55
|
};
|
56
|
-
|
57
56
|
if (width) {
|
58
57
|
attrs['data-width'] = isFinite(width) && Math.floor(width) === width ? width : width.toFixed(2);
|
59
58
|
}
|
60
|
-
|
61
59
|
return ['div', attrs, 0];
|
62
60
|
}
|
63
|
-
|
64
61
|
};
|
65
|
-
export const mediaSingleWithCaption = {
|
62
|
+
export const mediaSingleWithCaption = {
|
63
|
+
...mediaSingle,
|
66
64
|
atom: false,
|
67
65
|
content: 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*'
|
68
66
|
};
|
@@ -71,7 +69,6 @@ export const toJSON = node => ({
|
|
71
69
|
if (node.attrs[key] !== null) {
|
72
70
|
obj[key] = node.attrs[key];
|
73
71
|
}
|
74
|
-
|
75
72
|
return obj;
|
76
73
|
}, {})
|
77
74
|
});
|
@@ -53,45 +53,40 @@ export const createMediaSpec = (attributes, inline = false) => {
|
|
53
53
|
tag: `${domNodeType}[data-node-type="${nodeName}"]`,
|
54
54
|
getAttrs: dom => {
|
55
55
|
const attrs = {};
|
56
|
-
|
57
56
|
if (attributes) {
|
58
57
|
Object.keys(attributes).forEach(k => {
|
59
58
|
const key = camelCaseToKebabCase(k).replace(/^__/, '');
|
60
59
|
const value = dom.getAttribute(`data-${key}`) || '';
|
61
|
-
|
62
60
|
if (value) {
|
63
61
|
attrs[k] = value;
|
64
62
|
}
|
65
63
|
});
|
66
|
-
}
|
67
|
-
|
64
|
+
}
|
68
65
|
|
66
|
+
// Need to do validation & type conversion manually
|
69
67
|
if (attrs.__fileSize) {
|
70
68
|
attrs.__fileSize = +attrs.__fileSize;
|
71
69
|
}
|
72
|
-
|
73
70
|
const width = Number(attrs.width);
|
74
|
-
|
75
71
|
if (typeof width !== 'undefined' && !isNaN(width)) {
|
76
72
|
attrs.width = width;
|
77
73
|
}
|
78
|
-
|
79
74
|
const height = Number(attrs.height);
|
80
|
-
|
81
75
|
if (typeof height !== 'undefined' && !isNaN(height)) {
|
82
76
|
attrs.height = height;
|
83
77
|
}
|
84
|
-
|
85
78
|
return attrs;
|
86
79
|
}
|
87
|
-
},
|
80
|
+
},
|
81
|
+
// Don't match data URI
|
88
82
|
{
|
89
83
|
tag: 'img[src^="data:image"]',
|
90
84
|
ignore: true
|
91
|
-
}];
|
85
|
+
}];
|
86
|
+
|
87
|
+
// media-inline.ts uses this same function to generate the nodespec
|
92
88
|
// this ensures that we don't make a media inline out of a copied image
|
93
89
|
// https://product-fabric.atlassian.net/browse/EDM-2996
|
94
|
-
|
95
90
|
if (!inline) {
|
96
91
|
parseDOM.push({
|
97
92
|
tag: 'img:not(.smart-link-icon)',
|
@@ -104,14 +99,12 @@ export const createMediaSpec = (attributes, inline = false) => {
|
|
104
99
|
}
|
105
100
|
});
|
106
101
|
}
|
107
|
-
|
108
102
|
return {
|
109
103
|
selectable: true,
|
110
104
|
inline,
|
111
105
|
group: inline ? 'inline' : undefined,
|
112
106
|
attrs: attributes,
|
113
107
|
parseDOM,
|
114
|
-
|
115
108
|
toDOM(node) {
|
116
109
|
const attrs = {
|
117
110
|
'data-id': node.attrs.id,
|
@@ -134,7 +127,6 @@ export const createMediaSpec = (attributes, inline = false) => {
|
|
134
127
|
copyPrivateAttributes(node.attrs, attrs, key => `data-${camelCaseToKebabCase(key.slice(2))}`);
|
135
128
|
return [`${domNodeType}`, attrs];
|
136
129
|
}
|
137
|
-
|
138
130
|
};
|
139
131
|
};
|
140
132
|
export const media = createMediaSpec(defaultAttrs);
|
@@ -148,29 +140,27 @@ export const copyPrivateAttributes = (from, to, map) => {
|
|
148
140
|
});
|
149
141
|
}
|
150
142
|
};
|
143
|
+
|
151
144
|
/**
|
152
145
|
* There's no concept of optional property in ProseMirror. It sets value as `null`
|
153
146
|
* when there's no use of any property. We are filtering out all private & optional attrs here.
|
154
147
|
*/
|
155
|
-
|
156
148
|
const optionalAttributes = ['occurrenceKey', 'width', 'height', 'url', 'alt'];
|
157
149
|
const externalOnlyAttributes = ['type', 'url', 'width', 'height', 'alt'];
|
158
150
|
export const toJSON = node => ({
|
159
|
-
attrs: Object.keys(node.attrs)
|
151
|
+
attrs: Object.keys(node.attrs)
|
152
|
+
// Strip private attributes e.g. __fileName, __fileSize, __fileMimeType, etc.
|
160
153
|
.filter(key => !(key[0] === '_' && key[1] === '_')).reduce((obj, key) => {
|
161
154
|
if (node.attrs.type === 'external' && externalOnlyAttributes.indexOf(key) === -1) {
|
162
155
|
return obj;
|
163
156
|
}
|
164
|
-
|
165
157
|
if (optionalAttributes.indexOf(key) > -1 && (node.attrs[key] === null || node.attrs[key] === '')) {
|
166
158
|
return obj;
|
167
159
|
}
|
168
|
-
|
169
160
|
if (['width', 'height'].indexOf(key) !== -1) {
|
170
161
|
obj[key] = Number(node.attrs[key]);
|
171
162
|
return obj;
|
172
163
|
}
|
173
|
-
|
174
164
|
obj[key] = node.attrs[key];
|
175
165
|
return obj;
|
176
166
|
}, {})
|
@@ -1,11 +1,9 @@
|
|
1
1
|
export let USER_TYPES;
|
2
|
-
|
3
2
|
(function (USER_TYPES) {
|
4
3
|
USER_TYPES["DEFAULT"] = "DEFAULT";
|
5
4
|
USER_TYPES["SPECIAL"] = "SPECIAL";
|
6
5
|
USER_TYPES["APP"] = "APP";
|
7
6
|
})(USER_TYPES || (USER_TYPES = {}));
|
8
|
-
|
9
7
|
export const mention = {
|
10
8
|
inline: true,
|
11
9
|
group: 'inline',
|
@@ -34,15 +32,12 @@ export const mention = {
|
|
34
32
|
accessLevel: dom.getAttribute('data-access-level') || mention.attrs.accessLevel.default
|
35
33
|
};
|
36
34
|
const userType = dom.getAttribute('data-user-type');
|
37
|
-
|
38
35
|
if (USER_TYPES[userType]) {
|
39
36
|
attrs.userType = userType;
|
40
37
|
}
|
41
|
-
|
42
38
|
return attrs;
|
43
39
|
}
|
44
40
|
}],
|
45
|
-
|
46
41
|
toDOM(node) {
|
47
42
|
const {
|
48
43
|
id,
|
@@ -55,26 +50,20 @@ export const mention = {
|
|
55
50
|
'data-access-level': accessLevel,
|
56
51
|
contenteditable: 'false'
|
57
52
|
};
|
58
|
-
|
59
53
|
if (userType) {
|
60
54
|
attrs['data-user-type'] = userType;
|
61
55
|
}
|
62
|
-
|
63
56
|
return ['span', attrs, text];
|
64
57
|
}
|
65
|
-
|
66
58
|
};
|
67
|
-
|
68
59
|
const isOptional = key => {
|
69
60
|
return ['userType'].indexOf(key) > -1;
|
70
61
|
};
|
71
|
-
|
72
62
|
export const toJSON = node => ({
|
73
63
|
attrs: Object.keys(node.attrs).reduce((obj, key) => {
|
74
64
|
if (isOptional(key) && !node.attrs[key]) {
|
75
65
|
return obj;
|
76
66
|
}
|
77
|
-
|
78
67
|
obj[key] = node.attrs[key];
|
79
68
|
return obj;
|
80
69
|
}, {})
|
@@ -11,6 +11,7 @@
|
|
11
11
|
/**
|
12
12
|
* @name nestedExpand_with_no_marks_node
|
13
13
|
*/
|
14
|
+
|
14
15
|
export const nestedExpand = {
|
15
16
|
inline: false,
|
16
17
|
marks: 'unsupportedMark unsupportedNodeAttribute',
|
@@ -45,7 +46,6 @@ export const nestedExpand = {
|
|
45
46
|
};
|
46
47
|
}
|
47
48
|
}],
|
48
|
-
|
49
49
|
toDOM(node) {
|
50
50
|
const attrs = {
|
51
51
|
'data-node-type': 'nestedExpand',
|
@@ -54,5 +54,4 @@ export const nestedExpand = {
|
|
54
54
|
};
|
55
55
|
return ['div', attrs, 0];
|
56
56
|
}
|
57
|
-
|
58
57
|
};
|
@@ -12,56 +12,47 @@ export const orderedList = {
|
|
12
12
|
parseDOM: [{
|
13
13
|
tag: 'ol'
|
14
14
|
}],
|
15
|
-
|
16
15
|
toDOM() {
|
17
16
|
const attrs = {
|
18
17
|
class: orderedListSelector.substr(1)
|
19
18
|
};
|
20
19
|
return ['ol', attrs, 0];
|
21
20
|
}
|
21
|
+
};
|
22
22
|
|
23
|
-
|
23
|
+
// resolve "start" to a safe, 0+ integer, otherwise return undefined
|
24
24
|
// Note: Any changes to this function should also be made to "resolveOrder"
|
25
25
|
// in packages/editor/editor-common/src/utils/list.ts
|
26
|
-
|
27
26
|
const resolveStart = start => {
|
28
27
|
const num = Number(start);
|
29
|
-
|
30
28
|
if (Number.isNaN(num)) {
|
31
29
|
return;
|
32
30
|
}
|
33
|
-
|
34
31
|
if (num < 0) {
|
35
32
|
return;
|
36
33
|
}
|
37
|
-
|
38
34
|
return Math.floor(Math.max(num, 0));
|
39
35
|
};
|
40
|
-
|
41
|
-
|
36
|
+
export const orderedListWithOrder = {
|
37
|
+
...orderedList,
|
42
38
|
parseDOM: [{
|
43
39
|
tag: 'ol',
|
44
40
|
getAttrs: domNode => {
|
45
41
|
const dom = domNode;
|
46
42
|
let startDOMAttr = dom.getAttribute('start');
|
47
|
-
|
48
43
|
if (startDOMAttr) {
|
49
44
|
const start = resolveStart(startDOMAttr);
|
50
|
-
|
51
45
|
if (typeof start === 'number') {
|
52
46
|
return {
|
53
47
|
order: start
|
54
48
|
};
|
55
49
|
}
|
56
50
|
}
|
57
|
-
|
58
51
|
return null;
|
59
52
|
}
|
60
53
|
}],
|
61
|
-
|
62
54
|
toDOM(node) {
|
63
55
|
var _node$attrs;
|
64
|
-
|
65
56
|
const start = resolveStart(node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.order);
|
66
57
|
const attrs = {
|
67
58
|
start: typeof start === 'number' ? String(start) : undefined,
|
@@ -69,5 +60,4 @@ export const orderedListWithOrder = { ...orderedList,
|
|
69
60
|
};
|
70
61
|
return ['ol', attrs, 0];
|
71
62
|
}
|
72
|
-
|
73
63
|
};
|
@@ -1,5 +1,4 @@
|
|
1
1
|
export let PanelType;
|
2
|
-
|
3
2
|
(function (PanelType) {
|
4
3
|
PanelType["INFO"] = "info";
|
5
4
|
PanelType["NOTE"] = "note";
|
@@ -9,7 +8,6 @@ export let PanelType;
|
|
9
8
|
PanelType["SUCCESS"] = "success";
|
10
9
|
PanelType["CUSTOM"] = "custom";
|
11
10
|
})(PanelType || (PanelType = {}));
|
12
|
-
|
13
11
|
const getDefaultAttrs = () => {
|
14
12
|
let attrs = {
|
15
13
|
panelType: {
|
@@ -30,7 +28,6 @@ const getDefaultAttrs = () => {
|
|
30
28
|
};
|
31
29
|
return attrs;
|
32
30
|
};
|
33
|
-
|
34
31
|
const getDomAttrs = nodeAttrs => {
|
35
32
|
let attrs = {
|
36
33
|
'data-panel-type': nodeAttrs.panelType,
|
@@ -41,14 +38,13 @@ const getDomAttrs = nodeAttrs => {
|
|
41
38
|
};
|
42
39
|
return attrs;
|
43
40
|
};
|
44
|
-
|
45
41
|
const getParseDOMAttrs = (allowCustomPanel, dom) => {
|
46
42
|
let parseDOMAttrs = {
|
47
43
|
panelType: dom.getAttribute('data-panel-type')
|
48
44
|
};
|
49
|
-
|
50
45
|
if (allowCustomPanel) {
|
51
|
-
parseDOMAttrs = {
|
46
|
+
parseDOMAttrs = {
|
47
|
+
...parseDOMAttrs,
|
52
48
|
panelIcon: dom.getAttribute('data-panel-icon'),
|
53
49
|
panelIconId: dom.getAttribute('data-panel-icon-id'),
|
54
50
|
panelIconText: dom.getAttribute('data-panel-icon-text'),
|
@@ -57,21 +53,19 @@ const getParseDOMAttrs = (allowCustomPanel, dom) => {
|
|
57
53
|
} else {
|
58
54
|
parseDOMAttrs.panelType = parseDOMAttrs.panelType === PanelType.CUSTOM ? PanelType.INFO : parseDOMAttrs.panelType;
|
59
55
|
}
|
60
|
-
|
61
56
|
return parseDOMAttrs;
|
62
57
|
};
|
63
|
-
|
64
58
|
export const panel = allowCustomPanel => {
|
65
59
|
const panelNodeSpec = {
|
66
60
|
group: 'block',
|
67
61
|
content: '(paragraph | heading | bulletList | orderedList | blockCard | unsupportedBlock)+',
|
68
62
|
marks: 'unsupportedMark unsupportedNodeAttribute',
|
69
63
|
attrs: getDefaultAttrs(),
|
64
|
+
selectable: true,
|
70
65
|
parseDOM: [{
|
71
66
|
tag: 'div[data-panel-type]',
|
72
67
|
getAttrs: dom => getParseDOMAttrs(allowCustomPanel, dom)
|
73
68
|
}],
|
74
|
-
|
75
69
|
toDOM(node) {
|
76
70
|
const attrs = getDomAttrs(node.attrs);
|
77
71
|
const contentAttrs = {
|
@@ -79,7 +73,6 @@ export const panel = allowCustomPanel => {
|
|
79
73
|
};
|
80
74
|
return ['div', attrs, ['div', contentAttrs, 0]];
|
81
75
|
}
|
82
|
-
|
83
76
|
};
|
84
77
|
return panelNodeSpec;
|
85
78
|
};
|
@@ -22,26 +22,22 @@
|
|
22
22
|
/**
|
23
23
|
* @name paragraph_with_indentation_node
|
24
24
|
*/
|
25
|
+
|
25
26
|
const isImageNode = node => {
|
26
27
|
return Boolean(node && node.nodeName.toLowerCase() === 'img');
|
27
28
|
};
|
28
|
-
|
29
29
|
const hasInlineImage = node => {
|
30
30
|
if (!node) {
|
31
31
|
return false;
|
32
32
|
}
|
33
|
-
|
34
33
|
return Array.from(node.childNodes).some(child => {
|
35
34
|
const isImage = isImageNode(child);
|
36
|
-
|
37
35
|
if (!isImage && child.childNodes) {
|
38
36
|
return Array.from(node.childNodes).some(node => hasInlineImage(node));
|
39
37
|
}
|
40
|
-
|
41
38
|
return isImage;
|
42
39
|
});
|
43
40
|
};
|
44
|
-
|
45
41
|
const pDOM = ['p', 0];
|
46
42
|
export const paragraph = {
|
47
43
|
selectable: false,
|
@@ -51,9 +47,7 @@ export const paragraph = {
|
|
51
47
|
parseDOM: [{
|
52
48
|
tag: 'p'
|
53
49
|
}],
|
54
|
-
|
55
50
|
toDOM() {
|
56
51
|
return pDOM;
|
57
52
|
}
|
58
|
-
|
59
53
|
};
|
@@ -1,6 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* @name placeholder_node
|
3
3
|
*/
|
4
|
+
|
4
5
|
export const placeholder = {
|
5
6
|
inline: true,
|
6
7
|
group: 'inline',
|
@@ -17,7 +18,6 @@ export const placeholder = {
|
|
17
18
|
text: dom.getAttribute('data-placeholder') || placeholder.attrs.text.default
|
18
19
|
})
|
19
20
|
}],
|
20
|
-
|
21
21
|
toDOM(node) {
|
22
22
|
const {
|
23
23
|
text
|
@@ -29,5 +29,4 @@ export const placeholder = {
|
|
29
29
|
};
|
30
30
|
return ['span', attrs, text];
|
31
31
|
}
|
32
|
-
|
33
32
|
};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { uuid } from '../../utils/uuid';
|
2
|
+
|
2
3
|
/**
|
3
4
|
* @name status_node
|
4
5
|
*/
|
@@ -33,7 +34,6 @@ export const status = {
|
|
33
34
|
};
|
34
35
|
}
|
35
36
|
}],
|
36
|
-
|
37
37
|
toDOM(node) {
|
38
38
|
const {
|
39
39
|
text,
|
@@ -50,5 +50,4 @@ export const status = {
|
|
50
50
|
};
|
51
51
|
return ['span', attrs, text];
|
52
52
|
}
|
53
|
-
|
54
53
|
};
|