@atlaskit/editor-plugin-show-diff 6.3.2 → 6.4.1

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +38 -24
  3. package/dist/cjs/pm-plugins/decorations/colorSchemes/standard.js +7 -1
  4. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +21 -6
  5. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +14 -1
  6. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +7 -2
  7. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +159 -62
  8. package/dist/cjs/pm-plugins/main.js +10 -5
  9. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +37 -25
  10. package/dist/es2019/pm-plugins/decorations/colorSchemes/standard.js +6 -0
  11. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +20 -6
  12. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +13 -2
  13. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +4 -1
  14. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +120 -21
  15. package/dist/es2019/pm-plugins/main.js +10 -5
  16. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +38 -24
  17. package/dist/esm/pm-plugins/decorations/colorSchemes/standard.js +6 -0
  18. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +21 -6
  19. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +14 -2
  20. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +7 -2
  21. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +160 -63
  22. package/dist/esm/pm-plugins/main.js +10 -5
  23. package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +2 -1
  24. package/dist/types/pm-plugins/decorations/colorSchemes/standard.d.ts +1 -0
  25. package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
  26. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
  27. package/dist/types/pm-plugins/main.d.ts +1 -0
  28. package/dist/types/showDiffPluginType.d.ts +1 -0
  29. package/dist/types-ts4.5/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +2 -1
  30. package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/standard.d.ts +1 -0
  31. package/dist/types-ts4.5/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
  32. package/dist/types-ts4.5/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
  33. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -0
  34. package/dist/types-ts4.5/showDiffPluginType.d.ts +1 -0
  35. package/package.json +4 -4
@@ -31,7 +31,8 @@ const getChanges = ({
31
31
  if (diffType === 'block') {
32
32
  return groupChangesByBlock(changeset.changes, originalDoc, steppedDoc);
33
33
  }
34
- return simplifyChanges(changeset.changes, tr.doc);
34
+ const changes = simplifyChanges(changeset.changes, tr.doc);
35
+ return optimizeChanges(changes);
35
36
  }
36
37
  const changes = simplifyChanges(changeset.changes, tr.doc);
37
38
  return optimizeChanges(changes);
@@ -42,7 +43,8 @@ const calculateNodesForBlockDecoration = ({
42
43
  to,
43
44
  colorScheme,
44
45
  isInserted = true,
45
- activeIndexPos
46
+ activeIndexPos,
47
+ shouldHideDeleted = false
46
48
  }) => {
47
49
  const decorations = [];
48
50
  // Iterate over the document nodes within the range
@@ -58,7 +60,8 @@ const calculateNodesForBlockDecoration = ({
58
60
  },
59
61
  colorScheme,
60
62
  isInserted,
61
- isActive
63
+ isActive,
64
+ shouldHideDeleted
62
65
  });
63
66
  if (blockChangedDecorations.length) {
64
67
  decorations.push(...blockChangedDecorations);
@@ -76,7 +79,8 @@ const calculateDiffDecorationsInner = ({
76
79
  activeIndexPos,
77
80
  api,
78
81
  isInverted = false,
79
- diffType = 'inline'
82
+ diffType = 'inline',
83
+ hideDeletedDiffs = false
80
84
  }) => {
81
85
  const {
82
86
  originalDoc,
@@ -143,12 +147,14 @@ const calculateDiffDecorationsInner = ({
143
147
  // Our default operations are insertions, so it should match the opposite of isInverted.
144
148
  const isInserted = !isInverted;
145
149
  if (change.inserted.length > 0) {
150
+ const shouldHideDeleted = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? isInverted && hideDeletedDiffs : false;
146
151
  decorations.push(createInlineChangedDecoration({
147
152
  change,
148
153
  colorScheme,
149
154
  isActive,
150
155
  ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
151
- isInserted
156
+ isInserted,
157
+ shouldHideDeleted
152
158
  })
153
159
  }));
154
160
  decorations.push(...calculateNodesForBlockDecoration({
@@ -157,28 +163,32 @@ const calculateDiffDecorationsInner = ({
157
163
  to: change.toB,
158
164
  colorScheme,
159
165
  ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
160
- isInserted
166
+ isInserted,
167
+ shouldHideDeleted
161
168
  }),
162
169
  activeIndexPos,
163
170
  intl
164
171
  }));
165
172
  }
166
173
  if (change.deleted.length > 0) {
167
- const decoration = createNodeChangedDecorationWidget({
168
- change,
169
- doc: originalDoc,
170
- nodeViewSerializer,
171
- colorScheme,
172
- newDoc: tr.doc,
173
- intl,
174
- activeIndexPos,
175
- ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
176
- isInserted: !isInserted,
177
- diffType
178
- })
179
- });
180
- if (decoration) {
181
- decorations.push(...decoration);
174
+ const shouldHideDeleted = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? !isInverted && hideDeletedDiffs : false;
175
+ if (!shouldHideDeleted) {
176
+ const decoration = createNodeChangedDecorationWidget({
177
+ change,
178
+ doc: originalDoc,
179
+ nodeViewSerializer,
180
+ colorScheme,
181
+ newDoc: tr.doc,
182
+ intl,
183
+ activeIndexPos,
184
+ ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
185
+ isInserted: !isInserted,
186
+ diffType
187
+ })
188
+ });
189
+ if (decoration) {
190
+ decorations.push(...decoration);
191
+ }
182
192
  }
183
193
  }
184
194
  });
