@atlaskit/editor-plugin-show-diff 13.0.11 → 13.1.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 (45) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/afm-products/tsconfig.json +3 -0
  4. package/dist/cjs/pm-plugins/decorations/colorSchemes/factory.js +259 -23
  5. package/dist/cjs/pm-plugins/decorations/colorSchemes/schemes.js +21 -5
  6. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +87 -105
  7. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.styles.legacy.js +124 -0
  8. package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +15 -12
  9. package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.styles.legacy.js +37 -0
  10. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +109 -59
  11. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.styles.legacy.js +67 -0
  12. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +30 -168
  13. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +205 -0
  14. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +225 -0
  15. package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +247 -23
  16. package/dist/es2019/pm-plugins/decorations/colorSchemes/schemes.js +20 -4
  17. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +85 -105
  18. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.styles.legacy.js +118 -0
  19. package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +15 -12
  20. package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.styles.legacy.js +33 -0
  21. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +82 -37
  22. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.styles.legacy.js +62 -0
  23. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +15 -140
  24. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +143 -0
  25. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +200 -0
  26. package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +248 -23
  27. package/dist/esm/pm-plugins/decorations/colorSchemes/schemes.js +20 -4
  28. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +87 -105
  29. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.styles.legacy.js +118 -0
  30. package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +15 -12
  31. package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.styles.legacy.js +32 -0
  32. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +109 -59
  33. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.styles.legacy.js +61 -0
  34. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +15 -153
  35. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +198 -0
  36. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +218 -0
  37. package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +78 -6
  38. package/dist/types/pm-plugins/decorations/colorSchemes/schemes.d.ts +3 -0
  39. package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +13 -3
  40. package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.styles.legacy.d.ts +14 -0
  41. package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.styles.legacy.d.ts +22 -0
  42. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.styles.legacy.d.ts +26 -0
  43. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.d.ts +39 -0
  44. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.d.ts +40 -0
  45. package/package.json +4 -3
@@ -76,16 +76,16 @@ function textAccent(color) {
76
76
  return textAccentMap[color];
77
77
  }
78
78
 
79
- /** Outline colour for deleted table-cell overlays. */
80
- function deletedCellOutline(colors) {
81
- return colors.deletedCellBorderProminence === 'subtle' ? "var(--ds-border-disabled, #0515240F)" : borderAccent(colors.deletedCellColor);
82
- }
83
-
84
79
  /** Ring colour for an active (scroll-target) deleted block outline. */
85
80
  function deletedBlockOutlineActiveRing(colors) {
86
81
  return colors.deletedBlockOutlineActiveEmphasis === 'border' ? borderAccent(colors.deleteActiveColor) : bgSubtlerPressed(colors.deleteActiveColor);
87
82
  }
88
83
 
84
+ /** Outline colour for deleted table-cell overlays. */
85
+ function deletedCellOutline(colors) {
86
+ return colors.deletedCellBorderProminence === 'subtle' ? "var(--ds-border-disabled, #0515240F)" : borderAccent(colors.deletedCellColor);
87
+ }
88
+
89
89
  // --- Inserted content styles ---
90
90
 
91
91
  /** Inline inserted content — default state. */
