@atlaskit/editor-plugin-show-diff 5.0.5 → 5.0.7
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 +17 -0
- package/dist/cjs/pm-plugins/calculateDiffDecorations.js +12 -10
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +75 -0
- package/dist/cjs/pm-plugins/{deletedRowsHandler.js → decorations/createChangedRowDecorationWidgets.js} +31 -52
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +33 -0
- package/dist/cjs/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js} +29 -118
- package/dist/cjs/pm-plugins/{attributeDecorations.js → decorations/utils/getAttrChangeRanges.js} +1 -1
- package/dist/cjs/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js} +83 -21
- package/dist/cjs/pm-plugins/simplifyChanges.js +3 -4
- package/dist/es2019/pm-plugins/calculateDiffDecorations.js +6 -4
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +70 -0
- package/dist/es2019/pm-plugins/{deletedRowsHandler.js → decorations/createChangedRowDecorationWidgets.js} +28 -50
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +28 -0
- package/dist/es2019/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js} +16 -107
- package/dist/es2019/pm-plugins/{attributeDecorations.js → decorations/utils/getAttrChangeRanges.js} +1 -1
- package/dist/es2019/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js} +85 -18
- package/dist/es2019/pm-plugins/simplifyChanges.js +3 -4
- package/dist/esm/pm-plugins/calculateDiffDecorations.js +6 -4
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +69 -0
- package/dist/esm/pm-plugins/{deletedRowsHandler.js → decorations/createChangedRowDecorationWidgets.js} +30 -51
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +28 -0
- package/dist/esm/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js} +30 -119
- package/dist/esm/pm-plugins/{attributeDecorations.js → decorations/utils/getAttrChangeRanges.js} +1 -1
- package/dist/esm/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js} +80 -18
- package/dist/esm/pm-plugins/simplifyChanges.js +3 -4
- package/dist/types/pm-plugins/NodeViewSerializer.d.ts +1 -1
- package/dist/types/pm-plugins/calculateDiffDecorations.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +16 -0
- package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +17 -0
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +16 -0
- package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +15 -0
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +15 -0
- package/dist/types-ts4.5/pm-plugins/NodeViewSerializer.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/calculateDiffDecorations.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/decorations/createBlockChangedDecoration.d.ts +16 -0
- package/dist/types-ts4.5/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +17 -0
- package/dist/types-ts4.5/pm-plugins/decorations/createInlineChangedDecoration.d.ts +16 -0
- package/dist/types-ts4.5/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +15 -0
- package/dist/types-ts4.5/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +15 -0
- package/package.json +4 -7
- package/dist/types/pm-plugins/decorations.d.ts +0 -46
- package/dist/types/pm-plugins/deletedBlocksHandler.d.ts +0 -14
- package/dist/types/pm-plugins/deletedRowsHandler.d.ts +0 -36
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +0 -46
- package/dist/types-ts4.5/pm-plugins/deletedBlocksHandler.d.ts +0 -14
- package/dist/types-ts4.5/pm-plugins/deletedRowsHandler.d.ts +0 -36
- /package/dist/cjs/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.js +0 -0
- /package/dist/cjs/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.js +0 -0
- /package/dist/cjs/pm-plugins/{findSafeInsertPos.js → decorations/utils/findSafeInsertPos.js} +0 -0
- /package/dist/cjs/pm-plugins/{markDecorations.js → decorations/utils/getMarkChangeRanges.js} +0 -0
- /package/dist/es2019/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.js +0 -0
- /package/dist/es2019/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.js +0 -0
- /package/dist/es2019/pm-plugins/{findSafeInsertPos.js → decorations/utils/findSafeInsertPos.js} +0 -0
- /package/dist/es2019/pm-plugins/{markDecorations.js → decorations/utils/getMarkChangeRanges.js} +0 -0
- /package/dist/esm/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.js +0 -0
- /package/dist/esm/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.js +0 -0
- /package/dist/esm/pm-plugins/{findSafeInsertPos.js → decorations/utils/findSafeInsertPos.js} +0 -0
- /package/dist/esm/pm-plugins/{markDecorations.js → decorations/utils/getMarkChangeRanges.js} +0 -0
- /package/dist/types/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.d.ts +0 -0
- /package/dist/types/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.d.ts +0 -0
- /package/dist/types/pm-plugins/{findSafeInsertPos.d.ts → decorations/utils/findSafeInsertPos.d.ts} +0 -0
- /package/dist/types/pm-plugins/{attributeDecorations.d.ts → decorations/utils/getAttrChangeRanges.d.ts} +0 -0
- /package/dist/types/pm-plugins/{markDecorations.d.ts → decorations/utils/getMarkChangeRanges.d.ts} +0 -0
- /package/dist/types-ts4.5/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.d.ts +0 -0
- /package/dist/types-ts4.5/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.d.ts +0 -0
- /package/dist/types-ts4.5/pm-plugins/{findSafeInsertPos.d.ts → decorations/utils/findSafeInsertPos.d.ts} +0 -0
- /package/dist/types-ts4.5/pm-plugins/{attributeDecorations.d.ts → decorations/utils/getAttrChangeRanges.d.ts} +0 -0
- /package/dist/types-ts4.5/pm-plugins/{markDecorations.d.ts → decorations/utils/getMarkChangeRanges.d.ts} +0 -0
package/dist/esm/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js}
RENAMED
|
@@ -1,40 +1,15 @@
|
|
|
1
1
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
|
-
import { deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive,
|
|
6
|
-
import { deletedTraditionalContentStyle, deletedTraditionalContentStyleUnbounded
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
* Inline decoration used for insertions as the content already exists in the document
|
|
12
|
-
*
|
|
13
|
-
* @param change Changeset "change" containing information about the change content + range
|
|
14
|
-
* @returns Prosemirror inline decoration
|
|
15
|
-
*/
|
|
16
|
-
export var createInlineChangedDecoration = function createInlineChangedDecoration(_ref) {
|
|
17
|
-
var change = _ref.change,
|
|
18
|
-
colorScheme = _ref.colorScheme,
|
|
19
|
-
_ref$isActive = _ref.isActive,
|
|
20
|
-
isActive = _ref$isActive === void 0 ? false : _ref$isActive;
|
|
21
|
-
var style;
|
|
22
|
-
if (colorScheme === 'traditional') {
|
|
23
|
-
style = isActive ? traditionalInsertStyleActive : traditionalInsertStyle;
|
|
24
|
-
} else {
|
|
25
|
-
style = isActive ? editingStyleActive : editingStyle;
|
|
26
|
-
}
|
|
27
|
-
return Decoration.inline(change.fromB, change.toB, {
|
|
28
|
-
style: style,
|
|
29
|
-
'data-testid': 'show-diff-changed-decoration'
|
|
30
|
-
}, {
|
|
31
|
-
key: 'diff-inline'
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
export var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
|
|
4
|
+
import { deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive, deletedContentStyleUnbounded } from './colorSchemes/standard';
|
|
5
|
+
import { deletedTraditionalContentStyle, deletedTraditionalContentStyleUnbounded } from './colorSchemes/traditional';
|
|
6
|
+
import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
|
|
7
|
+
import { findSafeInsertPos } from './utils/findSafeInsertPos';
|
|
8
|
+
import { wrapBlockNodeView } from './utils/wrapBlockNodeView';
|
|
9
|
+
var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
|
|
35
10
|
return colorScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
|
|
36
11
|
};
|
|
37
|
-
|
|
12
|
+
var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
|
|
38
13
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
39
14
|
if (colorScheme === 'traditional') {
|
|
40
15
|
return deletedTraditionalContentStyle;
|
|
@@ -44,38 +19,6 @@ export var getDeletedContentStyle = function getDeletedContentStyle(colorScheme)
|
|
|
44
19
|
}
|
|
45
20
|
return expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNew : deletedContentStyle;
|
|
46
21
|
};
|
|
47
|
-
var getNodeClass = function getNodeClass(name) {
|
|
48
|
-
switch (name) {
|
|
49
|
-
case 'extension':
|
|
50
|
-
return 'show-diff-changed-decoration-node';
|
|
51
|
-
default:
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
var getBlockNodeStyle = function getBlockNodeStyle(nodeName, colorScheme) {
|
|
56
|
-
var isTraditional = colorScheme === 'traditional';
|
|
57
|
-
if (['mediaSingle', 'mediaGroup', 'table',
|
|
58
|
-
// Handle table separately to avoid border issues
|
|
59
|
-
'tableRow', 'tableCell', 'tableHeader', 'paragraph',
|
|
60
|
-
// Paragraph and heading nodes do not need special styling
|
|
61
|
-
'heading', 'hardBreak', 'decisionList', 'taskList', 'taskItem', 'bulletList', 'orderedList', 'layoutSection'].includes(nodeName)) {
|
|
62
|
-
// Layout nodes do not need special styling
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
|
|
66
|
-
return isTraditional ? traditionalDecorationMarkerVariable : standardDecorationMarkerVariable;
|
|
67
|
-
}
|
|
68
|
-
if (nodeName === 'blockquote') {
|
|
69
|
-
return isTraditional ? traditionalStyleQuoteNode : editingStyleQuoteNode;
|
|
70
|
-
}
|
|
71
|
-
if (nodeName === 'rule') {
|
|
72
|
-
return isTraditional ? traditionalStyleRuleNode : editingStyleRuleNode;
|
|
73
|
-
}
|
|
74
|
-
if (nodeName === 'blockCard') {
|
|
75
|
-
return isTraditional ? traditionalStyleCardBlockNode : editingStyleCardBlockNode;
|
|
76
|
-
}
|
|
77
|
-
return isTraditional ? traditionalStyleNode : editingStyleNode;
|
|
78
|
-
};
|
|
79
22
|
|
|
80
23
|
/**
|
|
81
24
|
* Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
|
|
@@ -85,39 +28,6 @@ var createDeletedStyleWrapperWithoutOpacity = function createDeletedStyleWrapper
|
|
|
85
28
|
wrapper.setAttribute('style', getDeletedContentStyle(colorScheme, isActive));
|
|
86
29
|
return wrapper;
|
|
87
30
|
};
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Inline decoration used for insertions as the content already exists in the document
|
|
91
|
-
*
|
|
92
|
-
* @param change Changeset "change" containing information about the change content + range
|
|
93
|
-
* @returns Prosemirror inline decoration
|
|
94
|
-
*/
|
|
95
|
-
export var createBlockChangedDecoration = function createBlockChangedDecoration(_ref2) {
|
|
96
|
-
var change = _ref2.change,
|
|
97
|
-
colorScheme = _ref2.colorScheme;
|
|
98
|
-
if (fg('platform_editor_show_diff_scroll_navigation')) {
|
|
99
|
-
var style = getBlockNodeStyle(change.name, colorScheme);
|
|
100
|
-
var className = getNodeClass(change.name);
|
|
101
|
-
if (style || className) {
|
|
102
|
-
return Decoration.node(change.from, change.to, {
|
|
103
|
-
style: style,
|
|
104
|
-
'data-testid': 'show-diff-changed-decoration-node',
|
|
105
|
-
class: className
|
|
106
|
-
}, {
|
|
107
|
-
key: 'diff-block'
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
return undefined;
|
|
111
|
-
} else {
|
|
112
|
-
return Decoration.node(change.from, change.to, {
|
|
113
|
-
style: getBlockNodeStyle(change.name, colorScheme),
|
|
114
|
-
'data-testid': 'show-diff-changed-decoration-node',
|
|
115
|
-
class: getNodeClass(change.name)
|
|
116
|
-
}, {
|
|
117
|
-
key: 'diff-block'
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
31
|
var createContentWrapper = function createContentWrapper(colorScheme) {
|
|
122
32
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
123
33
|
var wrapper = document.createElement('span');
|
|
@@ -131,15 +41,15 @@ var createContentWrapper = function createContentWrapper(colorScheme) {
|
|
|
131
41
|
wrapper.append(strikethrough);
|
|
132
42
|
return wrapper;
|
|
133
43
|
};
|
|
134
|
-
export var
|
|
135
|
-
var change =
|
|
136
|
-
doc =
|
|
137
|
-
nodeViewSerializer =
|
|
138
|
-
colorScheme =
|
|
139
|
-
newDoc =
|
|
140
|
-
intl =
|
|
141
|
-
|
|
142
|
-
isActive =
|
|
44
|
+
export var createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref) {
|
|
45
|
+
var change = _ref.change,
|
|
46
|
+
doc = _ref.doc,
|
|
47
|
+
nodeViewSerializer = _ref.nodeViewSerializer,
|
|
48
|
+
colorScheme = _ref.colorScheme,
|
|
49
|
+
newDoc = _ref.newDoc,
|
|
50
|
+
intl = _ref.intl,
|
|
51
|
+
_ref$isActive = _ref.isActive,
|
|
52
|
+
isActive = _ref$isActive === void 0 ? false : _ref$isActive;
|
|
143
53
|
var slice = doc.slice(change.fromA, change.toA);
|
|
144
54
|
if (slice.content.content.length === 0) {
|
|
145
55
|
return;
|
|
@@ -158,18 +68,13 @@ export var createDeletedContentDecoration = function createDeletedContentDecorat
|
|
|
158
68
|
return;
|
|
159
69
|
}
|
|
160
70
|
if (isTableRowContent) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
nodeViewSerializer: nodeViewSerializer,
|
|
169
|
-
colorScheme: colorScheme
|
|
170
|
-
}),
|
|
171
|
-
decorations = _handleDeletedRows.decorations;
|
|
172
|
-
return decorations;
|
|
71
|
+
return createChangedRowDecorationWidgets({
|
|
72
|
+
changes: [change],
|
|
73
|
+
originalDoc: doc,
|
|
74
|
+
newDoc: newDoc,
|
|
75
|
+
nodeViewSerializer: nodeViewSerializer,
|
|
76
|
+
colorScheme: colorScheme
|
|
77
|
+
});
|
|
173
78
|
}
|
|
174
79
|
var serializer = nodeViewSerializer;
|
|
175
80
|
|
|
@@ -247,7 +152,13 @@ export var createDeletedContentDecoration = function createDeletedContentDecorat
|
|
|
247
152
|
dom.append(wrapper);
|
|
248
153
|
} else {
|
|
249
154
|
// Handle all block nodes with unified function
|
|
250
|
-
|
|
155
|
+
wrapBlockNodeView({
|
|
156
|
+
dom: dom,
|
|
157
|
+
nodeView: nodeView,
|
|
158
|
+
targetNode: node,
|
|
159
|
+
colorScheme: colorScheme,
|
|
160
|
+
intl: intl
|
|
161
|
+
});
|
|
251
162
|
}
|
|
252
163
|
} else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
|
|
253
164
|
// Skip the case where the node is a paragraph or table row that way it can still be rendered and delete the entire table
|
package/dist/esm/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js}
RENAMED
|
@@ -4,9 +4,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
5
5
|
import { trackChangesMessages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
|
+
import { deletedStyleQuoteNode, deletedStyleQuoteNodeWithLozenge, deletedBlockOutline, deletedBlockOutlineRounded, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive } from '../colorSchemes/standard';
|
|
9
|
+
import { deletedTraditionalStyleQuoteNode, deletedTraditionalBlockOutline, deletedTraditionalBlockOutlineRounded, deletedTraditionalContentStyle } from '../colorSchemes/traditional';
|
|
10
10
|
var lozengeStyle = convertToInlineCss({
|
|
11
11
|
display: 'inline-flex',
|
|
12
12
|
boxSizing: 'border-box',
|
|
@@ -23,7 +23,17 @@ var lozengeStyle = convertToInlineCss({
|
|
|
23
23
|
whiteSpace: 'nowrap',
|
|
24
24
|
color: "var(--ds-text-warning-inverse, #292A2E)"
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
|
|
27
|
+
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
28
|
+
if (colorScheme === 'traditional') {
|
|
29
|
+
return deletedTraditionalContentStyle;
|
|
30
|
+
}
|
|
31
|
+
if (isActive) {
|
|
32
|
+
return expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNewActive : deletedContentStyleActive;
|
|
33
|
+
}
|
|
34
|
+
return expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNew : deletedContentStyle;
|
|
35
|
+
};
|
|
36
|
+
var getDeletedStyleNode = function getDeletedStyleNode(nodeName, colorScheme) {
|
|
27
37
|
var isTraditional = colorScheme === 'traditional';
|
|
28
38
|
switch (nodeName) {
|
|
29
39
|
case 'blockquote':
|
|
@@ -69,7 +79,7 @@ var shouldAddShowDiffDeletedNodeClass = function shouldAddShowDiffDeletedNodeCla
|
|
|
69
79
|
* Checks if a node should apply deleted styles directly without wrapper
|
|
70
80
|
* to preserve natural block-level margins
|
|
71
81
|
*/
|
|
72
|
-
var
|
|
82
|
+
var shouldApplyStylesDirectly = function shouldApplyStylesDirectly(nodeName) {
|
|
73
83
|
return nodeName === 'heading' || nodeName === 'blockquote' && !fg('platform_editor_ai_aifc_patch_ga_blockers');
|
|
74
84
|
};
|
|
75
85
|
|
|
@@ -121,9 +131,12 @@ var createBlockNodeWrapper = function createBlockNodeWrapper() {
|
|
|
121
131
|
};
|
|
122
132
|
|
|
123
133
|
/**
|
|
124
|
-
* Applies
|
|
134
|
+
* Applies styles directly to an HTML element by merging with existing styles
|
|
125
135
|
*/
|
|
126
|
-
var
|
|
136
|
+
var applyStylesToElement = function applyStylesToElement(_ref) {
|
|
137
|
+
var element = _ref.element,
|
|
138
|
+
targetNode = _ref.targetNode,
|
|
139
|
+
colorScheme = _ref.colorScheme;
|
|
127
140
|
var currentStyle = element.getAttribute('style') || '';
|
|
128
141
|
var deletedContentStyle = getDeletedContentStyle(colorScheme);
|
|
129
142
|
var nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name, colorScheme) || '';
|
|
@@ -133,7 +146,10 @@ var applyDeletedStylesToElement = function applyDeletedStylesToElement(element,
|
|
|
133
146
|
/**
|
|
134
147
|
* Creates a content wrapper with deleted styles for a block node
|
|
135
148
|
*/
|
|
136
|
-
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(
|
|
149
|
+
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref2) {
|
|
150
|
+
var nodeView = _ref2.nodeView,
|
|
151
|
+
targetNode = _ref2.targetNode,
|
|
152
|
+
colorScheme = _ref2.colorScheme;
|
|
137
153
|
var contentWrapper = document.createElement('div');
|
|
138
154
|
var nodeStyle = getDeletedStyleNode(targetNode.type.name, colorScheme);
|
|
139
155
|
contentWrapper.setAttribute('style', "".concat(getDeletedContentStyle(colorScheme)).concat(nodeStyle || ''));
|
|
@@ -147,7 +163,12 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(nodeV
|
|
|
147
163
|
* to wait for the rich-media-item to appear before attaching the lozenge.
|
|
148
164
|
* @returns true if embedCard was handled
|
|
149
165
|
*/
|
|
150
|
-
var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(
|
|
166
|
+
var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref3) {
|
|
167
|
+
var dom = _ref3.dom,
|
|
168
|
+
nodeView = _ref3.nodeView,
|
|
169
|
+
targetNode = _ref3.targetNode,
|
|
170
|
+
lozenge = _ref3.lozenge,
|
|
171
|
+
colorScheme = _ref3.colorScheme;
|
|
151
172
|
if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
|
|
152
173
|
return false;
|
|
153
174
|
}
|
|
@@ -179,7 +200,12 @@ var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(dom, nodeVi
|
|
|
179
200
|
* Handles special mediaSingle node rendering with lozenge on child media element
|
|
180
201
|
* @returns true if mediaSingle was handled, false otherwise
|
|
181
202
|
*/
|
|
182
|
-
|
|
203
|
+
var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref4) {
|
|
204
|
+
var dom = _ref4.dom,
|
|
205
|
+
nodeView = _ref4.nodeView,
|
|
206
|
+
targetNode = _ref4.targetNode,
|
|
207
|
+
lozenge = _ref4.lozenge,
|
|
208
|
+
colorScheme = _ref4.colorScheme;
|
|
183
209
|
if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
|
|
184
210
|
return false;
|
|
185
211
|
}
|
|
@@ -208,19 +234,40 @@ export var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(
|
|
|
208
234
|
/**
|
|
209
235
|
* Appends a block node with wrapper, lozenge, and appropriate styling
|
|
210
236
|
*/
|
|
211
|
-
var
|
|
237
|
+
var wrapBlockNode = function wrapBlockNode(_ref5) {
|
|
238
|
+
var dom = _ref5.dom,
|
|
239
|
+
nodeView = _ref5.nodeView,
|
|
240
|
+
targetNode = _ref5.targetNode,
|
|
241
|
+
colorScheme = _ref5.colorScheme,
|
|
242
|
+
intl = _ref5.intl;
|
|
212
243
|
var blockWrapper = createBlockNodeWrapper();
|
|
213
244
|
if (shouldShowRemovedLozenge(targetNode.type.name)) {
|
|
214
245
|
var lozenge = createRemovedLozenge(intl);
|
|
215
|
-
if (handleEmbedCardWithLozenge(
|
|
246
|
+
if (handleEmbedCardWithLozenge({
|
|
247
|
+
dom: dom,
|
|
248
|
+
nodeView: nodeView,
|
|
249
|
+
targetNode: targetNode,
|
|
250
|
+
lozenge: lozenge,
|
|
251
|
+
colorScheme: colorScheme
|
|
252
|
+
}) && fg('platform_editor_ai_aifc_patch_ga_blockers')) {
|
|
216
253
|
return;
|
|
217
254
|
}
|
|
218
|
-
if (handleMediaSingleWithLozenge(
|
|
255
|
+
if (handleMediaSingleWithLozenge({
|
|
256
|
+
dom: dom,
|
|
257
|
+
nodeView: nodeView,
|
|
258
|
+
targetNode: targetNode,
|
|
259
|
+
lozenge: lozenge,
|
|
260
|
+
colorScheme: colorScheme
|
|
261
|
+
})) {
|
|
219
262
|
return;
|
|
220
263
|
}
|
|
221
264
|
blockWrapper.append(lozenge);
|
|
222
265
|
}
|
|
223
|
-
var contentWrapper = createBlockNodeContentWrapper(
|
|
266
|
+
var contentWrapper = createBlockNodeContentWrapper({
|
|
267
|
+
nodeView: nodeView,
|
|
268
|
+
targetNode: targetNode,
|
|
269
|
+
colorScheme: colorScheme
|
|
270
|
+
});
|
|
224
271
|
blockWrapper.append(contentWrapper);
|
|
225
272
|
if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
226
273
|
var showDiffDeletedNodeClass = colorScheme === 'traditional' && fg('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
|
|
@@ -234,13 +281,28 @@ var appendBlockNodeWithWrapper = function appendBlockNodeWithWrapper(dom, nodeVi
|
|
|
234
281
|
* For heading nodes, applies styles directly to preserve natural margins.
|
|
235
282
|
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
236
283
|
*/
|
|
237
|
-
export var
|
|
238
|
-
|
|
284
|
+
export var wrapBlockNodeView = function wrapBlockNodeView(_ref6) {
|
|
285
|
+
var dom = _ref6.dom,
|
|
286
|
+
nodeView = _ref6.nodeView,
|
|
287
|
+
targetNode = _ref6.targetNode,
|
|
288
|
+
colorScheme = _ref6.colorScheme,
|
|
289
|
+
intl = _ref6.intl;
|
|
290
|
+
if (shouldApplyStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
|
|
239
291
|
// Apply deleted styles directly to preserve natural block-level margins
|
|
240
|
-
|
|
292
|
+
applyStylesToElement({
|
|
293
|
+
element: nodeView,
|
|
294
|
+
targetNode: targetNode,
|
|
295
|
+
colorScheme: colorScheme
|
|
296
|
+
});
|
|
241
297
|
dom.append(nodeView);
|
|
242
298
|
} else {
|
|
243
299
|
// Use wrapper approach for other block nodes
|
|
244
|
-
|
|
300
|
+
wrapBlockNode({
|
|
301
|
+
dom: dom,
|
|
302
|
+
nodeView: nodeView,
|
|
303
|
+
targetNode: targetNode,
|
|
304
|
+
colorScheme: colorScheme,
|
|
305
|
+
intl: intl
|
|
306
|
+
});
|
|
245
307
|
}
|
|
246
308
|
};
|
|
@@ -4,7 +4,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
4
4
|
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
5
5
|
import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
|
|
6
6
|
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Attempts to merge two consecutive ReplaceStep operations.
|
|
@@ -28,7 +27,7 @@ function mergeReplaceSteps(step1, step2) {
|
|
|
28
27
|
|
|
29
28
|
// Simplifies the steps to improve performance and reduce fragmentation in diffs
|
|
30
29
|
export function simplifySteps(steps, originalDoc) {
|
|
31
|
-
var stepsToFilter =
|
|
30
|
+
var stepsToFilter = removeUnusedSteps(steps, originalDoc);
|
|
32
31
|
return stepsToFilter
|
|
33
32
|
// Remove steps that don't affect document structure or content
|
|
34
33
|
.filter(function (step) {
|
|
@@ -36,9 +35,9 @@ export function simplifySteps(steps, originalDoc) {
|
|
|
36
35
|
})
|
|
37
36
|
// Merge consecutive steps where possible
|
|
38
37
|
.reduce(function (acc, step) {
|
|
39
|
-
var _lastStep$merge, _lastStep$merge2
|
|
38
|
+
var _lastStep$merge, _lastStep$merge2;
|
|
40
39
|
var lastStep = acc[acc.length - 1];
|
|
41
|
-
var merged =
|
|
40
|
+
var merged = (_lastStep$merge = lastStep === null || lastStep === void 0 || (_lastStep$merge2 = lastStep.merge) === null || _lastStep$merge2 === void 0 ? void 0 : _lastStep$merge2.call(lastStep, step)) !== null && _lastStep$merge !== void 0 ? _lastStep$merge : mergeReplaceSteps(lastStep, step);
|
|
42
41
|
if (merged) {
|
|
43
42
|
acc[acc.length - 1] = merged;
|
|
44
43
|
} else {
|
|
@@ -67,7 +67,7 @@ export declare class NodeViewSerializer {
|
|
|
67
67
|
/**
|
|
68
68
|
* Serializes a fragment to a `DocumentFragment` using the schema's `DOMSerializer`.
|
|
69
69
|
*/
|
|
70
|
-
serializeFragment(fragment: Fragment):
|
|
70
|
+
serializeFragment(fragment: Fragment): DocumentFragment | HTMLElement | null;
|
|
71
71
|
/**
|
|
72
72
|
* Returns a copy of the current node view blocklist.
|
|
73
73
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { ColorScheme } from '../showDiffPluginType';
|
|
4
5
|
import type { ShowDiffPluginState } from './main';
|
|
5
6
|
import type { NodeViewSerializer } from './NodeViewSerializer';
|
|
6
7
|
export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, }: {
|
|
@@ -8,7 +9,7 @@ export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<
|
|
|
8
9
|
from: number;
|
|
9
10
|
to: number;
|
|
10
11
|
};
|
|
11
|
-
colorScheme?:
|
|
12
|
+
colorScheme?: ColorScheme;
|
|
12
13
|
intl: IntlShape;
|
|
13
14
|
nodeViewSerializer: NodeViewSerializer;
|
|
14
15
|
pluginState: Omit<ShowDiffPluginState, "decorations">;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import type { ColorScheme } from '../../showDiffPluginType';
|
|
3
|
+
/**
|
|
4
|
+
* Inline decoration used for insertions as the content already exists in the document
|
|
5
|
+
*
|
|
6
|
+
* @param change Changeset "change" containing information about the change content + range
|
|
7
|
+
* @returns Prosemirror inline decoration
|
|
8
|
+
*/
|
|
9
|
+
export declare const createBlockChangedDecoration: ({ change, colorScheme, }: {
|
|
10
|
+
change: {
|
|
11
|
+
from: number;
|
|
12
|
+
name: string;
|
|
13
|
+
to: number;
|
|
14
|
+
};
|
|
15
|
+
colorScheme?: ColorScheme;
|
|
16
|
+
}) => Decoration | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Change } from 'prosemirror-changeset';
|
|
2
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { ColorScheme } from '../../showDiffPluginType';
|
|
5
|
+
import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
6
|
+
type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
|
|
7
|
+
/**
|
|
8
|
+
* Main function to handle deleted rows - computes diff and creates decorations
|
|
9
|
+
*/
|
|
10
|
+
export declare const createChangedRowDecorationWidgets: ({ changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, }: {
|
|
11
|
+
changes: SimpleChange[];
|
|
12
|
+
colorScheme?: ColorScheme;
|
|
13
|
+
newDoc: PMNode;
|
|
14
|
+
nodeViewSerializer: NodeViewSerializer;
|
|
15
|
+
originalDoc: PMNode;
|
|
16
|
+
}) => Decoration[];
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import type { ColorScheme } from '../../showDiffPluginType';
|
|
3
|
+
/**
|
|
4
|
+
* Inline decoration used for insertions as the content already exists in the document
|
|
5
|
+
*
|
|
6
|
+
* @param change Changeset "change" containing information about the change content + range
|
|
7
|
+
* @returns Prosemirror inline decoration
|
|
8
|
+
*/
|
|
9
|
+
export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, }: {
|
|
10
|
+
change: {
|
|
11
|
+
fromB: number;
|
|
12
|
+
toB: number;
|
|
13
|
+
};
|
|
14
|
+
colorScheme?: ColorScheme;
|
|
15
|
+
isActive?: boolean;
|
|
16
|
+
}) => Decoration;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Change } from 'prosemirror-changeset';
|
|
2
|
+
import type { IntlShape } from 'react-intl-next';
|
|
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
|
+
export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, isActive, }: {
|
|
8
|
+
change: Pick<Change, "fromA" | "toA" | "fromB" | "deleted">;
|
|
9
|
+
colorScheme?: ColorScheme;
|
|
10
|
+
doc: PMNode;
|
|
11
|
+
intl: IntlShape;
|
|
12
|
+
isActive?: boolean;
|
|
13
|
+
newDoc: PMNode;
|
|
14
|
+
nodeViewSerializer: NodeViewSerializer;
|
|
15
|
+
}) => Decoration[] | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import type { ColorScheme } from '../../../showDiffPluginType';
|
|
4
|
+
/**
|
|
5
|
+
* Handles all block node rendering with appropriate deleted styling.
|
|
6
|
+
* For heading nodes, applies styles directly to preserve natural margins.
|
|
7
|
+
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
8
|
+
*/
|
|
9
|
+
export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, }: {
|
|
10
|
+
colorScheme?: ColorScheme;
|
|
11
|
+
dom: HTMLElement;
|
|
12
|
+
intl: IntlShape;
|
|
13
|
+
nodeView: Node;
|
|
14
|
+
targetNode: PMNode;
|
|
15
|
+
}) => void;
|
|
@@ -67,7 +67,7 @@ export declare class NodeViewSerializer {
|
|
|
67
67
|
/**
|
|
68
68
|
* Serializes a fragment to a `DocumentFragment` using the schema's `DOMSerializer`.
|
|
69
69
|
*/
|
|
70
|
-
serializeFragment(fragment: Fragment):
|
|
70
|
+
serializeFragment(fragment: Fragment): DocumentFragment | HTMLElement | null;
|
|
71
71
|
/**
|
|
72
72
|
* Returns a copy of the current node view blocklist.
|
|
73
73
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { ColorScheme } from '../showDiffPluginType';
|
|
4
5
|
import type { ShowDiffPluginState } from './main';
|
|
5
6
|
import type { NodeViewSerializer } from './NodeViewSerializer';
|
|
6
7
|
export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, }: {
|
|
@@ -8,7 +9,7 @@ export declare const calculateDiffDecorations: import("memoize-one").MemoizedFn<
|
|
|
8
9
|
from: number;
|
|
9
10
|
to: number;
|
|
10
11
|
};
|
|
11
|
-
colorScheme?:
|
|
12
|
+
colorScheme?: ColorScheme;
|
|
12
13
|
intl: IntlShape;
|
|
13
14
|
nodeViewSerializer: NodeViewSerializer;
|
|
14
15
|
pluginState: Omit<ShowDiffPluginState, "decorations">;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import type { ColorScheme } from '../../showDiffPluginType';
|
|
3
|
+
/**
|
|
4
|
+
* Inline decoration used for insertions as the content already exists in the document
|
|
5
|
+
*
|
|
6
|
+
* @param change Changeset "change" containing information about the change content + range
|
|
7
|
+
* @returns Prosemirror inline decoration
|
|
8
|
+
*/
|
|
9
|
+
export declare const createBlockChangedDecoration: ({ change, colorScheme, }: {
|
|
10
|
+
change: {
|
|
11
|
+
from: number;
|
|
12
|
+
name: string;
|
|
13
|
+
to: number;
|
|
14
|
+
};
|
|
15
|
+
colorScheme?: ColorScheme;
|
|
16
|
+
}) => Decoration | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Change } from 'prosemirror-changeset';
|
|
2
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { ColorScheme } from '../../showDiffPluginType';
|
|
5
|
+
import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
6
|
+
type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
|
|
7
|
+
/**
|
|
8
|
+
* Main function to handle deleted rows - computes diff and creates decorations
|
|
9
|
+
*/
|
|
10
|
+
export declare const createChangedRowDecorationWidgets: ({ changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, }: {
|
|
11
|
+
changes: SimpleChange[];
|
|
12
|
+
colorScheme?: ColorScheme;
|
|
13
|
+
newDoc: PMNode;
|
|
14
|
+
nodeViewSerializer: NodeViewSerializer;
|
|
15
|
+
originalDoc: PMNode;
|
|
16
|
+
}) => Decoration[];
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import type { ColorScheme } from '../../showDiffPluginType';
|
|
3
|
+
/**
|
|
4
|
+
* Inline decoration used for insertions as the content already exists in the document
|
|
5
|
+
*
|
|
6
|
+
* @param change Changeset "change" containing information about the change content + range
|
|
7
|
+
* @returns Prosemirror inline decoration
|
|
8
|
+
*/
|
|
9
|
+
export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, }: {
|
|
10
|
+
change: {
|
|
11
|
+
fromB: number;
|
|
12
|
+
toB: number;
|
|
13
|
+
};
|
|
14
|
+
colorScheme?: ColorScheme;
|
|
15
|
+
isActive?: boolean;
|
|
16
|
+
}) => Decoration;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Change } from 'prosemirror-changeset';
|
|
2
|
+
import type { IntlShape } from 'react-intl-next';
|
|
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
|
+
export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, isActive, }: {
|
|
8
|
+
change: Pick<Change, "fromA" | "toA" | "fromB" | "deleted">;
|
|
9
|
+
colorScheme?: ColorScheme;
|
|
10
|
+
doc: PMNode;
|
|
11
|
+
intl: IntlShape;
|
|
12
|
+
isActive?: boolean;
|
|
13
|
+
newDoc: PMNode;
|
|
14
|
+
nodeViewSerializer: NodeViewSerializer;
|
|
15
|
+
}) => Decoration[] | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import type { ColorScheme } from '../../../showDiffPluginType';
|
|
4
|
+
/**
|
|
5
|
+
* Handles all block node rendering with appropriate deleted styling.
|
|
6
|
+
* For heading nodes, applies styles directly to preserve natural margins.
|
|
7
|
+
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
8
|
+
*/
|
|
9
|
+
export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, }: {
|
|
10
|
+
colorScheme?: ColorScheme;
|
|
11
|
+
dom: HTMLElement;
|
|
12
|
+
intl: IntlShape;
|
|
13
|
+
nodeView: Node;
|
|
14
|
+
targetNode: PMNode;
|
|
15
|
+
}) => void;
|