@@ -213,7 +223,8 @@ export const calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner
213
223
  intl,
214
224
  activeIndexPos,
215
225
  isInverted,
216
- diffType
226
+ diffType,
227
+ hideDeletedDiffs
217
228
  }], [{
218
229
  pluginState: lastPluginState,
219
230
  state: lastState,
@@ -221,13 +232,14 @@ export const calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner
221
232
  intl: lastIntl,
222
233
  activeIndexPos: lastActiveIndexPos,
223
234
  isInverted: lastIsInverted,
224
- diffType: lastDiffType
235
+ diffType: lastDiffType,
236
+ hideDeletedDiffs: lastHideDeletedDiffs
225
237
  }]) => {
226
238
  var _ref2;
227
239
  const originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
228
240
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
229
241
  var _ref;
230
- return (_ref = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && isEqual(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc)) !== null && _ref !== void 0 ? _ref : false;
242
+ return (_ref = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && isEqual(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref !== void 0 ? _ref : false;
231
243
  }
232
- return (_ref2 = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos)) !== null && _ref2 !== void 0 ? _ref2 : false;
244
+ return (_ref2 = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref2 !== void 0 ? _ref2 : false;
233
245
  });
@@ -6,6 +6,12 @@ export const editingStyle = convertToInlineCss({
6
6
  textDecorationThickness: "var(--ds-space-025, 2px)",
7
7
  textDecorationColor: "var(--ds-border-accent-purple, #AF59E1)"
8
8
  });
