@atlaskit/editor-common 88.6.1 → 88.7.0

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 (75) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/analytics/fire-analytics-event.js +2 -2
  3. package/dist/cjs/element-browser/components/CategoryList.js +2 -2
  4. package/dist/cjs/element-browser/components/ElementList/ElementList.js +2 -2
  5. package/dist/cjs/element-browser/components/ElementSearch.js +2 -2
  6. package/dist/cjs/element-browser/components/StatelessElementBrowser.js +4 -3
  7. package/dist/cjs/lazy-node-view/index.js +89 -11
  8. package/dist/cjs/lazy-node-view/node-view.js +27 -7
  9. package/dist/cjs/link/ConfigureLinkOverlay/Dropdown.js +2 -2
  10. package/dist/cjs/link/ConfigureLinkOverlay/index.js +2 -2
  11. package/dist/cjs/link/ConfigureLinkOverlay/useLinkOverlayAnalyticsEvents.js +6 -6
  12. package/dist/cjs/link/LinkPicker/EditorLinkPicker/index.js +2 -2
  13. package/dist/cjs/link/LinkPicker/HyperlinkAddToolbar/HyperlinkAddToolbar.js +2 -2
  14. package/dist/cjs/media-inline/media-inline-image-card.js +2 -2
  15. package/dist/cjs/monitoring/error.js +1 -1
  16. package/dist/cjs/ui/DropList/index.js +7 -5
  17. package/dist/cjs/ui/WithCreateAnalyticsEvent/index.js +2 -2
  18. package/dist/cjs/ui-menu/ColorPickerButton/index.js +4 -3
  19. package/dist/cjs/ui-menu/ToolbarButton/index.js +2 -2
  20. package/dist/es2019/analytics/fire-analytics-event.js +1 -1
  21. package/dist/es2019/element-browser/components/CategoryList.js +1 -1
  22. package/dist/es2019/element-browser/components/ElementList/ElementList.js +1 -1
  23. package/dist/es2019/element-browser/components/ElementSearch.js +1 -1
  24. package/dist/es2019/element-browser/components/StatelessElementBrowser.js +2 -1
  25. package/dist/es2019/lazy-node-view/index.js +81 -11
  26. package/dist/es2019/lazy-node-view/node-view.js +25 -6
  27. package/dist/es2019/link/ConfigureLinkOverlay/Dropdown.js +1 -1
  28. package/dist/es2019/link/ConfigureLinkOverlay/index.js +1 -1
  29. package/dist/es2019/link/ConfigureLinkOverlay/useLinkOverlayAnalyticsEvents.js +2 -2
  30. package/dist/es2019/link/LinkPicker/EditorLinkPicker/index.js +1 -1
  31. package/dist/es2019/link/LinkPicker/HyperlinkAddToolbar/HyperlinkAddToolbar.js +1 -1
  32. package/dist/es2019/media-inline/media-inline-image-card.js +1 -1
  33. package/dist/es2019/monitoring/error.js +1 -1
  34. package/dist/es2019/ui/DropList/index.js +4 -2
  35. package/dist/es2019/ui/WithCreateAnalyticsEvent/index.js +1 -1
  36. package/dist/es2019/ui-menu/ColorPickerButton/index.js +2 -1
  37. package/dist/es2019/ui-menu/ToolbarButton/index.js +1 -1
  38. package/dist/esm/analytics/fire-analytics-event.js +1 -1
  39. package/dist/esm/element-browser/components/CategoryList.js +1 -1
  40. package/dist/esm/element-browser/components/ElementList/ElementList.js +1 -1
  41. package/dist/esm/element-browser/components/ElementSearch.js +1 -1
  42. package/dist/esm/element-browser/components/StatelessElementBrowser.js +2 -1
  43. package/dist/esm/lazy-node-view/index.js +85 -11
  44. package/dist/esm/lazy-node-view/node-view.js +27 -7
  45. package/dist/esm/link/ConfigureLinkOverlay/Dropdown.js +1 -1
  46. package/dist/esm/link/ConfigureLinkOverlay/index.js +1 -1
  47. package/dist/esm/link/ConfigureLinkOverlay/useLinkOverlayAnalyticsEvents.js +2 -2
  48. package/dist/esm/link/LinkPicker/EditorLinkPicker/index.js +1 -1
  49. package/dist/esm/link/LinkPicker/HyperlinkAddToolbar/HyperlinkAddToolbar.js +1 -1
  50. package/dist/esm/media-inline/media-inline-image-card.js +1 -1
  51. package/dist/esm/monitoring/error.js +1 -1
  52. package/dist/esm/ui/DropList/index.js +4 -2
  53. package/dist/esm/ui/WithCreateAnalyticsEvent/index.js +1 -1
  54. package/dist/esm/ui-menu/ColorPickerButton/index.js +2 -1
  55. package/dist/esm/ui-menu/ToolbarButton/index.js +1 -1
  56. package/dist/types/analytics/fire-analytics-event.d.ts +1 -1
  57. package/dist/types/analytics/types/events.d.ts +1 -1
  58. package/dist/types/element-browser/components/ElementSearch.d.ts +1 -1
  59. package/dist/types/lazy-node-view/index.d.ts +18 -1
  60. package/dist/types/lazy-node-view/node-view.d.ts +4 -5
  61. package/dist/types/link/ConfigureLinkOverlay/Dropdown.d.ts +1 -1
  62. package/dist/types/link/ConfigureLinkOverlay/index.d.ts +1 -1
  63. package/dist/types-ts4.5/analytics/fire-analytics-event.d.ts +1 -1
  64. package/dist/types-ts4.5/analytics/types/events.d.ts +1 -1
  65. package/dist/types-ts4.5/element-browser/components/ElementSearch.d.ts +1 -1
  66. package/dist/types-ts4.5/lazy-node-view/index.d.ts +18 -1
  67. package/dist/types-ts4.5/lazy-node-view/node-view.d.ts +4 -5
  68. package/dist/types-ts4.5/link/ConfigureLinkOverlay/Dropdown.d.ts +1 -1
  69. package/dist/types-ts4.5/link/ConfigureLinkOverlay/index.d.ts +1 -1
  70. package/package.json +1 -1
  71. package/dist/cjs/lazy-node-view/replace-node-views.js +0 -173
  72. package/dist/es2019/lazy-node-view/replace-node-views.js +0 -166
  73. package/dist/esm/lazy-node-view/replace-node-views.js +0 -166
  74. package/dist/types/lazy-node-view/replace-node-views.d.ts +0 -34
  75. package/dist/types-ts4.5/lazy-node-view/replace-node-views.d.ts +0 -34
