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