@atlaskit/editor-plugin-show-diff 3.2.3 → 3.2.5
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 +18 -0
- package/afm-jira/tsconfig.json +1 -1
- package/dist/cjs/pm-plugins/decorations.js +33 -220
- package/dist/cjs/pm-plugins/deletedBlocksHandler.js +220 -0
- package/dist/cjs/pm-plugins/deletedRowsHandler.js +1 -1
- package/dist/es2019/pm-plugins/decorations.js +29 -216
- package/dist/es2019/pm-plugins/deletedBlocksHandler.js +214 -0
- package/dist/es2019/pm-plugins/deletedRowsHandler.js +1 -1
- package/dist/esm/pm-plugins/decorations.js +30 -217
- package/dist/esm/pm-plugins/deletedBlocksHandler.js +214 -0
- package/dist/esm/pm-plugins/deletedRowsHandler.js +1 -1
- package/dist/types/pm-plugins/NodeViewSerializer.d.ts +1 -1
- package/dist/types/pm-plugins/decorations.d.ts +2 -0
- package/dist/types/pm-plugins/deletedBlocksHandler.d.ts +48 -0
- package/dist/types-ts4.5/pm-plugins/NodeViewSerializer.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/deletedBlocksHandler.d.ts +48 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 3.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a05464ea42678`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a05464ea42678) -
|
|
8
|
+
EDITOR-2791 bump adf-schema
|
|
9
|
+
- [`657693883946f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/657693883946f) -
|
|
10
|
+
Fix diffs for extension nodes
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 3.2.4
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`0b00861d972cd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0b00861d972cd) -
|
|
18
|
+
[EDITOR-2668] refactored deleted mediaSingle decorations to maintain alignment/wrap on diff view
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 3.2.3
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/afm-jira/tsconfig.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"extends": "../../../../tsconfig.entry-points.jira.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"target": "es5",
|
|
5
|
-
"outDir": "../../../../../tsDist/@atlaskit__editor-plugin-show-diff/app",
|
|
5
|
+
"outDir": "../../../../../jira/tsDist/@atlaskit__editor-plugin-show-diff/app",
|
|
6
6
|
"rootDir": "../",
|
|
7
7
|
"composite": true
|
|
8
8
|
},
|
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.createInlineChangedDecoration = exports.createDeletedContentDecoration = exports.createBlockChangedDecoration = void 0;
|
|
6
|
+
exports.getDeletedContentStyleUnbounded = exports.getDeletedContentStyle = exports.createInlineChangedDecoration = exports.createDeletedContentDecoration = exports.createBlockChangedDecoration = void 0;
|
|
7
7
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
8
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
9
8
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
10
9
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
|
+
var _deletedBlocksHandler = require("./deletedBlocksHandler");
|
|
11
11
|
var _deletedRowsHandler = require("./deletedRowsHandler");
|
|
12
12
|
var _findSafeInsertPos = require("./findSafeInsertPos");
|
|
13
13
|
var editingStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
14
|
-
background: "var(--ds-background-accent-purple-subtlest, #
|
|
14
|
+
background: "var(--ds-background-accent-purple-subtlest, #F8EEFE)",
|
|
15
15
|
textDecoration: 'underline',
|
|
16
16
|
textDecorationStyle: 'dotted',
|
|
17
17
|
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
18
|
-
textDecorationColor: "var(--ds-border-accent-purple, #
|
|
18
|
+
textDecorationColor: "var(--ds-border-accent-purple, #AF59E1)"
|
|
19
19
|
});
|
|
20
20
|
var traditionalInsertStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
21
21
|
background: "var(--ds-background-accent-green-subtlest, #DCFFF1)",
|
|
@@ -49,10 +49,6 @@ var getEditorStyleNode = function getEditorStyleNode(nodeName, colourScheme) {
|
|
|
49
49
|
case 'tableHeader':
|
|
50
50
|
return undefined;
|
|
51
51
|
// Handle table separately to avoid border issues
|
|
52
|
-
case 'embedCard':
|
|
53
|
-
return (0, _lazyNodeView.convertToInlineCss)({
|
|
54
|
-
'--diff-decoration-marker-color': colourScheme === 'traditional' ? "var(--ds-border-accent-green, #22A06B)" : "var(--ds-border-accent-purple, #8270DB)"
|
|
55
|
-
});
|
|
56
52
|
case 'paragraph':
|
|
57
53
|
case 'heading':
|
|
58
54
|
case 'hardBreak':
|
|
@@ -64,9 +60,11 @@ var getEditorStyleNode = function getEditorStyleNode(nodeName, colourScheme) {
|
|
|
64
60
|
case 'bulletList':
|
|
65
61
|
case 'orderedList':
|
|
66
62
|
return undefined;
|
|
63
|
+
case 'extension':
|
|
64
|
+
case 'embedCard':
|
|
67
65
|
case 'listItem':
|
|
68
66
|
return (0, _lazyNodeView.convertToInlineCss)({
|
|
69
|
-
'--diff-decoration-marker-color': colourScheme === 'traditional' ? "var(--ds-border-accent-green, #22A06B)" : "var(--ds-border-accent-purple, #
|
|
67
|
+
'--diff-decoration-marker-color': colourScheme === 'traditional' ? "var(--ds-border-accent-green, #22A06B)" : "var(--ds-border-accent-purple, #AF59E1)"
|
|
70
68
|
});
|
|
71
69
|
case 'layoutSection':
|
|
72
70
|
return undefined;
|
|
@@ -79,73 +77,20 @@ var getEditorStyleNode = function getEditorStyleNode(nodeName, colourScheme) {
|
|
|
79
77
|
return colourScheme === 'traditional' ? traditionalStyleNode : editingStyleNode;
|
|
80
78
|
}
|
|
81
79
|
};
|
|
82
|
-
var getDeletedStyleNode = function getDeletedStyleNode(nodeName) {
|
|
83
|
-
switch (nodeName) {
|
|
84
|
-
case 'blockquote':
|
|
85
|
-
return deletedStyleQuoteNode;
|
|
86
|
-
case 'expand':
|
|
87
|
-
case 'decisionList':
|
|
88
|
-
return deletedBlockOutline;
|
|
89
|
-
case 'panel':
|
|
90
|
-
case 'codeBlock':
|
|
91
|
-
return deletedBlockOutlineRounded;
|
|
92
|
-
default:
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
var shouldShowRemovedLozenge = function shouldShowRemovedLozenge(nodeName) {
|
|
97
|
-
switch (nodeName) {
|
|
98
|
-
case 'expand':
|
|
99
|
-
case 'codeBlock':
|
|
100
|
-
case 'mediaSingle':
|
|
101
|
-
case 'panel':
|
|
102
|
-
case 'decisionList':
|
|
103
|
-
return true;
|
|
104
|
-
default:
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
var shouldFitContentWidth = function shouldFitContentWidth(nodeName) {
|
|
109
|
-
switch (nodeName) {
|
|
110
|
-
case 'mediaSingle':
|
|
111
|
-
case 'embedCard':
|
|
112
|
-
case 'blockCard':
|
|
113
|
-
return true;
|
|
114
|
-
default:
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
var shouldAddShowDiffDeletedNodeClass = function shouldAddShowDiffDeletedNodeClass(nodeName) {
|
|
119
|
-
switch (nodeName) {
|
|
120
|
-
case 'mediaSingle':
|
|
121
|
-
case 'embedCard':
|
|
122
|
-
return true;
|
|
123
|
-
default:
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Checks if a node should apply deleted styles directly without wrapper
|
|
130
|
-
* to preserve natural block-level margins
|
|
131
|
-
*/
|
|
132
|
-
var shouldApplyDeletedStylesDirectly = function shouldApplyDeletedStylesDirectly(nodeName) {
|
|
133
|
-
return nodeName === 'blockquote' || nodeName === 'heading';
|
|
134
|
-
};
|
|
135
80
|
var editingStyleQuoteNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
136
|
-
borderLeft: "2px solid ".concat("var(--ds-border-accent-purple, #
|
|
81
|
+
borderLeft: "2px solid ".concat("var(--ds-border-accent-purple, #AF59E1)")
|
|
137
82
|
});
|
|
138
83
|
var traditionalStyleQuoteNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
139
84
|
borderLeft: "2px solid ".concat("var(--ds-border-accent-green, #22A06B)")
|
|
140
85
|
});
|
|
141
86
|
var editingStyleRuleNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
142
|
-
backgroundColor: "var(--ds-border-accent-purple, #
|
|
87
|
+
backgroundColor: "var(--ds-border-accent-purple, #AF59E1)"
|
|
143
88
|
});
|
|
144
89
|
var traditionalStyleRuleNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
145
90
|
backgroundColor: "var(--ds-border-accent-green, #22A06B)"
|
|
146
91
|
});
|
|
147
92
|
var editingStyleNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
148
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-purple, #
|
|
93
|
+
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-purple, #AF59E1)"),
|
|
149
94
|
borderRadius: "var(--ds-radius-small, 4px)"
|
|
150
95
|
});
|
|
151
96
|
var traditionalStyleNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
@@ -153,39 +98,15 @@ var traditionalStyleNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
|
153
98
|
borderRadius: "var(--ds-radius-small, 4px)"
|
|
154
99
|
});
|
|
155
100
|
var editingStyleCardBlockNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
156
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-purple, #
|
|
101
|
+
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-purple, #AF59E1)"),
|
|
157
102
|
borderRadius: "var(--ds-radius-medium, 6px)"
|
|
158
103
|
});
|
|
159
104
|
var traditionalStyleCardBlockNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
160
105
|
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-green, #22A06B)"),
|
|
161
106
|
borderRadius: "var(--ds-radius-medium, 6px)"
|
|
162
107
|
});
|
|
163
|
-
var deletedStyleQuoteNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
164
|
-
borderLeft: "2px solid ".concat("var(--ds-border-accent-gray, #758195)")
|
|
165
|
-
});
|
|
166
|
-
var deletedBlockOutline = (0, _lazyNodeView.convertToInlineCss)({
|
|
167
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #758195)"),
|
|
168
|
-
borderRadius: "var(--ds-radius-small, 4px)"
|
|
169
|
-
});
|
|
170
|
-
var deletedBlockOutlineRounded = (0, _lazyNodeView.convertToInlineCss)({
|
|
171
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #758195)"),
|
|
172
|
-
borderRadius: "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)")
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Inline decoration used for insertions as the content already exists in the document
|
|
177
|
-
*
|
|
178
|
-
* @param change Changeset "change" containing information about the change content + range
|
|
179
|
-
* @returns Prosemirror inline decoration
|
|
180
|
-
*/
|
|
181
|
-
var createBlockChangedDecoration = exports.createBlockChangedDecoration = function createBlockChangedDecoration(change, colourScheme) {
|
|
182
|
-
return _view.Decoration.node(change.from, change.to, {
|
|
183
|
-
style: getEditorStyleNode(change.name, colourScheme),
|
|
184
|
-
'data-testid': 'show-diff-changed-decoration-node'
|
|
185
|
-
}, {});
|
|
186
|
-
};
|
|
187
108
|
var deletedContentStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
188
|
-
color: "var(--ds-text-accent-gray, #
|
|
109
|
+
color: "var(--ds-text-accent-gray, #505258)",
|
|
189
110
|
textDecoration: 'line-through',
|
|
190
111
|
position: 'relative',
|
|
191
112
|
opacity: 0.6
|
|
@@ -195,7 +116,7 @@ var deletedContentStyleUnbounded = (0, _lazyNodeView.convertToInlineCss)({
|
|
|
195
116
|
top: '50%',
|
|
196
117
|
width: '100%',
|
|
197
118
|
display: 'inline-block',
|
|
198
|
-
borderTop: "1px solid ".concat("var(--ds-text-accent-gray, #
|
|
119
|
+
borderTop: "1px solid ".concat("var(--ds-text-accent-gray, #505258)"),
|
|
199
120
|
pointerEvents: 'none',
|
|
200
121
|
zIndex: 1
|
|
201
122
|
});
|
|
@@ -214,141 +135,33 @@ var deletedTraditionalContentStyleUnbounded = (0, _lazyNodeView.convertToInlineC
|
|
|
214
135
|
pointerEvents: 'none',
|
|
215
136
|
zIndex: 1
|
|
216
137
|
});
|
|
217
|
-
var
|
|
218
|
-
display: 'inline-flex',
|
|
219
|
-
boxSizing: 'border-box',
|
|
220
|
-
position: 'static',
|
|
221
|
-
blockSize: 'min-content',
|
|
222
|
-
borderRadius: "var(--ds-radius-small, 4px)",
|
|
223
|
-
overflow: 'hidden',
|
|
224
|
-
paddingInlineStart: "var(--ds-space-050, 4px)",
|
|
225
|
-
paddingInlineEnd: "var(--ds-space-050, 4px)",
|
|
226
|
-
backgroundColor: "var(--ds-background-accent-gray-subtler, #DCDFE4)",
|
|
227
|
-
font: "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
|
|
228
|
-
fontWeight: "var(--ds-font-weight-bold, 700)",
|
|
229
|
-
textOverflow: 'ellipsis',
|
|
230
|
-
whiteSpace: 'nowrap',
|
|
231
|
-
color: "var(--ds-text-warning-inverse, #172B4D)"
|
|
232
|
-
});
|
|
233
|
-
var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colourScheme) {
|
|
138
|
+
var getDeletedContentStyleUnbounded = exports.getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colourScheme) {
|
|
234
139
|
return colourScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
|
|
235
140
|
};
|
|
236
|
-
var getDeletedContentStyle = function getDeletedContentStyle(colourScheme) {
|
|
141
|
+
var getDeletedContentStyle = exports.getDeletedContentStyle = function getDeletedContentStyle(colourScheme) {
|
|
237
142
|
return colourScheme === 'traditional' ? deletedTraditionalContentStyle : deletedContentStyle;
|
|
238
143
|
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
var borderTopRightRadius;
|
|
246
|
-
var borderTopLeftRadius;
|
|
247
|
-
if (['expand', 'decisionList'].includes(nodeName || '')) {
|
|
248
|
-
borderTopRightRadius = "var(--ds-radius-small, 4px)";
|
|
249
|
-
} else if (['panel', 'codeBlock'].includes(nodeName || '')) {
|
|
250
|
-
borderTopRightRadius = "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)");
|
|
251
|
-
} else if (nodeName === 'mediaSingle') {
|
|
252
|
-
borderTopLeftRadius = "var(--ds-radius-small, 4px)";
|
|
253
|
-
}
|
|
254
|
-
var containerStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
255
|
-
position: 'absolute',
|
|
256
|
-
top: nodeName === 'mediaSingle' ? "var(--ds-space-300, 24px)" : "var(--ds-space-0, 0px)",
|
|
257
|
-
right: nodeName === 'mediaSingle' ? undefined : "var(--ds-space-0, 0px)",
|
|
258
|
-
left: nodeName === 'mediaSingle' ? "var(--ds-space-0, 0px)" : undefined,
|
|
259
|
-
zIndex: 2,
|
|
260
|
-
pointerEvents: 'none',
|
|
261
|
-
display: 'flex',
|
|
262
|
-
overflow: 'hidden',
|
|
263
|
-
borderTopRightRadius: borderTopRightRadius,
|
|
264
|
-
borderTopLeftRadius: borderTopLeftRadius
|
|
265
|
-
});
|
|
266
|
-
container.setAttribute('style', containerStyle);
|
|
267
|
-
container.setAttribute('data-testid', 'show-diff-removed-lozenge');
|
|
268
|
-
|
|
269
|
-
// Create vanilla HTML lozenge element with Atlaskit Lozenge styling (visual refresh)
|
|
270
|
-
var lozengeElement = document.createElement('span');
|
|
271
|
-
lozengeElement.setAttribute('style', lozengeStyle);
|
|
272
|
-
lozengeElement.textContent = intl.formatMessage(_messages.trackChangesMessages.removed).toUpperCase();
|
|
273
|
-
container.appendChild(lozengeElement);
|
|
274
|
-
return container;
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Wraps a block node in a container with relative positioning to support absolute positioned lozenge
|
|
279
|
-
*/
|
|
280
|
-
var createBlockNodeWrapper = function createBlockNodeWrapper(nodeName) {
|
|
281
|
-
var wrapper = document.createElement('div');
|
|
282
|
-
var fitContent = shouldFitContentWidth(nodeName);
|
|
283
|
-
var baseStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
284
|
-
position: 'relative',
|
|
285
|
-
display: fitContent ? 'inline-block' : 'block',
|
|
286
|
-
width: fitContent ? 'fit-content' : undefined,
|
|
287
|
-
height: fitContent ? 'fit-content' : undefined,
|
|
288
|
-
opacity: 1
|
|
289
|
-
});
|
|
290
|
-
wrapper.setAttribute('style', baseStyle);
|
|
291
|
-
return wrapper;
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
|
|
296
|
-
*/
|
|
297
|
-
var createDeletedStyleWrapperWithoutOpacity = function createDeletedStyleWrapperWithoutOpacity(colourScheme) {
|
|
298
|
-
var wrapper = document.createElement('span');
|
|
299
|
-
wrapper.setAttribute('style', getDeletedContentStyle(colourScheme));
|
|
300
|
-
return wrapper;
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Applies deleted styles directly to an HTML element by merging with existing styles
|
|
305
|
-
*/
|
|
306
|
-
var applyDeletedStylesToElement = function applyDeletedStylesToElement(element, targetNode, colourScheme) {
|
|
307
|
-
var currentStyle = element.getAttribute('style') || '';
|
|
308
|
-
var deletedContentStyle = getDeletedContentStyle(colourScheme);
|
|
309
|
-
var nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name) || '';
|
|
310
|
-
element.setAttribute('style', "".concat(currentStyle).concat(deletedContentStyle).concat(nodeSpecificStyle));
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Appends a block node with wrapper, lozenge, and appropriate styling
|
|
315
|
-
*/
|
|
316
|
-
var appendBlockNodeWithWrapper = function appendBlockNodeWithWrapper(dom, nodeView, targetNode, colourScheme, intl) {
|
|
317
|
-
var blockWrapper = createBlockNodeWrapper(targetNode.type.name);
|
|
318
|
-
if (shouldShowRemovedLozenge(targetNode.type.name)) {
|
|
319
|
-
var lozenge = createRemovedLozenge(intl, targetNode.type.name);
|
|
320
|
-
blockWrapper.append(lozenge);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// Wrap the nodeView in a content wrapper that has the opacity style AND the box-shadow
|
|
324
|
-
// This keeps the lozenge at full opacity while the content AND border are faded
|
|
325
|
-
var contentWrapper = document.createElement('div');
|
|
326
|
-
var nodeStyle = getDeletedStyleNode(targetNode.type.name);
|
|
327
|
-
contentWrapper.setAttribute('style', "".concat(getDeletedContentStyle(colourScheme)).concat(nodeStyle || ''));
|
|
328
|
-
contentWrapper.append(nodeView);
|
|
329
|
-
blockWrapper.append(contentWrapper);
|
|
330
|
-
if (nodeView instanceof HTMLElement) {
|
|
331
|
-
if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
332
|
-
nodeView.classList.add('show-diff-deleted-node');
|
|
333
|
-
}
|
|
144
|
+
var getNodeClass = function getNodeClass(name) {
|
|
145
|
+
switch (name) {
|
|
146
|
+
case 'extension':
|
|
147
|
+
return 'show-diff-changed-decoration-node';
|
|
148
|
+
default:
|
|
149
|
+
return undefined;
|
|
334
150
|
}
|
|
335
|
-
dom.append(blockWrapper);
|
|
336
151
|
};
|
|
337
152
|
|
|
338
153
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
154
|
+
* Inline decoration used for insertions as the content already exists in the document
|
|
155
|
+
*
|
|
156
|
+
* @param change Changeset "change" containing information about the change content + range
|
|
157
|
+
* @returns Prosemirror inline decoration
|
|
342
158
|
*/
|
|
343
|
-
var
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
// Use wrapper approach for other block nodes
|
|
350
|
-
appendBlockNodeWithWrapper(dom, nodeView, targetNode, colourScheme, intl);
|
|
351
|
-
}
|
|
159
|
+
var createBlockChangedDecoration = exports.createBlockChangedDecoration = function createBlockChangedDecoration(change, colourScheme) {
|
|
160
|
+
return _view.Decoration.node(change.from, change.to, {
|
|
161
|
+
style: getEditorStyleNode(change.name, colourScheme),
|
|
162
|
+
'data-testid': 'show-diff-changed-decoration-node',
|
|
163
|
+
class: getNodeClass(change.name)
|
|
164
|
+
}, {});
|
|
352
165
|
};
|
|
353
166
|
var createDeletedContentDecoration = exports.createDeletedContentDecoration = function createDeletedContentDecoration(_ref) {
|
|
354
167
|
var change = _ref.change,
|
|
@@ -491,7 +304,7 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
491
304
|
dom.append(wrapper);
|
|
492
305
|
} else if ((0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta_2')) {
|
|
493
306
|
// Handle all block nodes with unified function
|
|
494
|
-
handleBlockNodeView(dom, nodeView, targetNode, colourScheme, intl);
|
|
307
|
+
(0, _deletedBlocksHandler.handleBlockNodeView)(dom, nodeView, targetNode, colourScheme, intl);
|
|
495
308
|
} else {
|
|
496
309
|
dom.append(nodeView);
|
|
497
310
|
}
|
|
@@ -502,7 +315,7 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
502
315
|
var fallbackNode = fallbackSerialization();
|
|
503
316
|
if (fallbackNode) {
|
|
504
317
|
if ((0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta_2')) {
|
|
505
|
-
var _wrapper2 = createDeletedStyleWrapperWithoutOpacity(colourScheme);
|
|
318
|
+
var _wrapper2 = (0, _deletedBlocksHandler.createDeletedStyleWrapperWithoutOpacity)(colourScheme);
|
|
506
319
|
_wrapper2.append(fallbackNode);
|
|
507
320
|
dom.append(_wrapper2);
|
|
508
321
|
} else {
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shouldShowRemovedLozenge = exports.shouldApplyDeletedStylesDirectly = exports.shouldAddShowDiffDeletedNodeClass = exports.handleMediaSingleWithLozenge = exports.handleBlockNodeView = exports.getDeletedStyleNode = exports.deletedStyleQuoteNode = exports.deletedBlockOutlineRounded = exports.deletedBlockOutline = exports.createRemovedLozenge = exports.createDeletedStyleWrapperWithoutOpacity = exports.createBlockNodeWrapper = exports.createBlockNodeContentWrapper = exports.applyDeletedStylesToElement = exports.appendBlockNodeWithWrapper = void 0;
|
|
7
|
+
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
8
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
9
|
+
var _decorations = require("./decorations");
|
|
10
|
+
var deletedStyleQuoteNode = exports.deletedStyleQuoteNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
11
|
+
borderLeft: "2px solid ".concat("var(--ds-border-accent-gray, #7D818A)")
|
|
12
|
+
});
|
|
13
|
+
var deletedBlockOutline = exports.deletedBlockOutline = (0, _lazyNodeView.convertToInlineCss)({
|
|
14
|
+
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #7D818A)"),
|
|
15
|
+
borderRadius: "var(--ds-radius-small, 4px)"
|
|
16
|
+
});
|
|
17
|
+
var deletedBlockOutlineRounded = exports.deletedBlockOutlineRounded = (0, _lazyNodeView.convertToInlineCss)({
|
|
18
|
+
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #7D818A)"),
|
|
19
|
+
borderRadius: "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)")
|
|
20
|
+
});
|
|
21
|
+
var lozengeStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
22
|
+
display: 'inline-flex',
|
|
23
|
+
boxSizing: 'border-box',
|
|
24
|
+
position: 'static',
|
|
25
|
+
blockSize: 'min-content',
|
|
26
|
+
borderRadius: "var(--ds-radius-small, 4px)",
|
|
27
|
+
overflow: 'hidden',
|
|
28
|
+
paddingInlineStart: "var(--ds-space-050, 4px)",
|
|
29
|
+
paddingInlineEnd: "var(--ds-space-050, 4px)",
|
|
30
|
+
backgroundColor: "var(--ds-background-accent-gray-subtler, #DDDEE1)",
|
|
31
|
+
font: "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
|
|
32
|
+
fontWeight: "var(--ds-font-weight-bold, 700)",
|
|
33
|
+
textOverflow: 'ellipsis',
|
|
34
|
+
whiteSpace: 'nowrap',
|
|
35
|
+
color: "var(--ds-text-warning-inverse, #292A2E)"
|
|
36
|
+
});
|
|
37
|
+
var getDeletedStyleNode = exports.getDeletedStyleNode = function getDeletedStyleNode(nodeName) {
|
|
38
|
+
switch (nodeName) {
|
|
39
|
+
case 'blockquote':
|
|
40
|
+
return deletedStyleQuoteNode;
|
|
41
|
+
case 'expand':
|
|
42
|
+
case 'decisionList':
|
|
43
|
+
return deletedBlockOutline;
|
|
44
|
+
case 'panel':
|
|
45
|
+
case 'codeBlock':
|
|
46
|
+
return deletedBlockOutlineRounded;
|
|
47
|
+
default:
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var shouldShowRemovedLozenge = exports.shouldShowRemovedLozenge = function shouldShowRemovedLozenge(nodeName) {
|
|
52
|
+
switch (nodeName) {
|
|
53
|
+
case 'expand':
|
|
54
|
+
case 'codeBlock':
|
|
55
|
+
case 'mediaSingle':
|
|
56
|
+
case 'panel':
|
|
57
|
+
case 'decisionList':
|
|
58
|
+
return true;
|
|
59
|
+
default:
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var shouldAddShowDiffDeletedNodeClass = exports.shouldAddShowDiffDeletedNodeClass = function shouldAddShowDiffDeletedNodeClass(nodeName) {
|
|
64
|
+
switch (nodeName) {
|
|
65
|
+
case 'mediaSingle':
|
|
66
|
+
case 'embedCard':
|
|
67
|
+
return true;
|
|
68
|
+
default:
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Checks if a node should apply deleted styles directly without wrapper
|
|
75
|
+
* to preserve natural block-level margins
|
|
76
|
+
*/
|
|
77
|
+
var shouldApplyDeletedStylesDirectly = exports.shouldApplyDeletedStylesDirectly = function shouldApplyDeletedStylesDirectly(nodeName) {
|
|
78
|
+
return nodeName === 'blockquote' || nodeName === 'heading';
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Creates a "Removed" lozenge to be displayed at the top right corner of deleted block nodes
|
|
83
|
+
*/
|
|
84
|
+
var createRemovedLozenge = exports.createRemovedLozenge = function createRemovedLozenge(intl, nodeName) {
|
|
85
|
+
var container = document.createElement('span');
|
|
86
|
+
var borderTopRightRadius;
|
|
87
|
+
if (['expand', 'decisionList'].includes(nodeName || '')) {
|
|
88
|
+
borderTopRightRadius = "var(--ds-radius-small, 4px)";
|
|
89
|
+
} else if (['panel', 'codeBlock', 'mediaSingle'].includes(nodeName || '')) {
|
|
90
|
+
borderTopRightRadius = "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)");
|
|
91
|
+
}
|
|
92
|
+
var containerStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
93
|
+
position: 'absolute',
|
|
94
|
+
top: "var(--ds-space-0, 0px)",
|
|
95
|
+
right: "var(--ds-space-0, 0px)",
|
|
96
|
+
zIndex: 2,
|
|
97
|
+
pointerEvents: 'none',
|
|
98
|
+
display: 'flex',
|
|
99
|
+
overflow: 'hidden',
|
|
100
|
+
borderTopRightRadius: borderTopRightRadius
|
|
101
|
+
});
|
|
102
|
+
container.setAttribute('style', containerStyle);
|
|
103
|
+
container.setAttribute('data-testid', 'show-diff-removed-lozenge');
|
|
104
|
+
|
|
105
|
+
// Create vanilla HTML lozenge element with Atlaskit Lozenge styling (visual refresh)
|
|
106
|
+
var lozengeElement = document.createElement('span');
|
|
107
|
+
lozengeElement.setAttribute('style', lozengeStyle);
|
|
108
|
+
lozengeElement.textContent = intl.formatMessage(_messages.trackChangesMessages.removed).toUpperCase();
|
|
109
|
+
container.appendChild(lozengeElement);
|
|
110
|
+
return container;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Wraps a block node in a container with relative positioning to support absolute positioned lozenge
|
|
115
|
+
*/
|
|
116
|
+
var createBlockNodeWrapper = exports.createBlockNodeWrapper = function createBlockNodeWrapper(nodeName) {
|
|
117
|
+
var wrapper = document.createElement('div');
|
|
118
|
+
var baseStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
119
|
+
position: 'relative',
|
|
120
|
+
display: 'block',
|
|
121
|
+
opacity: 1
|
|
122
|
+
});
|
|
123
|
+
wrapper.setAttribute('style', baseStyle);
|
|
124
|
+
return wrapper;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
|
|
129
|
+
*/
|
|
130
|
+
var createDeletedStyleWrapperWithoutOpacity = exports.createDeletedStyleWrapperWithoutOpacity = function createDeletedStyleWrapperWithoutOpacity(colourScheme) {
|
|
131
|
+
var wrapper = document.createElement('span');
|
|
132
|
+
wrapper.setAttribute('style', (0, _decorations.getDeletedContentStyle)(colourScheme));
|
|
133
|
+
return wrapper;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Applies deleted styles directly to an HTML element by merging with existing styles
|
|
138
|
+
*/
|
|
139
|
+
var applyDeletedStylesToElement = exports.applyDeletedStylesToElement = function applyDeletedStylesToElement(element, targetNode, colourScheme) {
|
|
140
|
+
var currentStyle = element.getAttribute('style') || '';
|
|
141
|
+
var deletedContentStyle = (0, _decorations.getDeletedContentStyle)(colourScheme);
|
|
142
|
+
var nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name) || '';
|
|
143
|
+
element.setAttribute('style', "".concat(currentStyle).concat(deletedContentStyle).concat(nodeSpecificStyle));
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Creates a content wrapper with deleted styles for a block node
|
|
148
|
+
*/
|
|
149
|
+
var createBlockNodeContentWrapper = exports.createBlockNodeContentWrapper = function createBlockNodeContentWrapper(nodeView, targetNode, colourScheme) {
|
|
150
|
+
var contentWrapper = document.createElement('div');
|
|
151
|
+
var nodeStyle = getDeletedStyleNode(targetNode.type.name);
|
|
152
|
+
contentWrapper.setAttribute('style', "".concat((0, _decorations.getDeletedContentStyle)(colourScheme)).concat(nodeStyle || ''));
|
|
153
|
+
contentWrapper.append(nodeView);
|
|
154
|
+
return contentWrapper;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Handles special mediaSingle node rendering with lozenge on child media element
|
|
159
|
+
* @returns true if mediaSingle was handled, false otherwise
|
|
160
|
+
*/
|
|
161
|
+
var handleMediaSingleWithLozenge = exports.handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge) {
|
|
162
|
+
if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
var mediaNode = nodeView.querySelector('[data-prosemirror-node-name="media"]');
|
|
166
|
+
if (!mediaNode || !(mediaNode instanceof HTMLElement)) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Add relative positioning to media node to anchor lozenge
|
|
171
|
+
var currentStyle = mediaNode.getAttribute('style') || '';
|
|
172
|
+
var relativePositionStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
173
|
+
position: 'relative'
|
|
174
|
+
});
|
|
175
|
+
mediaNode.setAttribute('style', "".concat(currentStyle).concat(relativePositionStyle));
|
|
176
|
+
mediaNode.append(lozenge);
|
|
177
|
+
|
|
178
|
+
// Add deleted node class if needed
|
|
179
|
+
if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
180
|
+
nodeView.classList.add('show-diff-deleted-node');
|
|
181
|
+
}
|
|
182
|
+
dom.append(nodeView);
|
|
183
|
+
return true;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Appends a block node with wrapper, lozenge, and appropriate styling
|
|
188
|
+
*/
|
|
189
|
+
var appendBlockNodeWithWrapper = exports.appendBlockNodeWithWrapper = function appendBlockNodeWithWrapper(dom, nodeView, targetNode, colourScheme, intl) {
|
|
190
|
+
var blockWrapper = createBlockNodeWrapper(targetNode.type.name);
|
|
191
|
+
if (shouldShowRemovedLozenge(targetNode.type.name)) {
|
|
192
|
+
var lozenge = createRemovedLozenge(intl, targetNode.type.name);
|
|
193
|
+
if (handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
blockWrapper.append(lozenge);
|
|
197
|
+
}
|
|
198
|
+
var contentWrapper = createBlockNodeContentWrapper(nodeView, targetNode, colourScheme);
|
|
199
|
+
blockWrapper.append(contentWrapper);
|
|
200
|
+
if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
201
|
+
nodeView.classList.add('show-diff-deleted-node');
|
|
202
|
+
}
|
|
203
|
+
dom.append(blockWrapper);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Handles all block node rendering with appropriate deleted styling.
|
|
208
|
+
* For blockquote and heading nodes, applies styles directly to preserve natural margins.
|
|
209
|
+
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
210
|
+
*/
|
|
211
|
+
var handleBlockNodeView = exports.handleBlockNodeView = function handleBlockNodeView(dom, nodeView, targetNode, colourScheme, intl) {
|
|
212
|
+
if (shouldApplyDeletedStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
|
|
213
|
+
// Apply deleted styles directly to preserve natural block-level margins
|
|
214
|
+
applyDeletedStylesToElement(nodeView, targetNode, colourScheme);
|
|
215
|
+
dom.append(nodeView);
|
|
216
|
+
} else {
|
|
217
|
+
// Use wrapper approach for other block nodes
|
|
218
|
+
appendBlockNodeWithWrapper(dom, nodeView, targetNode, colourScheme, intl);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
@@ -16,7 +16,7 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
16
16
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
17
17
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
18
18
|
var deletedRowStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
19
|
-
color: "var(--ds-text-accent-gray, #
|
|
19
|
+
color: "var(--ds-text-accent-gray, #505258)",
|
|
20
20
|
textDecoration: 'line-through',
|
|
21
21
|
opacity: 0.6,
|
|
22
22
|
display: 'table-row'
|