9
+ export const editingContentStyleInBlock = convertToInlineCss({
10
+ textDecoration: 'underline',
11
+ textDecorationStyle: 'dotted',
12
+ textDecorationThickness: "var(--ds-space-025, 2px)",
13
+ textDecorationColor: "var(--ds-border-accent-purple, #AF59E1)"
14
+ });
9
15
  export const editingStyleActive = convertToInlineCss({
10
16
  background: "var(--ds-background-accent-purple-subtler-pressed, #D8A0F7)",
11
17
  textDecoration: 'underline',
@@ -4,6 +4,9 @@ import { fg } from '@atlaskit/platform-feature-flags';
4
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
5
  import { standardDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode, deletedContentStyleNew, deletedStyleQuoteNode, addedCellOverlayStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
6
6
  import { traditionalDecorationMarkerVariable, traditionalDecorationMarkerVariableActive, traditionalDecorationMarkerVariableNew, traditionalDeletedDecorationMarkerVariable, traditionalDeletedDecorationMarkerVariableActive, traditionalDeletedDecorationMarkerVariableNew, traditionalStyleQuoteNode, traditionalStyleQuoteNodeActive, traditionalStyleQuoteNodeNew, traditionalStyleRuleNode, traditionalStyleRuleNodeActive, traditionalStyleRuleNodeNew, traditionalStyleCardBlockNode, traditionalStyleCardBlockNodeActive, traditionalStyleCardBlockNodeNew, traditionalStyleNode, traditionalStyleNodeActive, traditionalStyleNodeNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, traditionalAddedCellOverlayStyle, deletedTraditionalCellOverlayStyle } from './colorSchemes/traditional';
7
+ const displayNoneStyle = convertToInlineCss({
8
+ display: 'none'
9
+ });
7
10
  const getNodeClass = name => {
8
11
  switch (name) {
9
12
  case 'extension':
@@ -99,9 +102,19 @@ export const createBlockChangedDecoration = ({
99
102
  change,
100
103
  colorScheme,
101
104
  isInserted = true,
102
- isActive = false
105
+ isActive = false,
106
+ shouldHideDeleted = false
103
107
  }) => {
104
108
  const decorations = [];
109
+ if (shouldHideDeleted) {
110
+ return [Decoration.node(change.from, change.to, {
111
+ style: displayNoneStyle
112
+ }, {
113
+ key: 'diff-block',
114
+ nodeName: change.name
115
+ })];
116
+ }
117
+ let style;
105
118
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && ['tableCell', 'tableHeader'].includes(change.name)) {
106
119
  const cellOverlay = document.createElement('div');
107
120
  const cellOverlayStyle = isInserted ? colorScheme === 'traditional' ? traditionalAddedCellOverlayStyle : addedCellOverlayStyle : colorScheme === 'traditional' ? deletedTraditionalCellOverlayStyle : deletedCellOverlayStyle;
@@ -112,11 +125,6 @@ export const createBlockChangedDecoration = ({
112
125
  key: `diff-widget-cell-overlay-${change.to}`
113
126
  }));
114
127
  }
115
- let style = getBlockNodeStyle({
116
- nodeName: change.name,
117
- colorScheme,
118
- isActive
119
- });
120
128
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
121
129
  style = getBlockNodeStyle({
122
130
  nodeName: change.name,
@@ -124,6 +132,12 @@ export const createBlockChangedDecoration = ({
124
132
  isInserted,
125
133
  isActive
126
134
  });
135
+ } else {
136
+ style = getBlockNodeStyle({
137
+ nodeName: change.name,
138
+ colorScheme,
139
+ isActive
140
+ });
127
141
  }
128
142
  const className = getNodeClass(change.name);
129
143
  if (fg('platform_editor_show_diff_scroll_navigation')) {
@@ -1,8 +1,11 @@
1
+ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
1
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  import { editingStyle, editingStyleActive, deletedContentStyle, deletedContentStyleActive } from './colorSchemes/standard';
4
5
  import { traditionalInsertStyle, traditionalInsertStyleActive, getDeletedTraditionalInlineStyle } from './colorSchemes/traditional';
5
-
6
+ const displayNoneStyle = convertToInlineCss({
7
+ display: 'none'
8
+ });
6
9
  /**
7
10
  * Inline decoration used for insertions as the content already exists in the document
8
11
  *
@@ -14,8 +17,16 @@ export const createInlineChangedDecoration = ({
14
17
  change,
15
18
  colorScheme,
16
19
  isActive = false,
17
- isInserted = true
20
+ isInserted = true,
21
+ shouldHideDeleted = false
18
22
  }) => {
23
+ if (shouldHideDeleted) {
24
+ return Decoration.inline(change.fromB, change.toB, {
25
+ style: displayNoneStyle
26
+ }, {
27
+ key: 'diff-inline'
28
+ });
29
+ }
19
30
  let style;
20
31
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
21
32
  if (isInserted) {
@@ -240,7 +240,10 @@ export const createNodeChangedDecorationWidget = ({
240
240
  dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
241
241
  const decorations = [];
242
242
  decorations.push(Decoration.widget(safeInsertPos, dom, {
243
- key: `diff-widget-${isActive ? 'active' : 'inactive'}`
243
+ key: `diff-widget-${isActive ? 'active' : 'inactive'}`,
244
+ ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
245
+ side: -1
246
+ })
244
247
  }));
245
248
  return decorations;
246
249
  };
@@ -2,7 +2,7 @@ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
2
2
  import { trackChangesMessages } from '@atlaskit/editor-common/messages';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
- import { deletedBlockOutline, deletedBlockOutlineActive, deletedBlockOutlineRounded, deletedBlockOutlineRoundedActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedStyleQuoteNodeWithLozenge, deletedStyleQuoteNodeWithLozengeActive, editingStyle, editingStyleActive, editingStyleNode, addedCellOverlayStyle, deletedCellOverlayStyle } from '../colorSchemes/standard';
5
+ import { deletedBlockOutline, deletedBlockOutlineActive, deletedBlockOutlineRounded, deletedBlockOutlineRoundedActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedStyleQuoteNodeWithLozenge, deletedStyleQuoteNodeWithLozengeActive, editingContentStyleInBlock, editingStyle, editingStyleActive, editingStyleNode, addedCellOverlayStyle, deletedCellOverlayStyle } from '../colorSchemes/standard';
6
6
  import { deletedTraditionalBlockOutline, deletedTraditionalBlockOutlineActive, deletedTraditionalBlockOutlineNew, deletedTraditionalBlockOutlineRounded, deletedTraditionalBlockOutlineRoundedActive, deletedTraditionalBlockOutlineRoundedNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, deletedTraditionalStyleQuoteNodeActive, traditionalInsertStyle, traditionalInsertStyleActive, traditionalStyleNode, traditionalStyleNodeActive, traditionalStyleNodeNew, traditionalAddedCellOverlayStyle, traditionalAddedCellOverlayStyleNew, deletedTraditionalCellOverlayStyle } from '../colorSchemes/traditional';
7
7
  const lozengeStyle = convertToInlineCss({
8
8
  display: 'inline-flex',
@@ -70,7 +70,10 @@ const getChangedContentStyle = (colorScheme, isActive = false, isInserted = fals
70
70
  const getChangedNodeStyle = (nodeName, colorScheme, isInserted = false, isActive = false) => {
71
71
  const isTraditional = colorScheme === 'traditional';
72
72
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted) {
73
- if (shouldApplyStylesDirectly(nodeName)) {
73
+ if (isMultiContainerBlockNode(nodeName)) {
74
+ return editingContentStyleInBlock;
75
+ }
76
+ if (isTextLikeBlockNode(nodeName)) {
74
77
  return undefined;
75
78
  }
76
79
  if (isTraditional) {
@@ -151,6 +154,12 @@ const maybeAddDeletedOutlineNewClass = ({
151
154
  const shouldApplyStylesDirectly = nodeName => {
152
155
  return nodeName === 'heading';
153
156
  };
157
+ const isMultiContainerBlockNode = nodeName => {
158
+ return ['decisionList', 'layoutSection'].includes(nodeName);
159
+ };
160
+ const isTextLikeBlockNode = nodeName => {
161
+ return ['heading', 'bulletList', 'orderedList', 'listItem', 'taskList', 'blockquote'].includes(nodeName);
162
+ };
154
163
  const applyCellOverlayStyles = ({
155
164
  element,
156
165
  colorScheme,
@@ -218,6 +227,58 @@ const applyStylesToElement = ({
218
227
  const nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive) || '';
219
228
  element.setAttribute('style', `${currentStyle}${contentStyle}${nodeSpecificStyle}`);
220
229
  };
230
+ const applyMultiContainerLikeStyles = ({
231
+ element,
232
+ targetNode,
233
+ colorScheme,
234
+ isActive,
235
+ isInserted
236
+ }) => {
237
+ const currentStyle = element.getAttribute('style') || '';
238
+ const nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive) || '';
239
+ if (targetNode.type.name === 'decisionList') {
240
+ element.querySelectorAll('li').forEach(listItem => {
241
+ const currentListItemStyle = listItem.getAttribute('style') || '';
242
+ listItem.setAttribute('style', `${currentListItemStyle}${editingStyleNode}`);
243
+ });
244
+ } else if (targetNode.type.name === 'layoutSection') {
245
+ element.querySelectorAll('[data-layout-column="true"]').forEach(section => {
246
+ const currentSectionStyle = section.getAttribute('style') || '';
247
+ section.setAttribute('style', `${currentSectionStyle}${editingStyleNode}`);
248
+ });
249
+ } else if (targetNode.type.name === 'taskList') {
250
+ element.querySelectorAll('li').forEach(listItem => {
251
+ const currentListItemStyle = listItem.getAttribute('style') || '';
252
+ listItem.setAttribute('style', `${currentListItemStyle}${editingStyleNode}`);
253
+ });
254
+ }
255
+ element.setAttribute('style', `${currentStyle};${nodeSpecificStyle}`);
256
+ };
257
+ const applyTextLikeBlockNodeStyles = ({
258
+ element,
259
+ targetNode,
260
+ colorScheme,
261
+ isActive,
262
+ isInserted
263
+ }) => {
264
+ getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive) || '';
265
+ const contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted);
266
+ const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
267
+ const textNodesToWrap = [];
268
+ let currentNode = walker.nextNode();
269
+ while (currentNode) {
270
+ if (currentNode instanceof Text && currentNode.textContent !== '' && currentNode.parentElement) {
271
+ textNodesToWrap.push(currentNode);
272
+ }
273
+ currentNode = walker.nextNode();
274
+ }
275
+ textNodesToWrap.forEach(textNode => {
276
+ const contentWrapper = document.createElement('span');
277
+ contentWrapper.setAttribute('style', contentStyle);
278
+ textNode.replaceWith(contentWrapper);
279
+ contentWrapper.append(textNode);
280
+ });
281
+ };
221
282
 
222
283
  /**
223
284
  * Creates a content wrapper with deleted styles for a block node
@@ -407,25 +468,40 @@ export const wrapBlockNodeView = ({
407
468
  isActive = false,
408
469
  isInserted = false
409
470
  }) => {
410
- if (shouldApplyStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
411
- // Apply deleted styles directly to preserve natural block-level margins
412
- applyStylesToElement({
413
- element: nodeView,
414
- targetNode,
415
- colorScheme,
416
- isActive,
417
- isInserted
418
- });
419
- dom.append(nodeView);
420
- } else if (targetNode.type.name === 'table' && nodeView instanceof HTMLElement && expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
421
- applyCellOverlayStyles({
422
- element: nodeView,
423
- colorScheme,
424
- isInserted
425
- });
426
- dom.append(nodeView);
427
- } else {
428
- // Use wrapper approach for other block nodes
471
+ if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
472
+ if (nodeView instanceof HTMLElement) {
473
+ if (isInserted && isMultiContainerBlockNode(targetNode.type.name)) {
474
+ applyMultiContainerLikeStyles({
475
+ element: nodeView,
476
+ targetNode,
477
+ colorScheme,
478
+ isActive,
479
+ isInserted
480
+ });
481
+ dom.append(nodeView);
482
+ return;
483
+ }
484
+ if (isTextLikeBlockNode(targetNode.type.name)) {
485
+ applyTextLikeBlockNodeStyles({
486
+ element: nodeView,
487
+ targetNode,
488
+ colorScheme,
489
+ isActive,
490
+ isInserted
491
+ });
492
+ dom.append(nodeView);
493
+ return;
494
+ }
495
+ if (targetNode.type.name === 'table') {
496
+ applyCellOverlayStyles({
497
+ element: nodeView,
498
+ colorScheme,
499
+ isInserted
500
+ });
501
+ dom.append(nodeView);
502
+ return;
503
+ }
504
+ }
429
505
  wrapBlockNode({
430
506
  dom,
431
507
  nodeView,
@@ -435,5 +511,28 @@ export const wrapBlockNodeView = ({
435
511
  isActive,
436
512
  isInserted
437
513
  });
514
+ return;
515
+ } else {
516
+ if (shouldApplyStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
517
+ // Apply deleted styles directly to preserve natural block-level margins
518
+ applyStylesToElement({
519
+ element: nodeView,
520
+ targetNode,
521
+ colorScheme,
522
+ isActive,
523
+ isInserted
524
+ });
525
+ dom.append(nodeView);
526
+ } else {
527
+ wrapBlockNode({
528
+ dom,
529
+ nodeView,
530
+ targetNode,
531
+ colorScheme,
532
+ intl,
533
+ isActive,
534
+ isInserted
535
+ });
536
+ }
438
537
  }
439
538
  };
@@ -33,7 +33,8 @@ export const createPlugin = (config, getIntl, api) => {
33
33
  isDisplayingChanges: false,
34
34
  ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
35
35
  isInverted: false,
36
- diffType: 'inline'
36
+ diffType: 'inline',
37
+ hideDeletedDiffs: false
37
38
  } : {})
38
39
  };
39
40
  },
@@ -42,7 +43,7 @@ export const createPlugin = (config, getIntl, api) => {
42
43
  let newPluginState = currentPluginState;
43
44
  if (meta) {
44
45
  if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
45
- var _newPluginState, _newPluginState2;
46
+ var _newPluginState, _newPluginState2, _newPluginState3;
46
47
  // Update the plugin state with the new metadata
47
48
  newPluginState = {
48
49
  ...currentPluginState,
@@ -61,7 +62,8 @@ export const createPlugin = (config, getIntl, api) => {
61
62
  api,
62
63
  ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
63
64
  isInverted: (_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.isInverted,
64
- diffType: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType
65
+ diffType: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType,
66
+ hideDeletedDiffs: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.hideDeletedDiffs
65
67
  } : {})
66
68
  });
67
69
  // Update the decorations
@@ -79,7 +81,8 @@ export const createPlugin = (config, getIntl, api) => {
79
81
  */
80
82
  ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
81
83
  isInverted: false,
82
- diffType: 'inline'
84
+ diffType: 'inline',
85
+ hideDeletedDiffs: false
83
86
  } : {})
84
87
  };
85
88
  } else if (((meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_NEXT' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_PREVIOUS') && fg('platform_editor_show_diff_scroll_navigation')) {
@@ -120,7 +123,9 @@ export const createPlugin = (config, getIntl, api) => {
120
123
  activeIndexPos: newPluginState.activeIndexPos,
121
124
  api,
122
125
  ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
123
- isInverted: newPluginState.isInverted
126
+ isInverted: newPluginState.isInverted,
127
+ diffType: newPluginState.diffType,
128
+ hideDeletedDiffs: newPluginState.hideDeletedDiffs
124
129
  } : {})
125
130
  });
126
131
  newPluginState.decorations = updatedDecorations;
@@ -38,7 +38,8 @@ var getChanges = function getChanges(_ref) {
38
38
  if (diffType === 'block') {
39
39
  return groupChangesByBlock(changeset.changes, originalDoc, steppedDoc);
40
40
  }
41
- return simplifyChanges(changeset.changes, tr.doc);
41
+ var _changes = simplifyChanges(changeset.changes, tr.doc);
42
+ return optimizeChanges(_changes);
42
43
  }
43
44
  var changes = simplifyChanges(changeset.changes, tr.doc);
44
45
  return optimizeChanges(changes);
@@ -50,7 +51,9 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
50
51
  colorScheme = _ref2.colorScheme,
51
52
  _ref2$isInserted = _ref2.isInserted,
52
53
  isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted,
53
- activeIndexPos = _ref2.activeIndexPos;
54
+ activeIndexPos = _ref2.activeIndexPos,
55
+ _ref2$shouldHideDelet = _ref2.shouldHideDeleted,
56
+ shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet;
54
57
  var decorations = [];
55
58
  // Iterate over the document nodes within the range
56
59
  doc.nodesBetween(from, to, function (node, pos) {
@@ -65,7 +68,8 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
65
68
  },
66
69
  colorScheme: colorScheme,
67
70
  isInserted: isInserted,
68
- isActive: isActive
71
+ isActive: isActive,
72
+ shouldHideDeleted: shouldHideDeleted
69
73
  });
