@atlaskit/editor-plugin-show-diff 10.1.10 → 10.1.11
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/calculateDiff/calculateDiffDecorations.js +118 -31
- package/dist/cjs/pm-plugins/calculateDiff/diffBySteps.js +124 -1
- package/dist/cjs/pm-plugins/decorations/createGranularBlockReferenceWidget.js +125 -0
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +17 -103
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +79 -1
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +91 -7
- package/dist/es2019/pm-plugins/calculateDiff/diffBySteps.js +104 -0
- package/dist/es2019/pm-plugins/decorations/createGranularBlockReferenceWidget.js +120 -0
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +1 -81
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +74 -2
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +119 -32
- package/dist/esm/pm-plugins/calculateDiff/diffBySteps.js +123 -0
- package/dist/esm/pm-plugins/decorations/createGranularBlockReferenceWidget.js +120 -0
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +13 -98
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +79 -2
- package/dist/types/pm-plugins/calculateDiff/diffBySteps.d.ts +20 -0
- package/dist/types/pm-plugins/decorations/createGranularBlockReferenceWidget.d.ts +36 -0
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +15 -0
- package/package.json +2 -2
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
3
|
import { trackChangesMessages } from '@atlaskit/editor-common/messages';
|
|
3
4
|
import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
|
|
4
5
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
|
-
import { deletedBlockOutline, deletedBlockOutlineActive, deletedBlockOutlineRounded, deletedBlockOutlineRoundedActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedStyleQuoteNodeWithLozenge, deletedStyleQuoteNodeWithLozengeActive, editingContentStyleInBlockExtended, editingStyleExtended, editingStyleActiveExtended, editingStyleNode, addedCellOverlayStyle, deletedCellOverlayStyle } from '../colorSchemes/standard';
|
|
6
|
-
import { deletedTraditionalBlockOutlineActive, deletedTraditionalBlockOutlineNew, deletedTraditionalBlockOutlineRoundedActive, deletedTraditionalBlockOutlineRoundedNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, deletedTraditionalStyleQuoteNodeActive, traditionalInsertStyle, traditionalInsertStyleActive, traditionalStyleNodeActive, traditionalStyleNodeNew, traditionalAddedCellOverlayStyleNew, deletedTraditionalCellOverlayStyle } from '../colorSchemes/traditional';
|
|
6
|
+
import { deletedBlockOutline, deletedBlockOutlineActive, deletedBlockOutlineRounded, deletedBlockOutlineRoundedActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleUnbounded, deletedInlineContentStyleExtended, deletedStyleQuoteNodeWithLozenge, deletedStyleQuoteNodeWithLozengeActive, editingContentStyleInBlockExtended, editingStyleExtended, editingStyleActiveExtended, editingStyleNode, addedCellOverlayStyle, deletedCellOverlayStyle } from '../colorSchemes/standard';
|
|
7
|
+
import { deletedTraditionalBlockOutlineActive, deletedTraditionalBlockOutlineNew, deletedTraditionalBlockOutlineRoundedActive, deletedTraditionalBlockOutlineRoundedNew, deletedTraditionalContentStyleUnbounded, deletedTraditionalContentStyleUnboundedActive, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, deletedTraditionalStyleQuoteNodeActive, traditionalInsertStyle, traditionalInsertStyleActive, traditionalStyleNodeActive, traditionalStyleNodeNew, traditionalAddedCellOverlayStyleNew, deletedTraditionalCellOverlayStyle } from '../colorSchemes/traditional';
|
|
7
8
|
var lozengeStyle = convertToInlineCss({
|
|
8
9
|
display: 'inline-flex',
|
|
9
10
|
boxSizing: 'border-box',
|
|
@@ -545,4 +546,80 @@ export var wrapBlockNodeView = function wrapBlockNodeView(_ref0) {
|
|
|
545
546
|
});
|
|
546
547
|
}
|
|
547
548
|
}
|
|
549
|
+
};
|
|
550
|
+
var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
|
|
551
|
+
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
552
|
+
if (colorScheme === 'traditional' && isActive) {
|
|
553
|
+
return deletedTraditionalContentStyleUnboundedActive;
|
|
554
|
+
}
|
|
555
|
+
return colorScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
|
|
556
|
+
};
|
|
557
|
+
var getInsertedContentStyle = function getInsertedContentStyle(colorScheme) {
|
|
558
|
+
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
559
|
+
if (colorScheme === 'traditional') {
|
|
560
|
+
return isActive ? traditionalInsertStyleActive : traditionalInsertStyle;
|
|
561
|
+
}
|
|
562
|
+
if (isActive) {
|
|
563
|
+
return editingStyleActiveExtended;
|
|
564
|
+
}
|
|
565
|
+
return editingStyleExtended;
|
|
566
|
+
};
|
|
567
|
+
var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
|
|
568
|
+
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
569
|
+
if (colorScheme === 'traditional') {
|
|
570
|
+
return getDeletedTraditionalInlineStyle(isActive);
|
|
571
|
+
}
|
|
572
|
+
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
573
|
+
return (isActive ? deletedContentStyleActive : deletedContentStyleNew) + deletedInlineContentStyleExtended;
|
|
574
|
+
}
|
|
575
|
+
return isActive ? deletedContentStyleActive : deletedContentStyleNew;
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Injects a styled inner wrapper span around the children of a block node element.
|
|
580
|
+
* CSS backgrounds don't work when applied to a wrapper around a paragraph, so
|
|
581
|
+
* the wrapper needs to be injected inside the node around the child content.
|
|
582
|
+
*/
|
|
583
|
+
export var injectInnerWrapper = function injectInnerWrapper(_ref1) {
|
|
584
|
+
var node = _ref1.node,
|
|
585
|
+
colorScheme = _ref1.colorScheme,
|
|
586
|
+
isActive = _ref1.isActive,
|
|
587
|
+
isInserted = _ref1.isInserted;
|
|
588
|
+
var wrapper = document.createElement('span');
|
|
589
|
+
wrapper.setAttribute('style', isInserted ? getInsertedContentStyle(colorScheme, isActive) : getDeletedContentStyle(colorScheme, isActive));
|
|
590
|
+
_toConsumableArray(node.childNodes).forEach(function (child) {
|
|
591
|
+
var removedChild = node.removeChild(child);
|
|
592
|
+
wrapper.append(removedChild);
|
|
593
|
+
});
|
|
594
|
+
node.appendChild(wrapper);
|
|
595
|
+
return node;
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Creates a styled span wrapper for inline content within a change decoration.
|
|
600
|
+
*/
|
|
601
|
+
export var createContentWrapper = function createContentWrapper(colorScheme) {
|
|
602
|
+
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
603
|
+
var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
604
|
+
var wrapper = document.createElement('span');
|
|
605
|
+
var baseStyle = convertToInlineCss({
|
|
606
|
+
position: 'relative',
|
|
607
|
+
width: 'fit-content'
|
|
608
|
+
});
|
|
609
|
+
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
610
|
+
if (isInserted) {
|
|
611
|
+
wrapper.setAttribute('style', "".concat(baseStyle).concat(getInsertedContentStyle(colorScheme, isActive)));
|
|
612
|
+
} else {
|
|
613
|
+
wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
|
|
614
|
+
var strikethrough = document.createElement('span');
|
|
615
|
+
strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
|
|
616
|
+
wrapper.append(strikethrough);
|
|
617
|
+
}
|
|
618
|
+
} else {
|
|
619
|
+
wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
|
|
620
|
+
var _strikethrough = document.createElement('span');
|
|
621
|
+
_strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
|
|
622
|
+
wrapper.append(_strikethrough);
|
|
623
|
+
}
|
|
624
|
+
return wrapper;
|
|
548
625
|
};
|
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import { type Change } from 'prosemirror-changeset';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
4
|
+
type StepChanges = {
|
|
5
|
+
changes: Change[];
|
|
6
|
+
isGranular: boolean;
|
|
7
|
+
};
|
|
4
8
|
export declare const diffBySteps: (originalDoc: PMNode, steps: Step[]) => Change[];
|
|
9
|
+
/**
|
|
10
|
+
* A fork of `diffBySteps` that returns changes grouped per step, rather than as a flat list.
|
|
11
|
+
*
|
|
12
|
+
* Why forked rather than refactoring `diffBySteps`:
|
|
13
|
+
* - `diffBySteps` returns a flat `Change[]` and is consumed by the existing decoration path.
|
|
14
|
+
* Changing its return shape would require threading per-step metadata through all callers,
|
|
15
|
+
* adding complexity to a stable code path.
|
|
16
|
+
* - The per-step grouping is only needed for the `platform_editor_diff_granular_extended` gate,
|
|
17
|
+
* where we need to know how many granular changes a single step produced in order to decide
|
|
18
|
+
* whether to suppress deleted decorations (threshold: > 3 granular changes per step).
|
|
19
|
+
* - Keeping the two functions separate means each has a clear, focused contract and neither
|
|
20
|
+
* accumulates the other's concerns. Shared logic (mapping helpers, `mergeOverlappingByNewDocRange`,
|
|
21
|
+
* `shouldCheckGranularDiff`, etc.) is already extracted and reused by both.
|
|
22
|
+
*/
|
|
23
|
+
export declare const getStepChanges: (originalDoc: PMNode, steps: Step[]) => StepChanges[];
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Change } from 'prosemirror-changeset';
|
|
2
|
+
import type { IntlShape } from 'react-intl';
|
|
3
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import type { ColorScheme } from '../../showDiffPluginType';
|
|
6
|
+
import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a single block widget that renders a reference text block content
|
|
9
|
+
* beneath a granular diff set, for reference when deleted content is hidden.
|
|
10
|
+
*
|
|
11
|
+
* Since granular diffing only applies to singular isTextBlock=true nodes, this
|
|
12
|
+
* widget always renders exactly one block node and does not need the slice/fragment
|
|
13
|
+
* complexity of createNodeChangedDecorationWidget.
|
|
14
|
+
*
|
|
15
|
+
* Resolves which doc and positions to render based on isInverted:
|
|
16
|
+
* - !isInverted: renders originalDoc at A-side positions (what was there before)
|
|
17
|
+
* - isInverted: renders newDoc at B-side positions (the current/new content)
|
|
18
|
+
*
|
|
19
|
+
* The widget is always inserted at the B-side block boundary in newDoc since
|
|
20
|
+
* ProseMirror decorations are always anchored against the live (new) document.
|
|
21
|
+
*/
|
|
22
|
+
export declare const createGranularBlockReferenceWidget: ({ change, originalDoc, newDoc, isInverted, nodeViewSerializer, colorScheme, intl, activeIndexPos, diffId, showIndicators, }: {
|
|
23
|
+
activeIndexPos?: {
|
|
24
|
+
from: number;
|
|
25
|
+
to: number;
|
|
26
|
+
};
|
|
27
|
+
change: Change;
|
|
28
|
+
colorScheme?: ColorScheme;
|
|
29
|
+
diffId: string;
|
|
30
|
+
intl: IntlShape;
|
|
31
|
+
isInverted: boolean;
|
|
32
|
+
newDoc: PMNode;
|
|
33
|
+
nodeViewSerializer: NodeViewSerializer;
|
|
34
|
+
originalDoc: PMNode;
|
|
35
|
+
showIndicators?: boolean;
|
|
36
|
+
}) => Decoration[];
|
|
@@ -15,3 +15,18 @@ export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorSchem
|
|
|
15
15
|
nodeView: Node;
|
|
16
16
|
targetNode: PMNode;
|
|
17
17
|
}) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Injects a styled inner wrapper span around the children of a block node element.
|
|
20
|
+
* CSS backgrounds don't work when applied to a wrapper around a paragraph, so
|
|
21
|
+
* the wrapper needs to be injected inside the node around the child content.
|
|
22
|
+
*/
|
|
23
|
+
export declare const injectInnerWrapper: ({ node, colorScheme, isActive, isInserted, }: {
|
|
24
|
+
colorScheme?: ColorScheme;
|
|
25
|
+
isActive?: boolean;
|
|
26
|
+
isInserted?: boolean;
|
|
27
|
+
node: HTMLElement;
|
|
28
|
+
}) => HTMLElement;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a styled span wrapper for inline content within a change decoration.
|
|
31
|
+
*/
|
|
32
|
+
export declare const createContentWrapper: (colorScheme?: ColorScheme, isActive?: boolean, isInserted?: boolean) => HTMLElement;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.11",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
29
29
|
"@atlaskit/editor-tables": "^3.0.0",
|
|
30
30
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
31
|
-
"@atlaskit/tmp-editor-statsig": "^114.
|
|
31
|
+
"@atlaskit/tmp-editor-statsig": "^114.5.0",
|
|
32
32
|
"@atlaskit/tokens": "^15.2.0",
|
|
33
33
|
"@babel/runtime": "^7.0.0",
|
|
34
34
|
"@compiled/react": "^0.20.0",
|