@@ -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.6.1";
10
+ var packageVersion = "88.7.0";
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
@@ -16,11 +16,13 @@ import { Component } from 'react';
16
16
 
17
17
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
18
18
  import { css, jsx } from '@emotion/react';
19
- import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
19
+ import createAndFireEvent from '@atlaskit/analytics-next/createAndFireEvents';
20
+ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext';
21
+ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
20
22
  import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
21
23
  import Layer from '../Layer';
22
24
  var packageName = "@atlaskit/editor-common";
23
- var packageVersion = "88.6.1";
25
+ var packageVersion = "88.7.0";
24
26
  var halfFocusRing = 1;
25
27
  var dropOffset = '0, 8';
26
28
  var DropList = /*#__PURE__*/function (_Component) {
@@ -6,7 +6,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
7
7
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
8
  import React from 'react';
9
- import { withAnalyticsEvents } from '@atlaskit/analytics-next';
9
+ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
10
10
  export var WithCreateAnalyticsEvent = withAnalyticsEvents()( /*#__PURE__*/function (_React$Component) {
11
11
  _inherits(WithCreateAnalyticsEvent, _React$Component);
12
12
  var _super = _createSuper(WithCreateAnalyticsEvent);
@@ -7,7 +7,8 @@ import React from 'react';
7
7
 
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
9
  import { css, jsx } from '@emotion/react';
10
- import { withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
10
+ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext';
11
+ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
11
12
  import Button from '@atlaskit/button/standard-button';
12
13
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
13
14
  import { N0, N30A, N60A } from '@atlaskit/theme/colors';
@@ -11,7 +11,7 @@ import React, { useCallback } from 'react';
11
11
 
12
12
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
13
13
  import { css, jsx } from '@emotion/react';
14
- import { FabricChannel } from '@atlaskit/analytics-listeners';
14
+ import { FabricChannel } from '@atlaskit/analytics-listeners/types';
15
15
  import { fg } from '@atlaskit/platform-feature-flags';
16
16
  import Tooltip from '@atlaskit/tooltip';
17
17
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, TOOLBAR_ACTION_SUBJECT_ID } from '../../analytics';
@@ -1,4 +1,4 @@
1
- import { FabricChannel } from '@atlaskit/analytics-listeners';
1
+ import { FabricChannel } from '@atlaskit/analytics-listeners/types';
2
2
  import type { FireAnalyticsEvent } from './types';
3
3
  export declare const editorAnalyticsChannel = FabricChannel.editor;
4
4
  export declare const fireAnalyticsEvent: FireAnalyticsEvent;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
+ import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next/types';
3
3
  import type { EditorState, PluginKey } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { NewCollabSyncUpErrorAttributes } from '../../collab';
5
5
  import type { UnsupportedContentPayload, UnsupportedContentTooltipPayload, UserBrowserExtensionResults } from '../../utils';
@@ -18,5 +18,5 @@ interface Props {
18
18
  }
19
19
  declare const MemoizedElementSearchWithAnalytics: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<Props & WrappedComponentProps, "intl"> & {
20
20
  forwardedRef?: React.Ref<any> | undefined;
21
- } & import("@atlaskit/analytics-next").WithContextProps & React.RefAttributes<any>>>;
21
+ } & import("@atlaskit/analytics-next/withAnalyticsContext").WithContextProps & React.RefAttributes<any>>>;
22
22
  export default MemoizedElementSearchWithAnalytics;
@@ -1,9 +1,16 @@
1
1
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
3
  import type { Decoration, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
3
4
  import type { DispatchAnalyticsEvent } from '../analytics';
4
5
  import type { LazyNodeViewToDOMConfiguration, NodeViewConstructor } from './types';
5
6
  export { convertToInlineCss } from './css-helper';
6
7
  export type { NodeViewConstructor, LazyNodeViewToDOMConfiguration };
8
+ /**
9
+ * 📢 Public Plugin Key
10
+ *
11
+ * Communication channel between LazyNodeView loader and LazyNodeViewDecorationPlugin.
12
+ */
13
+ export declare const lazyNodeViewDecorationPluginKey: PluginKey<any>;
7
14
  /**
8
15
  * 📢 Public Type
9
16
  *
@@ -21,6 +28,16 @@ export type LazyLoadingProps<NodeViewOptions> = {
21
28
  getNodeViewOptions: () => NodeViewOptions;
22
29
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
23
30
  };
31
+ /**
32
+ * 🧱 Internal: Editor FE Platform
33
+ *
34
+ * Used in tests to prevent lazy node view being replaced by a real node view.
35
+ *
36
+ * This needs to be replaced with proper implementation once LazyNodeView is converted to a plugin.
37
+ *
38
+ * @deprecated DO NOT USE THIS OUSIDE TESTS.
39
+ */
40
+ export declare function testOnlyIgnoreLazyNodeView(view: EditorView): void;
24
41
  /**
25
42
  * 📢 Public: Any EditorPlugin can use this function
26
43
  *
@@ -61,4 +78,4 @@ export type LazyLoadingProps<NodeViewOptions> = {
61
78
  *
62
79
  * // Then, use `lazyTableView` in ProseMirror editor setup to enhance 'table' nodes with lazy loading
63
80
  */
64
- export declare const withLazyLoading: <Options>({ nodeName, loader, getNodeViewOptions, dispatchAnalyticsEvent, }: LazyLoadingProps<Options>) => NodeViewConstructor;
81
+ export declare const withLazyLoading: <Options>({ nodeName, loader, getNodeViewOptions, }: LazyLoadingProps<Options>) => NodeViewConstructor;
@@ -9,9 +9,8 @@ export declare class LazyNodeView implements NodeView {
9
9
  dom: Node;
10
10
  contentDOM?: HTMLElement;
11
11
  private node;
12
- constructor(node: PMNode, view: EditorView, getPos: () => number | undefined);
13
- ignoreMutation(mutation: MutationRecord | {
14
- type: 'selection';
15
- target: Element;
16
- }): boolean;
12
+ private isNodeViewLoaded;
13
+ constructor(node: PMNode, view: EditorView, _getPos: () => number | undefined, nodeViewLoader: Promise<unknown>);
14
+ update: (node: PMNode) => boolean;
15
+ ignoreMutation(): boolean;
17
16
  }
@@ -15,5 +15,5 @@ export type DropdownProps = {
15
15
  editorView: EditorView;
16
16
  testId: string;
17
17
  };
18
- declare const _default: import("react").ForwardRefExoticComponent<DropdownProps & import("@atlaskit/analytics-next").WithContextProps & import("react").RefAttributes<any>>;
18
+ declare const _default: import("react").ForwardRefExoticComponent<DropdownProps & import("@atlaskit/analytics-next/withAnalyticsContext").WithContextProps & import("react").RefAttributes<any>>;
19
19
  export default _default;
@@ -18,4 +18,4 @@ export interface OverlayButtonProps {
18
18
  */
19
19
  onOpenLinkClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
20
20
  }
21
- export declare const OverlayButton: import("react").ForwardRefExoticComponent<OverlayButtonProps & import("@atlaskit/analytics-next").WithContextProps & import("react").RefAttributes<any>>;
21
+ export declare const OverlayButton: import("react").ForwardRefExoticComponent<OverlayButtonProps & import("@atlaskit/analytics-next/withAnalyticsContext").WithContextProps & import("react").RefAttributes<any>>;
@@ -1,4 +1,4 @@
1
- import { FabricChannel } from '@atlaskit/analytics-listeners';
1
+ import { FabricChannel } from '@atlaskit/analytics-listeners/types';
2
2
  import type { FireAnalyticsEvent } from './types';
3
3
  export declare const editorAnalyticsChannel = FabricChannel.editor;
4
4
  export declare const fireAnalyticsEvent: FireAnalyticsEvent;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
+ import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next/types';
3
3
  import type { EditorState, PluginKey } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { NewCollabSyncUpErrorAttributes } from '../../collab';
5
5
  import type { UnsupportedContentPayload, UnsupportedContentTooltipPayload, UserBrowserExtensionResults } from '../../utils';
@@ -18,5 +18,5 @@ interface Props {
18
18
  }
19
19
  declare const MemoizedElementSearchWithAnalytics: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<Props & WrappedComponentProps, "intl"> & {
20
20
  forwardedRef?: React.Ref<any> | undefined;
21
- } & import("@atlaskit/analytics-next").WithContextProps & React.RefAttributes<any>>>;
21
+ } & import("@atlaskit/analytics-next/withAnalyticsContext").WithContextProps & React.RefAttributes<any>>>;
22
22
  export default MemoizedElementSearchWithAnalytics;
@@ -1,9 +1,16 @@
1
1
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
3
  import type { Decoration, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
3
4
  import type { DispatchAnalyticsEvent } from '../analytics';
4
5
  import type { LazyNodeViewToDOMConfiguration, NodeViewConstructor } from './types';
5
6
  export { convertToInlineCss } from './css-helper';
6
7
  export type { NodeViewConstructor, LazyNodeViewToDOMConfiguration };
8
+ /**
9
+ * 📢 Public Plugin Key
10
+ *
11
+ * Communication channel between LazyNodeView loader and LazyNodeViewDecorationPlugin.
12
+ */
13
+ export declare const lazyNodeViewDecorationPluginKey: PluginKey<any>;
7
14
  /**
8
15
  * 📢 Public Type
9
16
  *
@@ -21,6 +28,16 @@ export type LazyLoadingProps<NodeViewOptions> = {
21
28
  getNodeViewOptions: () => NodeViewOptions;
22
29
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
23
30
  };
31
+ /**
32
+ * 🧱 Internal: Editor FE Platform
33
+ *
34
+ * Used in tests to prevent lazy node view being replaced by a real node view.
35
+ *
36
+ * This needs to be replaced with proper implementation once LazyNodeView is converted to a plugin.
37
+ *
38
+ * @deprecated DO NOT USE THIS OUSIDE TESTS.
39
+ */
40
+ export declare function testOnlyIgnoreLazyNodeView(view: EditorView): void;
24
41
  /**
25
42
  * 📢 Public: Any EditorPlugin can use this function
26
43
  *
@@ -61,4 +78,4 @@ export type LazyLoadingProps<NodeViewOptions> = {
61
78
  *
62
79
  * // Then, use `lazyTableView` in ProseMirror editor setup to enhance 'table' nodes with lazy loading
63
80
  */
64
- export declare const withLazyLoading: <Options>({ nodeName, loader, getNodeViewOptions, dispatchAnalyticsEvent, }: LazyLoadingProps<Options>) => NodeViewConstructor;
81
+ export declare const withLazyLoading: <Options>({ nodeName, loader, getNodeViewOptions, }: LazyLoadingProps<Options>) => NodeViewConstructor;
@@ -9,9 +9,8 @@ export declare class LazyNodeView implements NodeView {
9
9
  dom: Node;
10
10
  contentDOM?: HTMLElement;
11
11
  private node;
12
- constructor(node: PMNode, view: EditorView, getPos: () => number | undefined);
13
- ignoreMutation(mutation: MutationRecord | {
14
- type: 'selection';
15
- target: Element;
16
- }): boolean;
12
+ private isNodeViewLoaded;
13
+ constructor(node: PMNode, view: EditorView, _getPos: () => number | undefined, nodeViewLoader: Promise<unknown>);
14
+ update: (node: PMNode) => boolean;
15
+ ignoreMutation(): boolean;
17
16
  }
@@ -15,5 +15,5 @@ export type DropdownProps = {
15
15
  editorView: EditorView;
16
16
  testId: string;
17
17
  };
18
- declare const _default: import("react").ForwardRefExoticComponent<DropdownProps & import("@atlaskit/analytics-next").WithContextProps & import("react").RefAttributes<any>>;
18
+ declare const _default: import("react").ForwardRefExoticComponent<DropdownProps & import("@atlaskit/analytics-next/withAnalyticsContext").WithContextProps & import("react").RefAttributes<any>>;
19
19
  export default _default;
@@ -18,4 +18,4 @@ export interface OverlayButtonProps {
18
18
  */
19
19
  onOpenLinkClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
20
20
  }
21
- export declare const OverlayButton: import("react").ForwardRefExoticComponent<OverlayButtonProps & import("@atlaskit/analytics-next").WithContextProps & import("react").RefAttributes<any>>;
21
+ export declare const OverlayButton: import("react").ForwardRefExoticComponent<OverlayButtonProps & import("@atlaskit/analytics-next/withAnalyticsContext").WithContextProps & import("react").RefAttributes<any>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "88.6.1",
3
+ "version": "88.7.0",
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/"
@@ -1,173 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.queueReplaceNodeViews = exports.debouncedReplaceNodeviews = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _debounce = _interopRequireDefault(require("lodash/debounce"));
10
- var _memoize = _interopRequireDefault(require("lodash/memoize"));
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; }
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; }
13
- /**
14
- * 🧱 Internal: Editor FE Platform
15
- */
16
- var isFirefox = /gecko\/\d/i.test(navigator.userAgent);
17
-
18
- /**
19
- * 🧱 Internal: Editor FE Platform
20
- *
21
- * Replaces the node views in a ProseMirror editor with lazy-loaded node views.
22
- *
23
- * This function is used to update the `nodeViews` property of the `EditorView` after lazy-loaded
24
- * node views have been loaded.
25
- *
26
- * The function checks if there are any loaded node views in the cache associated with the given
27
- * `EditorView`. If there are, it replaces the current `nodeViews` in the `EditorView` with the
28
- * loaded node views. The replacement is scheduled using `requestIdleCallback` or
29
- * `requestAnimationFrame` to avoid blocking the main thread, especially in Firefox where
30
- * `requestIdleCallback` may not be supported.
31
- *
32
- * @param {WeakMap<EditorView, Record<string, NodeViewConstructor>>} cache - A WeakMap that stores
33
- * the loaded node views for each `EditorView`. The key is the `EditorView`, and the value
34
- * is a record of node type names to their corresponding `NodeViewConstructor`.
35
- * @param {EditorView} view - The ProseMirror `EditorView` instance whose `nodeViews` property
36
- * needs to be updated.
37
- *
38
- * @example
39
- * const cache = new WeakMap();
40
- * const view = new EditorView(...);
41
- *
42
- * // Assume some node views have been loaded and stored in the cache
43
- * cache.set(view, {
44
- * 'table': TableViewConstructor,
45
- * 'tableCell': TableCellViewConstructor,
46
- * });
47
- *
48
- * replaceNodeViews(cache, view);
49
- */
50
- var replaceNodeViews = function replaceNodeViews(cache, view) {
51
- var loadedNodeviews = cache.get(view);
52
- if (!loadedNodeviews || Object.keys(loadedNodeviews).length === 0) {
53
- return;
54
- }
55
- var nodeViewsToReplace = _objectSpread({}, loadedNodeviews);
56
-
57
- // Make sure the cache is cleaned
58
- // From here, we will access the loaded node views by lexical scope
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;
69
-
70
- /*
71
- * For reasons that goes beyond my knowledge
72
- * some Firefox versions aren't calling the requestIdleCallback.
73
- *
74
- * So, we need this check to make sure we are using the requestAnimationFrame for Firefox
75
- */
76
- if (isFirefox || typeof idle !== 'function') {
77
- window.requestAnimationFrame(callback);
78
- } else {
79
- idle(callback, {
80
- timeout: 2000
81
- });
82
- }
83
- };
84
-
85
- /**
86
- * 🧱 Internal: Editor FE Platform
87
- */
88
- var loadedPerEditorView = new WeakMap();
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
-
163
- /**
164
- * 🧱 Internal: Editor FE Platform
165
- */
166
- var queueReplaceNodeViews = exports.queueReplaceNodeViews = function queueReplaceNodeViews(view, _ref) {
167
- var nodeName = _ref.nodeName,
168
- nodeViewFunc = _ref.nodeViewFunc;
169
- var nodeViews = loadedPerEditorView.get(view) || {};
170
- nodeViews[nodeName] = nodeViewFunc;
171
- loadedPerEditorView.set(view, nodeViews);
172
- debouncedReplaceNodeviews(loadedPerEditorView, view);
173
- };
@@ -1,166 +0,0 @@
1
- import debounce from 'lodash/debounce';
2
- import memoize from 'lodash/memoize';
3
- /**
4
- * 🧱 Internal: Editor FE Platform
5
- */
6
- const isFirefox = /gecko\/\d/i.test(navigator.userAgent);
7
-
8
- /**
9
- * 🧱 Internal: Editor FE Platform
10
- *
11
- * Replaces the node views in a ProseMirror editor with lazy-loaded node views.
12
- *
13
- * This function is used to update the `nodeViews` property of the `EditorView` after lazy-loaded
14
- * node views have been loaded.
15
- *
16
- * The function checks if there are any loaded node views in the cache associated with the given
17
- * `EditorView`. If there are, it replaces the current `nodeViews` in the `EditorView` with the
18
- * loaded node views. The replacement is scheduled using `requestIdleCallback` or
19
- * `requestAnimationFrame` to avoid blocking the main thread, especially in Firefox where
20
- * `requestIdleCallback` may not be supported.
21
- *
22
- * @param {WeakMap<EditorView, Record<string, NodeViewConstructor>>} cache - A WeakMap that stores
23
- * the loaded node views for each `EditorView`. The key is the `EditorView`, and the value
24
- * is a record of node type names to their corresponding `NodeViewConstructor`.
25
- * @param {EditorView} view - The ProseMirror `EditorView` instance whose `nodeViews` property
26
- * needs to be updated.
27
- *
28
- * @example
29
- * const cache = new WeakMap();
30
- * const view = new EditorView(...);
31
- *
32
- * // Assume some node views have been loaded and stored in the cache
33
- * cache.set(view, {
34
- * 'table': TableViewConstructor,
35
- * 'tableCell': TableCellViewConstructor,
36
- * });
37
- *
38
- * replaceNodeViews(cache, view);
39
- */
40
- const replaceNodeViews = (cache, view) => {
41
- const loadedNodeviews = cache.get(view);
42
- if (!loadedNodeviews || Object.keys(loadedNodeviews).length === 0) {
43
- return;
44
- }
45
- const nodeViewsToReplace = {
46
- ...loadedNodeviews
47
- };
48
-
49
- // Make sure the cache is cleaned
50
- // From here, we will access the loaded node views by lexical scope
51
- cache.set(view, {});
52
- const callback = () => {
53
- const currentNodeViews = view.props.nodeViews;
54
- const nextNodeViews = {
55
- ...currentNodeViews,
56
- ...nodeViewsToReplace
57
- };
58
- view.setProps({
59
- nodeViews: nextNodeViews
60
- });
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
- };
79
-
80
- /**
81
- * 🧱 Internal: Editor FE Platform
82
- */
83
- const loadedPerEditorView = new WeakMap();
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
-
155
- /**
156
- * 🧱 Internal: Editor FE Platform
157
- */
158
- export const queueReplaceNodeViews = (view, {
159
- nodeName,
160
- nodeViewFunc
161
- }) => {
162
- const nodeViews = loadedPerEditorView.get(view) || {};
163
- nodeViews[nodeName] = nodeViewFunc;
164
- loadedPerEditorView.set(view, nodeViews);
165
- debouncedReplaceNodeviews(loadedPerEditorView, view);
166
- };