@atlaskit/editor-common 87.6.0 → 87.6.1

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/keymaps/index.js +7 -4
  3. package/dist/cjs/lazy-node-view/index.js +10 -3
  4. package/dist/cjs/lazy-node-view/node-view.js +32 -20
  5. package/dist/cjs/lazy-node-view/replace-node-views.js +94 -25
  6. package/dist/cjs/monitoring/error.js +1 -1
  7. package/dist/cjs/styles/shared/code-block.js +3 -4
  8. package/dist/cjs/ui/DropList/index.js +1 -1
  9. package/dist/es2019/keymaps/index.js +2 -1
  10. package/dist/es2019/lazy-node-view/index.js +10 -3
  11. package/dist/es2019/lazy-node-view/node-view.js +6 -1
  12. package/dist/es2019/lazy-node-view/replace-node-views.js +94 -28
  13. package/dist/es2019/monitoring/error.js +1 -1
  14. package/dist/es2019/styles/shared/code-block.js +15 -3
  15. package/dist/es2019/ui/DropList/index.js +1 -1
  16. package/dist/esm/keymaps/index.js +2 -1
  17. package/dist/esm/lazy-node-view/index.js +10 -3
  18. package/dist/esm/lazy-node-view/node-view.js +32 -20
  19. package/dist/esm/lazy-node-view/replace-node-views.js +94 -25
  20. package/dist/esm/monitoring/error.js +1 -1
  21. package/dist/esm/styles/shared/code-block.js +3 -4
  22. package/dist/esm/ui/DropList/index.js +1 -1
  23. package/dist/types/keymaps/index.d.ts +2 -0
  24. package/dist/types/lazy-node-view/index.d.ts +5 -2
  25. package/dist/types/lazy-node-view/node-view.d.ts +6 -1
  26. package/dist/types/lazy-node-view/replace-node-views.d.ts +15 -25
  27. package/dist/types/lazy-node-view/types.d.ts +7 -0
  28. package/dist/types/styles/shared/code-block.d.ts +1 -0
  29. package/dist/types-ts4.5/keymaps/index.d.ts +2 -0
  30. package/dist/types-ts4.5/lazy-node-view/index.d.ts +5 -2
  31. package/dist/types-ts4.5/lazy-node-view/node-view.d.ts +6 -1
  32. package/dist/types-ts4.5/lazy-node-view/replace-node-views.d.ts +15 -25
  33. package/dist/types-ts4.5/lazy-node-view/types.d.ts +7 -0
  34. package/dist/types-ts4.5/styles/shared/code-block.d.ts +1 -0
  35. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 87.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#128180](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/128180)
