@atlaskit/editor-plugin-show-diff 5.0.4 → 5.0.6
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 +66 -39
- package/dist/cjs/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.js +32 -30
- package/dist/cjs/pm-plugins/decorations/colorSchemes/traditional.js +75 -0
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +75 -0
- package/dist/cjs/pm-plugins/{deletedRowsHandler.js → decorations/createChangedRowDecorationWidgets.js} +34 -61
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +33 -0
- package/dist/cjs/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js} +27 -71
- package/dist/cjs/pm-plugins/{attributeDecorations.js → decorations/utils/getAttrChangeRanges.js} +1 -1
- package/dist/cjs/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js} +90 -70
- package/dist/es2019/pm-plugins/calculateDiffDecorations.js +41 -13
- package/dist/es2019/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.js +31 -29
- package/dist/es2019/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.js +28 -29
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +70 -0
- package/dist/es2019/pm-plugins/{deletedRowsHandler.js → decorations/createChangedRowDecorationWidgets.js} +30 -57
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +28 -0
- package/dist/es2019/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js} +27 -71
- package/dist/es2019/pm-plugins/{attributeDecorations.js → decorations/utils/getAttrChangeRanges.js} +1 -1
- package/dist/es2019/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js} +89 -64
- package/dist/esm/pm-plugins/calculateDiffDecorations.js +62 -35
- package/dist/esm/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.js +31 -29
- package/dist/esm/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.js +28 -29
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +69 -0
- package/dist/esm/pm-plugins/{deletedRowsHandler.js → decorations/createChangedRowDecorationWidgets.js} +32 -59
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +28 -0
- package/dist/esm/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js} +27 -71
- package/dist/esm/pm-plugins/{attributeDecorations.js → decorations/utils/getAttrChangeRanges.js} +1 -1
- package/dist/esm/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js} +84 -64
- 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/colorSchemes/standard.d.ts +17 -0
- package/dist/types/pm-plugins/decorations/colorSchemes/traditional.d.ts +13 -0
- 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/colorSchemes/standard.d.ts +17 -0
- package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/traditional.d.ts +13 -0
- 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 +3 -3
- package/dist/cjs/pm-plugins/colorSchemes/traditional.js +0 -76
- package/dist/types/pm-plugins/colorSchemes/standard.d.ts +0 -8
- package/dist/types/pm-plugins/colorSchemes/traditional.d.ts +0 -5
- package/dist/types/pm-plugins/decorations.d.ts +0 -39
- package/dist/types/pm-plugins/deletedBlocksHandler.d.ts +0 -59
- package/dist/types/pm-plugins/deletedRowsHandler.d.ts +0 -30
- package/dist/types-ts4.5/pm-plugins/colorSchemes/standard.d.ts +0 -8
- package/dist/types-ts4.5/pm-plugins/colorSchemes/traditional.d.ts +0 -5
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +0 -39
- package/dist/types-ts4.5/pm-plugins/deletedBlocksHandler.d.ts +0 -59
- package/dist/types-ts4.5/pm-plugins/deletedRowsHandler.d.ts +0 -30
- /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/{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/{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/{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/{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/cjs/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js}
RENAMED
|
@@ -3,41 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createNodeChangedDecorationWidget = void 0;
|
|
7
7
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
8
8
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
9
9
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
10
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
11
11
|
var _standard = require("./colorSchemes/standard");
|
|
12
12
|
var _traditional = require("./colorSchemes/traditional");
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
* Inline decoration used for insertions as the content already exists in the document
|
|
18
|
-
*
|
|
19
|
-
* @param change Changeset "change" containing information about the change content + range
|
|
20
|
-
* @returns Prosemirror inline decoration
|
|
21
|
-
*/
|
|
22
|
-
var createInlineChangedDecoration = exports.createInlineChangedDecoration = function createInlineChangedDecoration(change, colorScheme) {
|
|
23
|
-
var isActive = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
24
|
-
var style;
|
|
25
|
-
if (colorScheme === 'traditional') {
|
|
26
|
-
style = isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
|
|
27
|
-
} else {
|
|
28
|
-
style = isActive ? _standard.editingStyleActive : _standard.editingStyle;
|
|
29
|
-
}
|
|
30
|
-
return _view.Decoration.inline(change.fromB, change.toB, {
|
|
31
|
-
style: style,
|
|
32
|
-
'data-testid': 'show-diff-changed-decoration'
|
|
33
|
-
}, {
|
|
34
|
-
key: 'diff-inline'
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
var getDeletedContentStyleUnbounded = exports.getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
|
|
13
|
+
var _createChangedRowDecorationWidgets = require("./createChangedRowDecorationWidgets");
|
|
14
|
+
var _findSafeInsertPos = require("./utils/findSafeInsertPos");
|
|
15
|
+
var _wrapBlockNodeView = require("./utils/wrapBlockNodeView");
|
|
16
|
+
var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
|
|
38
17
|
return colorScheme === 'traditional' ? _traditional.deletedTraditionalContentStyleUnbounded : _standard.deletedContentStyleUnbounded;
|
|
39
18
|
};
|
|
40
|
-
var getDeletedContentStyle =
|
|
19
|
+
var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
|
|
41
20
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
42
21
|
if (colorScheme === 'traditional') {
|
|
43
22
|
return _traditional.deletedTraditionalContentStyle;
|
|
@@ -47,47 +26,14 @@ var getDeletedContentStyle = exports.getDeletedContentStyle = function getDelete
|
|
|
47
26
|
}
|
|
48
27
|
return (0, _expValEquals.expValEquals)('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? _standard.deletedContentStyleNew : _standard.deletedContentStyle;
|
|
49
28
|
};
|
|
50
|
-
var getNodeClass = function getNodeClass(name) {
|
|
51
|
-
switch (name) {
|
|
52
|
-
case 'extension':
|
|
53
|
-
return 'show-diff-changed-decoration-node';
|
|
54
|
-
default:
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
var getBlockNodeStyle = function getBlockNodeStyle(name, colorScheme) {
|
|
59
|
-
return colorScheme === 'traditional' ? (0, _traditional.getTraditionalNodeStyle)(name) : (0, _standard.getStandardNodeStyle)(name);
|
|
60
|
-
};
|
|
61
29
|
|
|
62
30
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* @param change Changeset "change" containing information about the change content + range
|
|
66
|
-
* @returns Prosemirror inline decoration
|
|
31
|
+
* Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
|
|
67
32
|
*/
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (style || className) {
|
|
73
|
-
return _view.Decoration.node(change.from, change.to, {
|
|
74
|
-
style: style,
|
|
75
|
-
'data-testid': 'show-diff-changed-decoration-node',
|
|
76
|
-
class: className
|
|
77
|
-
}, {
|
|
78
|
-
key: 'diff-block'
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return undefined;
|
|
82
|
-
} else {
|
|
83
|
-
return _view.Decoration.node(change.from, change.to, {
|
|
84
|
-
style: getBlockNodeStyle(change.name, colorScheme),
|
|
85
|
-
'data-testid': 'show-diff-changed-decoration-node',
|
|
86
|
-
class: getNodeClass(change.name)
|
|
87
|
-
}, {
|
|
88
|
-
key: 'diff-block'
|
|
89
|
-
});
|
|
90
|
-
}
|
|
33
|
+
var createDeletedStyleWrapperWithoutOpacity = function createDeletedStyleWrapperWithoutOpacity(colorScheme, isActive) {
|
|
34
|
+
var wrapper = document.createElement('span');
|
|
35
|
+
wrapper.setAttribute('style', getDeletedContentStyle(colorScheme, isActive));
|
|
36
|
+
return wrapper;
|
|
91
37
|
};
|
|
92
38
|
var createContentWrapper = function createContentWrapper(colorScheme) {
|
|
93
39
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -102,7 +48,7 @@ var createContentWrapper = function createContentWrapper(colorScheme) {
|
|
|
102
48
|
wrapper.append(strikethrough);
|
|
103
49
|
return wrapper;
|
|
104
50
|
};
|
|
105
|
-
var
|
|
51
|
+
var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref) {
|
|
106
52
|
var change = _ref.change,
|
|
107
53
|
doc = _ref.doc,
|
|
108
54
|
nodeViewSerializer = _ref.nodeViewSerializer,
|
|
@@ -132,9 +78,13 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
132
78
|
if (!(0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga')) {
|
|
133
79
|
return;
|
|
134
80
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
81
|
+
return (0, _createChangedRowDecorationWidgets.createChangedRowDecorationWidgets)({
|
|
82
|
+
changes: [change],
|
|
83
|
+
originalDoc: doc,
|
|
84
|
+
newDoc: newDoc,
|
|
85
|
+
nodeViewSerializer: nodeViewSerializer,
|
|
86
|
+
colorScheme: colorScheme
|
|
87
|
+
});
|
|
138
88
|
}
|
|
139
89
|
var serializer = nodeViewSerializer;
|
|
140
90
|
|
|
@@ -212,7 +162,13 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
212
162
|
dom.append(wrapper);
|
|
213
163
|
} else {
|
|
214
164
|
// Handle all block nodes with unified function
|
|
215
|
-
(0,
|
|
165
|
+
(0, _wrapBlockNodeView.wrapBlockNodeView)({
|
|
166
|
+
dom: dom,
|
|
167
|
+
nodeView: nodeView,
|
|
168
|
+
targetNode: node,
|
|
169
|
+
colorScheme: colorScheme,
|
|
170
|
+
intl: intl
|
|
171
|
+
});
|
|
216
172
|
}
|
|
217
173
|
} else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
|
|
218
174
|
// Skip the case where the node is a paragraph or table row that way it can still be rendered and delete the entire table
|
|
@@ -220,7 +176,7 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
220
176
|
} else {
|
|
221
177
|
var fallbackNode = fallbackSerialization();
|
|
222
178
|
if (fallbackNode) {
|
|
223
|
-
var _wrapper2 =
|
|
179
|
+
var _wrapper2 = createDeletedStyleWrapperWithoutOpacity(colorScheme, isActive);
|
|
224
180
|
_wrapper2.append(fallbackNode);
|
|
225
181
|
dom.append(_wrapper2);
|
|
226
182
|
}
|
package/dist/cjs/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js}
RENAMED
|
@@ -4,49 +4,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.wrapBlockNodeView = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
10
10
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
11
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
-
var
|
|
12
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
13
|
+
var _standard = require("../colorSchemes/standard");
|
|
14
|
+
var _traditional = require("../colorSchemes/traditional");
|
|
13
15
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
16
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
-
var deletedStyleQuoteNode = exports.deletedStyleQuoteNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
16
|
-
borderLeft: "2px solid ".concat("var(--ds-border-accent-gray, #7D818A)")
|
|
17
|
-
});
|
|
18
|
-
var deletedStyleQuoteNodeWithLozenge = exports.deletedStyleQuoteNodeWithLozenge = (0, _lazyNodeView.convertToInlineCss)({
|
|
19
|
-
marginTop: "var(--ds-space-150, 12px)",
|
|
20
|
-
paddingTop: "var(--ds-space-025, 2px)",
|
|
21
|
-
paddingBottom: "var(--ds-space-025, 2px)",
|
|
22
|
-
paddingLeft: "var(--ds-space-025, 2px)",
|
|
23
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #7D818A)"),
|
|
24
|
-
borderRadius: "var(--ds-radius-small, 4px)"
|
|
25
|
-
});
|
|
26
|
-
var deletedTraditionalStyleQuoteNode = exports.deletedTraditionalStyleQuoteNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
27
|
-
marginTop: "var(--ds-space-150, 12px)",
|
|
28
|
-
paddingTop: "var(--ds-space-025, 2px)",
|
|
29
|
-
paddingBottom: "var(--ds-space-025, 2px)",
|
|
30
|
-
paddingLeft: "var(--ds-space-025, 2px)",
|
|
31
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-red, #E2483D)"),
|
|
32
|
-
borderRadius: "var(--ds-radius-small, 4px)"
|
|
33
|
-
});
|
|
34
|
-
var deletedBlockOutline = exports.deletedBlockOutline = (0, _lazyNodeView.convertToInlineCss)({
|
|
35
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #7D818A)"),
|
|
36
|
-
borderRadius: "var(--ds-radius-small, 4px)"
|
|
37
|
-
});
|
|
38
|
-
var deletedTraditionalBlockOutline = exports.deletedTraditionalBlockOutline = (0, _lazyNodeView.convertToInlineCss)({
|
|
39
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-red, #E2483D)"),
|
|
40
|
-
borderRadius: "var(--ds-radius-small, 4px)"
|
|
41
|
-
});
|
|
42
|
-
var deletedBlockOutlineRounded = exports.deletedBlockOutlineRounded = (0, _lazyNodeView.convertToInlineCss)({
|
|
43
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #7D818A)"),
|
|
44
|
-
borderRadius: "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)")
|
|
45
|
-
});
|
|
46
|
-
var deletedTraditionalBlockOutlineRounded = exports.deletedTraditionalBlockOutlineRounded = (0, _lazyNodeView.convertToInlineCss)({
|
|
47
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-red, #E2483D)"),
|
|
48
|
-
borderRadius: "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)")
|
|
49
|
-
});
|
|
50
17
|
var lozengeStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
51
18
|
display: 'inline-flex',
|
|
52
19
|
boxSizing: 'border-box',
|
|
@@ -63,22 +30,32 @@ var lozengeStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
|
63
30
|
whiteSpace: 'nowrap',
|
|
64
31
|
color: "var(--ds-text-warning-inverse, #292A2E)"
|
|
65
32
|
});
|
|
66
|
-
var
|
|
33
|
+
var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
|
|
34
|
+
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
35
|
+
if (colorScheme === 'traditional') {
|
|
36
|
+
return _traditional.deletedTraditionalContentStyle;
|
|
37
|
+
}
|
|
38
|
+
if (isActive) {
|
|
39
|
+
return (0, _expValEquals.expValEquals)('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? _standard.deletedContentStyleNewActive : _standard.deletedContentStyleActive;
|
|
40
|
+
}
|
|
41
|
+
return (0, _expValEquals.expValEquals)('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? _standard.deletedContentStyleNew : _standard.deletedContentStyle;
|
|
42
|
+
};
|
|
43
|
+
var getDeletedStyleNode = function getDeletedStyleNode(nodeName, colorScheme) {
|
|
67
44
|
var isTraditional = colorScheme === 'traditional';
|
|
68
45
|
switch (nodeName) {
|
|
69
46
|
case 'blockquote':
|
|
70
|
-
return (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNodeWithLozenge : deletedStyleQuoteNode;
|
|
47
|
+
return (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? isTraditional ? _traditional.deletedTraditionalStyleQuoteNode : _standard.deletedStyleQuoteNodeWithLozenge : _standard.deletedStyleQuoteNode;
|
|
71
48
|
case 'expand':
|
|
72
49
|
case 'decisionList':
|
|
73
|
-
return isTraditional && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? deletedTraditionalBlockOutline : deletedBlockOutline;
|
|
50
|
+
return isTraditional && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? _traditional.deletedTraditionalBlockOutline : _standard.deletedBlockOutline;
|
|
74
51
|
case 'panel':
|
|
75
52
|
case 'codeBlock':
|
|
76
|
-
return isTraditional && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? deletedTraditionalBlockOutlineRounded : deletedBlockOutlineRounded;
|
|
53
|
+
return isTraditional && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? _traditional.deletedTraditionalBlockOutlineRounded : _standard.deletedBlockOutlineRounded;
|
|
77
54
|
default:
|
|
78
55
|
return undefined;
|
|
79
56
|
}
|
|
80
57
|
};
|
|
81
|
-
var shouldShowRemovedLozenge =
|
|
58
|
+
var shouldShowRemovedLozenge = function shouldShowRemovedLozenge(nodeName) {
|
|
82
59
|
switch (nodeName) {
|
|
83
60
|
case 'expand':
|
|
84
61
|
case 'codeBlock':
|
|
@@ -93,7 +70,7 @@ var shouldShowRemovedLozenge = exports.shouldShowRemovedLozenge = function shoul
|
|
|
93
70
|
return false;
|
|
94
71
|
}
|
|
95
72
|
};
|
|
96
|
-
var shouldAddShowDiffDeletedNodeClass =
|
|
73
|
+
var shouldAddShowDiffDeletedNodeClass = function shouldAddShowDiffDeletedNodeClass(nodeName) {
|
|
97
74
|
switch (nodeName) {
|
|
98
75
|
case 'mediaSingle':
|
|
99
76
|
case 'embedCard':
|
|
@@ -109,14 +86,14 @@ var shouldAddShowDiffDeletedNodeClass = exports.shouldAddShowDiffDeletedNodeClas
|
|
|
109
86
|
* Checks if a node should apply deleted styles directly without wrapper
|
|
110
87
|
* to preserve natural block-level margins
|
|
111
88
|
*/
|
|
112
|
-
var
|
|
89
|
+
var shouldApplyStylesDirectly = function shouldApplyStylesDirectly(nodeName) {
|
|
113
90
|
return nodeName === 'heading' || nodeName === 'blockquote' && !(0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers');
|
|
114
91
|
};
|
|
115
92
|
|
|
116
93
|
/**
|
|
117
94
|
* Creates a "Removed" lozenge to be displayed at the top right corner of deleted block nodes
|
|
118
95
|
*/
|
|
119
|
-
var createRemovedLozenge =
|
|
96
|
+
var createRemovedLozenge = function createRemovedLozenge(intl, nodeName) {
|
|
120
97
|
var container = document.createElement('span');
|
|
121
98
|
var borderTopRightRadius;
|
|
122
99
|
if (['expand', 'decisionList'].includes(nodeName || '')) {
|
|
@@ -149,7 +126,7 @@ var createRemovedLozenge = exports.createRemovedLozenge = function createRemoved
|
|
|
149
126
|
/**
|
|
150
127
|
* Wraps a block node in a container with relative positioning to support absolute positioned lozenge
|
|
151
128
|
*/
|
|
152
|
-
var createBlockNodeWrapper =
|
|
129
|
+
var createBlockNodeWrapper = function createBlockNodeWrapper() {
|
|
153
130
|
var wrapper = document.createElement('div');
|
|
154
131
|
var baseStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
155
132
|
position: 'relative',
|
|
@@ -161,20 +138,14 @@ var createBlockNodeWrapper = exports.createBlockNodeWrapper = function createBlo
|
|
|
161
138
|
};
|
|
162
139
|
|
|
163
140
|
/**
|
|
164
|
-
*
|
|
141
|
+
* Applies styles directly to an HTML element by merging with existing styles
|
|
165
142
|
*/
|
|
166
|
-
var
|
|
167
|
-
var
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Applies deleted styles directly to an HTML element by merging with existing styles
|
|
174
|
-
*/
|
|
175
|
-
var applyDeletedStylesToElement = exports.applyDeletedStylesToElement = function applyDeletedStylesToElement(element, targetNode, colorScheme) {
|
|
143
|
+
var applyStylesToElement = function applyStylesToElement(_ref) {
|
|
144
|
+
var element = _ref.element,
|
|
145
|
+
targetNode = _ref.targetNode,
|
|
146
|
+
colorScheme = _ref.colorScheme;
|
|
176
147
|
var currentStyle = element.getAttribute('style') || '';
|
|
177
|
-
var deletedContentStyle =
|
|
148
|
+
var deletedContentStyle = getDeletedContentStyle(colorScheme);
|
|
178
149
|
var nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name, colorScheme) || '';
|
|
179
150
|
element.setAttribute('style', "".concat(currentStyle).concat(deletedContentStyle).concat(nodeSpecificStyle));
|
|
180
151
|
};
|
|
@@ -182,10 +153,13 @@ var applyDeletedStylesToElement = exports.applyDeletedStylesToElement = function
|
|
|
182
153
|
/**
|
|
183
154
|
* Creates a content wrapper with deleted styles for a block node
|
|
184
155
|
*/
|
|
185
|
-
var createBlockNodeContentWrapper =
|
|
156
|
+
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref2) {
|
|
157
|
+
var nodeView = _ref2.nodeView,
|
|
158
|
+
targetNode = _ref2.targetNode,
|
|
159
|
+
colorScheme = _ref2.colorScheme;
|
|
186
160
|
var contentWrapper = document.createElement('div');
|
|
187
161
|
var nodeStyle = getDeletedStyleNode(targetNode.type.name, colorScheme);
|
|
188
|
-
contentWrapper.setAttribute('style', "".concat(
|
|
162
|
+
contentWrapper.setAttribute('style', "".concat(getDeletedContentStyle(colorScheme)).concat(nodeStyle || ''));
|
|
189
163
|
contentWrapper.append(nodeView);
|
|
190
164
|
return contentWrapper;
|
|
191
165
|
};
|
|
@@ -196,7 +170,12 @@ var createBlockNodeContentWrapper = exports.createBlockNodeContentWrapper = func
|
|
|
196
170
|
* to wait for the rich-media-item to appear before attaching the lozenge.
|
|
197
171
|
* @returns true if embedCard was handled
|
|
198
172
|
*/
|
|
199
|
-
var handleEmbedCardWithLozenge =
|
|
173
|
+
var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref3) {
|
|
174
|
+
var dom = _ref3.dom,
|
|
175
|
+
nodeView = _ref3.nodeView,
|
|
176
|
+
targetNode = _ref3.targetNode,
|
|
177
|
+
lozenge = _ref3.lozenge,
|
|
178
|
+
colorScheme = _ref3.colorScheme;
|
|
200
179
|
if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
|
|
201
180
|
return false;
|
|
202
181
|
}
|
|
@@ -228,7 +207,12 @@ var handleEmbedCardWithLozenge = exports.handleEmbedCardWithLozenge = function h
|
|
|
228
207
|
* Handles special mediaSingle node rendering with lozenge on child media element
|
|
229
208
|
* @returns true if mediaSingle was handled, false otherwise
|
|
230
209
|
*/
|
|
231
|
-
var handleMediaSingleWithLozenge =
|
|
210
|
+
var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref4) {
|
|
211
|
+
var dom = _ref4.dom,
|
|
212
|
+
nodeView = _ref4.nodeView,
|
|
213
|
+
targetNode = _ref4.targetNode,
|
|
214
|
+
lozenge = _ref4.lozenge,
|
|
215
|
+
colorScheme = _ref4.colorScheme;
|
|
232
216
|
if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
|
|
233
217
|
return false;
|
|
234
218
|
}
|
|
@@ -257,19 +241,40 @@ var handleMediaSingleWithLozenge = exports.handleMediaSingleWithLozenge = functi
|
|
|
257
241
|
/**
|
|
258
242
|
* Appends a block node with wrapper, lozenge, and appropriate styling
|
|
259
243
|
*/
|
|
260
|
-
var
|
|
244
|
+
var wrapBlockNode = function wrapBlockNode(_ref5) {
|
|
245
|
+
var dom = _ref5.dom,
|
|
246
|
+
nodeView = _ref5.nodeView,
|
|
247
|
+
targetNode = _ref5.targetNode,
|
|
248
|
+
colorScheme = _ref5.colorScheme,
|
|
249
|
+
intl = _ref5.intl;
|
|
261
250
|
var blockWrapper = createBlockNodeWrapper();
|
|
262
251
|
if (shouldShowRemovedLozenge(targetNode.type.name)) {
|
|
263
252
|
var lozenge = createRemovedLozenge(intl);
|
|
264
|
-
if (handleEmbedCardWithLozenge(
|
|
253
|
+
if (handleEmbedCardWithLozenge({
|
|
254
|
+
dom: dom,
|
|
255
|
+
nodeView: nodeView,
|
|
256
|
+
targetNode: targetNode,
|
|
257
|
+
lozenge: lozenge,
|
|
258
|
+
colorScheme: colorScheme
|
|
259
|
+
}) && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers')) {
|
|
265
260
|
return;
|
|
266
261
|
}
|
|
267
|
-
if (handleMediaSingleWithLozenge(
|
|
262
|
+
if (handleMediaSingleWithLozenge({
|
|
263
|
+
dom: dom,
|
|
264
|
+
nodeView: nodeView,
|
|
265
|
+
targetNode: targetNode,
|
|
266
|
+
lozenge: lozenge,
|
|
267
|
+
colorScheme: colorScheme
|
|
268
|
+
})) {
|
|
268
269
|
return;
|
|
269
270
|
}
|
|
270
271
|
blockWrapper.append(lozenge);
|
|
271
272
|
}
|
|
272
|
-
var contentWrapper = createBlockNodeContentWrapper(
|
|
273
|
+
var contentWrapper = createBlockNodeContentWrapper({
|
|
274
|
+
nodeView: nodeView,
|
|
275
|
+
targetNode: targetNode,
|
|
276
|
+
colorScheme: colorScheme
|
|
277
|
+
});
|
|
273
278
|
blockWrapper.append(contentWrapper);
|
|
274
279
|
if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
275
280
|
var showDiffDeletedNodeClass = colorScheme === 'traditional' && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
|
|
@@ -283,13 +288,28 @@ var appendBlockNodeWithWrapper = exports.appendBlockNodeWithWrapper = function a
|
|
|
283
288
|
* For heading nodes, applies styles directly to preserve natural margins.
|
|
284
289
|
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
285
290
|
*/
|
|
286
|
-
var
|
|
287
|
-
|
|
291
|
+
var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_ref6) {
|
|
292
|
+
var dom = _ref6.dom,
|
|
293
|
+
nodeView = _ref6.nodeView,
|
|
294
|
+
targetNode = _ref6.targetNode,
|
|
295
|
+
colorScheme = _ref6.colorScheme,
|
|
296
|
+
intl = _ref6.intl;
|
|
297
|
+
if (shouldApplyStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
|
|
288
298
|
// Apply deleted styles directly to preserve natural block-level margins
|
|
289
|
-
|
|
299
|
+
applyStylesToElement({
|
|
300
|
+
element: nodeView,
|
|
301
|
+
targetNode: targetNode,
|
|
302
|
+
colorScheme: colorScheme
|
|
303
|
+
});
|
|
290
304
|
dom.append(nodeView);
|
|
291
305
|
} else {
|
|
292
306
|
// Use wrapper approach for other block nodes
|
|
293
|
-
|
|
307
|
+
wrapBlockNode({
|
|
308
|
+
dom: dom,
|
|
309
|
+
nodeView: nodeView,
|
|
310
|
+
targetNode: targetNode,
|
|
311
|
+
colorScheme: colorScheme,
|
|
312
|
+
intl: intl
|
|
313
|
+
});
|
|
294
314
|
}
|
|
295
315
|
};
|
|
@@ -4,20 +4,30 @@ import memoizeOne from 'memoize-one';
|
|
|
4
4
|
import { ChangeSet, simplifyChanges } from 'prosemirror-changeset';
|
|
5
5
|
import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
|
|
6
6
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
-
import {
|
|
8
|
-
import { createInlineChangedDecoration
|
|
9
|
-
import {
|
|
7
|
+
import { createBlockChangedDecoration } from './decorations/createBlockChangedDecoration';
|
|
8
|
+
import { createInlineChangedDecoration } from './decorations/createInlineChangedDecoration';
|
|
9
|
+
import { createNodeChangedDecorationWidget } from './decorations/createNodeChangedDecorationWidget';
|
|
10
|
+
import { getAttrChangeRanges, stepIsValidAttrChange } from './decorations/utils/getAttrChangeRanges';
|
|
11
|
+
import { getMarkChangeRanges } from './decorations/utils/getMarkChangeRanges';
|
|
10
12
|
import { simplifySteps } from './simplifyChanges';
|
|
11
|
-
const calculateNodesForBlockDecoration = (
|
|
13
|
+
const calculateNodesForBlockDecoration = ({
|
|
14
|
+
doc,
|
|
15
|
+
from,
|
|
16
|
+
to,
|
|
17
|
+
colorScheme
|
|
18
|
+
}) => {
|
|
12
19
|
const decorations = [];
|
|
13
20
|
// Iterate over the document nodes within the range
|
|
14
21
|
doc.nodesBetween(from, to, (node, pos) => {
|
|
15
22
|
if (node.isBlock) {
|
|
16
23
|
const decoration = createBlockChangedDecoration({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
change: {
|
|
25
|
+
from: pos,
|
|
26
|
+
to: pos + node.nodeSize,
|
|
27
|
+
name: node.type.name
|
|
28
|
+
},
|
|
29
|
+
colorScheme
|
|
30
|
+
});
|
|
21
31
|
if (decoration) {
|
|
22
32
|
decorations.push(decoration);
|
|
23
33
|
}
|
|
@@ -107,12 +117,21 @@ const calculateDiffDecorationsInner = ({
|
|
|
107
117
|
optimizedChanges.forEach(change => {
|
|
108
118
|
const isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
109
119
|
if (change.inserted.length > 0) {
|
|
110
|
-
decorations.push(createInlineChangedDecoration(
|
|
111
|
-
|
|
120
|
+
decorations.push(createInlineChangedDecoration({
|
|
121
|
+
change,
|
|
122
|
+
colorScheme,
|
|
123
|
+
isActive
|
|
124
|
+
}));
|
|
125
|
+
decorations.push(...calculateNodesForBlockDecoration({
|
|
126
|
+
doc: tr.doc,
|
|
127
|
+
from: change.fromB,
|
|
128
|
+
to: change.toB,
|
|
129
|
+
colorScheme
|
|
130
|
+
}));
|
|
112
131
|
}
|
|
113
132
|
if (change.deleted.length > 0) {
|
|
114
133
|
const isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
115
|
-
const decoration =
|
|
134
|
+
const decoration = createNodeChangedDecorationWidget({
|
|
116
135
|
change,
|
|
117
136
|
doc: originalDoc,
|
|
118
137
|
nodeViewSerializer,
|
|
@@ -128,10 +147,19 @@ const calculateDiffDecorationsInner = ({
|
|
|
128
147
|
});
|
|
129
148
|
getMarkChangeRanges(steps).forEach(change => {
|
|
130
149
|
const isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
131
|
-
decorations.push(createInlineChangedDecoration(
|
|
150
|
+
decorations.push(createInlineChangedDecoration({
|
|
151
|
+
change,
|
|
152
|
+
colorScheme,
|
|
153
|
+
isActive
|
|
154
|
+
}));
|
|
132
155
|
});
|
|
133
156
|
getAttrChangeRanges(tr.doc, attrSteps).forEach(change => {
|
|
134
|
-
decorations.push(...calculateNodesForBlockDecoration(
|
|
157
|
+
decorations.push(...calculateNodesForBlockDecoration({
|
|
158
|
+
doc: tr.doc,
|
|
159
|
+
from: change.fromB,
|
|
160
|
+
to: change.toB,
|
|
161
|
+
colorScheme
|
|
162
|
+
}));
|
|
135
163
|
});
|
|
136
164
|
return DecorationSet.empty.add(tr.doc, decorations);
|
|
137
165
|
};
|
|
@@ -48,43 +48,45 @@ export const deletedContentStyleUnbounded = convertToInlineCss({
|
|
|
48
48
|
pointerEvents: 'none',
|
|
49
49
|
zIndex: 1
|
|
50
50
|
});
|
|
51
|
-
const
|
|
51
|
+
export const deletedStyleQuoteNode = convertToInlineCss({
|
|
52
|
+
borderLeft: `2px solid ${"var(--ds-border-accent-gray, #7D818A)"}`
|
|
53
|
+
});
|
|
54
|
+
export const deletedStyleQuoteNodeWithLozenge = convertToInlineCss({
|
|
55
|
+
marginTop: "var(--ds-space-150, 12px)",
|
|
56
|
+
paddingTop: "var(--ds-space-025, 2px)",
|
|
57
|
+
paddingBottom: "var(--ds-space-025, 2px)",
|
|
58
|
+
paddingLeft: "var(--ds-space-025, 2px)",
|
|
59
|
+
boxShadow: `0 0 0 1px ${"var(--ds-border-accent-gray, #7D818A)"}`,
|
|
60
|
+
borderRadius: "var(--ds-radius-small, 4px)"
|
|
61
|
+
});
|
|
62
|
+
export const deletedBlockOutline = convertToInlineCss({
|
|
63
|
+
boxShadow: `0 0 0 1px ${"var(--ds-border-accent-gray, #7D818A)"}`,
|
|
64
|
+
borderRadius: "var(--ds-radius-small, 4px)"
|
|
65
|
+
});
|
|
66
|
+
export const deletedBlockOutlineRounded = convertToInlineCss({
|
|
67
|
+
boxShadow: `0 0 0 1px ${"var(--ds-border-accent-gray, #7D818A)"}`,
|
|
68
|
+
borderRadius: `calc(${"var(--ds-radius-xsmall, 2px)"} + 1px)`
|
|
69
|
+
});
|
|
70
|
+
export const deletedRowStyle = convertToInlineCss({
|
|
71
|
+
color: "var(--ds-text-accent-gray, #505258)",
|
|
72
|
+
textDecoration: 'line-through',
|
|
73
|
+
opacity: 0.6,
|
|
74
|
+
display: 'table-row'
|
|
75
|
+
});
|
|
76
|
+
export const editingStyleQuoteNode = convertToInlineCss({
|
|
52
77
|
borderLeft: `2px solid ${"var(--ds-border-accent-purple, #AF59E1)"}`
|
|
53
78
|
});
|
|
54
|
-
const editingStyleRuleNode = convertToInlineCss({
|
|
79
|
+
export const editingStyleRuleNode = convertToInlineCss({
|
|
55
80
|
backgroundColor: "var(--ds-border-accent-purple, #AF59E1)"
|
|
56
81
|
});
|
|
57
|
-
const editingStyleNode = convertToInlineCss({
|
|
82
|
+
export const editingStyleNode = convertToInlineCss({
|
|
58
83
|
boxShadow: `0 0 0 1px ${"var(--ds-border-accent-purple, #AF59E1)"}`,
|
|
59
84
|
borderRadius: "var(--ds-radius-small, 4px)"
|
|
60
85
|
});
|
|
61
|
-
const editingStyleCardBlockNode = convertToInlineCss({
|
|
86
|
+
export const editingStyleCardBlockNode = convertToInlineCss({
|
|
62
87
|
boxShadow: `0 0 0 1px ${"var(--ds-border-accent-purple, #AF59E1)"}`,
|
|
63
88
|
borderRadius: "var(--ds-radius-medium, 6px)"
|
|
64
89
|
});
|
|
65
|
-
const
|
|
90
|
+
export const standardDecorationMarkerVariable = convertToInlineCss({
|
|
66
91
|
'--diff-decoration-marker-color': "var(--ds-border-accent-purple, #AF59E1)"
|
|
67
|
-
});
|
|
68
|
-
export const getStandardNodeStyle = nodeName => {
|
|
69
|
-
if (['mediaSingle', 'mediaGroup', 'table',
|
|
70
|
-
// Handle table separately to avoid border issues
|
|
71
|
-
'tableRow', 'tableCell', 'tableHeader', 'paragraph',
|
|
72
|
-
// Paragraph and heading nodes do not need special styling
|
|
73
|
-
'heading', 'hardBreak', 'decisionList', 'taskList', 'taskItem', 'bulletList', 'orderedList', 'layoutSection'].includes(nodeName)) {
|
|
74
|
-
// Layout nodes do not need special styling
|
|
75
|
-
return undefined;
|
|
76
|
-
}
|
|
77
|
-
if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
|
|
78
|
-
return standardDecorationMarkerVariableName;
|
|
79
|
-
}
|
|
80
|
-
if (nodeName === 'blockquote') {
|
|
81
|
-
return editingStyleQuoteNode;
|
|
82
|
-
}
|
|
83
|
-
if (nodeName === 'rule') {
|
|
84
|
-
return editingStyleRuleNode;
|
|
85
|
-
}
|
|
86
|
-
if (nodeName === 'blockCard') {
|
|
87
|
-
return editingStyleCardBlockNode;
|
|
88
|
-
}
|
|
89
|
-
return editingStyleNode;
|
|
90
|
-
};
|
|
92
|
+
});
|