@atlaskit/editor-common 88.8.2 → 88.8.3

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,13 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 88.8.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#136760](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136760)
8
+ [`39e4b9c90b284`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/39e4b9c90b284) -
9
+ LazyNodeView update method to compare decorations
10
+
3
11
  ## 88.8.2
4
12
 
5
13
  ### Patch Changes
@@ -70,7 +70,7 @@ var testOnlyIgnoreLazyNodeViewSet = new WeakSet();
70
70
  *
71
71
  * This needs to be replaced with proper implementation once LazyNodeView is converted to a plugin.
72
72
  *
73
- * @deprecated DO NOT USE THIS OUSIDE TESTS.
73
+ * @deprecated DO NOT USE THIS OUTSIDE TESTS.
74
74
  */
75
75
  function testOnlyIgnoreLazyNodeView(view) {
76
76
  testOnlyIgnoreLazyNodeViewSet.add(view);
@@ -137,7 +137,7 @@ var withLazyLoading = exports.withLazyLoading = function withLazyLoading(_ref) {
137
137
  if (resolvedNodeView && !testOnlyIgnoreLazyNodeViewSet.has(view)) {
138
138
  return resolvedNodeView(node, view, getPos, decorations);
139
139
  }
140
- return new _nodeView.LazyNodeView(node, view, getPos, requestedNodes.get(nodeName));
140
+ return new _nodeView.LazyNodeView(node, view, getPos, decorations);
141
141
  }
142
142
  var loaderPromise = loader().then(function (nodeViewFuncModule) {
143
143
  var _resolvedNodesPerEdit;
@@ -187,7 +187,7 @@ var withLazyLoading = exports.withLazyLoading = function withLazyLoading(_ref) {
187
187
  // },
188
188
  // });
189
189
  }
190
- return new _nodeView.LazyNodeView(node, view, getPos, loaderPromise);
190
+ return new _nodeView.LazyNodeView(node, view, getPos, decorations);
191
191
  };
192
192
  return createLazyNodeView;
193
193
  };
@@ -15,23 +15,40 @@ var getEditorLineWidth = (0, _memoize.default)(function (view) {
15
15
  return (_view$dom = view.dom) === null || _view$dom === void 0 ? void 0 : _view$dom.clientWidth;
16
16
  });
17
17
 
18
+ // Copied from ProseMirror NodeView
19
+ // https://github.com/ProseMirror/prosemirror-view/blob/cfa73eb969777f63bcb39972594fd4a9110f5a93/src/viewdesc.ts#L1095-L1099
20
+ function sameOuterDeco(a, b) {
21
+ if (a.length !== b.length) {
22
+ return false;
23
+ }
24
+ for (var i = 0; i < a.length; i++) {
25
+ // @ts-expect-error type actually exist on decoration at runtime
26
+ if (!a[i].type) {
27
+ return false;
28
+ }
29
+
30
+ // @ts-expect-error type actually exist on decoration at runtime
31
+ if (!a[i].type.eq(b[i].type)) {
32
+ return false;
33
+ }
34
+ }
35
+ return true;
36
+ }
37
+
18
38
  /**
19
39
  * 🧱 Internal: Editor FE Platform
20
40
  *
21
41
  * A NodeView that serves as a placeholder until the actual NodeView is loaded.
22
42
  */
23
43
  var LazyNodeView = exports.LazyNodeView = /*#__PURE__*/function () {
24
- function LazyNodeView(_node, view, _getPos, nodeViewLoader) {
44
+ function LazyNodeView(_node, view, _getPos, _outerDeco) {
25
45
  var _this = this,
26
46
  _node$type;
27
47
  (0, _classCallCheck2.default)(this, LazyNodeView);
28
- (0, _defineProperty2.default)(this, "update", function (node) {
48
+ (0, _defineProperty2.default)(this, "update", function (node, outerDeco) {
29
49
  var prevNode = _this.node;
30
50
  _this.node = node;
31
-
32
- // Forcing NodeView to be re-created
33
- // so that ProseMirror can replace LazyNodeView with the real one.
34
- if (_this.isNodeViewLoaded) {
51
+ if (!sameOuterDeco(outerDeco, _this.outerDeco)) {
35
52
  return false;
36
53
  }
37
54
 
@@ -40,7 +57,7 @@ var LazyNodeView = exports.LazyNodeView = /*#__PURE__*/function () {
40
57
  return !_this.node.sameMarkup(prevNode);
41
58
  });
42
59
  this.node = _node;
43
- this.isNodeViewLoaded = false;
60
+ this.outerDeco = _outerDeco;
44
61
  if (typeof ((_node$type = _node.type) === null || _node$type === void 0 || (_node$type = _node$type.spec) === null || _node$type === void 0 ? void 0 : _node$type.toDOM) !== 'function') {
45
62
  this.dom = document.createElement('div');
46
63
  return;
@@ -63,9 +80,6 @@ var LazyNodeView = exports.LazyNodeView = /*#__PURE__*/function () {
63
80
  // before the test started
64
81
  this.dom.setAttribute('data-lazy-node-view-fallback', 'true');
65
82
  }
66
- nodeViewLoader.then(function () {
67
- _this.isNodeViewLoaded = true;
68
- });
69
83
  }
70
84
  (0, _createClass2.default)(LazyNodeView, [{
71
85
  key: "ignoreMutation",
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
18
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
19
19
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
20
- var packageVersion = "88.8.2";
20
+ var packageVersion = "88.8.3";
21
21
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
22
22
  // Remove URL as it has UGC
23
23
  // TODO: Sanitise the URL instead of just removing it
@@ -25,7 +25,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
25
25
  * @jsx jsx
26
26
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
27
27
  var packageName = "@atlaskit/editor-common";
28
- var packageVersion = "88.8.2";
28
+ var packageVersion = "88.8.3";
29
29
  var halfFocusRing = 1;
30
30
  var dropOffset = '0, 8';
31
31
  var DropList = /*#__PURE__*/function (_Component) {
@@ -54,7 +54,7 @@ const testOnlyIgnoreLazyNodeViewSet = new WeakSet();
54
54
  *
55
55
  * This needs to be replaced with proper implementation once LazyNodeView is converted to a plugin.
56
56
  *
57
- * @deprecated DO NOT USE THIS OUSIDE TESTS.
57
+ * @deprecated DO NOT USE THIS OUTSIDE TESTS.
58
58
  */
59
59
  export function testOnlyIgnoreLazyNodeView(view) {
60
60
  testOnlyIgnoreLazyNodeViewSet.add(view);
@@ -122,7 +122,7 @@ export const withLazyLoading = ({
122
122
  if (resolvedNodeView && !testOnlyIgnoreLazyNodeViewSet.has(view)) {
123
123
  return resolvedNodeView(node, view, getPos, decorations);
124
124
  }
125
- return new LazyNodeView(node, view, getPos, requestedNodes.get(nodeName));
125
+ return new LazyNodeView(node, view, getPos, decorations);
126
126
  }
127
127
  const loaderPromise = loader().then(nodeViewFuncModule => {
128
128
  var _resolvedNodesPerEdit;
@@ -169,7 +169,7 @@ export const withLazyLoading = ({
169
169
  // },
170
170
  // });
171
171
  }
172
- return new LazyNodeView(node, view, getPos, loaderPromise);
172
+ return new LazyNodeView(node, view, getPos, decorations);
173
173
  };
174
174
  return createLazyNodeView;
175
175
  };
@@ -6,21 +6,38 @@ const getEditorLineWidth = memoize(view => {
6
6
  return (_view$dom = view.dom) === null || _view$dom === void 0 ? void 0 : _view$dom.clientWidth;
7
7
  });
8
8
 
9
+ // Copied from ProseMirror NodeView
10
+ // https://github.com/ProseMirror/prosemirror-view/blob/cfa73eb969777f63bcb39972594fd4a9110f5a93/src/viewdesc.ts#L1095-L1099
11
+ function sameOuterDeco(a, b) {
12
+ if (a.length !== b.length) {
13
+ return false;
14
+ }
15
+ for (let i = 0; i < a.length; i++) {
16
+ // @ts-expect-error type actually exist on decoration at runtime
17
+ if (!a[i].type) {
18
+ return false;
19
+ }
20
+
21
+ // @ts-expect-error type actually exist on decoration at runtime
22
+ if (!a[i].type.eq(b[i].type)) {
23
+ return false;
24
+ }
25
+ }
26
+ return true;
27
+ }
28
+
9
29
  /**
10
30
  * 🧱 Internal: Editor FE Platform
11
31
  *
12
32
  * A NodeView that serves as a placeholder until the actual NodeView is loaded.
13
33
  */
14
34
  export class LazyNodeView {
15
- constructor(_node, view, _getPos, nodeViewLoader) {
35
+ constructor(_node, view, _getPos, _outerDeco) {
16
36
  var _node$type, _node$type$spec;
17
- _defineProperty(this, "update", node => {
37
+ _defineProperty(this, "update", (node, outerDeco) => {
18
38
  const prevNode = this.node;
19
39
  this.node = node;
20
-
21
- // Forcing NodeView to be re-created
22
- // so that ProseMirror can replace LazyNodeView with the real one.
23
- if (this.isNodeViewLoaded) {
40
+ if (!sameOuterDeco(outerDeco, this.outerDeco)) {
24
41
  return false;
25
42
  }
26
43
 
@@ -29,7 +46,7 @@ export class LazyNodeView {
29
46
  return !this.node.sameMarkup(prevNode);
30
47
  });
31
48
  this.node = _node;
32
- this.isNodeViewLoaded = false;
49
+ this.outerDeco = _outerDeco;
33
50
  if (typeof ((_node$type = _node.type) === null || _node$type === void 0 ? void 0 : (_node$type$spec = _node$type.spec) === null || _node$type$spec === void 0 ? void 0 : _node$type$spec.toDOM) !== 'function') {
34
51
  this.dom = document.createElement('div');
35
52
  return;
@@ -52,9 +69,6 @@ export class LazyNodeView {
52
69
  // before the test started
53
70
  this.dom.setAttribute('data-lazy-node-view-fallback', 'true');
54
71
  }
55
- nodeViewLoader.then(() => {
56
- this.isNodeViewLoaded = true;
57
- });
58
72
  }
59
73
  ignoreMutation() {
60
74
  if (this.node.type.isTextblock) {
@@ -1,7 +1,7 @@
1
1
  import { isFedRamp } from './environment';
2
2
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
3
3
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
4
- const packageVersion = "88.8.2";
4
+ const packageVersion = "88.8.3";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // TODO: Sanitise the URL instead of just removing it
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
15
15
  import Layer from '../Layer';
16
16
  const packageName = "@atlaskit/editor-common";
17
- const packageVersion = "88.8.2";
17
+ const packageVersion = "88.8.3";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  class DropList extends Component {
@@ -55,7 +55,7 @@ var testOnlyIgnoreLazyNodeViewSet = new WeakSet();
55
55
  *
56
56
  * This needs to be replaced with proper implementation once LazyNodeView is converted to a plugin.
57
57
  *
58
- * @deprecated DO NOT USE THIS OUSIDE TESTS.
58
+ * @deprecated DO NOT USE THIS OUTSIDE TESTS.
59
59
  */
60
60
  export function testOnlyIgnoreLazyNodeView(view) {
61
61
  testOnlyIgnoreLazyNodeViewSet.add(view);
@@ -122,7 +122,7 @@ export var withLazyLoading = function withLazyLoading(_ref) {
122
122
  if (resolvedNodeView && !testOnlyIgnoreLazyNodeViewSet.has(view)) {
123
123
  return resolvedNodeView(node, view, getPos, decorations);
124
124
  }
125
- return new LazyNodeView(node, view, getPos, requestedNodes.get(nodeName));
125
+ return new LazyNodeView(node, view, getPos, decorations);
126
126
  }
127
127
  var loaderPromise = loader().then(function (nodeViewFuncModule) {
128
128
  var _resolvedNodesPerEdit;
@@ -172,7 +172,7 @@ export var withLazyLoading = function withLazyLoading(_ref) {
172
172
  // },
173
173
  // });
174
174
  }
175
- return new LazyNodeView(node, view, getPos, loaderPromise);
175
+ return new LazyNodeView(node, view, getPos, decorations);
176
176
  };
177
177
  return createLazyNodeView;
178
178
  };
@@ -8,23 +8,40 @@ var getEditorLineWidth = memoize(function (view) {
8
8
  return (_view$dom = view.dom) === null || _view$dom === void 0 ? void 0 : _view$dom.clientWidth;
9
9
  });
10
10
 
11
+ // Copied from ProseMirror NodeView
12
+ // https://github.com/ProseMirror/prosemirror-view/blob/cfa73eb969777f63bcb39972594fd4a9110f5a93/src/viewdesc.ts#L1095-L1099
13
+ function sameOuterDeco(a, b) {
14
+ if (a.length !== b.length) {
15
+ return false;
16
+ }
17
+ for (var i = 0; i < a.length; i++) {
18
+ // @ts-expect-error type actually exist on decoration at runtime
19
+ if (!a[i].type) {
20
+ return false;
21
+ }
22
+
23
+ // @ts-expect-error type actually exist on decoration at runtime
24
+ if (!a[i].type.eq(b[i].type)) {
25
+ return false;
26
+ }
27
+ }
28
+ return true;
29
+ }
30
+
11
31
  /**
12
32
  * 🧱 Internal: Editor FE Platform
13
33
  *
14
34
  * A NodeView that serves as a placeholder until the actual NodeView is loaded.
15
35
  */
16
36
  export var LazyNodeView = /*#__PURE__*/function () {
17
- function LazyNodeView(_node, view, _getPos, nodeViewLoader) {
37
+ function LazyNodeView(_node, view, _getPos, _outerDeco) {
18
38
  var _this = this,
19
39
  _node$type;
20
40
  _classCallCheck(this, LazyNodeView);
21
- _defineProperty(this, "update", function (node) {
41
+ _defineProperty(this, "update", function (node, outerDeco) {
22
42
  var prevNode = _this.node;
23
43
  _this.node = node;
24
-
25
- // Forcing NodeView to be re-created
26
- // so that ProseMirror can replace LazyNodeView with the real one.
27
- if (_this.isNodeViewLoaded) {
44
+ if (!sameOuterDeco(outerDeco, _this.outerDeco)) {
28
45
  return false;
29
46
  }
30
47
 
@@ -33,7 +50,7 @@ export var LazyNodeView = /*#__PURE__*/function () {
33
50
  return !_this.node.sameMarkup(prevNode);
34
51
  });
35
52
  this.node = _node;
36
- this.isNodeViewLoaded = false;
53
+ this.outerDeco = _outerDeco;
37
54
  if (typeof ((_node$type = _node.type) === null || _node$type === void 0 || (_node$type = _node$type.spec) === null || _node$type === void 0 ? void 0 : _node$type.toDOM) !== 'function') {
38
55
  this.dom = document.createElement('div');
39
56
  return;
@@ -56,9 +73,6 @@ export var LazyNodeView = /*#__PURE__*/function () {
56
73
  // before the test started
57
74
  this.dom.setAttribute('data-lazy-node-view-fallback', 'true');
58
75
  }
59
- nodeViewLoader.then(function () {
60
- _this.isNodeViewLoaded = true;
61
- });
62
76
  }
63
77
  _createClass(LazyNodeView, [{
64
78
  key: "ignoreMutation",
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { isFedRamp } from './environment';
8
8
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
9
9
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
10
- var packageVersion = "88.8.2";
10
+ var packageVersion = "88.8.3";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // TODO: Sanitise the URL instead of just removing it
@@ -22,7 +22,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
22
22
  import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
23
23
  import Layer from '../Layer';
24
24
  var packageName = "@atlaskit/editor-common";
25
- var packageVersion = "88.8.2";
25
+ var packageVersion = "88.8.3";
26
26
  var halfFocusRing = 1;
27
27
  var dropOffset = '0, 8';
28
28
  var DropList = /*#__PURE__*/function (_Component) {
@@ -35,7 +35,7 @@ export type LazyLoadingProps<NodeViewOptions> = {
35
35
  *
36
36
  * This needs to be replaced with proper implementation once LazyNodeView is converted to a plugin.
37
37
  *
38
- * @deprecated DO NOT USE THIS OUSIDE TESTS.
38
+ * @deprecated DO NOT USE THIS OUTSIDE TESTS.
39
39
  */
40
40
  export declare function testOnlyIgnoreLazyNodeView(view: EditorView): void;
41
41
  /**
@@ -1,5 +1,5 @@
1
1
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
2
+ import type { Decoration, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
3
3
  /**
4
4
  * 🧱 Internal: Editor FE Platform
5
5
  *
@@ -9,8 +9,8 @@ export declare class LazyNodeView implements NodeView {
9
9
  dom: Node;
10
10
  contentDOM?: HTMLElement;
11
11
  private node;
12
- private isNodeViewLoaded;
13
- constructor(node: PMNode, view: EditorView, _getPos: () => number | undefined, nodeViewLoader: Promise<unknown>);
14
- update: (node: PMNode) => boolean;
12
+ private outerDeco;
13
+ constructor(node: PMNode, view: EditorView, _getPos: () => number | undefined, outerDeco: readonly Decoration[]);
14
+ update: (node: PMNode, outerDeco: readonly Decoration[]) => boolean;
15
15
  ignoreMutation(): boolean;
16
16
  }
@@ -35,7 +35,7 @@ export type LazyLoadingProps<NodeViewOptions> = {
35
35
  *
36
36
  * This needs to be replaced with proper implementation once LazyNodeView is converted to a plugin.
37
37
  *
38
- * @deprecated DO NOT USE THIS OUSIDE TESTS.
38
+ * @deprecated DO NOT USE THIS OUTSIDE TESTS.
39
39
  */
40
40
  export declare function testOnlyIgnoreLazyNodeView(view: EditorView): void;
41
41
  /**
@@ -1,5 +1,5 @@
1
1
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
2
+ import type { Decoration, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
3
3
  /**
4
4
  * 🧱 Internal: Editor FE Platform
5
5
  *
@@ -9,8 +9,8 @@ export declare class LazyNodeView implements NodeView {
9
9
  dom: Node;
10
10
  contentDOM?: HTMLElement;
11
11
  private node;
12
- private isNodeViewLoaded;
13
- constructor(node: PMNode, view: EditorView, _getPos: () => number | undefined, nodeViewLoader: Promise<unknown>);
14
- update: (node: PMNode) => boolean;
12
+ private outerDeco;
13
+ constructor(node: PMNode, view: EditorView, _getPos: () => number | undefined, outerDeco: readonly Decoration[]);
14
+ update: (node: PMNode, outerDeco: readonly Decoration[]) => boolean;
15
15
  ignoreMutation(): boolean;
16
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "88.8.2",
3
+ "version": "88.8.3",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"