@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
@@ -14,20 +14,19 @@ export var getCellAttrs = function getCellAttrs(dom) {
|
|
14
14
|
return Number(str);
|
15
15
|
}) : null;
|
16
16
|
var colspan = Number(dom.getAttribute('colspan') || 1);
|
17
|
-
var backgroundColor = dom.style.backgroundColor;
|
17
|
+
var backgroundColor = dom.style.backgroundColor;
|
18
18
|
|
19
|
+
// ignore setting background attr if ds neutral token is detected
|
19
20
|
if (backgroundColor.includes('--ds-background-neutral')) {
|
20
21
|
backgroundColor = '';
|
21
22
|
} else {
|
22
23
|
if (backgroundColor && isRgb(backgroundColor)) {
|
23
24
|
var result = rgbToHex(backgroundColor);
|
24
|
-
|
25
25
|
if (result !== null) {
|
26
26
|
backgroundColor = result;
|
27
27
|
}
|
28
28
|
}
|
29
29
|
}
|
30
|
-
|
31
30
|
return {
|
32
31
|
colspan: colspan,
|
33
32
|
rowspan: Number(dom.getAttribute('rowspan') || 1),
|
@@ -35,7 +34,6 @@ export var getCellAttrs = function getCellAttrs(dom) {
|
|
35
34
|
background: backgroundColor && backgroundColor !== defaultValues['background'] ? backgroundColor : null
|
36
35
|
};
|
37
36
|
};
|
38
|
-
|
39
37
|
/**
|
40
38
|
* gets cell dom attributes based on node attributes
|
41
39
|
* @returns CellDomAttrs
|
@@ -43,27 +41,23 @@ export var getCellAttrs = function getCellAttrs(dom) {
|
|
43
41
|
export var getCellDomAttrs = function getCellDomAttrs(node) {
|
44
42
|
var attrs = {};
|
45
43
|
var nodeType = node.type.name;
|
46
|
-
|
47
44
|
if (node.attrs.colspan !== 1) {
|
48
45
|
attrs.colspan = node.attrs.colspan;
|
49
46
|
}
|
50
|
-
|
51
47
|
if (node.attrs.rowspan !== 1) {
|
52
48
|
attrs.rowspan = node.attrs.rowspan;
|
53
49
|
}
|
54
|
-
|
55
50
|
if (node.attrs.colwidth) {
|
56
51
|
attrs['data-colwidth'] = node.attrs.colwidth.join(',');
|
57
52
|
}
|
58
|
-
|
59
53
|
if (node.attrs.background) {
|
60
|
-
var background = node.attrs.background;
|
54
|
+
var background = node.attrs.background;
|
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
|
var 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 var getCellDomAttrs = function 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 var tableBackgroundColorPalette = new Map();
|
@@ -86,13 +78,11 @@ export var tableBackgroundBorderColor = hexToRgba(N800, 0.12) || N0;
|
|
86
78
|
export var tableBackgroundColorNames = new Map();
|
87
79
|
[[N0, 'White'], [B50, 'Light blue'], [T50, 'Light teal'], [G50, 'Light green'], [Y50, 'Light yellow'], [R50, 'Light red'], [P50, 'Light purple'], [N20, 'Light gray'], [B75, 'Blue'], [T75, 'Teal'], [G75, 'Green'], [Y75, 'Yellow'], [R75, 'Red'], [P75, 'Purple'], [N60, 'Gray'], [B100, 'Dark blue'], [T100, 'Dark teal'], [G200, 'Dark green'], [Y200, 'Dark yellow'], [R100, 'Dark red'], [P100, 'Dark purple']].forEach(function (_ref) {
|
88
80
|
var _ref2 = _slicedToArray(_ref, 2),
|
89
|
-
|
90
|
-
|
91
|
-
|
81
|
+
colorValue = _ref2[0],
|
82
|
+
colorName = _ref2[1];
|
92
83
|
tableBackgroundColorPalette.set(colorValue.toLowerCase(), colorName);
|
93
84
|
tableBackgroundColorNames.set(colorName.toLowerCase(), colorValue.toLowerCase());
|
94
85
|
});
|
95
|
-
|
96
86
|
// TODO: Fix any, potential issue. ED-5048
|
97
87
|
var createTableSpec = function createTableSpec() {
|
98
88
|
var attrs = {
|
@@ -115,18 +105,18 @@ var createTableSpec = function createTableSpec() {
|
|
115
105
|
marks: 'unsupportedMark unsupportedNodeAttribute',
|
116
106
|
tableRole: 'table',
|
117
107
|
isolating: true,
|
118
|
-
selectable:
|
108
|
+
selectable: true,
|
119
109
|
group: 'block',
|
120
110
|
parseDOM: [{
|
121
111
|
tag: 'table',
|
122
112
|
getAttrs: function getAttrs(node) {
|
123
113
|
var _dom$parentElement;
|
124
|
-
|
125
114
|
var dom = node;
|
126
115
|
var breakoutWrapper = (_dom$parentElement = dom.parentElement) === null || _dom$parentElement === void 0 ? void 0 : _dom$parentElement.parentElement;
|
127
116
|
return {
|
128
117
|
isNumberColumnEnabled: dom.getAttribute('data-number-column') === 'true' ? true : false,
|
129
|
-
layout:
|
118
|
+
layout:
|
119
|
+
// copying from editor
|
130
120
|
dom.getAttribute('data-layout') || ( // copying from renderer
|
131
121
|
breakoutWrapper === null || breakoutWrapper === void 0 ? void 0 : breakoutWrapper.getAttribute('data-layout')) || 'default',
|
132
122
|
__autoSize: dom.getAttribute('data-autosize') === 'true' ? true : false,
|
@@ -146,13 +136,10 @@ var createTableSpec = function createTableSpec() {
|
|
146
136
|
};
|
147
137
|
return tableNodeSpec;
|
148
138
|
};
|
149
|
-
|
150
139
|
export var table = createTableSpec();
|
151
|
-
|
152
140
|
var shouldIncludeAttribute = function shouldIncludeAttribute(key, value) {
|
153
141
|
return !key.startsWith('__') && (key !== 'localId' || !!value);
|
154
142
|
};
|
155
|
-
|
156
143
|
export var tableToJSON = function tableToJSON(node) {
|
157
144
|
return {
|
158
145
|
attrs: Object.keys(node.attrs).filter(function (key) {
|
@@ -196,7 +183,8 @@ export var tableCell = {
|
|
196
183
|
tableRole: 'cell',
|
197
184
|
marks: 'alignment dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
|
198
185
|
isolating: true,
|
199
|
-
parseDOM: [
|
186
|
+
parseDOM: [
|
187
|
+
// Ignore number cell copied from renderer
|
200
188
|
{
|
201
189
|
tag: '.ak-renderer-table-number-column',
|
202
190
|
ignore: true
|
@@ -216,7 +204,6 @@ export var toJSONTableCell = function toJSONTableCell(node) {
|
|
216
204
|
if (cellAttrs[key].default !== node.attrs[key]) {
|
217
205
|
obj[key] = node.attrs[key];
|
218
206
|
}
|
219
|
-
|
220
207
|
return obj;
|
221
208
|
}, {})
|
222
209
|
};
|
@@ -26,8 +26,8 @@ export var taskItem = {
|
|
26
26
|
}],
|
27
27
|
toDOM: function toDOM(node) {
|
28
28
|
var _node$attrs = node.attrs,
|
29
|
-
|
30
|
-
|
29
|
+
localId = _node$attrs.localId,
|
30
|
+
state = _node$attrs.state;
|
31
31
|
var attrs = {
|
32
32
|
'data-task-local-id': localId || 'local-task',
|
33
33
|
'data-task-state': state || 'TODO'
|
@@ -6,30 +6,22 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
9
|
-
|
10
9
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
11
|
-
|
12
10
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
13
|
-
|
14
11
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
15
|
-
|
16
12
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
17
|
-
|
18
13
|
import { Step, StepResult, StepMap, ReplaceStep } from 'prosemirror-transform';
|
19
14
|
import { Slice } from 'prosemirror-model';
|
20
15
|
export var analyticsStepType = 'atlaskit-analytics';
|
21
16
|
export var analyticsInvertStepType = 'atlaskit-analytics-invert';
|
22
17
|
var HISTORY_ACTIONS;
|
23
|
-
|
24
18
|
(function (HISTORY_ACTIONS) {
|
25
19
|
HISTORY_ACTIONS["UNDID"] = "undid";
|
26
20
|
HISTORY_ACTIONS["REDID"] = "redid";
|
27
21
|
})(HISTORY_ACTIONS || (HISTORY_ACTIONS = {}));
|
28
|
-
|
29
22
|
/** Creates undo event from a normal analytics event */
|
30
23
|
function createUndoEvent(analyticsEvent) {
|
31
24
|
var _analyticsEvent$paylo;
|
32
|
-
|
33
25
|
return _objectSpread(_objectSpread({}, analyticsEvent), {}, {
|
34
26
|
payload: {
|
35
27
|
action: HISTORY_ACTIONS.UNDID,
|
@@ -43,9 +35,8 @@ function createUndoEvent(analyticsEvent) {
|
|
43
35
|
}
|
44
36
|
});
|
45
37
|
}
|
46
|
-
/** Toggles event action between undo & redo */
|
47
|
-
|
48
38
|
|
39
|
+
/** Toggles event action between undo & redo */
|
49
40
|
var toggleEventAction = function toggleEventAction(analyticsEvent) {
|
50
41
|
return _objectSpread(_objectSpread({}, analyticsEvent), {}, {
|
51
42
|
payload: _objectSpread(_objectSpread({}, analyticsEvent.payload), {}, {
|
@@ -53,11 +44,9 @@ var toggleEventAction = function toggleEventAction(analyticsEvent) {
|
|
53
44
|
})
|
54
45
|
});
|
55
46
|
};
|
56
|
-
|
57
47
|
function isHistoryAnalyticsEvent(event) {
|
58
48
|
return event.payload.action === HISTORY_ACTIONS.UNDID || event.payload.action === HISTORY_ACTIONS.REDID;
|
59
49
|
}
|
60
|
-
|
61
50
|
/**
|
62
51
|
* Custom Prosemirror Step to fire our GAS V3 analytics events
|
63
52
|
* Using a Step means that it will work with prosemirror-history and we get
|
@@ -65,39 +54,29 @@ function isHistoryAnalyticsEvent(event) {
|
|
65
54
|
*/
|
66
55
|
export var AnalyticsStep = /*#__PURE__*/function (_Step) {
|
67
56
|
_inherits(AnalyticsStep, _Step);
|
68
|
-
|
69
57
|
var _super = _createSuper(AnalyticsStep);
|
70
|
-
|
71
58
|
function AnalyticsStep(analyticsEvents) {
|
72
59
|
var _this;
|
73
|
-
|
74
60
|
var actionsToIgnore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
75
61
|
var pos // Used to create the map, prevent splitting history.
|
76
62
|
= arguments.length > 2 ? arguments[2] : undefined;
|
77
|
-
|
78
63
|
_classCallCheck(this, AnalyticsStep);
|
79
|
-
|
80
64
|
_this = _super.call(this);
|
81
|
-
|
82
65
|
_defineProperty(_assertThisInitialized(_this), "analyticsEvents", []);
|
83
|
-
|
84
66
|
_defineProperty(_assertThisInitialized(_this), "actionsToIgnore", []);
|
85
|
-
|
86
67
|
_this.analyticsEvents = analyticsEvents;
|
87
68
|
_this.actionsToIgnore = actionsToIgnore;
|
88
69
|
_this.pos = pos;
|
89
70
|
return _this;
|
90
71
|
}
|
72
|
+
|
91
73
|
/**
|
92
74
|
* Generate new undo/redo analytics event when step is inverted
|
93
75
|
*/
|
94
|
-
|
95
|
-
|
96
76
|
_createClass(AnalyticsStep, [{
|
97
77
|
key: "invert",
|
98
78
|
value: function invert() {
|
99
79
|
var _this2 = this;
|
100
|
-
|
101
80
|
var analyticsEvents = this.analyticsEvents.filter(function (analyticsEvent) {
|
102
81
|
return _this2.actionsToIgnore.indexOf(analyticsEvent.payload.action) === -1;
|
103
82
|
}).map(function (analyticsEvent) {
|
@@ -118,12 +97,10 @@ export var AnalyticsStep = /*#__PURE__*/function (_Step) {
|
|
118
97
|
key: "map",
|
119
98
|
value: function map(mapping) {
|
120
99
|
var newPos = this.pos;
|
121
|
-
|
122
100
|
if (typeof newPos === 'number') {
|
123
101
|
newPos = mapping.map(newPos);
|
124
|
-
}
|
125
|
-
|
126
|
-
|
102
|
+
}
|
103
|
+
// Return the same events, this step will never be removed
|
127
104
|
return new AnalyticsStep(this.analyticsEvents, this.actionsToIgnore, newPos);
|
128
105
|
}
|
129
106
|
}, {
|
@@ -132,7 +109,6 @@ export var AnalyticsStep = /*#__PURE__*/function (_Step) {
|
|
132
109
|
if (typeof this.pos === 'number') {
|
133
110
|
return new StepMap([this.pos, 0, 0]);
|
134
111
|
}
|
135
|
-
|
136
112
|
return new StepMap([]);
|
137
113
|
}
|
138
114
|
}, {
|
@@ -142,7 +118,6 @@ export var AnalyticsStep = /*#__PURE__*/function (_Step) {
|
|
142
118
|
var otherAnalyticsEvents = other.analyticsEvents;
|
143
119
|
return new AnalyticsStep([].concat(_toConsumableArray(otherAnalyticsEvents), _toConsumableArray(this.analyticsEvents)));
|
144
120
|
}
|
145
|
-
|
146
121
|
return null;
|
147
122
|
}
|
148
123
|
}, {
|
@@ -158,9 +133,8 @@ export var AnalyticsStep = /*#__PURE__*/function (_Step) {
|
|
158
133
|
return new ReplaceStep(0, 0, Slice.empty);
|
159
134
|
}
|
160
135
|
}]);
|
161
|
-
|
162
136
|
return AnalyticsStep;
|
163
137
|
}(Step);
|
164
|
-
/** Register this step with Prosemirror */
|
165
138
|
|
139
|
+
/** Register this step with Prosemirror */
|
166
140
|
Step.jsonID(analyticsStepType, AnalyticsStep);
|
@@ -5,53 +5,39 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
5
|
import _inherits from "@babel/runtime/helpers/inherits";
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
8
|
-
|
9
8
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
10
|
-
|
11
9
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
12
|
-
|
13
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
14
|
-
|
15
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
16
|
-
|
17
12
|
import { Step, StepResult } from 'prosemirror-transform';
|
18
13
|
import { Slice, Fragment } from 'prosemirror-model';
|
14
|
+
|
19
15
|
/**
|
20
16
|
* For more context on what this is about:
|
21
17
|
* @see https://discuss.prosemirror.net/t/preventing-image-placeholder-replacement-from-being-undone/1394
|
22
18
|
*/
|
23
|
-
|
24
19
|
export var SetAttrsStep = /*#__PURE__*/function (_Step) {
|
25
20
|
_inherits(SetAttrsStep, _Step);
|
26
|
-
|
27
21
|
var _super = _createSuper(SetAttrsStep);
|
28
|
-
|
29
22
|
function SetAttrsStep(pos, attrs) {
|
30
23
|
var _this;
|
31
|
-
|
32
24
|
_classCallCheck(this, SetAttrsStep);
|
33
|
-
|
34
25
|
_this = _super.call(this);
|
35
26
|
_this.pos = pos;
|
36
27
|
_this.attrs = attrs;
|
37
28
|
return _this;
|
38
29
|
}
|
39
|
-
|
40
30
|
_createClass(SetAttrsStep, [{
|
41
31
|
key: "apply",
|
42
32
|
value: function apply(doc) {
|
43
33
|
var target = doc.nodeAt(this.pos);
|
44
|
-
|
45
34
|
if (!target) {
|
46
35
|
return StepResult.fail('No node at given position');
|
47
36
|
}
|
48
|
-
|
49
37
|
if (target.isText) {
|
50
38
|
return StepResult.fail('Target is a text node. Attributes are not allowed.');
|
51
39
|
}
|
52
|
-
|
53
40
|
var attrs = _objectSpread(_objectSpread({}, target.attrs || {}), this.attrs || {});
|
54
|
-
|
55
41
|
var newNode = target.type.create(attrs, Fragment.empty, target.marks);
|
56
42
|
var slice = new Slice(Fragment.from(newNode), 0, target.isLeaf ? 0 : 1);
|
57
43
|
return StepResult.fromReplace(doc, this.pos, this.pos + 1, slice);
|
@@ -83,11 +69,9 @@ export var SetAttrsStep = /*#__PURE__*/function (_Step) {
|
|
83
69
|
if (typeof json.pos !== 'number' || json.attrs !== null && _typeof(json.attrs) !== 'object') {
|
84
70
|
throw new RangeError('Invalid input for SetAttrsStep.fromJSON');
|
85
71
|
}
|
86
|
-
|
87
72
|
return new SetAttrsStep(json.pos, json.attrs);
|
88
73
|
}
|
89
74
|
}]);
|
90
|
-
|
91
75
|
return SetAttrsStep;
|
92
76
|
}(Step);
|
93
77
|
Step.jsonID('setAttrs', SetAttrsStep);
|