70
74
  if (blockChangedDecorations.length) {
71
75
  decorations.push.apply(decorations, _toConsumableArray(blockChangedDecorations));
@@ -85,7 +89,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
85
89
  _ref3$isInverted = _ref3.isInverted,
86
90
  isInverted = _ref3$isInverted === void 0 ? false : _ref3$isInverted,
87
91
  _ref3$diffType = _ref3.diffType,
88
- diffType = _ref3$diffType === void 0 ? 'inline' : _ref3$diffType;
92
+ diffType = _ref3$diffType === void 0 ? 'inline' : _ref3$diffType,
93
+ _ref3$hideDeletedDiff = _ref3.hideDeletedDiffs,
94
+ hideDeletedDiffs = _ref3$hideDeletedDiff === void 0 ? false : _ref3$hideDeletedDiff;
89
95
  var originalDoc = pluginState.originalDoc,
90
96
  steps = pluginState.steps;
91
97
  if (!originalDoc || !pluginState.isDisplayingChanges) {
@@ -156,12 +162,14 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
156
162
  // Our default operations are insertions, so it should match the opposite of isInverted.
157
163
  var isInserted = !isInverted;
158
164
  if (change.inserted.length > 0) {
165
+ var shouldHideDeleted = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? isInverted && hideDeletedDiffs : false;
159
166
  decorations.push(createInlineChangedDecoration(_objectSpread({
160
167
  change: change,
161
168
  colorScheme: colorScheme,
162
169
  isActive: isActive
163
170
  }, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
164
- isInserted: isInserted
171
+ isInserted: isInserted,
172
+ shouldHideDeleted: shouldHideDeleted
165
173
  })));
166
174
  decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration(_objectSpread(_objectSpread({
167
175
  doc: tr.doc,
@@ -169,27 +177,31 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
169
177
  to: change.toB,
170
178
  colorScheme: colorScheme
171
179
  }, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
172
- isInserted: isInserted
180
+ isInserted: isInserted,
181
+ shouldHideDeleted: shouldHideDeleted
173
182
  }), {}, {
174
183
  activeIndexPos: activeIndexPos,
175
184
  intl: intl
176
185
  }))));
