@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
@@ -12,20 +12,19 @@ export const getCellAttrs = (dom, defaultValues = {}) => {
|
|
12
12
|
const colspan = Number(dom.getAttribute('colspan') || 1);
|
13
13
|
let {
|
14
14
|
backgroundColor
|
15
|
-
} = dom.style;
|
15
|
+
} = dom.style;
|
16
16
|
|
17
|
+
// ignore setting background attr if ds neutral token is detected
|
17
18
|
if (backgroundColor.includes('--ds-background-neutral')) {
|
18
19
|
backgroundColor = '';
|
19
20
|
} else {
|
20
21
|
if (backgroundColor && isRgb(backgroundColor)) {
|
21
22
|
const result = rgbToHex(backgroundColor);
|
22
|
-
|
23
23
|
if (result !== null) {
|
24
24
|
backgroundColor = result;
|
25
25
|
}
|
26
26
|
}
|
27
27
|
}
|
28
|
-
|
29
28
|
return {
|
30
29
|
colspan,
|
31
30
|
rowspan: Number(dom.getAttribute('rowspan') || 1),
|
@@ -33,7 +32,6 @@ export const getCellAttrs = (dom, defaultValues = {}) => {
|
|
33
32
|
background: backgroundColor && backgroundColor !== defaultValues['background'] ? backgroundColor : null
|
34
33
|
};
|
35
34
|
};
|
36
|
-
|
37
35
|
/**
|
38
36
|
* gets cell dom attributes based on node attributes
|
39
37
|
* @returns CellDomAttrs
|
@@ -41,29 +39,25 @@ export const getCellAttrs = (dom, defaultValues = {}) => {
|
|
41
39
|
export const getCellDomAttrs = node => {
|
42
40
|
const attrs = {};
|
43
41
|
const nodeType = node.type.name;
|
44
|
-
|
45
42
|
if (node.attrs.colspan !== 1) {
|
46
43
|
attrs.colspan = node.attrs.colspan;
|
47
44
|
}
|
48
|
-
|
49
45
|
if (node.attrs.rowspan !== 1) {
|
50
46
|
attrs.rowspan = node.attrs.rowspan;
|
51
47
|
}
|
52
|
-
|
53
48
|
if (node.attrs.colwidth) {
|
54
49
|
attrs['data-colwidth'] = node.attrs.colwidth.join(',');
|
55
50
|
}
|
56
|
-
|
57
51
|
if (node.attrs.background) {
|
58
52
|
const {
|
59
53
|
background
|
60
|
-
} = node.attrs;
|
54
|
+
} = node.attrs;
|
55
|
+
|
56
|
+
// to ensure that we don't overwrite product's style:
|
61
57
|
// - it clears background color for <th> if its set to gray
|
62
58
|
// - it clears background color for <td> if its set to white
|
63
59
|
// - it clears background color for <th> if ds neutral token is detected
|
64
|
-
|
65
60
|
const ignored = nodeType === 'tableHeader' && background === tableBackgroundColorNames.get('light gray') || nodeType === 'tableCell' && background === tableBackgroundColorNames.get('white') || nodeType === 'tableHeader' && background.includes('--ds-background-neutral');
|
66
|
-
|
67
61
|
if (ignored) {
|
68
62
|
attrs.style = '';
|
69
63
|
} else {
|
@@ -72,13 +66,11 @@ export const getCellDomAttrs = node => {
|
|
72
66
|
attrs.colorname = tableBackgroundColorPalette.get(color);
|
73
67
|
}
|
74
68
|
}
|
75
|
-
|
76
69
|
if (nodeType === 'tableHeader') {
|
77
70
|
attrs.class = tableHeaderSelector;
|
78
71
|
} else {
|
79
72
|
attrs.class = tableCellSelector;
|
80
73
|
}
|
81
|
-
|
82
74
|
return attrs;
|
83
75
|
};
|
84
76
|
export const tableBackgroundColorPalette = new Map();
|
@@ -88,7 +80,6 @@ export const tableBackgroundColorNames = new Map();
|
|
88
80
|
tableBackgroundColorPalette.set(colorValue.toLowerCase(), colorName);
|
89
81
|
tableBackgroundColorNames.set(colorName.toLowerCase(), colorValue.toLowerCase());
|
90
82
|
});
|
91
|
-
|
92
83
|
// TODO: Fix any, potential issue. ED-5048
|
93
84
|
const createTableSpec = () => {
|
94
85
|
const attrs = {
|
@@ -111,18 +102,18 @@ const createTableSpec = () => {
|
|
111
102
|
marks: 'unsupportedMark unsupportedNodeAttribute',
|
112
103
|
tableRole: 'table',
|
113
104
|
isolating: true,
|
114
|
-
selectable:
|
105
|
+
selectable: true,
|
115
106
|
group: 'block',
|
116
107
|
parseDOM: [{
|
117
108
|
tag: 'table',
|
118
109
|
getAttrs: node => {
|
119
110
|
var _dom$parentElement;
|
120
|
-
|
121
111
|
const dom = node;
|
122
112
|
const breakoutWrapper = (_dom$parentElement = dom.parentElement) === null || _dom$parentElement === void 0 ? void 0 : _dom$parentElement.parentElement;
|
123
113
|
return {
|
124
114
|
isNumberColumnEnabled: dom.getAttribute('data-number-column') === 'true' ? true : false,
|
125
|
-
layout:
|
115
|
+
layout:
|
116
|
+
// copying from editor
|
126
117
|
dom.getAttribute('data-layout') || ( // copying from renderer
|
127
118
|
breakoutWrapper === null || breakoutWrapper === void 0 ? void 0 : breakoutWrapper.getAttribute('data-layout')) || 'default',
|
128
119
|
__autoSize: dom.getAttribute('data-autosize') === 'true' ? true : false,
|
@@ -130,7 +121,6 @@ const createTableSpec = () => {
|
|
130
121
|
};
|
131
122
|
}
|
132
123
|
}],
|
133
|
-
|
134
124
|
toDOM(node) {
|
135
125
|
const attrs = {
|
136
126
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
@@ -140,15 +130,11 @@ const createTableSpec = () => {
|
|
140
130
|
};
|
141
131
|
return ['table', attrs, ['tbody', 0]];
|
142
132
|
}
|
143
|
-
|
144
133
|
};
|
145
134
|
return tableNodeSpec;
|
146
135
|
};
|
147
|
-
|
148
136
|
export const table = createTableSpec();
|
149
|
-
|
150
137
|
const shouldIncludeAttribute = (key, value) => !key.startsWith('__') && (key !== 'localId' || !!value);
|
151
|
-
|
152
138
|
export const tableToJSON = node => ({
|
153
139
|
attrs: Object.keys(node.attrs).filter(key => shouldIncludeAttribute(key, node.attrs[key])).reduce((obj, key) => {
|
154
140
|
obj[key] = node.attrs[key];
|
@@ -163,11 +149,9 @@ export const tableRow = {
|
|
163
149
|
parseDOM: [{
|
164
150
|
tag: 'tr'
|
165
151
|
}],
|
166
|
-
|
167
152
|
toDOM() {
|
168
153
|
return ['tr', 0];
|
169
154
|
}
|
170
|
-
|
171
155
|
};
|
172
156
|
const cellAttrs = {
|
173
157
|
colspan: {
|
@@ -190,7 +174,8 @@ export const tableCell = {
|
|
190
174
|
tableRole: 'cell',
|
191
175
|
marks: 'alignment dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
|
192
176
|
isolating: true,
|
193
|
-
parseDOM: [
|
177
|
+
parseDOM: [
|
178
|
+
// Ignore number cell copied from renderer
|
194
179
|
{
|
195
180
|
tag: '.ak-renderer-table-number-column',
|
196
181
|
ignore: true
|
@@ -205,7 +190,6 @@ export const toJSONTableCell = node => ({
|
|
205
190
|
if (cellAttrs[key].default !== node.attrs[key]) {
|
206
191
|
obj[key] = node.attrs[key];
|
207
192
|
}
|
208
|
-
|
209
193
|
return obj;
|
210
194
|
}, {})
|
211
195
|
});
|
@@ -14,7 +14,6 @@ export const unsupportedBlock = {
|
|
14
14
|
originalValue: JSON.parse(dom.getAttribute('data-original-value') || '{}')
|
15
15
|
})
|
16
16
|
}],
|
17
|
-
|
18
17
|
toDOM(node) {
|
19
18
|
const attrs = {
|
20
19
|
'data-node-type': 'unsupportedBlock',
|
@@ -22,5 +21,4 @@ export const unsupportedBlock = {
|
|
22
21
|
};
|
23
22
|
return ['div', attrs, 'Unsupported content'];
|
24
23
|
}
|
25
|
-
|
26
24
|
};
|
@@ -13,7 +13,6 @@ export const unsupportedInline = {
|
|
13
13
|
originalValue: JSON.parse(dom.getAttribute('data-original-value') || '{}')
|
14
14
|
})
|
15
15
|
}],
|
16
|
-
|
17
16
|
toDOM(node) {
|
18
17
|
const attrs = {
|
19
18
|
'data-node-type': 'unsupportedInline',
|
@@ -21,5 +20,4 @@ export const unsupportedInline = {
|
|
21
20
|
};
|
22
21
|
return ['span', attrs, 'Unsupported content'];
|
23
22
|
}
|
24
|
-
|
25
23
|
};
|
@@ -4,22 +4,21 @@ import { Slice } from 'prosemirror-model';
|
|
4
4
|
export const analyticsStepType = 'atlaskit-analytics';
|
5
5
|
export const analyticsInvertStepType = 'atlaskit-analytics-invert';
|
6
6
|
var HISTORY_ACTIONS;
|
7
|
-
|
8
7
|
(function (HISTORY_ACTIONS) {
|
9
8
|
HISTORY_ACTIONS["UNDID"] = "undid";
|
10
9
|
HISTORY_ACTIONS["REDID"] = "redid";
|
11
10
|
})(HISTORY_ACTIONS || (HISTORY_ACTIONS = {}));
|
12
|
-
|
13
11
|
/** Creates undo event from a normal analytics event */
|
14
12
|
function createUndoEvent(analyticsEvent) {
|
15
13
|
var _analyticsEvent$paylo;
|
16
|
-
|
17
|
-
|
14
|
+
return {
|
15
|
+
...analyticsEvent,
|
18
16
|
payload: {
|
19
17
|
action: HISTORY_ACTIONS.UNDID,
|
20
18
|
actionSubject: analyticsEvent.payload.actionSubject,
|
21
19
|
actionSubjectId: analyticsEvent.payload.action,
|
22
|
-
attributes: {
|
20
|
+
attributes: {
|
21
|
+
...analyticsEvent.payload.attributes,
|
23
22
|
actionSubjectId: analyticsEvent.payload.actionSubjectId,
|
24
23
|
inputMethod: ((_analyticsEvent$paylo = analyticsEvent.payload.attributes) === null || _analyticsEvent$paylo === void 0 ? void 0 : _analyticsEvent$paylo.inputMethod) || ''
|
25
24
|
},
|
@@ -27,19 +26,18 @@ function createUndoEvent(analyticsEvent) {
|
|
27
26
|
}
|
28
27
|
};
|
29
28
|
}
|
30
|
-
/** Toggles event action between undo & redo */
|
31
29
|
|
32
|
-
|
33
|
-
const toggleEventAction = analyticsEvent => ({
|
34
|
-
|
30
|
+
/** Toggles event action between undo & redo */
|
31
|
+
const toggleEventAction = analyticsEvent => ({
|
32
|
+
...analyticsEvent,
|
33
|
+
payload: {
|
34
|
+
...analyticsEvent.payload,
|
35
35
|
action: analyticsEvent.payload.action === HISTORY_ACTIONS.UNDID ? HISTORY_ACTIONS.REDID : HISTORY_ACTIONS.UNDID
|
36
36
|
}
|
37
37
|
});
|
38
|
-
|
39
38
|
function isHistoryAnalyticsEvent(event) {
|
40
39
|
return event.payload.action === HISTORY_ACTIONS.UNDID || event.payload.action === HISTORY_ACTIONS.REDID;
|
41
40
|
}
|
42
|
-
|
43
41
|
/**
|
44
42
|
* Custom Prosemirror Step to fire our GAS V3 analytics events
|
45
43
|
* Using a Step means that it will work with prosemirror-history and we get
|
@@ -49,20 +47,16 @@ export class AnalyticsStep extends Step {
|
|
49
47
|
constructor(analyticsEvents, actionsToIgnore = [], pos // Used to create the map, prevent splitting history.
|
50
48
|
) {
|
51
49
|
super();
|
52
|
-
|
53
50
|
_defineProperty(this, "analyticsEvents", []);
|
54
|
-
|
55
51
|
_defineProperty(this, "actionsToIgnore", []);
|
56
|
-
|
57
52
|
this.analyticsEvents = analyticsEvents;
|
58
53
|
this.actionsToIgnore = actionsToIgnore;
|
59
54
|
this.pos = pos;
|
60
55
|
}
|
56
|
+
|
61
57
|
/**
|
62
58
|
* Generate new undo/redo analytics event when step is inverted
|
63
59
|
*/
|
64
|
-
|
65
|
-
|
66
60
|
invert() {
|
67
61
|
const analyticsEvents = this.analyticsEvents.filter(analyticsEvent => this.actionsToIgnore.indexOf(analyticsEvent.payload.action) === -1).map(analyticsEvent => {
|
68
62
|
if (isHistoryAnalyticsEvent(analyticsEvent)) {
|
@@ -73,50 +67,39 @@ export class AnalyticsStep extends Step {
|
|
73
67
|
});
|
74
68
|
return new AnalyticsStep(analyticsEvents, []);
|
75
69
|
}
|
76
|
-
|
77
70
|
apply(doc) {
|
78
71
|
return StepResult.ok(doc);
|
79
72
|
}
|
80
|
-
|
81
73
|
map(mapping) {
|
82
74
|
let newPos = this.pos;
|
83
|
-
|
84
75
|
if (typeof newPos === 'number') {
|
85
76
|
newPos = mapping.map(newPos);
|
86
|
-
}
|
87
|
-
|
88
|
-
|
77
|
+
}
|
78
|
+
// Return the same events, this step will never be removed
|
89
79
|
return new AnalyticsStep(this.analyticsEvents, this.actionsToIgnore, newPos);
|
90
80
|
}
|
91
|
-
|
92
81
|
getMap() {
|
93
82
|
if (typeof this.pos === 'number') {
|
94
83
|
return new StepMap([this.pos, 0, 0]);
|
95
84
|
}
|
96
|
-
|
97
85
|
return new StepMap([]);
|
98
86
|
}
|
99
|
-
|
100
87
|
merge(other) {
|
101
88
|
if (other instanceof AnalyticsStep) {
|
102
89
|
const otherAnalyticsEvents = other.analyticsEvents;
|
103
90
|
return new AnalyticsStep([...otherAnalyticsEvents, ...this.analyticsEvents]);
|
104
91
|
}
|
105
|
-
|
106
92
|
return null;
|
107
93
|
}
|
108
|
-
|
109
94
|
toJSON() {
|
110
95
|
return {
|
111
96
|
stepType: analyticsStepType
|
112
97
|
};
|
113
98
|
}
|
114
|
-
|
115
99
|
static fromJSON() {
|
116
100
|
return new ReplaceStep(0, 0, Slice.empty);
|
117
101
|
}
|
118
|
-
|
119
102
|
}
|
120
|
-
/** Register this step with Prosemirror */
|
121
103
|
|
104
|
+
/** Register this step with Prosemirror */
|
122
105
|
Step.jsonID(analyticsStepType, AnalyticsStep);
|
@@ -1,46 +1,40 @@
|
|
1
1
|
import { Step, StepResult } from 'prosemirror-transform';
|
2
2
|
import { Slice, Fragment } from 'prosemirror-model';
|
3
|
+
|
3
4
|
/**
|
4
5
|
* For more context on what this is about:
|
5
6
|
* @see https://discuss.prosemirror.net/t/preventing-image-placeholder-replacement-from-being-undone/1394
|
6
7
|
*/
|
7
|
-
|
8
8
|
export class SetAttrsStep extends Step {
|
9
9
|
constructor(pos, attrs) {
|
10
10
|
super();
|
11
11
|
this.pos = pos;
|
12
12
|
this.attrs = attrs;
|
13
13
|
}
|
14
|
-
|
15
14
|
apply(doc) {
|
16
15
|
let target = doc.nodeAt(this.pos);
|
17
|
-
|
18
16
|
if (!target) {
|
19
17
|
return StepResult.fail('No node at given position');
|
20
18
|
}
|
21
|
-
|
22
19
|
if (target.isText) {
|
23
20
|
return StepResult.fail('Target is a text node. Attributes are not allowed.');
|
24
21
|
}
|
25
|
-
|
26
|
-
|
22
|
+
const attrs = {
|
23
|
+
...(target.attrs || {}),
|
27
24
|
...(this.attrs || {})
|
28
25
|
};
|
29
26
|
let newNode = target.type.create(attrs, Fragment.empty, target.marks);
|
30
27
|
let slice = new Slice(Fragment.from(newNode), 0, target.isLeaf ? 0 : 1);
|
31
28
|
return StepResult.fromReplace(doc, this.pos, this.pos + 1, slice);
|
32
29
|
}
|
33
|
-
|
34
30
|
invert(doc) {
|
35
31
|
let target = doc.nodeAt(this.pos);
|
36
32
|
return new SetAttrsStep(this.pos, target ? target.attrs : {});
|
37
33
|
}
|
38
|
-
|
39
34
|
map(mapping) {
|
40
35
|
let result = mapping.mapResult(this.pos, 1);
|
41
36
|
return result.deleted ? null : new SetAttrsStep(result.pos, this.attrs);
|
42
37
|
}
|
43
|
-
|
44
38
|
toJSON() {
|
45
39
|
return {
|
46
40
|
stepType: 'setAttrs',
|
@@ -48,14 +42,11 @@ export class SetAttrsStep extends Step {
|
|
48
42
|
attrs: this.attrs
|
49
43
|
};
|
50
44
|
}
|
51
|
-
|
52
45
|
static fromJSON(_schema, json) {
|
53
46
|
if (typeof json.pos !== 'number' || json.attrs !== null && typeof json.attrs !== 'object') {
|
54
47
|
throw new RangeError('Invalid input for SetAttrsStep.fromJSON');
|
55
48
|
}
|
56
|
-
|
57
49
|
return new SetAttrsStep(json.pos, json.attrs);
|
58
50
|
}
|
59
|
-
|
60
51
|
}
|
61
52
|
Step.jsonID('setAttrs', SetAttrsStep);
|