@atlaskit/editor-plugin-show-diff 24.1.4 → 24.1.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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 24.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`143a5760293cf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/143a5760293cf) -
8
+ EDITOR-9591 Preserve the agent-coloured emoji diff outline after emoji data loads
9
+ - [`2a0c61ea46c19`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2a0c61ea46c19) -
10
+ Apply scroll margins to existing block diff decorations without contributor anchors and use
11
+ styling-only decorations for otherwise unstyled nodes, preserving diff navigation and
12
+ contributor-tag grouping. Enabled behind platform_editor_ai_show_diff_patch_2 and
13
+ platform_editor_ai_show_diff_patch_1.
14
+ - Updated dependencies
15
+
16
+ ## 24.1.5
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 24.1.4
4
23
 
5
24
  ### Patch Changes
@@ -47,14 +47,6 @@ function isEditorViewWithNodeViews(view) {
47
47
  /** Expand-family nodes whose expanded state lives in a node-keyed WeakMap. */
48
48
  var EXPAND_TYPES = new Set(['expand', 'nestedExpand']);
49
49
 
50
- /** Merges an inline style string onto an element's existing `style` attribute. */
51
- var appendInlineStyle = function appendInlineStyle(element, style) {
52
- var _element$getAttribute;
53
- var currentStyle = (_element$getAttribute = element.getAttribute('style')) !== null && _element$getAttribute !== void 0 ? _element$getAttribute : '';
54
- var separator = currentStyle && style && !currentStyle.trimEnd().endsWith(';') ? '; ' : '';
55
- element.setAttribute('style', "".concat(currentStyle).concat(separator).concat(style));
56
- };
57
-
58
50
  /** Tables are the only node views that read and write positions, so only they need a preview. */
59
51
  var containsTable = function containsTable(node) {
60
52
  var table = node.type.schema.nodes.table;
@@ -121,15 +113,15 @@ var NodeViewSerializer = exports.NodeViewSerializer = /*#__PURE__*/function () {
121
113
  // Give inserted atomic children the same box-shadow
122
114
  // highlight an in-place attribute change already gets (`getAtomicInlineChangedAttrs`).
123
115
  if (isInserted && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_deleted_nodeview_content') && (0, _getAttrChangeRanges.isInlineAttrChangeNodeName)(child.type.name) && childNode instanceof HTMLElement) {
124
- var _childNode$getAttribu;
125
116
  var _getAtomicInlineChang = (0, _createInlineChangedDecoration.getAtomicInlineChangedAttrs)(child.type.name, colorScheme),
126
117
  className = _getAtomicInlineChang.className,
127
118
  styleSuffix = _getAtomicInlineChang.styleSuffix;
128
- var existingClassName = (_childNode$getAttribu = childNode.getAttribute('class')) !== null && _childNode$getAttribu !== void 0 ? _childNode$getAttribu : '';
129
- childNode.setAttribute('class', existingClassName ? "".concat(existingClassName, " ").concat(className) : className);
130
- if (styleSuffix) {
131
- appendInlineStyle(childNode, styleSuffix);
132
- }
119
+ // create wrapper to add the diff styles to to avoid conflicting with any nodeView styles
120
+ var wrapper = document.createElement('span');
121
+ wrapper.className = className;
122
+ wrapper.setAttribute('style', styleSuffix);
123
+ wrapper.append(childNode);
124
+ childNode = wrapper;
133
125
  }
134
126
  contentDOM === null || contentDOM === void 0 || contentDOM.append(childNode);
135
127
  }
@@ -237,9 +237,14 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
237
237
  isInserted: isInserted,
238
238
  isActive: isActive
239
239
  });
240
- var style = tagAnchorName ? [nodeStyle, (0, _cssHelper.convertToInlineCss)({
240
+ var styleOld = tagAnchorName ? [nodeStyle, (0, _cssHelper.convertToInlineCss)({
241
241
  anchorName: "--".concat(tagAnchorName)
242
242
  }), (0, _fg.fg)('platform_editor_ai_show_diff_patch_1') ? _decorationKeys.scrollMarginTopStyle : undefined].filter(Boolean).join(' ') : nodeStyle;
243
+ var style = (0, _fg.fg)('platform_editor_ai_show_diff_patch_2') ? [nodeStyle, tagAnchorName ? (0, _cssHelper.convertToInlineCss)({
244
+ anchorName: "--".concat(tagAnchorName)
245
+ }) : undefined,
246
+ // only add margin top if the node actually should be styled to avoid incorrect diff decoration specs being built
247
+ nodeStyle ? _decorationKeys.scrollMarginTopStyle : undefined].filter(Boolean).join(' ') : styleOld;
243
248
  var className = getNodeClass(change.name);
244
249
  if (style || className) {
245
250
  decorations.push(_view.Decoration.node(change.from, change.to, _objectSpread({
@@ -38,14 +38,6 @@ export function isEditorViewWithNodeViews(view) {
38
38
  /** Expand-family nodes whose expanded state lives in a node-keyed WeakMap. */
39
39
  const EXPAND_TYPES = new Set(['expand', 'nestedExpand']);
40
40
 
41
- /** Merges an inline style string onto an element's existing `style` attribute. */
42
- const appendInlineStyle = (element, style) => {
43
- var _element$getAttribute;
44
- const currentStyle = (_element$getAttribute = element.getAttribute('style')) !== null && _element$getAttribute !== void 0 ? _element$getAttribute : '';
45
- const separator = currentStyle && style && !currentStyle.trimEnd().endsWith(';') ? '; ' : '';
46
- element.setAttribute('style', `${currentStyle}${separator}${style}`);
47
- };
48
-
49
41
  /** Tables are the only node views that read and write positions, so only they need a preview. */
50
42
  const containsTable = node => {
51
43
  const {
@@ -99,21 +91,21 @@ export class NodeViewSerializer {
99
91
  // views resolve to their real depth instead of every one of them seeing depth 0.
100
92
  let childPos = basePos + 1;
101
93
  children.forEach(child => {
102
- const childNode = this.tryCreateNodeViewInner(child, childPos, editorProxy, isInserted, colorScheme) || this.serializeNode(child);
94
+ let childNode = this.tryCreateNodeViewInner(child, childPos, editorProxy, isInserted, colorScheme) || this.serializeNode(child);
103
95
  if (childNode) {
104
96
  // Give inserted atomic children the same box-shadow
105
97
  // highlight an in-place attribute change already gets (`getAtomicInlineChangedAttrs`).
106
98
  if (isInserted && isExperimentEnabled('platform_editor_show_diff_deleted_nodeview_content') && isInlineAttrChangeNodeName(child.type.name) && childNode instanceof HTMLElement) {
107
- var _childNode$getAttribu;
108
99
  const {
109
100
  className,
110
101
  styleSuffix
111
102
  } = getAtomicInlineChangedAttrs(child.type.name, colorScheme);
112
- const existingClassName = (_childNode$getAttribu = childNode.getAttribute('class')) !== null && _childNode$getAttribu !== void 0 ? _childNode$getAttribu : '';
113
- childNode.setAttribute('class', existingClassName ? `${existingClassName} ${className}` : className);
114
- if (styleSuffix) {
115
- appendInlineStyle(childNode, styleSuffix);
116
- }
103
+ // create wrapper to add the diff styles to to avoid conflicting with any nodeView styles
104
+ const wrapper = document.createElement('span');
105
+ wrapper.className = className;
106
+ wrapper.setAttribute('style', styleSuffix);
107
+ wrapper.append(childNode);
108
+ childNode = wrapper;
117
109
  }
118
110
  contentDOM === null || contentDOM === void 0 ? void 0 : contentDOM.append(childNode);
119
111
  }
@@ -223,9 +223,14 @@ export const createBlockChangedDecoration = ({
223
223
  isInserted,
224
224
  isActive
225
225
  });
226
- const style = tagAnchorName ? [nodeStyle, convertToInlineCss({
226
+ const styleOld = tagAnchorName ? [nodeStyle, convertToInlineCss({
227
227
  anchorName: `--${tagAnchorName}`
228
228
  }), fg('platform_editor_ai_show_diff_patch_1') ? scrollMarginTopStyle : undefined].filter(Boolean).join(' ') : nodeStyle;
229
+ const style = fg('platform_editor_ai_show_diff_patch_2') ? [nodeStyle, tagAnchorName ? convertToInlineCss({
230
+ anchorName: `--${tagAnchorName}`
231
+ }) : undefined,
232
+ // only add margin top if the node actually should be styled to avoid incorrect diff decoration specs being built
233
+ nodeStyle ? scrollMarginTopStyle : undefined].filter(Boolean).join(' ') : styleOld;
229
234
  const className = getNodeClass(change.name);
230
235
  if (style || className) {
231
236
  decorations.push(Decoration.node(change.from, change.to, {
@@ -40,14 +40,6 @@ export function isEditorViewWithNodeViews(view) {
40
40
  /** Expand-family nodes whose expanded state lives in a node-keyed WeakMap. */
41
41
  var EXPAND_TYPES = new Set(['expand', 'nestedExpand']);
42
42
 
43
- /** Merges an inline style string onto an element's existing `style` attribute. */
44
- var appendInlineStyle = function appendInlineStyle(element, style) {
45
- var _element$getAttribute;
46
- var currentStyle = (_element$getAttribute = element.getAttribute('style')) !== null && _element$getAttribute !== void 0 ? _element$getAttribute : '';
47
- var separator = currentStyle && style && !currentStyle.trimEnd().endsWith(';') ? '; ' : '';
48
- element.setAttribute('style', "".concat(currentStyle).concat(separator).concat(style));
49
- };
50
-
51
43
  /** Tables are the only node views that read and write positions, so only they need a preview. */
52
44
  var containsTable = function containsTable(node) {
53
45
  var table = node.type.schema.nodes.table;
@@ -114,15 +106,15 @@ export var NodeViewSerializer = /*#__PURE__*/function () {
114
106
  // Give inserted atomic children the same box-shadow
115
107
  // highlight an in-place attribute change already gets (`getAtomicInlineChangedAttrs`).
116
108
  if (isInserted && isExperimentEnabled('platform_editor_show_diff_deleted_nodeview_content') && isInlineAttrChangeNodeName(child.type.name) && childNode instanceof HTMLElement) {
117
- var _childNode$getAttribu;
118
109
  var _getAtomicInlineChang = getAtomicInlineChangedAttrs(child.type.name, colorScheme),
119
110
  className = _getAtomicInlineChang.className,
120
111
  styleSuffix = _getAtomicInlineChang.styleSuffix;
121
- var existingClassName = (_childNode$getAttribu = childNode.getAttribute('class')) !== null && _childNode$getAttribu !== void 0 ? _childNode$getAttribu : '';
122
- childNode.setAttribute('class', existingClassName ? "".concat(existingClassName, " ").concat(className) : className);
123
- if (styleSuffix) {
124
- appendInlineStyle(childNode, styleSuffix);
125
- }
112
+ // create wrapper to add the diff styles to to avoid conflicting with any nodeView styles
113
+ var wrapper = document.createElement('span');
114
+ wrapper.className = className;
115
+ wrapper.setAttribute('style', styleSuffix);
116
+ wrapper.append(childNode);
117
+ childNode = wrapper;
126
118
  }
127
119
  contentDOM === null || contentDOM === void 0 || contentDOM.append(childNode);
128
120
  }
@@ -230,9 +230,14 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
230
230
  isInserted: isInserted,
231
231
  isActive: isActive
232
232
  });
233
- var style = tagAnchorName ? [nodeStyle, convertToInlineCss({
233
+ var styleOld = tagAnchorName ? [nodeStyle, convertToInlineCss({
234
234
  anchorName: "--".concat(tagAnchorName)
235
235
  }), fg('platform_editor_ai_show_diff_patch_1') ? scrollMarginTopStyle : undefined].filter(Boolean).join(' ') : nodeStyle;
236
+ var style = fg('platform_editor_ai_show_diff_patch_2') ? [nodeStyle, tagAnchorName ? convertToInlineCss({
237
+ anchorName: "--".concat(tagAnchorName)
238
+ }) : undefined,
239
+ // only add margin top if the node actually should be styled to avoid incorrect diff decoration specs being built
240
+ nodeStyle ? scrollMarginTopStyle : undefined].filter(Boolean).join(' ') : styleOld;
236
241
  var className = getNodeClass(change.name);
237
242
  if (style || className) {
238
243
  decorations.push(Decoration.node(change.from, change.to, _objectSpread({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "24.1.4",
3
+ "version": "24.1.6",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -39,7 +39,7 @@
39
39
  "@atlaskit/platform-feature-experiments": "^0.3.0",
40
40
  "@atlaskit/platform-feature-flags": "^2.2.0",
41
41
  "@atlaskit/primitives": "^22.5.0",
42
- "@atlaskit/tmp-editor-statsig": "^232.0.0",
42
+ "@atlaskit/tmp-editor-statsig": "^234.0.0",
43
43
  "@atlaskit/tokens": "^20.4.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "@compiled/react": "^1.0.2",
@@ -53,7 +53,7 @@
53
53
  "@atlaskit/button": "^25.4.0",
54
54
  "@atlaskit/css": "^1.1.0",
55
55
  "@atlaskit/dropdown-menu": "^21.0.0",
56
- "@atlaskit/editor-core": "^236.0.0",
56
+ "@atlaskit/editor-core": "^236.1.0",
57
57
  "@atlaskit/editor-json-transformer": "^10.0.0",
58
58
  "@atlaskit/editor-plugins": "^16.2.0",
59
59
  "@atlaskit/form": "^18.2.0",
@@ -64,14 +64,14 @@
64
64
  "@atlassian/confluence-presets": "workspace:^",
65
65
  "@atlassian/content-reconciliation": "^0.1.3506",
66
66
  "@atlassian/editor-ai-injected-editors": "^40.0.0",
67
- "@atlassian/editor-plugin-ai": "^80.0.0",
67
+ "@atlassian/editor-plugin-ai": "^80.1.0",
68
68
  "@atlassian/structured-docs-types": "workspace:^",
69
69
  "react": "^19.2.0",
70
70
  "react-dom": "^19.2.0",
71
71
  "react-intl": "^7.0.0"
72
72
  },
73
73
  "peerDependencies": {
74
- "@atlaskit/editor-common": "^130.3.0",
74
+ "@atlaskit/editor-common": "^130.5.0",
75
75
  "react": "^18.2.0 || ^19.2.0",
76
76
  "react-dom": "^18.2.0 || ^19.2.0",
77
77
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"