177
186
  }
178
187
  if (change.deleted.length > 0) {
179
- var decoration = createNodeChangedDecorationWidget(_objectSpread({
180
- change: change,
181
- doc: originalDoc,
182
- nodeViewSerializer: nodeViewSerializer,
183
- colorScheme: colorScheme,
184
- newDoc: tr.doc,
185
- intl: intl,
186
- activeIndexPos: activeIndexPos
187
- }, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
188
- isInserted: !isInserted,
189
- diffType: diffType
190
- }));
191
- if (decoration) {
192
- decorations.push.apply(decorations, _toConsumableArray(decoration));
188
+ var _shouldHideDeleted = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? !isInverted && hideDeletedDiffs : false;
189
+ if (!_shouldHideDeleted) {
190
+ var decoration = createNodeChangedDecorationWidget(_objectSpread({
191
+ change: change,
192
+ doc: originalDoc,
193
+ nodeViewSerializer: nodeViewSerializer,
194
+ colorScheme: colorScheme,
195
+ newDoc: tr.doc,
196
+ intl: intl,
197
+ activeIndexPos: activeIndexPos
198
+ }, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
199
+ isInserted: !isInserted,
200
+ diffType: diffType
201
+ }));
202
+ if (decoration) {
203
+ decorations.push.apply(decorations, _toConsumableArray(decoration));
204
+ }
193
205
  }