8
+ [`51b4ef21250bf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/51b4ef21250bf) -
9
+ [ux] [EDF-1228](https://product-fabric.atlassian.net/browse/EDF-1228) - add shortcut to the
10
+ `Continue in Chat` button in the Rovo Agent modal
11
+ - [#128458](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/128458)
12
+ [`26e17a7d801e4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/26e17a7d801e4) -
13
+ ED-24514 Added ignoreMutationDelegate to lazyNodeView
14
+ - [#128180](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/128180)
15
+ [`d6c81622b7636`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d6c81622b7636) -
16
+ [ED-24553] Fix Lazy NodeView race conditions when multiple Editors are running at the same time
17
+ - [#127940](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/127940)
18
+ [`7f340ec35b8a4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7f340ec35b8a4) -
19
+ [ux] ED-24320 Hook up decorators for toggled on and toggled off wrapping states in floating
20
+ toolbar
21
+ - Updated dependencies
22
+
3
23
  ## 87.6.0
4
24
 
5
25
  ### Minor Changes
@@ -82,12 +82,14 @@ exports.backspace = exports.altPaste = exports.alignRight = exports.alignLeft =
82
82
  exports.bindKeymapArrayWithCommand = bindKeymapArrayWithCommand;
83
83
  exports.bindKeymapWithCommand = bindKeymapWithCommand;
84
84
  exports.bindKeymapWithEditorCommand = bindKeymapWithEditorCommand;
85
- exports.find = exports.escape = exports.enter = exports.dragToMoveUp = exports.dragToMoveDown = exports.deleteRow = exports.deleteKey = exports.deleteColumn = exports.decreaseMediaSize = exports.cut = exports.ctrlBackSpace = exports.copy = exports.clearFormatting = void 0;
85
+ exports.find = exports.escape = exports.enter = exports.dragToMoveUp = exports.dragToMoveDown = exports.deleteRow = exports.deleteKey = exports.deleteColumn = exports.decreaseMediaSize = exports.cut = exports.ctrlBackSpace = exports.copy = exports.continueInRovoChat = exports.clearFormatting = void 0;
86
86
  exports.findKeyMapForBrowser = findKeyMapForBrowser;
87
87
  exports.findKeymapByDescription = findKeymapByDescription;
88
88
  exports.findShortcutByDescription = findShortcutByDescription;
89
89
  exports.findShortcutByKeymap = findShortcutByKeymap;
90
- exports.forwardDelete = exports.focusToContextMenuTrigger = exports.focusTableResizer = void 0;
90
+ exports.focusToContextMenuTrigger = exports.focusTableResizer = void 0;
91
+ exports.formatShortcut = formatShortcut;
92
+ exports.forwardDelete = void 0;
91
93
  exports.getAriaKeyshortcuts = getAriaKeyshortcuts;
92
94
  exports.insertRule = exports.insertNewLine = exports.indentList = exports.indent = exports.increaseMediaSize = void 0;
93
95
  exports.isCapsLockOnAndModifyKeyboardEvent = isCapsLockOnAndModifyKeyboardEvent;
@@ -100,8 +102,8 @@ Object.defineProperty(exports, "keymap", {
100
102
  exports.makeKeyMapArrayWithCommon = makeKeyMapArrayWithCommon;
101
103
  exports.makeKeyMapWithCommon = makeKeyMapWithCommon;
102
104
  exports.makeKeymap = makeKeymap;
103
- exports.toggleBold = exports.toggleBlockQuote = exports.tab = exports.submit = exports.startColumnResizing = exports.splitListItem = exports.splitCodeBlock = exports.space = exports.showElementDragHandle = exports.shiftTab = exports.shiftEnter = exports.shiftBackspace = exports.shiftArrowUp = exports.setNormalText = exports.selectTable = exports.selectRow = exports.selectColumn = exports.redo = exports.previousCell = exports.pastePlainText = exports.paste = exports.outdentList = exports.outdent = exports.openHelp = exports.nextCell = exports.navToFloatingToolbar = exports.navToEditorToolbar = exports.moveUp = exports.moveRowUp = exports.moveRowDown = exports.moveRight = exports.moveLeft = exports.moveDown = exports.moveColumnRight = exports.moveColumnLeft = void 0;
104
- exports.toggleUnderline = exports.toggleTaskItemCheckbox = exports.toggleTable = exports.toggleSuperscript = exports.toggleSubscript = exports.toggleStrikethrough = exports.toggleOrderedList = exports.toggleItalic = exports.toggleHighlightPalette = exports.toggleHeading6 = exports.toggleHeading5 = exports.toggleHeading4 = exports.toggleHeading3 = exports.toggleHeading2 = exports.toggleHeading1 = exports.toggleCode = exports.toggleBulletList = void 0;
105
+ exports.tab = exports.submit = exports.startColumnResizing = exports.splitListItem = exports.splitCodeBlock = exports.space = exports.showElementDragHandle = exports.shiftTab = exports.shiftEnter = exports.shiftBackspace = exports.shiftArrowUp = exports.setNormalText = exports.selectTable = exports.selectRow = exports.selectColumn = exports.redo = exports.previousCell = exports.pastePlainText = exports.paste = exports.outdentList = exports.outdent = exports.openHelp = exports.nextCell = exports.navToFloatingToolbar = exports.navToEditorToolbar = exports.moveUp = exports.moveRowUp = exports.moveRowDown = exports.moveRight = exports.moveLeft = exports.moveDown = exports.moveColumnRight = exports.moveColumnLeft = void 0;
106
+ exports.toggleUnderline = exports.toggleTaskItemCheckbox = exports.toggleTable = exports.toggleSuperscript = exports.toggleSubscript = exports.toggleStrikethrough = exports.toggleOrderedList = exports.toggleItalic = exports.toggleHighlightPalette = exports.toggleHeading6 = exports.toggleHeading5 = exports.toggleHeading4 = exports.toggleHeading3 = exports.toggleHeading2 = exports.toggleHeading1 = exports.toggleCode = exports.toggleBulletList = exports.toggleBold = exports.toggleBlockQuote = void 0;
105
107
  exports.tooltip = tooltip;
106
108
  exports.undo = void 0;
107
109
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
@@ -214,6 +216,7 @@ var focusToContextMenuTrigger = exports.focusToContextMenuTrigger = makeKeyMapWi
214
216
  var dragToMoveUp = exports.dragToMoveUp = makeKeyMapWithCommon('Move node up in the document', 'Ctrl-Shift-ArrowUp');
215
217
  var dragToMoveDown = exports.dragToMoveDown = makeKeyMapWithCommon('Move node down in the document', 'Ctrl-Shift-ArrowDown');
216
218
  var showElementDragHandle = exports.showElementDragHandle = makeKeyMapWithCommon('Show drag handle for editor element', 'Ctrl-Shift-h');
219
+ var continueInRovoChat = exports.continueInRovoChat = makeKeyMapWithCommon('Continue in Rovo chat', 'Alt-Enter');
217
220
  var arrowKeysMap = {
218
221
  // for reference: https://wincent.com/wiki/Unicode_representations_of_modifier_keys
219
222
  ARROWLEFT: "\u2190",
@@ -76,7 +76,10 @@ var withLazyLoading = exports.withLazyLoading = function withLazyLoading(_ref) {
76
76
  var nodeName = _ref.nodeName,
77
77
  loader = _ref.loader,
78
78
  getNodeViewOptions = _ref.getNodeViewOptions,
79
- dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
79
+ dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
80
+ _ref$lazyNodeViewOpti = _ref.lazyNodeViewOptions,
81
+ _ref$lazyNodeViewOpti2 = _ref$lazyNodeViewOpti === void 0 ? {} : _ref$lazyNodeViewOpti,
82
+ ignoreMutationDelegate = _ref$lazyNodeViewOpti2.ignoreMutationDelegate;
80
83
  var createLazyNodeView = function createLazyNodeView(node, view, getPos, decorations) {
81
84
  var _node$type;
82
85
  var requestedNodes = requestedNodesPerEditorView.get(view);
@@ -85,7 +88,9 @@ var withLazyLoading = exports.withLazyLoading = function withLazyLoading(_ref) {
85
88
  }
86
89
  var wasAlreadyRequested = requestedNodes.has(nodeName);
87
90
  if (wasAlreadyRequested) {
88
- return new _nodeView.LazyNodeView(node, view, getPos);
91
+ return new _nodeView.LazyNodeView(node, view, getPos, {
92
+ ignoreMutationDelegate: ignoreMutationDelegate
93
+ });
89
94
  }
90
95
  requestedNodes.add(nodeName);
91
96
  loader().then(function (nodeViewFuncModule) {
@@ -109,7 +114,9 @@ var withLazyLoading = exports.withLazyLoading = function withLazyLoading(_ref) {
109
114
  // },
110
115
  // });
111
116
  }
112
- return new _nodeView.LazyNodeView(node, view, getPos);
117
+ return new _nodeView.LazyNodeView(node, view, getPos, {
118
+ ignoreMutationDelegate: ignoreMutationDelegate
119
+ });
113
120
  };
114
121
  return createLazyNodeView;
115
122
  };
@@ -5,31 +5,43 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.LazyNodeView = void 0;
8
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
9
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _model = require("@atlaskit/editor-prosemirror/model");
11
11
  /**
12
12
  * 🧱 Internal: Editor FE Platform
13
13
  *
14
14
  * A NodeView that serves as a placeholder until the actual NodeView is loaded.
15
15
  */
16
- var LazyNodeView = exports.LazyNodeView = /*#__PURE__*/(0, _createClass2.default)(function LazyNodeView(node, view, getPos) {
17
- var _node$type;
18
- (0, _classCallCheck2.default)(this, LazyNodeView);
19
- 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') {
20
- this.dom = document.createElement('div');
21
- return;
22
- }
23
- var fallback = _model.DOMSerializer.renderSpec(document, node.type.spec.toDOM(node));
24
- this.dom = fallback.dom;
25
- this.contentDOM = fallback.contentDOM;
26
- if (this.dom instanceof HTMLElement) {
27
- // This attribute is mostly used for debugging purposed
28
- // It will help us to found out when the node was replaced
29
- this.dom.setAttribute('data-lazy-node-view', node.type.name);
30
- // This is used on Libra tests
31
- // We are using this to make sure all lazy noded were replaced
32
- // before the test started
33
- this.dom.setAttribute('data-lazy-node-view-fallback', 'true');
16
+ var LazyNodeView = exports.LazyNodeView = /*#__PURE__*/function () {
17
+ function LazyNodeView(node, view, getPos) {
18
+ var _node$type;
19
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
20
+ (0, _classCallCheck2.default)(this, LazyNodeView);
21
+ this.ignoreMutationDelegate = options === null || options === void 0 ? void 0 : options.ignoreMutationDelegate;
22
+ 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') {
23
+ this.dom = document.createElement('div');
24
+ return;
25
+ }
26
+ var fallback = _model.DOMSerializer.renderSpec(document, node.type.spec.toDOM(node));
27
+ this.dom = fallback.dom;
28
+ this.contentDOM = fallback.contentDOM;
29
+ if (this.dom instanceof HTMLElement) {
30
+ // This attribute is mostly used for debugging purposed
31
+ // It will help us to found out when the node was replaced
32
+ this.dom.setAttribute('data-lazy-node-view', node.type.name);
33
+ // This is used on Libra tests
34
+ // We are using this to make sure all lazy noded were replaced
35
+ // before the test started
36
+ this.dom.setAttribute('data-lazy-node-view-fallback', 'true');
37
+ }
34
38
  }
35
- });
39
+ (0, _createClass2.default)(LazyNodeView, [{
40
+ key: "ignoreMutation",
41
+ value: function ignoreMutation(mutation) {
42
+ var _this$ignoreMutationD;
43
+ return !!((_this$ignoreMutationD = this.ignoreMutationDelegate) !== null && _this$ignoreMutationD !== void 0 && _this$ignoreMutationD.call(this, mutation));
44
+ }
45
+ }]);
46
+ return LazyNodeView;
47
+ }();
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.queueReplaceNodeViews = exports.debouncedReplaceNodeviews = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _debounce = _interopRequireDefault(require("lodash/debounce"));
10
+ var _memoize = _interopRequireDefault(require("lodash/memoize"));
10
11
  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; }
11
12
  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; }
12
13
  /**
@@ -17,11 +18,10 @@ var isFirefox = /gecko\/\d/i.test(navigator.userAgent);
17
18
  /**
18
19
  * 🧱 Internal: Editor FE Platform
19
20
  *
20
- * Debounces and replaces the node views in a ProseMirror editor with lazy-loaded node views.
21
+ * Replaces the node views in a ProseMirror editor with lazy-loaded node views.
21
22
  *
22
23
  * This function is used to update the `nodeViews` property of the `EditorView` after lazy-loaded
23
- * node views have been loaded. It uses a debounced approach to ensure that the replacement does
24
- * not happen too frequently, which can be performance-intensive.
24
+ * node views have been loaded.
25
25
  *
26
26
  * The function checks if there are any loaded node views in the cache associated with the given
27
27
  * `EditorView`. If there are, it replaces the current `nodeViews` in the `EditorView` with the
@@ -45,9 +45,9 @@ var isFirefox = /gecko\/\d/i.test(navigator.userAgent);
45
45
  * 'tableCell': TableCellViewConstructor,
46
46
  * });
47
47
  *
48
- * debouncedReplaceNodeviews(cache, view);
48
+ * replaceNodeViews(cache, view);
49
49
  */
50
- var debouncedReplaceNodeviews = exports.debouncedReplaceNodeviews = (0, _debounce.default)(function (cache, view) {
50
+ var replaceNodeViews = function replaceNodeViews(cache, view) {
51
51
  var loadedNodeviews = cache.get(view);
52
52
  if (!loadedNodeviews || Object.keys(loadedNodeviews).length === 0) {
53
53
  return;
@@ -57,40 +57,109 @@ var debouncedReplaceNodeviews = exports.debouncedReplaceNodeviews = (0, _debounc
57
57
  // Make sure the cache is cleaned
58
58
  // From here, we will access the loaded node views by lexical scope
59
59
  cache.set(view, {});
60
+ var callback = function callback() {
61
+ var currentNodeViews = view.props.nodeViews;
62
+ var nextNodeViews = _objectSpread(_objectSpread({}, currentNodeViews), nodeViewsToReplace);
63
+ view.setProps({
64
+ nodeViews: nextNodeViews
65
+ });
66
+ };
67
+ // eslint-disable-next-line compat/compat
68
+ var idle = window.requestIdleCallback;
60
69
 
61
70
  /*
62
71
  * For reasons that goes beyond my knowledge
63
72
  * some Firefox versions aren't calling the requestIdleCallback.
64
73
  *
65
- * So, we need this check to make sure we use the requestAnimationFrame instead
66
- *
67
- * setting timeout to 2s to ensure this function is called, but not before prosemirror render
68
- * and other important tasks are done - adjust this timeout based on user feedback
74
+ * So, we need this check to make sure we are using the requestAnimationFrame for Firefox
69
75
  */
70
- var later = function later(callback) {
71
- // eslint-disable-next-line compat/compat
72
- if (isFirefox || !window.requestIdleCallback) {
73
- return window.requestAnimationFrame(callback);
74
- }
75
- // eslint-disable-next-line compat/compat
76
- window.requestIdleCallback(callback, {
76
+ if (isFirefox || typeof idle !== 'function') {
77
+ window.requestAnimationFrame(callback);
78
+ } else {
79
+ idle(callback, {
77
80
  timeout: 2000
78
81
  });
79
- };
80
- later(function () {
81
- var currentNodeViews = view.props.nodeViews;
82
- var nextNodeViews = _objectSpread(_objectSpread({}, currentNodeViews), nodeViewsToReplace);
83
- view.setProps({
84
- nodeViews: nextNodeViews
85
- });
86
- });
87
- });
82
+ }
83
+ };
88
84
 
89
85
  /**
90
86
  * 🧱 Internal: Editor FE Platform
91
87
  */
92
88
  var loadedPerEditorView = new WeakMap();
93
89
 
90
+ /**
91
+ * 🧱 Internal: Editor FE Platform
92
+ * Based on https://github.com/lodash/lodash/issues/2403#issuecomment-1706130395
93
+ *
94
+ * Creates a debounced function that delays invoking the provided function until after a specified
95
+ * wait time has elapsed since the last time the debounced function was invoked. Additionally, the
96
+ * debounced function is memoized so that the same function instance is used for each unique set
97
+ * of arguments based on the resolver.
98
+ *
99
+ * This is particularly useful in scenarios where you want to debounce function calls while ensuring
100
+ * that each unique input combination receives its own debounced function instance. It's a combination
101
+ * of lodash's `debounce` and `memoize`.
102
+ *
103
+ * @template T
104
+ * @param {T} func - The function to debounce.
105
+ * @param {number} [wait=0] - The number of milliseconds to delay.
106
+ * @param {Object} [options] - The options object to pass to `debounce`.
107
+ * @param {Function} [resolver] - The function to resolve the cache key for memoization.
108
+ * @returns {Function} A new debounced and memoized function.
109
+ *
110
+ * @example
111
+ * const debouncedFunction = memoizeDebounce(myFunction, 300, { leading: true }, myResolver);
112
+ * debouncedFunction(arg1, arg2);
113
+ */
114
+ function memoizeDebounce(func) {
115
+ var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
116
+ var options = arguments.length > 2 ? arguments[2] : undefined;
117
+ var resolver = arguments.length > 3 ? arguments[3] : undefined;
118
+ var mem = (0, _memoize.default)(function () {
119
+ return (0, _debounce.default)(func, wait, options);
120
+ }, resolver);
121
+ return function () {
122
+ return mem.apply(void 0, arguments).apply(void 0, arguments);
123
+ };
124
+ }
125
+
126
+ /**
127
+ * 🧱 Internal: Editor FE Platform
128
+ *
129
+ * Debounced and memoized version of `replaceNodeViews`.
130
+ *
131
+ * This function is designed to update the `nodeViews` property of an `EditorView` after a
132
+ * period of inactivity (debounce), ensuring that multiple rapid updates do not occur in quick
133
+ * succession. It uses lodash's `debounce` to handle the debouncing.
134
+ *
135
+ * Memoization is crucial here to ensure that each `EditorView` instance has its own opportunity
136
+ * to update the node views. Without memoization, if you have multiple `EditorView` instances on
137
+ * the same page, only one instance would potentially call `view.setProps`, which could lead to
138
+ * incorrect or missing updates in other `EditorView` instances. By memoizing the debounced function,
139
+ * we ensure that each `EditorView` maintains its own debounced update logic.
140
+ *
141
+ * @param {CacheLoadedReactNodeViews} cache - A WeakMap that stores the loaded node views for each
142
+ * `EditorView`. The key is the `EditorView`, and the value is a record of node type names
143
+ * to their corresponding `NodeViewConstructor`.
144
+ * @param {EditorView} view - The ProseMirror `EditorView` instance whose `nodeViews` property
145
+ * needs to be updated.
146
+ *
147
+ * This function is typically not called directly. Instead, it is invoked through `queueReplaceNodeViews`,
148
+ * which handles adding node views to the cache and triggering this debounced update.
149
+ */
150
+ var debouncedReplaceNodeviews = exports.debouncedReplaceNodeviews = memoizeDebounce(replaceNodeViews, 0,
151
+ /**
152
+ * Use the default debounce options:
153
+ * {leading: false, trailing: true}
154
+ */
155
+ undefined, function (cache, view) {
156
+ /**
157
+ * EditorView is a singleton.
158
+ * There is only one instance per Editor.
159
+ */
160
+ return view;
161
+ });
162
+
94
163
  /**
95
164
  * 🧱 Internal: Editor FE Platform
96
165
  */
@@ -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 = "87.6.0";
20
+ var packageVersion = "87.6.1";
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
@@ -23,12 +23,11 @@ var CodeBlockSharedCssClassName = exports.CodeBlockSharedCssClassName = {
23
23
  DS_CODEBLOCK: '[data-ds--code--code-block]',
24
24
  CODEBLOCK_LINE_NUMBER_GUTTER_FG_WRAP: 'line-number-gutter--fg-wrap',
25
25
  CODEBLOCK_CONTENT_WRAPPED: 'code-content--wrapped',
26
- CODEBLOCK_CONTAINER_LINE_NUMBER_WRAPPED: 'code-content__line-number--wrapped'
26
+ CODEBLOCK_CONTAINER_LINE_NUMBER_WRAPPED: 'code-content__line-number--wrapped',
27
+ CODEBLOCK_WRAPPED: 'code-block--wrapped'
27
28
  };
28
-
29
- // TODO: ED-24222 Remove flex styling and hardcoded word
30
29
  var codeBlockSharedStyles = exports.codeBlockSharedStyles = function codeBlockSharedStyles() {
31
- return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n\t.", " {\n\t\tposition: relative;\n\t\tbackground-color: ", ";\n\t\tborder-radius: ", ";\n\t\tmargin: ", " 0 0 0;\n\t\tfont-family: ", ";\n\t\tmin-width: ", "px;\n\t\tcursor: pointer;\n\n\t\t--ds--code--bg-color: transparent;\n\n\t\t/* This is necessary to allow for arrow key navigation in/out of code blocks in Firefox. */\n\t\twhite-space: normal;\n\n\t\t.", " {\n\t\t\tposition: absolute;\n\t\t\tvisibility: hidden;\n\t\t\theight: 1.5rem;\n\t\t\ttop: 0px;\n\t\t\tleft: 0px;\n\t\t}\n\n\t\t.", " {\n\t\t\tposition: absolute;\n\t\t\tvisibility: hidden;\n\t\t\theight: 1.5rem;\n\t\t\tbottom: 0px;\n\t\t\tright: 0px;\n\t\t}\n\n\t\t.", " {\n\t\t\tbackground-color: ", ";\n\t\t\tdisplay: flex;\n\t\t\tborder-radius: ", ";\n\t\t\twidth: 100%;\n\t\t\tcounter-reset: line;\n\t\t\toverflow-x: auto;\n\n\t\t\tbackground-image: ", ";\n\n\t\t\tbackground-repeat: no-repeat;\n\t\t\tbackground-attachment: local, local, local, local, scroll, scroll, scroll, scroll;\n\t\t\tbackground-size:\n\t\t\t\t", " 100%,\n\t\t\t\t", " 100%,\n\t\t\t\t", " 100%,\n\t\t\t\t", " 100%,\n\t\t\t\t", " 100%,\n\t\t\t\t1px 100%,\n\t\t\t\t", " 100%,\n\t\t\t\t1px 100%;\n\t\t\tbackground-position:\n\t\t\t\t0 0,\n\t\t\t\t0 0,\n\t\t\t\t100% 0,\n\t\t\t\t100% 0,\n\t\t\t\t100% 0,\n\t\t\t\t100% 0,\n\t\t\t\t0 0,\n\t\t\t\t0 0;\n\n\t\t\t/* Be careful if refactoring this; it is needed to keep arrow key navigation in Firefox consistent with other browsers. */\n\t\t\toverflow-y: hidden;\n\t\t}\n\n\t\t.", " {\n\t\t\tflex-shrink: 0;\n\t\t\ttext-align: right;\n\t\t\tbackground-color: ", ";\n\t\t\tpadding: ", ";\n\t\t\tposition: relative;\n\n\t\t\tspan {\n\t\t\t\tdisplay: block;\n\t\t\t\tline-height: 0;\n\t\t\t\tfont-size: 0;\n\n\t\t\t\t::before {\n\t\t\t\t\tdisplay: inline-block;\n\t\t\t\t\tcontent: counter(line);\n\t\t\t\t\tcounter-increment: line;\n\t\t\t\t\tcolor: ", ";\n\t\t\t\t\tfont-size: ", ";\n\t\t\t\t\tline-height: 1.5rem;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t.", " {\n\t\t\tbackground-color: ", ";\n\t\t\tpadding: ", ";\n\t\t\tposition: relative;\n\t\t\twidth: 1rem;\n\t\t}\n\n\t\t.", " {\n\t\t\tdisplay: flex;\n\t\t\tflex: 1;\n\n\t\t\tcode {\n\t\t\t\tflex-grow: 1;\n\t\t\t\ttab-size: 4;\n\t\t\t\tcursor: text;\n\t\t\t\tcolor: ", ";\n\t\t\t\tborder-radius: ", ";\n\t\t\t\tmargin: ", ";\n\t\t\t\twhite-space: pre;\n\t\t\t\tfont-size: ", ";\n\t\t\t\tline-height: 1.5rem;\n\t\t\t}\n\t\t}\n\n\t\t.", " {\n\t\t\tcode {\n\t\t\t\tcounter-reset: line var(--line-num, 0);\n\t\t\t\tword-break: break-word;\n\t\t\t\twhite-space: pre-wrap;\n\t\t\t}\n\t\t}\n\n\t\t.", " {\n\t\t\tcounter-increment: line;\n\t\t\tline-height: 1rem;\n\t\t\tpointer-events: none;\n\n\t\t\t::before {\n\t\t\t\ttext-align: right;\n\t\t\t\tmin-width: 1.5rem;\n\t\t\t\tdisplay: block;\n\t\t\t\theight: 1rem;\n\t\t\t\tposition: absolute;\n\t\t\t\tpadding-right: ", ";\n\t\t\t\tpadding-left: ", ";\n\t\t\t\tmargin-top: ", ";\n\t\t\t\tmargin-right: ", ";\n\t\t\t\tleft: -0.5rem;\n\t\t\t\tcolor: ", ";\n\t\t\t\tfont-size: ", ";\n\t\t\t\tcontent: counter(line);\n\t\t\t}\n\t\t}\n\t}\n"])), CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER, "var(--ds-surface-raised, transparent)", "var(--ds-border-radius, 3px)", _editorSharedStyles.blockNodesVerticalMargin, _editorSharedStyles.akEditorCodeFontFamily, _editorSharedStyles.akEditorTableCellMinWidth, CodeBlockSharedCssClassName.CODEBLOCK_START, CodeBlockSharedCssClassName.CODEBLOCK_END, CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPER, "var(--ds-background-neutral, ".concat(_colors.N20, ")"), "var(--ds-border-radius, 3px)", (0, _editorSharedStyles.overflowShadow)({
30
+ return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n\t.", "\n\t\t> .", "\n\t\t> .", "\n\t\tcode {\n\t\tword-break: break-word;\n\t\twhite-space: pre-wrap;\n\t}\n\n\t.", " {\n\t\tposition: relative;\n\t\tbackground-color: ", ";\n\t\tborder-radius: ", ";\n\t\tmargin: ", " 0 0 0;\n\t\tfont-family: ", ";\n\t\tmin-width: ", "px;\n\t\tcursor: pointer;\n\n\t\t--ds--code--bg-color: transparent;\n\n\t\t/* This is necessary to allow for arrow key navigation in/out of code blocks in Firefox. */\n\t\twhite-space: normal;\n\n\t\t.", " {\n\t\t\tposition: absolute;\n\t\t\tvisibility: hidden;\n\t\t\theight: 1.5rem;\n\t\t\ttop: 0px;\n\t\t\tleft: 0px;\n\t\t}\n\n\t\t.", " {\n\t\t\tposition: absolute;\n\t\t\tvisibility: hidden;\n\t\t\theight: 1.5rem;\n\t\t\tbottom: 0px;\n\t\t\tright: 0px;\n\t\t}\n\n\t\t.", " {\n\t\t\tword-break: break-word;\n\t\t\twhite-space: pre-wrap;\n\t\t}\n\n\t\t.", " {\n\t\t\tbackground-color: ", ";\n\t\t\tdisplay: flex;\n\t\t\tborder-radius: ", ";\n\t\t\twidth: 100%;\n\t\t\tcounter-reset: line;\n\t\t\toverflow-x: auto;\n\n\t\t\tbackground-image: ", ";\n\n\t\t\tbackground-repeat: no-repeat;\n\t\t\tbackground-attachment: local, local, local, local, scroll, scroll, scroll, scroll;\n\t\t\tbackground-size:\n\t\t\t\t", " 100%,\n\t\t\t\t", " 100%,\n\t\t\t\t", " 100%,\n\t\t\t\t", " 100%,\n\t\t\t\t", " 100%,\n\t\t\t\t1px 100%,\n\t\t\t\t", " 100%,\n\t\t\t\t1px 100%;\n\t\t\tbackground-position:\n\t\t\t\t0 0,\n\t\t\t\t0 0,\n\t\t\t\t100% 0,\n\t\t\t\t100% 0,\n\t\t\t\t100% 0,\n\t\t\t\t100% 0,\n\t\t\t\t0 0,\n\t\t\t\t0 0;\n\n\t\t\t/* Be careful if refactoring this; it is needed to keep arrow key navigation in Firefox consistent with other browsers. */\n\t\t\toverflow-y: hidden;\n\t\t}\n\n\t\t.", " {\n\t\t\tflex-shrink: 0;\n\t\t\ttext-align: right;\n\t\t\tbackground-color: ", ";\n\t\t\tpadding: ", ";\n\t\t\tposition: relative;\n\n\t\t\tspan {\n\t\t\t\tdisplay: block;\n\t\t\t\tline-height: 0;\n\t\t\t\tfont-size: 0;\n\n\t\t\t\t::before {\n\t\t\t\t\tdisplay: inline-block;\n\t\t\t\t\tcontent: counter(line);\n\t\t\t\t\tcounter-increment: line;\n\t\t\t\t\tcolor: ", ";\n\t\t\t\t\tfont-size: ", ";\n\t\t\t\t\tline-height: 1.5rem;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t.", " {\n\t\t\tbackground-color: ", ";\n\t\t\tpadding: ", ";\n\t\t\tposition: relative;\n\t\t\twidth: 1rem;\n\t\t}\n\n\t\t.", " {\n\t\t\tdisplay: flex;\n\t\t\tflex: 1;\n\n\t\t\tcode {\n\t\t\t\tflex-grow: 1;\n\t\t\t\ttab-size: 4;\n\t\t\t\tcursor: text;\n\t\t\t\tcolor: ", ";\n\t\t\t\tborder-radius: ", ";\n\t\t\t\tmargin: ", ";\n\t\t\t\twhite-space: pre;\n\t\t\t\tfont-size: ", ";\n\t\t\t\tline-height: 1.5rem;\n\t\t\t}\n\t\t}\n\n\t\t.", " {\n\t\t\tcode {\n\t\t\t\tcounter-reset: line var(--line-num, 0);\n\t\t\t\tword-break: break-word;\n\t\t\t\twhite-space: pre-wrap;\n\t\t\t}\n\t\t}\n\n\t\t.", " {\n\t\t\tcounter-increment: line;\n\t\t\tline-height: 1rem;\n\t\t\tpointer-events: none;\n\n\t\t\t::before {\n\t\t\t\ttext-align: right;\n\t\t\t\tmin-width: 1.5rem;\n\t\t\t\tdisplay: block;\n\t\t\t\theight: 1rem;\n\t\t\t\tposition: absolute;\n\t\t\t\tpadding-right: ", ";\n\t\t\t\tpadding-left: ", ";\n\t\t\t\tmargin-top: ", ";\n\t\t\t\tmargin-right: ", ";\n\t\t\t\tleft: -0.5rem;\n\t\t\t\tcolor: ", ";\n\t\t\t\tfont-size: ", ";\n\t\t\t\tcontent: counter(line);\n\t\t\t}\n\t\t}\n\t}\n"])), CodeBlockSharedCssClassName.CODEBLOCK_WRAPPED, CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPER, CodeBlockSharedCssClassName.CODEBLOCK_CONTENT, CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER, "var(--ds-surface-raised, transparent)", "var(--ds-border-radius, 3px)", _editorSharedStyles.blockNodesVerticalMargin, _editorSharedStyles.akEditorCodeFontFamily, _editorSharedStyles.akEditorTableCellMinWidth, CodeBlockSharedCssClassName.CODEBLOCK_START, CodeBlockSharedCssClassName.CODEBLOCK_END, CodeBlockSharedCssClassName.CODEBLOCK_WRAPPED, CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPER, "var(--ds-background-neutral, ".concat(_colors.N20, ")"), "var(--ds-border-radius, 3px)", (0, _editorSharedStyles.overflowShadow)({
32
31
  leftCoverWidth: "var(--ds-space-300, 24px)"
33
32
  }), "var(--ds-space-300, 24px)", "var(--ds-space-300, 24px)", "var(--ds-space-100, 8px)", "var(--ds-space-100, 8px)", "var(--ds-space-100, 8px)", "var(--ds-space-100, 8px)", CodeBlockSharedCssClassName.CODEBLOCK_LINE_NUMBER_GUTTER, "var(--ds-background-neutral, ".concat(_colors.N30, ")"), "var(--ds-space-100, 8px)", "var(--ds-text-subtlest, ".concat(_colors.N400, ")"), (0, _editorSharedStyles.relativeFontSizeToBase16)((0, _constants.fontSize)()), CodeBlockSharedCssClassName.CODEBLOCK_LINE_NUMBER_GUTTER_FG_WRAP, "var(--ds-background-neutral, ".concat(_colors.N30, ")"), "var(--ds-space-100, 8px)", CodeBlockSharedCssClassName.CODEBLOCK_CONTENT, "var(--ds-text, ".concat(_colors.N800, ")"), "var(--ds-border-radius, 3px)", "var(--ds-space-100, 8px)", (0, _editorSharedStyles.relativeFontSizeToBase16)((0, _constants.fontSize)()), CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPED, CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER_LINE_NUMBER_WRAPPED, "var(--ds-space-100, 8px)", "var(--ds-space-100, 8px)", "var(--ds-space-050, 4px)", "var(--ds-space-100, 8px)", "var(--ds-text-subtlest, ".concat(_colors.N400, ")"), (0, _editorSharedStyles.relativeFontSizeToBase16)((0, _constants.fontSize)()));
34
33
  };
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
23
23
  * @jsx jsx
24
24
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
25
  var packageName = "@atlaskit/editor-common";
26
- var packageVersion = "87.6.0";
26
+ var packageVersion = "87.6.1";
27
27
  var halfFocusRing = 1;
28
28
  var dropOffset = '0, 8';
29
29
  var DropList = /*#__PURE__*/function (_Component) {
@@ -102,6 +102,7 @@ export const focusToContextMenuTrigger = makeKeyMapWithCommon('Focus table conte
102
102
  export const dragToMoveUp = makeKeyMapWithCommon('Move node up in the document', 'Ctrl-Shift-ArrowUp');
103
103
  export const dragToMoveDown = makeKeyMapWithCommon('Move node down in the document', 'Ctrl-Shift-ArrowDown');
104
104
  export const showElementDragHandle = makeKeyMapWithCommon('Show drag handle for editor element', 'Ctrl-Shift-h');
105
+ export const continueInRovoChat = makeKeyMapWithCommon('Continue in Rovo chat', 'Alt-Enter');
105
106
  const arrowKeysMap = {
106
107
  // for reference: https://wincent.com/wiki/Unicode_representations_of_modifier_keys
107
108
  ARROWLEFT: '\u2190',
@@ -116,7 +117,7 @@ const tooltipShortcutStyle = css({
116
117
  // NOTE: This might not actually do anything: https://atlassian.slack.com/archives/CFG3PSQ9E/p1647395052443259?thread_ts=1647394572.556029&cid=CFG3PSQ9E
117
118
  label: 'tooltip-shortcut'
118
119
  });
119
- function formatShortcut(keymap) {
120
+ export function formatShortcut(keymap) {
120
121
  let shortcut;
121
122
  if (browser.mac) {
122
123
  // for reference: https://wincent.com/wiki/Unicode_representations_of_modifier_keys
@@ -65,7 +65,10 @@ export const withLazyLoading = ({
65
65
  nodeName,
66
66
  loader,
67
67
  getNodeViewOptions,
68
- dispatchAnalyticsEvent
68
+ dispatchAnalyticsEvent,
69
+ lazyNodeViewOptions: {
70
+ ignoreMutationDelegate
71
+ } = {}
69
72
  }) => {
70
73
  const createLazyNodeView = (node, view, getPos, decorations) => {
71
74
  var _node$type, _node$type$spec;
@@ -75,7 +78,9 @@ export const withLazyLoading = ({
75
78
  }
76
79
  const wasAlreadyRequested = requestedNodes.has(nodeName);
77
80
  if (wasAlreadyRequested) {
78
- return new LazyNodeView(node, view, getPos);
81
+ return new LazyNodeView(node, view, getPos, {
82
+ ignoreMutationDelegate
83
+ });
79
84
  }
80
85
  requestedNodes.add(nodeName);
81
86
  loader().then(nodeViewFuncModule => {
@@ -99,7 +104,9 @@ export const withLazyLoading = ({
99
104
  // },
100
105
  // });
101
106
  }
102
- return new LazyNodeView(node, view, getPos);
107
+ return new LazyNodeView(node, view, getPos, {
108
+ ignoreMutationDelegate
109
+ });
103
110
  };
104
111
  return createLazyNodeView;
105
112
  };
@@ -5,8 +5,9 @@ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
5
5
  * A NodeView that serves as a placeholder until the actual NodeView is loaded.
6
6
  */
7
7
  export class LazyNodeView {
8
- constructor(node, view, getPos) {
8
+ constructor(node, view, getPos, options = {}) {
9
9
  var _node$type, _node$type$spec;
10
+ this.ignoreMutationDelegate = options === null || options === void 0 ? void 0 : options.ignoreMutationDelegate;
10
11
  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') {
11
12
  this.dom = document.createElement('div');
12
13
  return;
@@ -24,4 +25,8 @@ export class LazyNodeView {
24
25
  this.dom.setAttribute('data-lazy-node-view-fallback', 'true');
25
26
  }
26
27
  }
28
+ ignoreMutation(mutation) {
29
+ var _this$ignoreMutationD;
30
+ return !!((_this$ignoreMutationD = this.ignoreMutationDelegate) !== null && _this$ignoreMutationD !== void 0 && _this$ignoreMutationD.call(this, mutation));
31
+ }
27
32
  }
@@ -1,4 +1,5 @@
1
1
  import debounce from 'lodash/debounce';
2
+ import memoize from 'lodash/memoize';
2
3
  /**
3
4
  * 🧱 Internal: Editor FE Platform
4
5
  */
@@ -7,11 +8,10 @@ const isFirefox = /gecko\/\d/i.test(navigator.userAgent);
7
8
  /**
8
9
  * 🧱 Internal: Editor FE Platform
9
10
  *
10
- * Debounces and replaces the node views in a ProseMirror editor with lazy-loaded node views.
11
+ * Replaces the node views in a ProseMirror editor with lazy-loaded node views.
11
12
  *
12
13
  * This function is used to update the `nodeViews` property of the `EditorView` after lazy-loaded
13
- * node views have been loaded. It uses a debounced approach to ensure that the replacement does
14
- * not happen too frequently, which can be performance-intensive.
14
+ * node views have been loaded.
15
15
  *
16
16
  * The function checks if there are any loaded node views in the cache associated with the given
17
17
  * `EditorView`. If there are, it replaces the current `nodeViews` in the `EditorView` with the
@@ -35,9 +35,9 @@ const isFirefox = /gecko\/\d/i.test(navigator.userAgent);
35
35
  * 'tableCell': TableCellViewConstructor,
36
36
  * });
37
37
  *
38
- * debouncedReplaceNodeviews(cache, view);
38
+ * replaceNodeViews(cache, view);
39
39
  */
40
- export const debouncedReplaceNodeviews = debounce((cache, view) => {
40
+ const replaceNodeViews = (cache, view) => {
41
41
  const loadedNodeviews = cache.get(view);
42
42
  if (!loadedNodeviews || Object.keys(loadedNodeviews).length === 0) {
43
43
  return;
@@ -49,27 +49,7 @@ export const debouncedReplaceNodeviews = debounce((cache, view) => {
49
49
  // Make sure the cache is cleaned
50
50
  // From here, we will access the loaded node views by lexical scope
51
51
  cache.set(view, {});
52
-
53
- /*
54
- * For reasons that goes beyond my knowledge
55
- * some Firefox versions aren't calling the requestIdleCallback.
56
- *
57
- * So, we need this check to make sure we use the requestAnimationFrame instead
58
- *
59
- * setting timeout to 2s to ensure this function is called, but not before prosemirror render
60
- * and other important tasks are done - adjust this timeout based on user feedback
61
- */
62
- const later = callback => {
63
- // eslint-disable-next-line compat/compat
64
- if (isFirefox || !window.requestIdleCallback) {
65
- return window.requestAnimationFrame(callback);
66
- }
67
- // eslint-disable-next-line compat/compat
68
- window.requestIdleCallback(callback, {
69
- timeout: 2000
70
- });
71
- };
72
- later(() => {
52
+ const callback = () => {
73
53
  const currentNodeViews = view.props.nodeViews;
74
54
  const nextNodeViews = {
75
55
  ...currentNodeViews,
@@ -78,14 +58,100 @@ export const debouncedReplaceNodeviews = debounce((cache, view) => {
78
58
  view.setProps({
79
59
  nodeViews: nextNodeViews
80
60
  });
81
- });
82
- });
61
+ };
62
+ // eslint-disable-next-line compat/compat
63
+ const idle = window.requestIdleCallback;
64
+
65
+ /*
66
+ * For reasons that goes beyond my knowledge
67
+ * some Firefox versions aren't calling the requestIdleCallback.
68
+ *
69
+ * So, we need this check to make sure we are using the requestAnimationFrame for Firefox
70
+ */
71
+ if (isFirefox || typeof idle !== 'function') {
72
+ window.requestAnimationFrame(callback);
73
+ } else {
74
+ idle(callback, {
75
+ timeout: 2000
76
+ });
77
+ }
78
+ };
83
79
 
84
80
  /**
85
81
  * 🧱 Internal: Editor FE Platform
86
82
  */
87
83
  const loadedPerEditorView = new WeakMap();
88
84
 
85
+ /**
86
+ * 🧱 Internal: Editor FE Platform
87
+ * Based on https://github.com/lodash/lodash/issues/2403#issuecomment-1706130395
88
+ *
89
+ * Creates a debounced function that delays invoking the provided function until after a specified
90
+ * wait time has elapsed since the last time the debounced function was invoked. Additionally, the
91
+ * debounced function is memoized so that the same function instance is used for each unique set
92
+ * of arguments based on the resolver.
93
+ *
94
+ * This is particularly useful in scenarios where you want to debounce function calls while ensuring
95
+ * that each unique input combination receives its own debounced function instance. It's a combination
96
+ * of lodash's `debounce` and `memoize`.
97
+ *
98
+ * @template T
99
+ * @param {T} func - The function to debounce.
100
+ * @param {number} [wait=0] - The number of milliseconds to delay.
101
+ * @param {Object} [options] - The options object to pass to `debounce`.
102
+ * @param {Function} [resolver] - The function to resolve the cache key for memoization.
103
+ * @returns {Function} A new debounced and memoized function.
104
+ *
105
+ * @example
106
+ * const debouncedFunction = memoizeDebounce(myFunction, 300, { leading: true }, myResolver);
107
+ * debouncedFunction(arg1, arg2);
108
+ */
109
+ function memoizeDebounce(func, wait = 0, options, resolver) {
110
+ const mem = memoize(function () {
111
+ return debounce(func, wait, options);
112
+ }, resolver);
113
+ return function (...args) {
114
+ return mem(...args)(...args);
115
+ };
116
+ }
117
+
118
+ /**
119
+ * 🧱 Internal: Editor FE Platform
120
+ *
121
+ * Debounced and memoized version of `replaceNodeViews`.
122
+ *
123
+ * This function is designed to update the `nodeViews` property of an `EditorView` after a
124
+ * period of inactivity (debounce), ensuring that multiple rapid updates do not occur in quick
125
+ * succession. It uses lodash's `debounce` to handle the debouncing.
126
+ *
127
+ * Memoization is crucial here to ensure that each `EditorView` instance has its own opportunity
128
+ * to update the node views. Without memoization, if you have multiple `EditorView` instances on
129
+ * the same page, only one instance would potentially call `view.setProps`, which could lead to
130
+ * incorrect or missing updates in other `EditorView` instances. By memoizing the debounced function,
131
+ * we ensure that each `EditorView` maintains its own debounced update logic.
132
+ *
133
+ * @param {CacheLoadedReactNodeViews} cache - A WeakMap that stores the loaded node views for each
134
+ * `EditorView`. The key is the `EditorView`, and the value is a record of node type names
135
+ * to their corresponding `NodeViewConstructor`.
136
+ * @param {EditorView} view - The ProseMirror `EditorView` instance whose `nodeViews` property
137
+ * needs to be updated.
138
+ *
139
+ * This function is typically not called directly. Instead, it is invoked through `queueReplaceNodeViews`,
140
+ * which handles adding node views to the cache and triggering this debounced update.
141
+ */
142
+ export const debouncedReplaceNodeviews = memoizeDebounce(replaceNodeViews, 0,
143
+ /**
144
+ * Use the default debounce options:
145
+ * {leading: false, trailing: true}
146
+ */
147
+ undefined, (cache, view) => {
148
+ /**
149
+ * EditorView is a singleton.
150
+ * There is only one instance per Editor.
151
+ */
152
+ return view;
153
+ });
154
+
89
155
  /**
90
156
  * 🧱 Internal: Editor FE Platform
91
157
  */
@@ -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 = "87.6.0";
4
+ const packageVersion = "87.6.1";
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