@atlaskit/editor-plugin-show-diff 14.2.1 → 14.2.2
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 +9 -0
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +4 -1
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +19 -5
- package/dist/cjs/pm-plugins/decorations/utils/getAttrChangeRanges.js +2 -2
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +129 -66
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +1 -0
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +17 -5
- package/dist/es2019/pm-plugins/decorations/utils/getAttrChangeRanges.js +1 -1
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +67 -3
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +3 -0
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +19 -5
- package/dist/esm/pm-plugins/decorations/utils/getAttrChangeRanges.js +1 -1
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +129 -66
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +4 -0
- package/dist/types/pm-plugins/decorations/utils/getAttrChangeRanges.d.ts +1 -0
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 14.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`2c226f2acb3be`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2c226f2acb3be) -
|
|
8
|
+
Preserve complete block wrappers for multi-inline-node suggestion diffs while continuing to render
|
|
9
|
+
open slice boundaries as fragments behind platform_editor_ai_show_diff_patch_1.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 14.2.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.createInlineChangedDecoration = void 0;
|
|
7
|
+
exports.getAtomicInlineChangedAttrs = exports.createInlineChangedDecoration = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
@@ -97,6 +97,9 @@ var resolveAtomicInlineAttrs = function resolveAtomicInlineAttrs(inlineNodeName,
|
|
|
97
97
|
styleSuffix: ''
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
|
+
var getAtomicInlineChangedAttrs = exports.getAtomicInlineChangedAttrs = function getAtomicInlineChangedAttrs(inlineNodeName, colorScheme) {
|
|
101
|
+
return resolveAtomicInlineAttrs(inlineNodeName, colorScheme, getColorScheme(colorScheme));
|
|
102
|
+
};
|
|
100
103
|
|
|
101
104
|
/**
|
|
102
105
|
* Inline decoration used for insertions as the content already exists in the document
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.createNodeChangedDecorationWidget = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
10
|
+
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
10
11
|
var _isExtendedEnabled = require("../isExtendedEnabled");
|
|
11
12
|
var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
|
|
12
13
|
var _createChangedRowDecorationWidgets = require("./createChangedRowDecorationWidgets");
|
|
@@ -212,6 +213,11 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
212
213
|
}
|
|
213
214
|
var diffId = crypto.randomUUID();
|
|
214
215
|
var decorations = [];
|
|
216
|
+
var replacementNode = newDoc.nodeAt(change.fromB);
|
|
217
|
+
var firstReplacedNode = slice.content.firstChild;
|
|
218
|
+
var lastReplacedNode = slice.content.lastChild;
|
|
219
|
+
var showDiffPatch1 = (0, _fg.fg)('platform_editor_ai_show_diff_patch_1');
|
|
220
|
+
var isCompleteSameTypeReplacement = slice.content.childCount === 1 && firstReplacedNode !== null && replacementNode !== null && firstReplacedNode.type === replacementNode.type && replacementNode.nodeSize === change.toB - change.fromB;
|
|
215
221
|
|
|
216
222
|
/*
|
|
217
223
|
* The thinking is we separate out the fragment we got from doc.slice
|
|
@@ -219,9 +225,14 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
219
225
|
* or sliced End depth is and match only the entire node.
|
|
220
226
|
*/
|
|
221
227
|
slice.content.forEach(function (node) {
|
|
228
|
+
var isFirst = firstReplacedNode === node;
|
|
229
|
+
var isLast = lastReplacedNode === node;
|
|
230
|
+
var isOpenAtSliceBoundary = isFirst && slice.openStart > 0 || isLast && slice.openEnd > 0;
|
|
231
|
+
var shouldPreserveCompleteMultiInlineBlock = showDiffPatch1 && node.isBlock && node.type.inlineContent && node.content.childCount > 1 && !isOpenAtSliceBoundary && isCompleteSameTypeReplacement;
|
|
232
|
+
|
|
222
233
|
// Helper function to handle multiple child nodes
|
|
223
234
|
var handleMultipleChildNodes = function handleMultipleChildNodes(node) {
|
|
224
|
-
if (node.content.childCount > 1 && node.type.inlineContent) {
|
|
235
|
+
if (!shouldPreserveCompleteMultiInlineBlock && node.content.childCount > 1 && node.type.inlineContent) {
|
|
225
236
|
node.content.forEach(function (childNode) {
|
|
226
237
|
var childNodeView = serializer.tryCreateNodeView(childNode);
|
|
227
238
|
if (childNodeView) {
|
|
@@ -246,14 +257,16 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
246
257
|
};
|
|
247
258
|
|
|
248
259
|
// Determine which node to use and how to serialize
|
|
249
|
-
var isFirst = slice.content.firstChild === node;
|
|
250
|
-
var isLast = slice.content.lastChild === node;
|
|
251
260
|
var hasInlineContent = node.content.childCount > 0 && node.type.inlineContent === true;
|
|
252
261
|
var fallbackSerialization;
|
|
253
262
|
if (handleMultipleChildNodes(node)) {
|
|
254
263
|
return;
|
|
255
264
|
}
|
|
256
|
-
if (
|
|
265
|
+
if (shouldPreserveCompleteMultiInlineBlock) {
|
|
266
|
+
fallbackSerialization = function fallbackSerialization() {
|
|
267
|
+
return serializer.serializeNode(node);
|
|
268
|
+
};
|
|
269
|
+
} else if ((isFirst || isLast && slice.content.childCount > 2) && hasInlineContent) {
|
|
257
270
|
fallbackSerialization = function fallbackSerialization() {
|
|
258
271
|
return serializer.serializeFragment(node.content);
|
|
259
272
|
};
|
|
@@ -293,7 +306,8 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
293
306
|
isActive: isActive,
|
|
294
307
|
isInserted: isInserted,
|
|
295
308
|
diffType: diffType,
|
|
296
|
-
hideAddedDiffsUnderline: hideAddedDiffsUnderline
|
|
309
|
+
hideAddedDiffsUnderline: hideAddedDiffsUnderline,
|
|
310
|
+
highlightInlineLeafNodes: shouldPreserveCompleteMultiInlineBlock
|
|
297
311
|
});
|
|
298
312
|
}
|
|
299
313
|
} else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.stepIsValidAttrChange = exports.getAttrChangeRanges = void 0;
|
|
7
|
+
exports.stepIsValidAttrChange = exports.isInlineAttrChangeNodeName = exports.getAttrChangeRanges = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
10
10
|
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
@@ -37,7 +37,7 @@ var inlineNodeAttrMap = {
|
|
|
37
37
|
mention: mentionAttrs,
|
|
38
38
|
status: statusAttrs
|
|
39
39
|
};
|
|
40
|
-
var isInlineAttrChangeNodeName = function isInlineAttrChangeNodeName(nodeName) {
|
|
40
|
+
var isInlineAttrChangeNodeName = exports.isInlineAttrChangeNodeName = function isInlineAttrChangeNodeName(nodeName) {
|
|
41
41
|
return nodeName in inlineNodeAttrMap;
|
|
42
42
|
};
|
|
43
43
|
|
|
@@ -12,7 +12,9 @@ var _nodeTypeUtils = require("@atlaskit/editor-common/utils/node-type-utils");
|
|
|
12
12
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
13
13
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
14
|
var _isExtendedEnabled = require("../../isExtendedEnabled");
|
|
15
|
+
var _createInlineChangedDecoration = require("../createInlineChangedDecoration");
|
|
15
16
|
var _tableCellEdgeAttrs = require("./tableCellEdgeAttrs");
|
|
17
|
+
var _getAttrChangeRanges = require("./getAttrChangeRanges");
|
|
16
18
|
var _wrapBlockNodeViewStyles = require("./wrapBlockNodeViewStyles");
|
|
17
19
|
var shouldShowRemovedLozenge = function shouldShowRemovedLozenge(nodeName) {
|
|
18
20
|
switch (nodeName) {
|
|
@@ -233,15 +235,65 @@ var applyMultiContainerLikeStyles = function applyMultiContainerLikeStyles(_ref6
|
|
|
233
235
|
}
|
|
234
236
|
element.setAttribute('style', "".concat(currentStyle, ";").concat(nodeSpecificStyle));
|
|
235
237
|
};
|
|
236
|
-
var
|
|
238
|
+
var combineStyles = function combineStyles(currentStyle, appendedStyle) {
|
|
239
|
+
var separator = currentStyle && appendedStyle && !currentStyle.trimEnd().endsWith(';') ? '; ' : '';
|
|
240
|
+
return "".concat(currentStyle).concat(separator).concat(appendedStyle);
|
|
241
|
+
};
|
|
242
|
+
var appendStyleToElement = function appendStyleToElement(element, style) {
|
|
243
|
+
var currentStyle = element.getAttribute('style') || '';
|
|
244
|
+
element.setAttribute('style', combineStyles(currentStyle, style));
|
|
245
|
+
};
|
|
246
|
+
var wrapAtomicInlineNode = function wrapAtomicInlineNode(_ref7) {
|
|
237
247
|
var element = _ref7.element,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
248
|
+
className = _ref7.className,
|
|
249
|
+
style = _ref7.style;
|
|
250
|
+
var wrapper = document.createElement('span');
|
|
251
|
+
wrapper.className = className;
|
|
252
|
+
wrapper.setAttribute('style', style);
|
|
253
|
+
element.replaceWith(wrapper);
|
|
254
|
+
wrapper.append(element);
|
|
255
|
+
};
|
|
256
|
+
var applyInlineLeafNodeStyles = function applyInlineLeafNodeStyles(_ref8) {
|
|
257
|
+
var element = _ref8.element,
|
|
258
|
+
targetNode = _ref8.targetNode,
|
|
259
|
+
contentStyle = _ref8.contentStyle,
|
|
260
|
+
colorScheme = _ref8.colorScheme;
|
|
261
|
+
// NodeViewSerializer appends one DOM node per direct ProseMirror child, preserving order.
|
|
262
|
+
var childDomNodes = (0, _toConsumableArray2.default)(element.childNodes);
|
|
263
|
+
targetNode.content.forEach(function (childNode, _offset, index) {
|
|
264
|
+
if (childNode.isText || !childNode.isLeaf) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
var childElement = childDomNodes[index];
|
|
268
|
+
if (!(childElement instanceof HTMLElement)) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (!(0, _getAttrChangeRanges.isInlineAttrChangeNodeName)(childNode.type.name)) {
|
|
272
|
+
appendStyleToElement(childElement, contentStyle);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
var _getAtomicInlineChang = (0, _createInlineChangedDecoration.getAtomicInlineChangedAttrs)(childNode.type.name, colorScheme),
|
|
276
|
+
className = _getAtomicInlineChang.className,
|
|
277
|
+
styleSuffix = _getAtomicInlineChang.styleSuffix;
|
|
278
|
+
// Inline decorations use an outer span so node-specific descendant selectors match.
|
|
279
|
+
wrapAtomicInlineNode({
|
|
280
|
+
element: childElement,
|
|
281
|
+
className: className,
|
|
282
|
+
style: combineStyles(contentStyle, styleSuffix)
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
var applyTextLikeBlockNodeStyles = function applyTextLikeBlockNodeStyles(_ref9) {
|
|
287
|
+
var element = _ref9.element,
|
|
288
|
+
targetNode = _ref9.targetNode,
|
|
289
|
+
colorScheme = _ref9.colorScheme,
|
|
290
|
+
isActive = _ref9.isActive,
|
|
291
|
+
isInserted = _ref9.isInserted,
|
|
292
|
+
diffType = _ref9.diffType,
|
|
293
|
+
_ref9$hideAddedDiffsU = _ref9.hideAddedDiffsUnderline,
|
|
294
|
+
hideAddedDiffsUnderline = _ref9$hideAddedDiffsU === void 0 ? false : _ref9$hideAddedDiffsU,
|
|
295
|
+
_ref9$highlightInline = _ref9.highlightInlineLeafNodes,
|
|
296
|
+
highlightInlineLeafNodes = _ref9$highlightInline === void 0 ? false : _ref9$highlightInline;
|
|
245
297
|
var currentStyle = element.getAttribute('style') || '';
|
|
246
298
|
var nodeSpecificStyle = (0, _wrapBlockNodeViewStyles.getChangedNodeStyle)(targetNode.type.name, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) || '';
|
|
247
299
|
if (nodeSpecificStyle) {
|
|
@@ -263,20 +315,28 @@ var applyTextLikeBlockNodeStyles = function applyTextLikeBlockNodeStyles(_ref7)
|
|
|
263
315
|
textNode.replaceWith(contentWrapper);
|
|
264
316
|
contentWrapper.append(textNode);
|
|
265
317
|
});
|
|
318
|
+
if (highlightInlineLeafNodes && targetNode.type.inlineContent) {
|
|
319
|
+
applyInlineLeafNodeStyles({
|
|
320
|
+
element: element,
|
|
321
|
+
targetNode: targetNode,
|
|
322
|
+
contentStyle: contentStyle,
|
|
323
|
+
colorScheme: colorScheme
|
|
324
|
+
});
|
|
325
|
+
}
|
|
266
326
|
};
|
|
267
327
|
|
|
268
328
|
/**
|
|
269
329
|
* Creates a content wrapper with deleted styles for a block node
|
|
270
330
|
*/
|
|
271
|
-
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(
|
|
272
|
-
var nodeView =
|
|
273
|
-
targetNode =
|
|
274
|
-
colorScheme =
|
|
275
|
-
isActive =
|
|
276
|
-
isInserted =
|
|
277
|
-
diffType =
|
|
278
|
-
|
|
279
|
-
hideAddedDiffsUnderline =
|
|
331
|
+
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref0) {
|
|
332
|
+
var nodeView = _ref0.nodeView,
|
|
333
|
+
targetNode = _ref0.targetNode,
|
|
334
|
+
colorScheme = _ref0.colorScheme,
|
|
335
|
+
isActive = _ref0.isActive,
|
|
336
|
+
isInserted = _ref0.isInserted,
|
|
337
|
+
diffType = _ref0.diffType,
|
|
338
|
+
_ref0$hideAddedDiffsU = _ref0.hideAddedDiffsUnderline,
|
|
339
|
+
hideAddedDiffsUnderline = _ref0$hideAddedDiffsU === void 0 ? false : _ref0$hideAddedDiffsU;
|
|
280
340
|
var contentWrapper = document.createElement('div');
|
|
281
341
|
var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
|
|
282
342
|
var nodeStyle = (0, _wrapBlockNodeViewStyles.getChangedNodeStyle)(targetNodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline);
|
|
@@ -297,14 +357,14 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref8
|
|
|
297
357
|
* to wait for the rich-media-item to appear before attaching the lozenge.
|
|
298
358
|
* @returns true if embedCard was handled
|
|
299
359
|
*/
|
|
300
|
-
var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(
|
|
301
|
-
var dom =
|
|
302
|
-
nodeView =
|
|
303
|
-
targetNode =
|
|
304
|
-
lozenge =
|
|
305
|
-
colorScheme =
|
|
306
|
-
|
|
307
|
-
isActive =
|
|
360
|
+
var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref1) {
|
|
361
|
+
var dom = _ref1.dom,
|
|
362
|
+
nodeView = _ref1.nodeView,
|
|
363
|
+
targetNode = _ref1.targetNode,
|
|
364
|
+
lozenge = _ref1.lozenge,
|
|
365
|
+
colorScheme = _ref1.colorScheme,
|
|
366
|
+
_ref1$isActive = _ref1.isActive,
|
|
367
|
+
isActive = _ref1$isActive === void 0 ? false : _ref1$isActive;
|
|
308
368
|
if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
|
|
309
369
|
return false;
|
|
310
370
|
}
|
|
@@ -340,14 +400,14 @@ var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref9) {
|
|
|
340
400
|
* Handles special mediaSingle node rendering with lozenge on child media element
|
|
341
401
|
* @returns true if mediaSingle was handled, false otherwise
|
|
342
402
|
*/
|
|
343
|
-
var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(
|
|
344
|
-
var dom =
|
|
345
|
-
nodeView =
|
|
346
|
-
targetNode =
|
|
347
|
-
lozenge =
|
|
348
|
-
colorScheme =
|
|
349
|
-
|
|
350
|
-
isActive =
|
|
403
|
+
var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref10) {
|
|
404
|
+
var dom = _ref10.dom,
|
|
405
|
+
nodeView = _ref10.nodeView,
|
|
406
|
+
targetNode = _ref10.targetNode,
|
|
407
|
+
lozenge = _ref10.lozenge,
|
|
408
|
+
colorScheme = _ref10.colorScheme,
|
|
409
|
+
_ref10$isActive = _ref10.isActive,
|
|
410
|
+
isActive = _ref10$isActive === void 0 ? false : _ref10$isActive;
|
|
351
411
|
if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
|
|
352
412
|
return false;
|
|
353
413
|
}
|
|
@@ -380,19 +440,19 @@ var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref0)
|
|
|
380
440
|
/**
|
|
381
441
|
* Appends a block node with wrapper, lozenge, and appropriate styling
|
|
382
442
|
*/
|
|
383
|
-
var wrapBlockNode = function wrapBlockNode(
|
|
384
|
-
var dom =
|
|
385
|
-
nodeView =
|
|
386
|
-
targetNode =
|
|
387
|
-
colorScheme =
|
|
388
|
-
intl =
|
|
389
|
-
|
|
390
|
-
isActive =
|
|
391
|
-
|
|
392
|
-
isInserted =
|
|
393
|
-
diffType =
|
|
394
|
-
|
|
395
|
-
hideAddedDiffsUnderline =
|
|
443
|
+
var wrapBlockNode = function wrapBlockNode(_ref11) {
|
|
444
|
+
var dom = _ref11.dom,
|
|
445
|
+
nodeView = _ref11.nodeView,
|
|
446
|
+
targetNode = _ref11.targetNode,
|
|
447
|
+
colorScheme = _ref11.colorScheme,
|
|
448
|
+
intl = _ref11.intl,
|
|
449
|
+
_ref11$isActive = _ref11.isActive,
|
|
450
|
+
isActive = _ref11$isActive === void 0 ? false : _ref11$isActive,
|
|
451
|
+
_ref11$isInserted = _ref11.isInserted,
|
|
452
|
+
isInserted = _ref11$isInserted === void 0 ? false : _ref11$isInserted,
|
|
453
|
+
diffType = _ref11.diffType,
|
|
454
|
+
_ref11$hideAddedDiffs = _ref11.hideAddedDiffsUnderline,
|
|
455
|
+
hideAddedDiffsUnderline = _ref11$hideAddedDiffs === void 0 ? false : _ref11$hideAddedDiffs;
|
|
396
456
|
var blockWrapper = createBlockNodeWrapper();
|
|
397
457
|
var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
|
|
398
458
|
if (shouldShowRemovedLozenge(targetNodeName) && (!(0, _isExtendedEnabled.isExtendedEnabled)(diffType) || !isInserted)) {
|
|
@@ -445,19 +505,21 @@ var wrapBlockNode = function wrapBlockNode(_ref1) {
|
|
|
445
505
|
* For heading nodes, applies styles directly to preserve natural margins.
|
|
446
506
|
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
447
507
|
*/
|
|
448
|
-
var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(
|
|
449
|
-
var dom =
|
|
450
|
-
nodeView =
|
|
451
|
-
targetNode =
|
|
452
|
-
colorScheme =
|
|
453
|
-
intl =
|
|
454
|
-
|
|
455
|
-
isActive =
|
|
456
|
-
|
|
457
|
-
isInserted =
|
|
458
|
-
diffType =
|
|
459
|
-
|
|
460
|
-
hideAddedDiffsUnderline =
|
|
508
|
+
var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_ref12) {
|
|
509
|
+
var dom = _ref12.dom,
|
|
510
|
+
nodeView = _ref12.nodeView,
|
|
511
|
+
targetNode = _ref12.targetNode,
|
|
512
|
+
colorScheme = _ref12.colorScheme,
|
|
513
|
+
intl = _ref12.intl,
|
|
514
|
+
_ref12$isActive = _ref12.isActive,
|
|
515
|
+
isActive = _ref12$isActive === void 0 ? false : _ref12$isActive,
|
|
516
|
+
_ref12$isInserted = _ref12.isInserted,
|
|
517
|
+
isInserted = _ref12$isInserted === void 0 ? false : _ref12$isInserted,
|
|
518
|
+
diffType = _ref12.diffType,
|
|
519
|
+
_ref12$hideAddedDiffs = _ref12.hideAddedDiffsUnderline,
|
|
520
|
+
hideAddedDiffsUnderline = _ref12$hideAddedDiffs === void 0 ? false : _ref12$hideAddedDiffs,
|
|
521
|
+
_ref12$highlightInlin = _ref12.highlightInlineLeafNodes,
|
|
522
|
+
highlightInlineLeafNodes = _ref12$highlightInlin === void 0 ? false : _ref12$highlightInlin;
|
|
461
523
|
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
462
524
|
if (nodeView instanceof HTMLElement) {
|
|
463
525
|
if (isInserted && (0, _wrapBlockNodeViewStyles.isMultiContainerBlockNode)(targetNode.type.name)) {
|
|
@@ -481,7 +543,8 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
|
|
|
481
543
|
isActive: isActive,
|
|
482
544
|
isInserted: isInserted,
|
|
483
545
|
diffType: diffType,
|
|
484
|
-
hideAddedDiffsUnderline: hideAddedDiffsUnderline
|
|
546
|
+
hideAddedDiffsUnderline: hideAddedDiffsUnderline,
|
|
547
|
+
highlightInlineLeafNodes: highlightInlineLeafNodes
|
|
485
548
|
});
|
|
486
549
|
dom.append(nodeView);
|
|
487
550
|
return;
|
|
@@ -546,12 +609,12 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
|
|
|
546
609
|
* CSS backgrounds don't work when applied to a wrapper around a paragraph, so
|
|
547
610
|
* the wrapper needs to be injected inside the node around the child content.
|
|
548
611
|
*/
|
|
549
|
-
var injectInnerWrapper = exports.injectInnerWrapper = function injectInnerWrapper(
|
|
550
|
-
var node =
|
|
551
|
-
colorScheme =
|
|
552
|
-
isActive =
|
|
553
|
-
isInserted =
|
|
554
|
-
diffType =
|
|
612
|
+
var injectInnerWrapper = exports.injectInnerWrapper = function injectInnerWrapper(_ref13) {
|
|
613
|
+
var node = _ref13.node,
|
|
614
|
+
colorScheme = _ref13.colorScheme,
|
|
615
|
+
isActive = _ref13.isActive,
|
|
616
|
+
isInserted = _ref13.isInserted,
|
|
617
|
+
diffType = _ref13.diffType;
|
|
555
618
|
var wrapper = document.createElement('span');
|
|
556
619
|
wrapper.setAttribute('style', isInserted ? (0, _wrapBlockNodeViewStyles.getInsertedContentStyle)(colorScheme, isActive) : (0, _wrapBlockNodeViewStyles.getDeletedContentStyle)(colorScheme, isActive, diffType));
|
|
557
620
|
(0, _toConsumableArray2.default)(node.childNodes).forEach(function (child) {
|
|
@@ -82,6 +82,7 @@ const resolveAtomicInlineAttrs = (inlineNodeName, colorScheme, colors) => isExpe
|
|
|
82
82
|
className: getAtomicInlineNodeClassNameLegacy(inlineNodeName, getLegacyColorScheme(colorScheme)),
|
|
83
83
|
styleSuffix: ''
|
|
84
84
|
};
|
|
85
|
+
export const getAtomicInlineChangedAttrs = (inlineNodeName, colorScheme) => resolveAtomicInlineAttrs(inlineNodeName, colorScheme, getColorScheme(colorScheme));
|
|
85
86
|
|
|
86
87
|
/**
|
|
87
88
|
* Inline decoration used for insertions as the content already exists in the document
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
2
3
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
3
4
|
import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
4
5
|
import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
|
|
@@ -197,6 +198,11 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
197
198
|
}
|
|
198
199
|
const diffId = crypto.randomUUID();
|
|
199
200
|
const decorations = [];
|
|
201
|
+
const replacementNode = newDoc.nodeAt(change.fromB);
|
|
202
|
+
const firstReplacedNode = slice.content.firstChild;
|
|
203
|
+
const lastReplacedNode = slice.content.lastChild;
|
|
204
|
+
const showDiffPatch1 = fg('platform_editor_ai_show_diff_patch_1');
|
|
205
|
+
const isCompleteSameTypeReplacement = slice.content.childCount === 1 && firstReplacedNode !== null && replacementNode !== null && firstReplacedNode.type === replacementNode.type && replacementNode.nodeSize === change.toB - change.fromB;
|
|
200
206
|
|
|
201
207
|
/*
|
|
202
208
|
* The thinking is we separate out the fragment we got from doc.slice
|
|
@@ -204,9 +210,14 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
204
210
|
* or sliced End depth is and match only the entire node.
|
|
205
211
|
*/
|
|
206
212
|
slice.content.forEach(node => {
|
|
213
|
+
const isFirst = firstReplacedNode === node;
|
|
214
|
+
const isLast = lastReplacedNode === node;
|
|
215
|
+
const isOpenAtSliceBoundary = isFirst && slice.openStart > 0 || isLast && slice.openEnd > 0;
|
|
216
|
+
const shouldPreserveCompleteMultiInlineBlock = showDiffPatch1 && node.isBlock && node.type.inlineContent && node.content.childCount > 1 && !isOpenAtSliceBoundary && isCompleteSameTypeReplacement;
|
|
217
|
+
|
|
207
218
|
// Helper function to handle multiple child nodes
|
|
208
219
|
const handleMultipleChildNodes = node => {
|
|
209
|
-
if (node.content.childCount > 1 && node.type.inlineContent) {
|
|
220
|
+
if (!shouldPreserveCompleteMultiInlineBlock && node.content.childCount > 1 && node.type.inlineContent) {
|
|
210
221
|
node.content.forEach(childNode => {
|
|
211
222
|
const childNodeView = serializer.tryCreateNodeView(childNode);
|
|
212
223
|
if (childNodeView) {
|
|
@@ -231,14 +242,14 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
231
242
|
};
|
|
232
243
|
|
|
233
244
|
// Determine which node to use and how to serialize
|
|
234
|
-
const isFirst = slice.content.firstChild === node;
|
|
235
|
-
const isLast = slice.content.lastChild === node;
|
|
236
245
|
const hasInlineContent = node.content.childCount > 0 && node.type.inlineContent === true;
|
|
237
246
|
let fallbackSerialization;
|
|
238
247
|
if (handleMultipleChildNodes(node)) {
|
|
239
248
|
return;
|
|
240
249
|
}
|
|
241
|
-
if (
|
|
250
|
+
if (shouldPreserveCompleteMultiInlineBlock) {
|
|
251
|
+
fallbackSerialization = () => serializer.serializeNode(node);
|
|
252
|
+
} else if ((isFirst || isLast && slice.content.childCount > 2) && hasInlineContent) {
|
|
242
253
|
fallbackSerialization = () => serializer.serializeFragment(node.content);
|
|
243
254
|
} else if (isLast && slice.content.childCount === 2) {
|
|
244
255
|
fallbackSerialization = () => {
|
|
@@ -274,7 +285,8 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
274
285
|
isActive,
|
|
275
286
|
isInserted,
|
|
276
287
|
diffType,
|
|
277
|
-
hideAddedDiffsUnderline
|
|
288
|
+
hideAddedDiffsUnderline,
|
|
289
|
+
highlightInlineLeafNodes: shouldPreserveCompleteMultiInlineBlock
|
|
278
290
|
});
|
|
279
291
|
}
|
|
280
292
|
} else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
|
|
@@ -25,7 +25,7 @@ const inlineNodeAttrMap = {
|
|
|
25
25
|
mention: mentionAttrs,
|
|
26
26
|
status: statusAttrs
|
|
27
27
|
};
|
|
28
|
-
const isInlineAttrChangeNodeName = nodeName => nodeName in inlineNodeAttrMap;
|
|
28
|
+
export const isInlineAttrChangeNodeName = nodeName => nodeName in inlineNodeAttrMap;
|
|
29
29
|
|
|
30
30
|
// Extension node type names. Their "any attr except localId" exclude rule lives
|
|
31
31
|
// in the shared `diffableAttrs` map and is applied via `isDiffableAttr` below.
|
|
@@ -4,7 +4,9 @@ import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-uti
|
|
|
4
4
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
5
5
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
6
|
import { isExtendedEnabled } from '../../isExtendedEnabled';
|
|
7
|
+
import { getAtomicInlineChangedAttrs } from '../createInlineChangedDecoration';
|
|
7
8
|
import { applyTableCellEdgeAttrs } from './tableCellEdgeAttrs';
|
|
9
|
+
import { isInlineAttrChangeNodeName } from './getAttrChangeRanges';
|
|
8
10
|
import { getChangedContentStyle, getChangedNodeStyle, getDeletedContentStyle, getDeletedContentStyleUnbounded, getInsertedContentStyle, hasRestingDeletedRing, isMultiContainerBlockNode, isTextLikeBlockNode, resolveCellOverlayStyle, resolveDeletedNodeCSSVariables, resolveNestedInsertedNodeStyle, resolveRemovedLozengeStyle } from './wrapBlockNodeViewStyles';
|
|
9
11
|
const shouldShowRemovedLozenge = nodeName => {
|
|
10
12
|
switch (nodeName) {
|
|
@@ -222,6 +224,57 @@ const applyMultiContainerLikeStyles = ({
|
|
|
222
224
|
}
|
|
223
225
|
element.setAttribute('style', `${currentStyle};${nodeSpecificStyle}`);
|
|
224
226
|
};
|
|
227
|
+
const combineStyles = (currentStyle, appendedStyle) => {
|
|
228
|
+
const separator = currentStyle && appendedStyle && !currentStyle.trimEnd().endsWith(';') ? '; ' : '';
|
|
229
|
+
return `${currentStyle}${separator}${appendedStyle}`;
|
|
230
|
+
};
|
|
231
|
+
const appendStyleToElement = (element, style) => {
|
|
232
|
+
const currentStyle = element.getAttribute('style') || '';
|
|
233
|
+
element.setAttribute('style', combineStyles(currentStyle, style));
|
|
234
|
+
};
|
|
235
|
+
const wrapAtomicInlineNode = ({
|
|
236
|
+
element,
|
|
237
|
+
className,
|
|
238
|
+
style
|
|
239
|
+
}) => {
|
|
240
|
+
const wrapper = document.createElement('span');
|
|
241
|
+
wrapper.className = className;
|
|
242
|
+
wrapper.setAttribute('style', style);
|
|
243
|
+
element.replaceWith(wrapper);
|
|
244
|
+
wrapper.append(element);
|
|
245
|
+
};
|
|
246
|
+
const applyInlineLeafNodeStyles = ({
|
|
247
|
+
element,
|
|
248
|
+
targetNode,
|
|
249
|
+
contentStyle,
|
|
250
|
+
colorScheme
|
|
251
|
+
}) => {
|
|
252
|
+
// NodeViewSerializer appends one DOM node per direct ProseMirror child, preserving order.
|
|
253
|
+
const childDomNodes = [...element.childNodes];
|
|
254
|
+
targetNode.content.forEach((childNode, _offset, index) => {
|
|
255
|
+
if (childNode.isText || !childNode.isLeaf) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const childElement = childDomNodes[index];
|
|
259
|
+
if (!(childElement instanceof HTMLElement)) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (!isInlineAttrChangeNodeName(childNode.type.name)) {
|
|
263
|
+
appendStyleToElement(childElement, contentStyle);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const {
|
|
267
|
+
className,
|
|
268
|
+
styleSuffix
|
|
269
|
+
} = getAtomicInlineChangedAttrs(childNode.type.name, colorScheme);
|
|
270
|
+
// Inline decorations use an outer span so node-specific descendant selectors match.
|
|
271
|
+
wrapAtomicInlineNode({
|
|
272
|
+
element: childElement,
|
|
273
|
+
className,
|
|
274
|
+
style: combineStyles(contentStyle, styleSuffix)
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
};
|
|
225
278
|
const applyTextLikeBlockNodeStyles = ({
|
|
226
279
|
element,
|
|
227
280
|
targetNode,
|
|
@@ -229,7 +282,8 @@ const applyTextLikeBlockNodeStyles = ({
|
|
|
229
282
|
isActive,
|
|
230
283
|
isInserted,
|
|
231
284
|
diffType,
|
|
232
|
-
hideAddedDiffsUnderline = false
|
|
285
|
+
hideAddedDiffsUnderline = false,
|
|
286
|
+
highlightInlineLeafNodes = false
|
|
233
287
|
}) => {
|
|
234
288
|
const currentStyle = element.getAttribute('style') || '';
|
|
235
289
|
const nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) || '';
|
|
@@ -252,6 +306,14 @@ const applyTextLikeBlockNodeStyles = ({
|
|
|
252
306
|
textNode.replaceWith(contentWrapper);
|
|
253
307
|
contentWrapper.append(textNode);
|
|
254
308
|
});
|
|
309
|
+
if (highlightInlineLeafNodes && targetNode.type.inlineContent) {
|
|
310
|
+
applyInlineLeafNodeStyles({
|
|
311
|
+
element,
|
|
312
|
+
targetNode,
|
|
313
|
+
contentStyle,
|
|
314
|
+
colorScheme
|
|
315
|
+
});
|
|
316
|
+
}
|
|
255
317
|
};
|
|
256
318
|
|
|
257
319
|
/**
|
|
@@ -441,7 +503,8 @@ export const wrapBlockNodeView = ({
|
|
|
441
503
|
isActive = false,
|
|
442
504
|
isInserted = false,
|
|
443
505
|
diffType,
|
|
444
|
-
hideAddedDiffsUnderline = false
|
|
506
|
+
hideAddedDiffsUnderline = false,
|
|
507
|
+
highlightInlineLeafNodes = false
|
|
445
508
|
}) => {
|
|
446
509
|
if (isExtendedEnabled(diffType)) {
|
|
447
510
|
if (nodeView instanceof HTMLElement) {
|
|
@@ -466,7 +529,8 @@ export const wrapBlockNodeView = ({
|
|
|
466
529
|
isActive,
|
|
467
530
|
isInserted,
|
|
468
531
|
diffType,
|
|
469
|
-
hideAddedDiffsUnderline
|
|
532
|
+
hideAddedDiffsUnderline,
|
|
533
|
+
highlightInlineLeafNodes
|
|
470
534
|
});
|
|
471
535
|
dom.append(nodeView);
|
|
472
536
|
return;
|
|
@@ -90,6 +90,9 @@ var resolveAtomicInlineAttrs = function resolveAtomicInlineAttrs(inlineNodeName,
|
|
|
90
90
|
styleSuffix: ''
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
|
+
export var getAtomicInlineChangedAttrs = function getAtomicInlineChangedAttrs(inlineNodeName, colorScheme) {
|
|
94
|
+
return resolveAtomicInlineAttrs(inlineNodeName, colorScheme, getColorScheme(colorScheme));
|
|
95
|
+
};
|
|
93
96
|
|
|
94
97
|
/**
|
|
95
98
|
* Inline decoration used for insertions as the content already exists in the document
|
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
5
6
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
6
7
|
import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
7
8
|
import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
|
|
@@ -205,6 +206,11 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
205
206
|
}
|
|
206
207
|
var diffId = crypto.randomUUID();
|
|
207
208
|
var decorations = [];
|
|
209
|
+
var replacementNode = newDoc.nodeAt(change.fromB);
|
|
210
|
+
var firstReplacedNode = slice.content.firstChild;
|
|
211
|
+
var lastReplacedNode = slice.content.lastChild;
|
|
212
|
+
var showDiffPatch1 = fg('platform_editor_ai_show_diff_patch_1');
|
|
213
|
+
var isCompleteSameTypeReplacement = slice.content.childCount === 1 && firstReplacedNode !== null && replacementNode !== null && firstReplacedNode.type === replacementNode.type && replacementNode.nodeSize === change.toB - change.fromB;
|
|
208
214
|
|
|
209
215
|
/*
|
|
210
216
|
* The thinking is we separate out the fragment we got from doc.slice
|
|
@@ -212,9 +218,14 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
212
218
|
* or sliced End depth is and match only the entire node.
|
|
213
219
|
*/
|
|
214
220
|
slice.content.forEach(function (node) {
|
|
221
|
+
var isFirst = firstReplacedNode === node;
|
|
222
|
+
var isLast = lastReplacedNode === node;
|
|
223
|
+
var isOpenAtSliceBoundary = isFirst && slice.openStart > 0 || isLast && slice.openEnd > 0;
|
|
224
|
+
var shouldPreserveCompleteMultiInlineBlock = showDiffPatch1 && node.isBlock && node.type.inlineContent && node.content.childCount > 1 && !isOpenAtSliceBoundary && isCompleteSameTypeReplacement;
|
|
225
|
+
|
|
215
226
|
// Helper function to handle multiple child nodes
|
|
216
227
|
var handleMultipleChildNodes = function handleMultipleChildNodes(node) {
|
|
217
|
-
if (node.content.childCount > 1 && node.type.inlineContent) {
|
|
228
|
+
if (!shouldPreserveCompleteMultiInlineBlock && node.content.childCount > 1 && node.type.inlineContent) {
|
|
218
229
|
node.content.forEach(function (childNode) {
|
|
219
230
|
var childNodeView = serializer.tryCreateNodeView(childNode);
|
|
220
231
|
if (childNodeView) {
|
|
@@ -239,14 +250,16 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
239
250
|
};
|
|
240
251
|
|
|
241
252
|
// Determine which node to use and how to serialize
|
|
242
|
-
var isFirst = slice.content.firstChild === node;
|
|
243
|
-
var isLast = slice.content.lastChild === node;
|
|
244
253
|
var hasInlineContent = node.content.childCount > 0 && node.type.inlineContent === true;
|
|
245
254
|
var fallbackSerialization;
|
|
246
255
|
if (handleMultipleChildNodes(node)) {
|
|
247
256
|
return;
|
|
248
257
|
}
|
|
249
|
-
if (
|
|
258
|
+
if (shouldPreserveCompleteMultiInlineBlock) {
|
|
259
|
+
fallbackSerialization = function fallbackSerialization() {
|
|
260
|
+
return serializer.serializeNode(node);
|
|
261
|
+
};
|
|
262
|
+
} else if ((isFirst || isLast && slice.content.childCount > 2) && hasInlineContent) {
|
|
250
263
|
fallbackSerialization = function fallbackSerialization() {
|
|
251
264
|
return serializer.serializeFragment(node.content);
|
|
252
265
|
};
|
|
@@ -286,7 +299,8 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
286
299
|
isActive: isActive,
|
|
287
300
|
isInserted: isInserted,
|
|
288
301
|
diffType: diffType,
|
|
289
|
-
hideAddedDiffsUnderline: hideAddedDiffsUnderline
|
|
302
|
+
hideAddedDiffsUnderline: hideAddedDiffsUnderline,
|
|
303
|
+
highlightInlineLeafNodes: shouldPreserveCompleteMultiInlineBlock
|
|
290
304
|
});
|
|
291
305
|
}
|
|
292
306
|
} else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
|
|
@@ -30,7 +30,7 @@ var inlineNodeAttrMap = {
|
|
|
30
30
|
mention: mentionAttrs,
|
|
31
31
|
status: statusAttrs
|
|
32
32
|
};
|
|
33
|
-
var isInlineAttrChangeNodeName = function isInlineAttrChangeNodeName(nodeName) {
|
|
33
|
+
export var isInlineAttrChangeNodeName = function isInlineAttrChangeNodeName(nodeName) {
|
|
34
34
|
return nodeName in inlineNodeAttrMap;
|
|
35
35
|
};
|
|
36
36
|
|
|
@@ -5,7 +5,9 @@ import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-uti
|
|
|
5
5
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
6
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
7
|
import { isExtendedEnabled } from '../../isExtendedEnabled';
|
|
8
|
+
import { getAtomicInlineChangedAttrs } from '../createInlineChangedDecoration';
|
|
8
9
|
import { applyTableCellEdgeAttrs } from './tableCellEdgeAttrs';
|
|
10
|
+
import { isInlineAttrChangeNodeName } from './getAttrChangeRanges';
|
|
9
11
|
import { getChangedContentStyle, getChangedNodeStyle, getDeletedContentStyle, getDeletedContentStyleUnbounded, getInsertedContentStyle, hasRestingDeletedRing, isMultiContainerBlockNode, isTextLikeBlockNode, resolveCellOverlayStyle, resolveDeletedNodeCSSVariables, resolveNestedInsertedNodeStyle, resolveRemovedLozengeStyle } from './wrapBlockNodeViewStyles';
|
|
10
12
|
var shouldShowRemovedLozenge = function shouldShowRemovedLozenge(nodeName) {
|
|
11
13
|
switch (nodeName) {
|
|
@@ -226,15 +228,65 @@ var applyMultiContainerLikeStyles = function applyMultiContainerLikeStyles(_ref6
|
|
|
226
228
|
}
|
|
227
229
|
element.setAttribute('style', "".concat(currentStyle, ";").concat(nodeSpecificStyle));
|
|
228
230
|
};
|
|
229
|
-
var
|
|
231
|
+
var combineStyles = function combineStyles(currentStyle, appendedStyle) {
|
|
232
|
+
var separator = currentStyle && appendedStyle && !currentStyle.trimEnd().endsWith(';') ? '; ' : '';
|
|
233
|
+
return "".concat(currentStyle).concat(separator).concat(appendedStyle);
|
|
234
|
+
};
|
|
235
|
+
var appendStyleToElement = function appendStyleToElement(element, style) {
|
|
236
|
+
var currentStyle = element.getAttribute('style') || '';
|
|
237
|
+
element.setAttribute('style', combineStyles(currentStyle, style));
|
|
238
|
+
};
|
|
239
|
+
var wrapAtomicInlineNode = function wrapAtomicInlineNode(_ref7) {
|
|
230
240
|
var element = _ref7.element,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
241
|
+
className = _ref7.className,
|
|
242
|
+
style = _ref7.style;
|
|
243
|
+
var wrapper = document.createElement('span');
|
|
244
|
+
wrapper.className = className;
|
|
245
|
+
wrapper.setAttribute('style', style);
|
|
246
|
+
element.replaceWith(wrapper);
|
|
247
|
+
wrapper.append(element);
|
|
248
|
+
};
|
|
249
|
+
var applyInlineLeafNodeStyles = function applyInlineLeafNodeStyles(_ref8) {
|
|
250
|
+
var element = _ref8.element,
|
|
251
|
+
targetNode = _ref8.targetNode,
|
|
252
|
+
contentStyle = _ref8.contentStyle,
|
|
253
|
+
colorScheme = _ref8.colorScheme;
|
|
254
|
+
// NodeViewSerializer appends one DOM node per direct ProseMirror child, preserving order.
|
|
255
|
+
var childDomNodes = _toConsumableArray(element.childNodes);
|
|
256
|
+
targetNode.content.forEach(function (childNode, _offset, index) {
|
|
257
|
+
if (childNode.isText || !childNode.isLeaf) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
var childElement = childDomNodes[index];
|
|
261
|
+
if (!(childElement instanceof HTMLElement)) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (!isInlineAttrChangeNodeName(childNode.type.name)) {
|
|
265
|
+
appendStyleToElement(childElement, contentStyle);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
var _getAtomicInlineChang = getAtomicInlineChangedAttrs(childNode.type.name, colorScheme),
|
|
269
|
+
className = _getAtomicInlineChang.className,
|
|
270
|
+
styleSuffix = _getAtomicInlineChang.styleSuffix;
|
|
271
|
+
// Inline decorations use an outer span so node-specific descendant selectors match.
|
|
272
|
+
wrapAtomicInlineNode({
|
|
273
|
+
element: childElement,
|
|
274
|
+
className: className,
|
|
275
|
+
style: combineStyles(contentStyle, styleSuffix)
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
var applyTextLikeBlockNodeStyles = function applyTextLikeBlockNodeStyles(_ref9) {
|
|
280
|
+
var element = _ref9.element,
|
|
281
|
+
targetNode = _ref9.targetNode,
|
|
282
|
+
colorScheme = _ref9.colorScheme,
|
|
283
|
+
isActive = _ref9.isActive,
|
|
284
|
+
isInserted = _ref9.isInserted,
|
|
285
|
+
diffType = _ref9.diffType,
|
|
286
|
+
_ref9$hideAddedDiffsU = _ref9.hideAddedDiffsUnderline,
|
|
287
|
+
hideAddedDiffsUnderline = _ref9$hideAddedDiffsU === void 0 ? false : _ref9$hideAddedDiffsU,
|
|
288
|
+
_ref9$highlightInline = _ref9.highlightInlineLeafNodes,
|
|
289
|
+
highlightInlineLeafNodes = _ref9$highlightInline === void 0 ? false : _ref9$highlightInline;
|
|
238
290
|
var currentStyle = element.getAttribute('style') || '';
|
|
239
291
|
var nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) || '';
|
|
240
292
|
if (nodeSpecificStyle) {
|
|
@@ -256,20 +308,28 @@ var applyTextLikeBlockNodeStyles = function applyTextLikeBlockNodeStyles(_ref7)
|
|
|
256
308
|
textNode.replaceWith(contentWrapper);
|
|
257
309
|
contentWrapper.append(textNode);
|
|
258
310
|
});
|
|
311
|
+
if (highlightInlineLeafNodes && targetNode.type.inlineContent) {
|
|
312
|
+
applyInlineLeafNodeStyles({
|
|
313
|
+
element: element,
|
|
314
|
+
targetNode: targetNode,
|
|
315
|
+
contentStyle: contentStyle,
|
|
316
|
+
colorScheme: colorScheme
|
|
317
|
+
});
|
|
318
|
+
}
|
|
259
319
|
};
|
|
260
320
|
|
|
261
321
|
/**
|
|
262
322
|
* Creates a content wrapper with deleted styles for a block node
|
|
263
323
|
*/
|
|
264
|
-
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(
|
|
265
|
-
var nodeView =
|
|
266
|
-
targetNode =
|
|
267
|
-
colorScheme =
|
|
268
|
-
isActive =
|
|
269
|
-
isInserted =
|
|
270
|
-
diffType =
|
|
271
|
-
|
|
272
|
-
hideAddedDiffsUnderline =
|
|
324
|
+
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref0) {
|
|
325
|
+
var nodeView = _ref0.nodeView,
|
|
326
|
+
targetNode = _ref0.targetNode,
|
|
327
|
+
colorScheme = _ref0.colorScheme,
|
|
328
|
+
isActive = _ref0.isActive,
|
|
329
|
+
isInserted = _ref0.isInserted,
|
|
330
|
+
diffType = _ref0.diffType,
|
|
331
|
+
_ref0$hideAddedDiffsU = _ref0.hideAddedDiffsUnderline,
|
|
332
|
+
hideAddedDiffsUnderline = _ref0$hideAddedDiffsU === void 0 ? false : _ref0$hideAddedDiffsU;
|
|
273
333
|
var contentWrapper = document.createElement('div');
|
|
274
334
|
var targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
|
|
275
335
|
var nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline);
|
|
@@ -290,14 +350,14 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref8
|
|
|
290
350
|
* to wait for the rich-media-item to appear before attaching the lozenge.
|
|
291
351
|
* @returns true if embedCard was handled
|
|
292
352
|
*/
|
|
293
|
-
var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(
|
|
294
|
-
var dom =
|
|
295
|
-
nodeView =
|
|
296
|
-
targetNode =
|
|
297
|
-
lozenge =
|
|
298
|
-
colorScheme =
|
|
299
|
-
|
|
300
|
-
isActive =
|
|
353
|
+
var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref1) {
|
|
354
|
+
var dom = _ref1.dom,
|
|
355
|
+
nodeView = _ref1.nodeView,
|
|
356
|
+
targetNode = _ref1.targetNode,
|
|
357
|
+
lozenge = _ref1.lozenge,
|
|
358
|
+
colorScheme = _ref1.colorScheme,
|
|
359
|
+
_ref1$isActive = _ref1.isActive,
|
|
360
|
+
isActive = _ref1$isActive === void 0 ? false : _ref1$isActive;
|
|
301
361
|
if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
|
|
302
362
|
return false;
|
|
303
363
|
}
|
|
@@ -333,14 +393,14 @@ var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref9) {
|
|
|
333
393
|
* Handles special mediaSingle node rendering with lozenge on child media element
|
|
334
394
|
* @returns true if mediaSingle was handled, false otherwise
|
|
335
395
|
*/
|
|
336
|
-
var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(
|
|
337
|
-
var dom =
|
|
338
|
-
nodeView =
|
|
339
|
-
targetNode =
|
|
340
|
-
lozenge =
|
|
341
|
-
colorScheme =
|
|
342
|
-
|
|
343
|
-
isActive =
|
|
396
|
+
var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref10) {
|
|
397
|
+
var dom = _ref10.dom,
|
|
398
|
+
nodeView = _ref10.nodeView,
|
|
399
|
+
targetNode = _ref10.targetNode,
|
|
400
|
+
lozenge = _ref10.lozenge,
|
|
401
|
+
colorScheme = _ref10.colorScheme,
|
|
402
|
+
_ref10$isActive = _ref10.isActive,
|
|
403
|
+
isActive = _ref10$isActive === void 0 ? false : _ref10$isActive;
|
|
344
404
|
if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
|
|
345
405
|
return false;
|
|
346
406
|
}
|
|
@@ -373,19 +433,19 @@ var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref0)
|
|
|
373
433
|
/**
|
|
374
434
|
* Appends a block node with wrapper, lozenge, and appropriate styling
|
|
375
435
|
*/
|
|
376
|
-
var wrapBlockNode = function wrapBlockNode(
|
|
377
|
-
var dom =
|
|
378
|
-
nodeView =
|
|
379
|
-
targetNode =
|
|
380
|
-
colorScheme =
|
|
381
|
-
intl =
|
|
382
|
-
|
|
383
|
-
isActive =
|
|
384
|
-
|
|
385
|
-
isInserted =
|
|
386
|
-
diffType =
|
|
387
|
-
|
|
388
|
-
hideAddedDiffsUnderline =
|
|
436
|
+
var wrapBlockNode = function wrapBlockNode(_ref11) {
|
|
437
|
+
var dom = _ref11.dom,
|
|
438
|
+
nodeView = _ref11.nodeView,
|
|
439
|
+
targetNode = _ref11.targetNode,
|
|
440
|
+
colorScheme = _ref11.colorScheme,
|
|
441
|
+
intl = _ref11.intl,
|
|
442
|
+
_ref11$isActive = _ref11.isActive,
|
|
443
|
+
isActive = _ref11$isActive === void 0 ? false : _ref11$isActive,
|
|
444
|
+
_ref11$isInserted = _ref11.isInserted,
|
|
445
|
+
isInserted = _ref11$isInserted === void 0 ? false : _ref11$isInserted,
|
|
446
|
+
diffType = _ref11.diffType,
|
|
447
|
+
_ref11$hideAddedDiffs = _ref11.hideAddedDiffsUnderline,
|
|
448
|
+
hideAddedDiffsUnderline = _ref11$hideAddedDiffs === void 0 ? false : _ref11$hideAddedDiffs;
|
|
389
449
|
var blockWrapper = createBlockNodeWrapper();
|
|
390
450
|
var targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
|
|
391
451
|
if (shouldShowRemovedLozenge(targetNodeName) && (!isExtendedEnabled(diffType) || !isInserted)) {
|
|
@@ -438,19 +498,21 @@ var wrapBlockNode = function wrapBlockNode(_ref1) {
|
|
|
438
498
|
* For heading nodes, applies styles directly to preserve natural margins.
|
|
439
499
|
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
440
500
|
*/
|
|
441
|
-
export var wrapBlockNodeView = function wrapBlockNodeView(
|
|
442
|
-
var dom =
|
|
443
|
-
nodeView =
|
|
444
|
-
targetNode =
|
|
445
|
-
colorScheme =
|
|
446
|
-
intl =
|
|
447
|
-
|
|
448
|
-
isActive =
|
|
449
|
-
|
|
450
|
-
isInserted =
|
|
451
|
-
diffType =
|
|
452
|
-
|
|
453
|
-
hideAddedDiffsUnderline =
|
|
501
|
+
export var wrapBlockNodeView = function wrapBlockNodeView(_ref12) {
|
|
502
|
+
var dom = _ref12.dom,
|
|
503
|
+
nodeView = _ref12.nodeView,
|
|
504
|
+
targetNode = _ref12.targetNode,
|
|
505
|
+
colorScheme = _ref12.colorScheme,
|
|
506
|
+
intl = _ref12.intl,
|
|
507
|
+
_ref12$isActive = _ref12.isActive,
|
|
508
|
+
isActive = _ref12$isActive === void 0 ? false : _ref12$isActive,
|
|
509
|
+
_ref12$isInserted = _ref12.isInserted,
|
|
510
|
+
isInserted = _ref12$isInserted === void 0 ? false : _ref12$isInserted,
|
|
511
|
+
diffType = _ref12.diffType,
|
|
512
|
+
_ref12$hideAddedDiffs = _ref12.hideAddedDiffsUnderline,
|
|
513
|
+
hideAddedDiffsUnderline = _ref12$hideAddedDiffs === void 0 ? false : _ref12$hideAddedDiffs,
|
|
514
|
+
_ref12$highlightInlin = _ref12.highlightInlineLeafNodes,
|
|
515
|
+
highlightInlineLeafNodes = _ref12$highlightInlin === void 0 ? false : _ref12$highlightInlin;
|
|
454
516
|
if (isExtendedEnabled(diffType)) {
|
|
455
517
|
if (nodeView instanceof HTMLElement) {
|
|
456
518
|
if (isInserted && isMultiContainerBlockNode(targetNode.type.name)) {
|
|
@@ -474,7 +536,8 @@ export var wrapBlockNodeView = function wrapBlockNodeView(_ref10) {
|
|
|
474
536
|
isActive: isActive,
|
|
475
537
|
isInserted: isInserted,
|
|
476
538
|
diffType: diffType,
|
|
477
|
-
hideAddedDiffsUnderline: hideAddedDiffsUnderline
|
|
539
|
+
hideAddedDiffsUnderline: hideAddedDiffsUnderline,
|
|
540
|
+
highlightInlineLeafNodes: highlightInlineLeafNodes
|
|
478
541
|
});
|
|
479
542
|
dom.append(nodeView);
|
|
480
543
|
return;
|
|
@@ -539,12 +602,12 @@ export var wrapBlockNodeView = function wrapBlockNodeView(_ref10) {
|
|
|
539
602
|
* CSS backgrounds don't work when applied to a wrapper around a paragraph, so
|
|
540
603
|
* the wrapper needs to be injected inside the node around the child content.
|
|
541
604
|
*/
|
|
542
|
-
export var injectInnerWrapper = function injectInnerWrapper(
|
|
543
|
-
var node =
|
|
544
|
-
colorScheme =
|
|
545
|
-
isActive =
|
|
546
|
-
isInserted =
|
|
547
|
-
diffType =
|
|
605
|
+
export var injectInnerWrapper = function injectInnerWrapper(_ref13) {
|
|
606
|
+
var node = _ref13.node,
|
|
607
|
+
colorScheme = _ref13.colorScheme,
|
|
608
|
+
isActive = _ref13.isActive,
|
|
609
|
+
isInserted = _ref13.isInserted,
|
|
610
|
+
diffType = _ref13.diffType;
|
|
548
611
|
var wrapper = document.createElement('span');
|
|
549
612
|
wrapper.setAttribute('style', isInserted ? getInsertedContentStyle(colorScheme, isActive) : getDeletedContentStyle(colorScheme, isActive, diffType));
|
|
550
613
|
_toConsumableArray(node.childNodes).forEach(function (child) {
|
|
@@ -3,6 +3,10 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
3
3
|
import type { DiffType } from '../../showDiffPluginType';
|
|
4
4
|
import type { ColorScheme } from './colorSchemes/types';
|
|
5
5
|
import type { InlineAttrChangeNodeName } from './utils/getAttrChangeRanges';
|
|
6
|
+
export declare const getAtomicInlineChangedAttrs: (inlineNodeName: InlineAttrChangeNodeName, colorScheme: ColorScheme | undefined) => {
|
|
7
|
+
className: string;
|
|
8
|
+
styleSuffix: string;
|
|
9
|
+
};
|
|
6
10
|
/**
|
|
7
11
|
* Inline decoration used for insertions as the content already exists in the document
|
|
8
12
|
*
|
|
@@ -26,6 +26,7 @@ type StepRange = {
|
|
|
26
26
|
toA?: number;
|
|
27
27
|
toB: number;
|
|
28
28
|
};
|
|
29
|
+
export declare const isInlineAttrChangeNodeName: (nodeName: string) => nodeName is InlineAttrChangeNodeName;
|
|
29
30
|
export declare const getAttrChangeRanges: (doc: PMNode, attrStepContexts: AttrStepContext[], originalDoc: PMNode) => StepRange[];
|
|
30
31
|
/**
|
|
31
32
|
* Check if the step was a valid attr change and affected the doc
|
|
@@ -7,11 +7,12 @@ import type { ColorScheme } from '../colorSchemes/types';
|
|
|
7
7
|
* For heading nodes, applies styles directly to preserve natural margins.
|
|
8
8
|
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
9
9
|
*/
|
|
10
|
-
export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, isActive, isInserted, diffType, hideAddedDiffsUnderline, }: {
|
|
10
|
+
export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, isActive, isInserted, diffType, hideAddedDiffsUnderline, highlightInlineLeafNodes, }: {
|
|
11
11
|
colorScheme?: ColorScheme;
|
|
12
12
|
diffType?: DiffType;
|
|
13
13
|
dom: HTMLElement;
|
|
14
14
|
hideAddedDiffsUnderline?: boolean;
|
|
15
|
+
highlightInlineLeafNodes?: boolean;
|
|
15
16
|
intl: IntlShape;
|
|
16
17
|
isActive?: boolean;
|
|
17
18
|
isInserted: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "14.2.
|
|
3
|
+
"version": "14.2.2",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"react-intl": "^7.0.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@atlaskit/editor-common": "^120.
|
|
62
|
+
"@atlaskit/editor-common": "^120.4.0",
|
|
63
63
|
"react": "^18.2.0 || ^19.2.0"
|
|
64
64
|
},
|
|
65
65
|
"techstack": {
|
|
@@ -99,6 +99,9 @@
|
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
"platform-feature-flags": {
|
|
102
|
+
"platform_editor_ai_show_diff_patch_1": {
|
|
103
|
+
"type": "boolean"
|
|
104
|
+
},
|
|
102
105
|
"platform_editor_ai_smart_diff": {
|
|
103
106
|
"type": "boolean"
|
|
104
107
|
},
|