194
206
  }
195
207
  });
@@ -227,7 +239,8 @@ function (_ref4, _ref5) {
227
239
  intl = _ref6$.intl,
228
240
  activeIndexPos = _ref6$.activeIndexPos,
229
241
  isInverted = _ref6$.isInverted,
230
- diffType = _ref6$.diffType;
242
+ diffType = _ref6$.diffType,
243
+ hideDeletedDiffs = _ref6$.hideDeletedDiffs;
231
244
  var _ref7 = _slicedToArray(_ref5, 1),
232
245
  _ref7$ = _ref7[0],
233
246
  lastPluginState = _ref7$.pluginState,
@@ -236,11 +249,12 @@ function (_ref4, _ref5) {
236
249
  lastIntl = _ref7$.intl,
237
250
  lastActiveIndexPos = _ref7$.activeIndexPos,
238
251
  lastIsInverted = _ref7$.isInverted,
239
- lastDiffType = _ref7$.diffType;
252
+ lastDiffType = _ref7$.diffType,
253
+ lastHideDeletedDiffs = _ref7$.hideDeletedDiffs;
240
254
  var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
241
255
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
242
256
  var _ref8;
243
- return (_ref8 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && isEqual(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc)) !== null && _ref8 !== void 0 ? _ref8 : false;
257
+ return (_ref8 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && isEqual(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref8 !== void 0 ? _ref8 : false;
244
258
  }
245
- return (_ref9 = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos)) !== null && _ref9 !== void 0 ? _ref9 : false;
259
+ return (_ref9 = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref9 !== void 0 ? _ref9 : false;
246
260
  });
@@ -6,6 +6,12 @@ export var editingStyle = convertToInlineCss({
6
6
  textDecorationThickness: "var(--ds-space-025, 2px)",
7
7
  textDecorationColor: "var(--ds-border-accent-purple, #AF59E1)"
8
8
  });
9
+ export var editingContentStyleInBlock = convertToInlineCss({
10
+ textDecoration: 'underline',
11
+ textDecorationStyle: 'dotted',
12
+ textDecorationThickness: "var(--ds-space-025, 2px)",
13
+ textDecorationColor: "var(--ds-border-accent-purple, #AF59E1)"
14
+ });
9
15
  export var editingStyleActive = convertToInlineCss({
10
16
  background: "var(--ds-background-accent-purple-subtler-pressed, #D8A0F7)",
11
17
  textDecoration: 'underline',