@@ -171,6 +171,7 @@ export function buildInsertStyleActive(colors) {
171
171
 
172
172
  // --- Deleted inline content styles ---
173
173
 
174
+ /** Base deleted-inline-style object, shared by several exports. */
174
175
  function deletedInlineStyleBase(colors) {
175
176
  return {
176
177
  textDecorationColor: borderAccent(colors.deleteColor),
@@ -179,6 +180,8 @@ function deletedInlineStyleBase(colors) {
179
180
  opacity: 1
180
181
  };
181
182
  }
183
+
184
+ /** Active deleted-inline-style object, extending the base. */
182
185
  function deletedInlineStyleActiveBase(colors) {
183
186
  return _objectSpread(_objectSpread({}, deletedInlineStyleBase(colors)), {}, {
184
187
  textDecorationThickness: '2px',
@@ -255,8 +258,6 @@ export function buildDeletedStyleQuoteNodeWithLozengeActive(colors) {
255
258
  borderRadius: "var(--ds-radius-small, 4px)"
256
259
  });
257
260
  }
258
-
259
- /** Deleted quote node — a 2px left border, or a 1px ring with padding, per `deletedQuoteNodeShape`. */
260
261
  export function buildDeletedStyleQuoteNode(colors) {
261
262
  if (colors.deletedQuoteNodeShape === 'borderLeft') {
262
263
  return convertToInlineCss({
@@ -337,18 +338,20 @@ export function buildDeletedBlockOutlineRoundedNew(colors) {
337
338
 
338
339
  // --- Deleted table row style ---
339
340
 
340
- /** Table row style for deleted rows. See `deletedRowTreatment`. */
341
+ /** Table row style for deleted rows. */
341
342
  export function buildDeletedRowStyle(colors) {
342
- var base = {
343
+ // Each branch emits exactly the CSS the pre-factory shim did for its scheme.
344
+ return colors.deletedRowTreatment === 'textTint' ? convertToInlineCss({
345
+ color: textAccent(colors.deleteColor),
343
346
  textDecoration: 'line-through',
344
347
  opacity: 0.6,
345
348
  display: 'table-row'
346
- };
347
- return colors.deletedRowTreatment === 'textTint' ? convertToInlineCss(_objectSpread(_objectSpread({}, base), {}, {
348
- color: textAccent(colors.deleteColor)
349
- })) : convertToInlineCss(_objectSpread(_objectSpread({}, base), {}, {
350
- textDecorationColor: borderAccent(colors.deleteColor)
351
- }));
349
+ }) : convertToInlineCss({
350
+ textDecorationColor: borderAccent(colors.deleteColor),
351
+ textDecoration: 'line-through',
352
+ opacity: 0.6,
353
+ display: 'table-row'
354
+ });
352
355
  }
353
356
 
354
357
  // --- Inserted block node styles — quote, rule, generic node, card ---
@@ -449,9 +452,11 @@ export function buildInsertStyleCardBlockNodeActive(colors) {
449
452
  });
450
453
  }
451
454
 
452
- // --- CSS custom properties ---
453
- // Applied inline on the decoration wrapper; cascade down to child/pseudo-element selectors in the
454
- // global stylesheet.
455
+ // ---------------------------------------------------------------------------
456
+ // CSS custom property variables (for nodes styled via global stylesheet)
457
+ // These are applied as inline styles on the decoration wrapper element and
458
+ // cascade down to child/pseudo-element selectors in the global stylesheet.
459
+ // ---------------------------------------------------------------------------
455
460
 
456
461
  /** CSS variables for an inserted node decoration marker — default state. */
457
462
  export function buildDecorationMarkerVariable(colors) {
@@ -485,7 +490,7 @@ export function buildDeletedDecorationMarkerVariable(colors) {
485
490
  }));
486
491
  }
487
492
 
488
- /** Opacity only, no position or strikethrough. Used by the standard scheme. */
493
+ /** Opacity only, no position or strikethrough. Used by 'static' schemes. */
489
494
  export function buildDeletedDecorationMarkerVariableSimple(colors) {
490
495
  return convertToInlineCss({
491
496
  opacity: 0.8,
@@ -494,6 +499,10 @@ export function buildDeletedDecorationMarkerVariableSimple(colors) {
494
499
  });
495
500
  }
496
501
 
502
+ /**
503
+ * 'glyphTint' deleted inline style — tints the glyph itself via `color:`. Opacity ramps 0.6
504
+ * default, 0.83 "new", 1 active.
505
+ */
497
506
  /** Extended deleted inline style — background highlight + border-bottom underline (standard scheme). */
498
507
  export function buildDeletedInlineContentStyleExtended(colors) {
499
508
  return convertToInlineCss({
@@ -502,8 +511,6 @@ export function buildDeletedInlineContentStyleExtended(colors) {
502
511
  padding: "1px 0 2px"
503
512
  });
504
513
  }
505
-
506
- /** Standard deleted inline style — colours the glyph itself, not just the strikethrough. */
507
514
  export function buildDeletedInlineStyleStandard(colors, state) {
508
515
  if (state === 'active') {
509
516
  return convertToInlineCss({
@@ -540,7 +547,7 @@ export function buildDeletedDecorationMarkerVariableActive(colors) {
540
547
 
541
548
  // --- Table cell overlay styles ---
542
549
 
543
- /** Cell overlay for added table cells — default state. Stacking order varies by scheme. */
550
+ /** Cell overlay for added table cells — default state (zIndex 1). */
544
551
  export function buildAddedCellOverlayStyle(colors) {
545
552
  return convertToInlineCss({
546
553
  position: 'absolute',
@@ -555,7 +562,7 @@ export function buildAddedCellOverlayStyle(colors) {
555
562
  });
556
563
  }
557
564
 
558
- /** Added cell overlay — rounded variant. See `roundedAddedCellOverlayInheritsBorder`. */
565
+ /** Cell overlay for added table cells — rounded variant (zIndex 2, inherits border/radius). */
559
566
  export function buildAddedCellOverlayRoundedStyle(colors) {
560
567
  return convertToInlineCss(_objectSpread(_objectSpread({
561
568
  position: 'absolute',
@@ -619,4 +626,222 @@ export function buildDeletedCellOverlayRoundedStyle(colors) {
619
626
  border: 'inherit',
620
627
  borderRadius: 'inherit'
621
628
  });
629
+ }
630
+
631
+ // ---------------------------------------------------------------------------
632
+ // CSS custom property variables for deleted node global stylesheet
633
+ //
634
+ // These are set as inline styles on the deleted node wrapper element and cascade
635
+ // down to child/pseudo-element selectors in the global smartCardStyles stylesheet.
636
+ // The stylesheet reads var(--diff-delete-color) etc. — one set of selectors for
637
+ // all schemes, written once, never needs to change when new schemes are added.
638
+ // ---------------------------------------------------------------------------
639
+
640
+ // --- Inline content style dispatch ---
641
+
642
+ /**
643
+ * Inserted inline content under the extended diff experience. `insertedInlineTreatment` picks
644
+ * `text-decoration` vs a `border-bottom` rule; only the latter honours `hideAddedDiffsUnderline`.
645
+ */
646
+ export function buildInsertedInlineStyle(colors, isActive, hideAddedDiffsUnderline) {
647
+ if (colors.insertedInlineTreatment === 'underline') {
648
+ return isActive ? buildInsertStyleActive(colors) : buildInsertStyle(colors);
649
+ }
650
+ if (isActive) {
651
+ return hideAddedDiffsUnderline ? buildInsertStyleExtendedNoUnderlineActive(colors) : buildInsertStyleExtendedActive(colors);
652
+ }
653
+ return hideAddedDiffsUnderline ? buildInsertStyleExtendedNoUnderline(colors) : buildInsertStyleExtended(colors);
654
+ }
655
+
656
+ /** The three visual states deleted inline content can be in. */
657
+
658
+ /**
659
+ * Deleted inline content in a given state. 'strikethrough' renders 'default' and 'new'
660
+ * identically; the 'new' step exists only for the 'glyphTint' opacity ramp.
661
+ */
662
+ export function buildDeletedInlineContentStyle(colors, state) {
663
+ return colors.deletedInlineTreatment === 'strikethrough' ? buildDeletedInlineStyle(colors, state === 'active') : buildDeletedInlineStyleStandard(colors, state);
664
+ }
665
+
666
+ /**
667
+ * The positioned line across deleted content spanning an unbounded range. 'stateful' thickens
668
+ * 1px to 2px when active and tints with the border accent; 'static' uses the text accent always.
669
+ */
670
+ export function buildDeletedStrikethroughLine(colors, isActive) {
671
+ if (colors.deletedNodeEmphasis !== 'stateful') {
672
+ return buildDeletedInlineStyleUnbounded(colors);
673
+ }
674
+ return isActive ? buildDeletedContentStyleUnboundedActive(colors) : buildDeletedContentStyleUnbounded(colors);
675
+ }
676
+
677
+ // --- Deleted-content "REMOVED" lozenge ---
678
+
679
+ /** Structural CSS shared by both lozenge states — everything except the background tint. */
680
+ var deletedLozengeBase = {
681
+ display: 'inline-flex',
682
+ boxSizing: 'border-box',
683
+ position: 'static',
684
+ blockSize: 'min-content',
685
+ borderRadius: "var(--ds-radius-small, 4px)",
686
+ overflow: 'hidden',
687
+ paddingInlineStart: "var(--ds-space-050, 4px)",
688
+ paddingInlineEnd: "var(--ds-space-050, 4px)",
689
+ font: "var(--ds-font-body-small, normal 400 12px/16px \"Atlassian Sans\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
690
+ fontWeight: "var(--ds-font-weight-bold, 653)",
691
+ textOverflow: 'ellipsis',
692
+ whiteSpace: 'nowrap',
693
+ color: "var(--ds-text-warning-inverse, #292A2E)"
694
+ };
695
+
696
+ /**
697
+ * The "REMOVED" lozenge on a deleted block node — resting state. Neutral gray in every scheme,
698
+ * so it takes no DiffColorScheme; only the active state is tinted.
699
+ */
700
+ export function buildDeletedLozengeStyle() {
701
+ return convertToInlineCss(_objectSpread(_objectSpread({}, deletedLozengeBase), {}, {
702
+ backgroundColor: "var(--ds-background-accent-gray-subtler, #DDDEE1)"
703
+ }));
704
+ }
705
+
706
+ /** The "REMOVED" lozenge — active state, tinted with the scheme's deleteActiveColor. */
707
+ export function buildDeletedLozengeActiveStyle(colors) {
708
+ return convertToInlineCss(_objectSpread(_objectSpread({}, deletedLozengeBase), {}, {
709
+ backgroundColor: bgSubtlerPressed(colors.deleteActiveColor)
710
+ }));
711
+ }
712
+
713
+ // ---------------------------------------------------------------------------
714
+ // Block node style dispatch
715
+ //
716
+ // A block node's decoration shape is a property of the *node type* — every scheme draws a
717
+ // blockquote with a left border and a horizontal rule as a filled bar. What varies per scheme
718
+ // is the emphasis and, for deleted content, which of the treatments below is used. Keeping that
719
+ // table here rather than in the decoration consumers means adding a scheme stays a change to
720
+ // `schemes.ts` alone.
721
+ // ---------------------------------------------------------------------------
722
+
723
+ /** The decoration shape an inserted block node takes. Determined by node type, not by scheme. */
724
+
725
+ /**
726
+ * Outline for an inserted block node. `insertedNodeEmphasis`: 'stateful' draws a 4px ring
727
+ * (`subtlest` at rest, `subtler.pressed` when focused), 'static' one 1px accent ring.
728
+ */
729
+ export function buildInsertedBlockNodeStyle(colors, shape, isActive) {
730
+ var isStateful = colors.insertedNodeEmphasis === 'stateful';
731
+ switch (shape) {
732
+ case 'quote':
733
+ if (!isStateful) {
734
+ return buildInsertStyleQuoteNode(colors);
735
+ }
736
+ return isActive ? buildInsertStyleQuoteNodeActive(colors) : buildInsertStyleQuoteNodeNew(colors);
737
+ case 'rule':
738
+ if (!isStateful) {
739
+ return buildInsertStyleRuleNode(colors);
740
+ }
741
+ return isActive ? buildInsertStyleRuleNodeActive(colors) : buildInsertStyleRuleNodeNew(colors);
742
+ case 'cardBlock':
743
+ if (!isStateful) {
744
+ return buildInsertStyleCardBlockNode(colors);
745
+ }
746
+ return isActive ? buildInsertStyleCardBlockNodeActive(colors) : buildInsertStyleCardBlockNodeNew(colors);
747
+ case 'marker':
748
+ if (!isStateful) {
749
+ return buildDecorationMarkerVariable(colors);
750
+ }
751
+ return isActive ? buildDecorationMarkerVariableActive(colors) : buildDecorationMarkerVariableNew(colors);
752
+ case 'node':
753
+ default:
754
+ if (!isStateful) {
755
+ return buildInsertStyleNode(colors);
756
+ }
757
+ return isActive ? buildInsertStyleNodeActive(colors) : buildInsertStyleNodeNew(colors);
758
+ }
759
+ }
760
+
761
+ /**
762
+ * The category a deleted block node falls into — by node type, not by scheme.
763
+ *
764
+ * 'container' — media, panel: content is a child element, so the node is only dimmed.
765
+ * 'listItem' — listItem: reads the marker variables via editor-core's list styles.
766
+ * 'marker' — extension, embedCard: same, via extension and smart-card styles.
767
+ * 'quote' — blockquote.
768
+ * 'generic' — rule, blockCard, everything else.
769
+ */
770
+
771
+ /**
772
+ * Outline for a deleted block node, driven by `deletedInlineTreatment` (strike vs tint) and
773
+ * `deletedNodeEmphasis` (whether the outline tracks scroll state and emits marker variables).
774
+ */
775
+ export function buildDeletedBlockNodeStyle(colors, category, isActive) {
776
+ var isStrikethrough = colors.deletedInlineTreatment === 'strikethrough';
777
+ var statefulMarker = function statefulMarker() {
778
+ return isActive ? buildDeletedDecorationMarkerVariableActive(colors) : buildDeletedDecorationMarkerVariableNew(colors);
779
+ };
780
+ switch (category) {
781
+ case 'quote':
782
+ // Both emphases share one builder here — `deletedQuoteNodeShape` already carries the
783
+ // only variance (a ring versus a left border).
784
+ return buildDeletedStyleQuoteNode(colors);
785
+ case 'container':
786
+ return isStrikethrough ? buildDeletedInlineStyle(colors, false) : buildDeletedDecorationMarkerVariableSimple(colors);
787
+ case 'listItem':
788
+ return colors.deletedNodeEmphasis === 'stateful' ? statefulMarker() : buildDeletedDecorationMarkerVariableSimple(colors);
789
+ case 'marker':
790
+ return colors.deletedNodeEmphasis === 'stateful' ? statefulMarker() : buildDeletedInlineStyleStandard(colors, 'new');
791
+ case 'generic':
792
+ default:
793
+ return isStrikethrough ? buildDeletedInlineStyle(colors, false) : buildDeletedInlineStyleStandard(colors, 'new');
794
+ }
795
+ }
796
+
797
+ /**
798
+ * Deleted blockquote inside a lozenge wrapper (the nodeview path). Always a ring, since the
799
+ * lozenge needs an enclosed shape, so `deletedQuoteNodeShape` does not apply — only
800
+ * `deletedQuoteNodeActiveTone`, which picks the active ring's tone.
801
+ */
802
+ export function buildDeletedQuoteNodeWithLozengeStyle(colors, isActive) {
803
+ if (!isActive) {
804
+ return buildDeletedStyleQuoteNodeWithLozenge(colors);
805
+ }
806
+ return colors.deletedQuoteNodeActiveTone === 'backgroundPressed' ? buildDeletedStyleQuoteNodeActive(colors) : buildDeletedStyleQuoteNodeWithLozengeActive(colors);
807
+ }
808
+
809
+ /**
810
+ * Outline for a deleted block node via the nodeview wrapper (expand, decisionList, panel,
811
+ * codeBlock). Every scheme shares the active state; `deletedNodeEmphasis` changes only the
812
+ * resting one — 'stateful' a 4px subtlest ring, 'static' a 1px accent ring.
813
+ */
814
+ export function buildDeletedWrappedBlockOutline(colors, _ref) {
815
+ var isActive = _ref.isActive,
816
+ isRounded = _ref.isRounded;
817
+ if (isActive) {
818
+ return isRounded ? buildDeletedBlockOutlineRoundedActive(colors) : buildDeletedBlockOutlineActive(colors);
819
+ }
820
+ if (colors.deletedNodeEmphasis === 'stateful') {
821
+ return isRounded ? buildDeletedBlockOutlineRoundedNew(colors) : buildDeletedBlockOutlineNew(colors);
822
+ }
823
+ return isRounded ? buildDeletedBlockOutlineRounded(colors) : buildDeletedBlockOutline(colors);
824
+ }
825
+
826
+ /**
827
+ * Accent colour for atomic inline changed nodes (date, emoji, mention, status). Set inline on the
828
+ * decoration span and read by the `.show-diff-atomic-inline-changed-*` selectors in
829
+ * EditorContentContainer, on the decorated element or a descendant, so it must inherit. Being
830
+ * inline it beats the stylesheet's fallback, making the plugin the only source of the colour.
831
+ */
832
+ export function buildAtomicInlineChangedCSSVariables(colors) {
833
+ return convertToInlineCss({
834
+ '--show-diff-atomic-inline-changed-border-color': borderAccent(colors.insertColor)
835
+ });
836
+ }
837
+
838
+ /** Deleted node wrapper variables, all three states. Read by the smartCardStyles selectors. */
839
+ export function buildDeletedNodeCSSVariables(colors) {
840
+ return convertToInlineCss({
841
+ '--diff-delete-color': borderAccent(colors.deleteColor),
842
+ '--diff-delete-color-default': borderAccent(colors.deleteActiveColor),
843
+ '--diff-delete-color-new': bgSubtlest(colors.deleteColor),
844
+ '--diff-delete-color-active': bgSubtlerPressed(colors.deleteActiveColor),
845
+ '--diff-delete-text-decoration-color': borderAccent(colors.deleteColor)
846
+ });
622
847
  }
@@ -6,13 +6,18 @@ export var traditionalScheme = {
6
6
  deleteColor: 'red',
7
7
  deleteActiveColor: 'red',
8
8
  deletedCellColor: 'gray',
9
+ deletedRowTreatment: 'strikeColor',
9
10
  insertedCellOpacity: 0.5,
10
11
  deletedQuoteNodeShape: 'ring',
11
12
  deletedCellBorderProminence: 'subtle',
12
- deletedRowTreatment: 'strikeColor',
13
13
  deletedBlockOutlineActiveEmphasis: 'background',
14
14
  addedCellOverlayZIndex: 1,
15
- roundedAddedCellOverlayInheritsBorder: true
15
+ roundedAddedCellOverlayInheritsBorder: true,
16
+ insertedInlineTreatment: 'underline',
17
+ deletedInlineTreatment: 'strikethrough',
18
+ insertedNodeEmphasis: 'stateful',
19
+ deletedNodeEmphasis: 'stateful',
20
+ deletedQuoteNodeActiveTone: 'backgroundPressed'
16
21
  };
17
22
 
18
23
  /** Purple insertions, gray deletions (red on active). */
@@ -23,11 +28,22 @@ export var standardScheme = {
23
28
  deleteColor: 'gray',
24
29
  deleteActiveColor: 'red',
25
30
  deletedCellColor: 'gray',
31
+ deletedRowTreatment: 'textTint',
26
32
  insertedCellOpacity: 0.2,
27
33
  deletedQuoteNodeShape: 'borderLeft',
28
34
  deletedCellBorderProminence: 'accent',
29
- deletedRowTreatment: 'textTint',
30
35
  deletedBlockOutlineActiveEmphasis: 'border',
31
36
  addedCellOverlayZIndex: 2,
32
- roundedAddedCellOverlayInheritsBorder: false
37
+ roundedAddedCellOverlayInheritsBorder: false,
38
+ insertedInlineTreatment: 'borderBottom',
39
+ deletedInlineTreatment: 'glyphTint',
40
+ insertedNodeEmphasis: 'static',
41
+ deletedNodeEmphasis: 'static',
42
+ deletedQuoteNodeActiveTone: 'borderAccent'
43
+ };
44
+
45
+ /** Maps the public ColorScheme string to its data object. Adding a scheme = one entry here. */
46
+ export var colorSchemeRegistry = {
47
+ traditional: traditionalScheme,
48
+ standard: standardScheme
33
49
  };
@@ -1,15 +1,65 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
3
3
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
4
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
6
  import { isExtendedEnabled } from '../isExtendedEnabled';
6
- import { standardDecorationMarkerVariable, deletedDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode, deletedContentStyleNew, deletedStyleQuoteNode, addedCellOverlayRoundedStyle, addedCellOverlayStyle, deletedCellOverlayStyle, deletedCellOverlayRoundedStyle } from './colorSchemes/standard';
7
- import { traditionalDecorationMarkerVariableActive, traditionalDecorationMarkerVariableNew, traditionalDeletedDecorationMarkerVariableActive, traditionalDeletedDecorationMarkerVariableNew, traditionalStyleQuoteNodeActive, traditionalStyleQuoteNodeNew, traditionalStyleRuleNodeActive, traditionalStyleRuleNodeNew, traditionalStyleCardBlockNodeActive, traditionalStyleCardBlockNodeNew, traditionalStyleNodeActive, traditionalStyleNodeNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, traditionalAddedCellOverlayRoundedStyle, traditionalAddedCellOverlayStyle, deletedTraditionalCellOverlayStyle, deletedTraditionalCellOverlayRoundedStyle } from './colorSchemes/traditional';
7
+ import { buildAddedCellOverlayRoundedStyle, buildAddedCellOverlayStyle, buildDeletedBlockNodeStyle, buildDeletedCellOverlayRoundedStyle, buildDeletedCellOverlayStyle, buildInsertedBlockNodeStyle } from './colorSchemes/factory';
8
+ import { colorSchemeRegistry } from './colorSchemes/schemes';
8
9
  import { createBlockIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
9
10
  import { buildDiffDecorationSpec } from './decorationKeys';
11
+ import { getBlockNodeStyleLegacy, resolveCellOverlayStyleLegacy } from './createBlockChangedDecoration.styles.legacy';
10
12
  var displayNoneStyle = convertToInlineCss({
11
13
  display: 'none'
12
14
  });
15
+ var DEFAULT_COLOR_SCHEME = 'standard';
16
+
17
+ /** Nodes that carry no decoration styling of their own — layout, lists, text blocks, media groups. */
18
+ var UNSTYLED_NODES = ['mediaSingle', 'mediaGroup', 'table',
19
+ // Handle table separately to avoid border issues
20
+ 'tableRow', 'paragraph',
21
+ // Paragraph and heading nodes do not need special styling
22
+ 'heading', 'hardBreak', 'decisionList', 'taskList', 'bulletList', 'orderedList', 'layoutSection'];
23
+ var CELL_NODES = ['tableCell', 'tableHeader'];
24
+
25
+ /** Positioning context for the cell overlay widget decorations. */
26
+ var cellPositionStyle = convertToInlineCss({
27
+ position: 'relative'
28
+ });
29
+ var getInsertedBlockNodeShape = function getInsertedBlockNodeShape(nodeName) {
30
+ switch (nodeName) {
31
+ case 'blockquote':
32
+ return 'quote';
33
+ case 'rule':
34
+ return 'rule';
35
+ case 'blockCard':
36
+ return 'cardBlock';
37
+ case 'extension':
38
+ case 'embedCard':
39
+ case 'listItem':
40
+ return 'marker';
41
+ default:
42
+ return 'node';
43
+ }
44
+ };
45
+ var getDeletedBlockNodeCategory = function getDeletedBlockNodeCategory(nodeName) {
46
+ switch (nodeName) {
47
+ case 'blockquote':
48
+ return 'quote';
49
+ // Media nodes inside mediaSingle should not get position:relative
50
+ // as it shifts the image outside its parent container (e.g. panel)
51
+ case 'media':
52
+ case 'panel':
53
+ return 'container';
54
+ case 'listItem':
55
+ return 'listItem';
56
+ case 'extension':
57
+ case 'embedCard':
58
+ return 'marker';
59
+ default:
60
+ return 'generic';
61
+ }
62
+ };
13
63
  var getNodeClass = function getNodeClass(name) {
14
64
  switch (name) {
15
65
  case 'extension':
@@ -18,7 +68,7 @@ var getNodeClass = function getNodeClass(name) {
18
68
  return undefined;
19
69
  }
20
70
  };
21
- var getBlockNodeStyle = function getBlockNodeStyle(_ref) {
71
+ var getBlockNodeStyleNext = function getBlockNodeStyleNext(_ref) {
22
72
  var nodeName = _ref.nodeName,
23
73
  colorScheme = _ref.colorScheme,
24
74
  _ref$isInserted = _ref.isInserted,
@@ -26,90 +76,29 @@ var getBlockNodeStyle = function getBlockNodeStyle(_ref) {
26
76
  _ref$isActive = _ref.isActive,
27
77
  isActive = _ref$isActive === void 0 ? false : _ref$isActive,
28
78
  diffType = _ref.diffType;
29
- var isTraditional = colorScheme === 'traditional';
30
- if (['mediaSingle', 'mediaGroup', 'table',
31
- // Handle table separately to avoid border issues
32
- 'tableRow', 'paragraph',
33
- // Paragraph and heading nodes do not need special styling
34
- 'heading', 'hardBreak', 'decisionList', 'taskList', 'bulletList', 'orderedList', 'layoutSection'].includes(nodeName)) {
35
- // Layout nodes do not need special styling
79
+ if (UNSTYLED_NODES.includes(nodeName)) {
36
80
  return undefined;
37
81
  }
38
- // Media nodes inside mediaSingle should not get position:relative
39
- // as it shifts the image outside its parent container (e.g. panel)
40
- if (nodeName === 'media') {
41
- if (!isInserted && isExtendedEnabled(diffType)) {
42
- return isTraditional ? getDeletedTraditionalInlineStyle(false) : deletedDecorationMarkerVariable;
43
- }
44
- return isTraditional ? isActive ? traditionalStyleNodeActive : traditionalStyleNodeNew : editingStyleNode;
45
- }
46
- if (['tableCell', 'tableHeader'].includes(nodeName)) {
47
- if (isExtendedEnabled(diffType)) {
48
- // This is used for positioning the cell overlay widget decorations
49
- return convertToInlineCss({
50
- position: 'relative'
51
- });
52
- }
53
- // When gate is off, it should return undefined as above
54
- return undefined;
55
- }
56
- if (nodeName === 'panel') {
57
- if (!isInserted && isExtendedEnabled(diffType)) {
58
- return isTraditional ? getDeletedTraditionalInlineStyle(false) : deletedDecorationMarkerVariable;
59
- }
60
- return isTraditional ? isActive ? traditionalStyleNodeActive : traditionalStyleNodeNew : editingStyleNode;
61
- }
62
- if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
63
- if (isExtendedEnabled(diffType)) {
64
- if (isInserted) {
65
- return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ? traditionalDecorationMarkerVariableNew : standardDecorationMarkerVariable;
66
- } else {
67
- if (nodeName === 'listItem') {
68
- return isTraditional && isActive ? traditionalDeletedDecorationMarkerVariableActive : isTraditional ? traditionalDeletedDecorationMarkerVariableNew : deletedDecorationMarkerVariable;
69
- }
70
- return isTraditional && isActive ? traditionalDeletedDecorationMarkerVariableActive : isTraditional ? traditionalDeletedDecorationMarkerVariableNew : deletedContentStyleNew;
71
- }
72
- }
73
- return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ? traditionalDecorationMarkerVariableNew : standardDecorationMarkerVariable;
74
- }
75
- if (nodeName === 'blockquote') {
76
- if (isExtendedEnabled(diffType)) {
77
- if (isInserted) {
78
- return isTraditional ? isActive ? traditionalStyleQuoteNodeActive : traditionalStyleQuoteNodeNew : editingStyleQuoteNode;
79
- } else {
80
- return isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNode;
81
- }
82
- }
83
- return isTraditional ? isActive ? traditionalStyleQuoteNodeActive : traditionalStyleQuoteNodeNew : editingStyleQuoteNode;
84
- }
85
- if (nodeName === 'rule') {
86
- if (isExtendedEnabled(diffType)) {
87
- if (isInserted) {
88
- return isTraditional ? isActive ? traditionalStyleRuleNodeActive : traditionalStyleRuleNodeNew : editingStyleRuleNode;
89
- } else {
90
- return isTraditional ? getDeletedTraditionalInlineStyle(false) : deletedContentStyleNew;
91
- }
92
- }
93
- return isTraditional ? isActive ? traditionalStyleRuleNodeActive : traditionalStyleRuleNodeNew : editingStyleRuleNode;
82
+ if (CELL_NODES.includes(nodeName)) {
83
+ // When the gate is off, cells get no styling — as with UNSTYLED_NODES above.
84
+ return isExtendedEnabled(diffType) ? cellPositionStyle : undefined;
94
85
  }
95
- if (nodeName === 'blockCard') {
96
- if (isExtendedEnabled(diffType)) {
97
- if (isInserted) {
98
- return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive : traditionalStyleCardBlockNodeNew : editingStyleCardBlockNode;
99
- } else {
100
- return isTraditional ? getDeletedTraditionalInlineStyle(false) : deletedContentStyleNew;
101
- }
102
- }
103
- return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive : traditionalStyleCardBlockNodeNew : editingStyleCardBlockNode;
104
- }
105
- if (isExtendedEnabled(diffType)) {
106
- if (isInserted) {
107
- return isTraditional ? isActive ? traditionalStyleNodeActive : traditionalStyleNodeNew : editingStyleNode;
108
- } else {
109
- return isTraditional ? getDeletedTraditionalInlineStyle(false) : deletedContentStyleNew;
110
- }
86
+ var colors = colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : DEFAULT_COLOR_SCHEME];
87
+
88
+ // Deleted nodes only differ under the extended experience; otherwise all are insertions.
89
+ if (!isInserted && isExtendedEnabled(diffType)) {
90
+ return buildDeletedBlockNodeStyle(colors, getDeletedBlockNodeCategory(nodeName), isActive);
111
91
  }
112
- return isTraditional ? isActive ? traditionalStyleNodeActive : traditionalStyleNodeNew : editingStyleNode;
92
+ return buildInsertedBlockNodeStyle(colors, getInsertedBlockNodeShape(nodeName), isActive);
93
+ };
94
+
95
+ /**
96
+ * Dispatches to the registry-driven implementation, or to the verbatim pre-refactor one for the
97
+ * OFF cohort of `platform_editor_show_diff_color_scheme_refactor`. Both are built to emit the
98
+ * same style strings for both shipped schemes; see EDITOR-8281.
99
+ */
100
+ var getBlockNodeStyle = function getBlockNodeStyle(props) {
101
+ return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getBlockNodeStyleNext(props) : getBlockNodeStyleLegacy(props);
113
102
  };
114
103
 
115
104
  /**
@@ -172,20 +161,21 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
172
161
  diffType: diffType
173
162
  }))];
174
163
  }
175
- var style;
176
- if (isExtendedEnabled(diffType) && ['tableCell', 'tableHeader'].includes(change.name)) {
164
+ if (isExtendedEnabled(diffType) && CELL_NODES.includes(change.name)) {
177
165
  var cellOverlay = document.createElement('div');
178
- var isTraditional = colorScheme === 'traditional';
166
+ var colors = colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : DEFAULT_COLOR_SCHEME];
179
167
  var isRoundedTable = expValEquals('platform_editor_table_diff_rounded_corners', 'isEnabled', true);
180
- var addedCellStyle = isTraditional ? isRoundedTable ? traditionalAddedCellOverlayRoundedStyle : traditionalAddedCellOverlayStyle : isRoundedTable ? addedCellOverlayRoundedStyle : addedCellOverlayStyle;
181
- var deletedCellStyle = isTraditional ? isRoundedTable ? deletedTraditionalCellOverlayRoundedStyle : deletedTraditionalCellOverlayStyle : isRoundedTable ? deletedCellOverlayRoundedStyle : deletedCellOverlayStyle;
182
168
 
183
169
  // On an inverted diff, an empty cell being filled is an addition, so give it the
184
170
  // added (purple) overlay instead of the deleted (grey) one (EDITOR-8442).
185
171
  var cellNode = doc === null || doc === void 0 ? void 0 : doc.nodeAt(change.from);
186
172
  var isEmptyCellBeingFilled = !isInserted && !!cellNode && isCellEmpty(cellNode);
187
173
  var useAddedStyle = isInserted || isEmptyCellBeingFilled;
188
- var cellOverlayStyle = useAddedStyle ? addedCellStyle : deletedCellStyle;
174
+ var cellOverlayStyle = isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? useAddedStyle ? isRoundedTable ? buildAddedCellOverlayRoundedStyle(colors) : buildAddedCellOverlayStyle(colors) : isRoundedTable ? buildDeletedCellOverlayRoundedStyle(colors) : buildDeletedCellOverlayStyle(colors) : resolveCellOverlayStyleLegacy({
175
+ colorScheme: colorScheme,
176
+ isRoundedTable: isRoundedTable,
177
+ useAddedStyle: useAddedStyle
178
+ });
189
179
  cellOverlay.setAttribute('style', cellOverlayStyle);
190
180
  decorations.push(
191
181
  // change.to - 1 to position the overlay inside the end of the cell
@@ -195,22 +185,14 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
195
185
  key: 'cell-overlay-decoration'
196
186
  }));
197
187
  }
198
- if (isExtendedEnabled(diffType)) {
199
- style = getBlockNodeStyle({
200
- nodeName: change.name,
201
- colorScheme: colorScheme,
202
- isInserted: isInserted,
203
- isActive: isActive,
204
- diffType: diffType
205
- });
206
- } else {
207
- style = getBlockNodeStyle({
208
- nodeName: change.name,
209
- colorScheme: colorScheme,
210
- isActive: isActive,
211
- diffType: diffType
212
- });
213
- }
188
+ // isInserted is only read under the extended experience, so pass it unconditionally.
189
+ var style = getBlockNodeStyle({
190
+ nodeName: change.name,
191
+ colorScheme: colorScheme,
192
+ isInserted: isInserted,
193
+ isActive: isActive,
194
+ diffType: diffType
195
+ });
214
196
  var className = getNodeClass(change.name);
215
197
  if (style || className) {
216
198
  decorations.push(Decoration.node(change.from, change.to, {