@atlaskit/editor-common 86.0.0 → 86.1.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 (35) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/lazy-node-view/index.js +217 -0
  3. package/dist/cjs/link/ConfigureLinkOverlay/Dropdown.js +19 -4
  4. package/dist/cjs/link/ConfigureLinkOverlay/index.js +2 -1
  5. package/dist/cjs/messages/help-dialog.js +5 -0
  6. package/dist/cjs/monitoring/error.js +1 -1
  7. package/dist/cjs/ui/DropList/index.js +1 -1
  8. package/dist/cjs/ui-menu/DropdownMenu/index.js +4 -4
  9. package/dist/cjs/ui-menu/ToolbarButton/index.js +7 -1
  10. package/dist/es2019/lazy-node-view/index.js +212 -0
  11. package/dist/es2019/link/ConfigureLinkOverlay/Dropdown.js +17 -4
  12. package/dist/es2019/link/ConfigureLinkOverlay/index.js +2 -1
  13. package/dist/es2019/messages/help-dialog.js +5 -0
  14. package/dist/es2019/monitoring/error.js +1 -1
  15. package/dist/es2019/ui/DropList/index.js +1 -1
  16. package/dist/es2019/ui-menu/DropdownMenu/index.js +4 -4
  17. package/dist/es2019/ui-menu/ToolbarButton/index.js +7 -1
  18. package/dist/esm/lazy-node-view/index.js +211 -0
  19. package/dist/esm/link/ConfigureLinkOverlay/Dropdown.js +19 -4
  20. package/dist/esm/link/ConfigureLinkOverlay/index.js +2 -1
  21. package/dist/esm/messages/help-dialog.js +5 -0
  22. package/dist/esm/monitoring/error.js +1 -1
  23. package/dist/esm/ui/DropList/index.js +1 -1
  24. package/dist/esm/ui-menu/DropdownMenu/index.js +4 -4
  25. package/dist/esm/ui-menu/ToolbarButton/index.js +7 -1
  26. package/dist/types/lazy-node-view/index.d.ts +109 -0
  27. package/dist/types/link/ConfigureLinkOverlay/Dropdown.d.ts +2 -0
  28. package/dist/types/messages/help-dialog.d.ts +5 -0
  29. package/dist/types/ui-menu/ToolbarButton/index.d.ts +3 -0
  30. package/dist/types-ts4.5/lazy-node-view/index.d.ts +109 -0
  31. package/dist/types-ts4.5/link/ConfigureLinkOverlay/Dropdown.d.ts +2 -0
  32. package/dist/types-ts4.5/messages/help-dialog.d.ts +5 -0
  33. package/dist/types-ts4.5/ui-menu/ToolbarButton/index.d.ts +3 -0
  34. package/lazy-node-view/package.json +15 -0
  35. package/package.json +4 -3
@@ -86,7 +86,8 @@ export const OverlayButton = withAnalyticsContext()(({
86
86
  }, showDropdown ? jsx(Dropdown, {
87
87
  testId: testId,
88
88
  onConfigureClick: handleConfigureClick,
89
- onDropdownChange: onDropdownChange
89
+ onDropdownChange: onDropdownChange,
90
+ editorView: editorView
90
91
  }) : jsx(Tooltip, {
91
92
  content: configureLinkLabel,
92
93
  hideTooltipOnClick: true,
@@ -70,6 +70,11 @@ export const helpDialogMessages = defineMessages({
70
70
  defaultMessage: 'Decrease table or media size',
71
71
  description: 'The text is shown as an shortcut description in help dialog modal, when the user uses the described shortcut, he is able to decrease the width of the selected element. Optimal characters less than 21.'
72
72
  },
73
+ openCellOptions: {
74
+ id: 'fabric.editor.openCellOptions',
75
+ defaultMessage: 'Open cell options',
76
+ description: 'Keyboard shortcut to open cell options.'
77
+ },
73
78
  focusTableResizeHandle: {
74
79
  id: 'fabric.editor.focusTableResizeHandle',
75
80
  defaultMessage: 'Focus table resize handle',
@@ -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 = "86.0.0";
4
+ const packageVersion = "86.1.0";
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
@@ -9,7 +9,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
9
9
  import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
10
10
  import Layer from '../Layer';
11
11
  const packageName = "@atlaskit/editor-common";
12
- const packageVersion = "86.0.0";
12
+ const packageVersion = "86.1.0";
13
13
  const halfFocusRing = 1;
14
14
  const dropOffset = '0, 8';
15
15
  class DropList extends Component {
@@ -106,7 +106,7 @@ export default class DropdownMenuWrapper extends PureComponent {
106
106
  _defineProperty(this, "handleCloseAndFocus", event => {
107
107
  var _this$state$target, _this$state$target$qu;
108
108
  (_this$state$target = this.state.target) === null || _this$state$target === void 0 ? void 0 : (_this$state$target$qu = _this$state$target.querySelector('button')) === null || _this$state$target$qu === void 0 ? void 0 : _this$state$target$qu.focus();
109
- if (fg('platform.editor.a11y-table-context-menu_y4c9c')) {
109
+ if (fg('platform_editor_a11y_table_context_menu')) {
110
110
  this.handleClose(event);
111
111
  } else {
112
112
  this.handleClose();
@@ -117,7 +117,7 @@ export default class DropdownMenuWrapper extends PureComponent {
117
117
  onOpenChange
118
118
  } = this.props;
119
119
  if (onOpenChange) {
120
- if (fg('platform.editor.a11y-table-context-menu_y4c9c')) {
120
+ if (fg('platform_editor_a11y_table_context_menu')) {
121
121
  onOpenChange({
122
122
  isOpen: false,
123
123
  event: event
@@ -195,7 +195,7 @@ export default class DropdownMenuWrapper extends PureComponent {
195
195
  handleClickOutside: this.handleClose,
196
196
  handleEscapeKeydown: fg('platform-editor-a11y-image-border-options-dropdown') ? handleEscapeKeydown || this.handleCloseAndFocus : this.handleCloseAndFocus,
197
197
  handleEnterKeydown: e => {
198
- if (fg('platform.editor.a11y-table-context-menu_y4c9c') || fg('platform-editor-a11y-image-border-options-dropdown')) {
198
+ if (fg('platform_editor_a11y_table_context_menu') || fg('platform-editor-a11y-image-border-options-dropdown')) {
199
199
  if (!allowEnterDefaultBehavior) {
200
200
  e.preventDefault();
201
201
  }
@@ -353,7 +353,7 @@ export function DropdownMenuItem({
353
353
  onMouseLeave: () => onMouseLeave && onMouseLeave({
354
354
  item
355
355
  }),
356
- "aria-expanded": fg('platform.editor.a11y-table-context-menu_y4c9c') ? item['aria-expanded'] : undefined
356
+ "aria-expanded": fg('platform_editor_a11y_table_context_menu') ? item['aria-expanded'] : undefined
357
357
  }, item.content));
358
358
  if (item.tooltipDescription) {
359
359
  var _item$key3;
@@ -6,8 +6,10 @@ import React, { useCallback } from 'react';
6
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
7
  import { css, jsx } from '@emotion/react';
8
8
  import { FabricChannel } from '@atlaskit/analytics-listeners';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
9
10
  import Tooltip from '@atlaskit/tooltip';
10
11
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, TOOLBAR_ACTION_SUBJECT_ID } from '../../analytics';
12
+ import { ToolTipContent } from '../../keymaps';
11
13
  import Button from './styles';
12
14
  export const TOOLBAR_BUTTON = TOOLBAR_ACTION_SUBJECT_ID;
13
15
  const buttonWrapper = css({
@@ -29,6 +31,7 @@ const ToolbarButton = /*#__PURE__*/React.forwardRef((props, ref) => {
29
31
  children,
30
32
  hideTooltip,
31
33
  title,
34
+ keymap,
32
35
  titlePosition = 'top',
33
36
  item,
34
37
  'aria-label': ariaLabel,
@@ -88,7 +91,10 @@ const ToolbarButton = /*#__PURE__*/React.forwardRef((props, ref) => {
88
91
  if (!title) {
89
92
  return button;
90
93
  }
91
- const tooltipContent = !hideTooltip ? title : null;
94
+ const tooltipContent = hideTooltip ? null : fg('platform_editor_a11y_table_context_menu') ? jsx(ToolTipContent, {
95
+ description: title,
96
+ keymap: keymap
97
+ }) : title;
92
98
  return jsx(Tooltip, {
93
99
  content: tooltipContent,
94
100
  hideTooltipOnClick: true,
@@ -0,0 +1,211 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
+ 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; }
5
+ 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) { _defineProperty(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; }
6
+ import debounce from 'lodash/debounce';
7
+ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
8
+
9
+ /**
10
+ * 📢 Public Type
11
+ *
12
+ * @see {withLazyLoading}
13
+ */
14
+
15
+ /**
16
+ * 📢 Public Type
17
+ *
18
+ * @see {withLazyLoading}
19
+ */
20
+
21
+ /**
22
+ * 🧱 Internal: Editor FE Platform
23
+ */
24
+
25
+ /**
26
+ * 🧱 Internal: Editor FE Platform
27
+ */
28
+
29
+ /**
30
+ * 🧱 Internal: Editor FE Platform
31
+ */
32
+
33
+ /**
34
+ * 🧱 Internal: Editor FE Platform
35
+ *
36
+ * A cache to store loaded React NodeViews for each EditorView.
37
+ *
38
+ * This cache will help us to avoid any race condition
39
+ * when multiple Editors exist in the same page.
40
+ *
41
+ * @type {CacheType}
42
+ */
43
+ var cachePerEditorView = new WeakMap();
44
+
45
+ /**
46
+ * 🧱 Internal: Editor FE Platform
47
+ */
48
+ var isFirefox = /gecko\/\d/i.test(navigator.userAgent);
49
+
50
+ /**
51
+ * 🧱 Internal: Editor FE Platform
52
+ *
53
+ * A NodeView that serves as a placeholder until the actual NodeView is loaded.
54
+ */
55
+ var LazyNodeView = /*#__PURE__*/_createClass(function LazyNodeView(node, view, getPos) {
56
+ var _node$type;
57
+ _classCallCheck(this, LazyNodeView);
58
+ 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') {
59
+ this.dom = document.createElement('div');
60
+ return;
61
+ }
62
+ var fallback = DOMSerializer.renderSpec(document, node.type.spec.toDOM(node));
63
+ this.dom = fallback.dom;
64
+ this.contentDOM = fallback.contentDOM;
65
+ if (this.dom instanceof HTMLElement) {
66
+ // This attribute is mostly used for debugging purposed
67
+ // It will help us to found out when the node was replaced
68
+ this.dom.setAttribute('data-lazy-node-view', node.type.name);
69
+ // This is used on Libra tests
70
+ // We are using this to make sure all lazy noded were replaced
71
+ // before the test started
72
+ this.dom.setAttribute('data-lazy-node-view-fallback', 'true');
73
+ }
74
+ });
75
+ /**
76
+ * 🧱 Internal: Editor FE Platform
77
+ *
78
+ * Debounces and replaces the node views in a ProseMirror editor with lazy-loaded node views.
79
+ *
80
+ * This function is used to update the `nodeViews` property of the `EditorView` after lazy-loaded
81
+ * node views have been loaded. It uses a debounced approach to ensure that the replacement does
82
+ * not happen too frequently, which can be performance-intensive.
83
+ *
84
+ * The function checks if there are any loaded node views in the cache associated with the given
85
+ * `EditorView`. If there are, it replaces the current `nodeViews` in the `EditorView` with the
86
+ * loaded node views. The replacement is scheduled using `requestIdleCallback` or
87
+ * `requestAnimationFrame` to avoid blocking the main thread, especially in Firefox where
88
+ * `requestIdleCallback` may not be supported.
89
+ *
90
+ * @param {WeakMap<EditorView, Record<string, NodeViewConstructor>>} cache - A WeakMap that stores
91
+ * the loaded node views for each `EditorView`. The key is the `EditorView`, and the value
92
+ * is a record of node type names to their corresponding `NodeViewConstructor`.
93
+ * @param {EditorView} view - The ProseMirror `EditorView` instance whose `nodeViews` property
94
+ * needs to be updated.
95
+ *
96
+ * @example
97
+ * const cache = new WeakMap();
98
+ * const view = new EditorView(...);
99
+ *
100
+ * // Assume some node views have been loaded and stored in the cache
101
+ * cache.set(view, {
102
+ * 'table': TableViewConstructor,
103
+ * 'tableCell': TableCellViewConstructor,
104
+ * });
105
+ *
106
+ * debouncedReplaceNodeviews(cache, view);
107
+ */
108
+ export var debouncedReplaceNodeviews = debounce(function (cache, view) {
109
+ var loadedNodeviews = cache.get(view);
110
+ if (!loadedNodeviews) {
111
+ return;
112
+ }
113
+ cache.delete(view);
114
+
115
+ // eslint-disable-next-line compat/compat
116
+ var idle = window.requestIdleCallback;
117
+
118
+ /*
119
+ * For reasons that goes beyond my knowledge
120
+ * some Firefox versions aren't calling the requestIdleCallback.
121
+ *
122
+ * So, we need this check to make sure we use the requestAnimationFrame instead
123
+ */
124
+ var later = isFirefox || typeof idle !== 'function' ? window.requestAnimationFrame : idle;
125
+ later(function () {
126
+ var currentNodeViews = view.props.nodeViews;
127
+ var nextNodeViews = _objectSpread(_objectSpread({}, currentNodeViews), loadedNodeviews);
128
+ view.setProps({
129
+ nodeViews: nextNodeViews
130
+ });
131
+ });
132
+ });
133
+
134
+ /**
135
+ * 📢 Public: Any EditorPlugin can use this function
136
+ *
137
+ * Wraps a NodeView constructor with laziness, allowing the NodeView to be loaded only when required.
138
+ *
139
+ * This higher-order function is designed to optimize the loading and rendering performance
140
+ * of ProseMirror editor nodes by deferring the loading of their associated NodeViews until they are actually needed.
141
+ * This is particularly useful for complex or heavy NodeViews, such as tables, table cells, rows, and headers within
142
+ * the ProseMirror editor. By using dynamic imports (with promises), the initial load time of the editor can be significantly
143
+ * reduced, leading to a smoother and faster user experience.
144
+ *
145
+ * The function accepts configuration parameters including the node name, a loader function that dynamically imports
146
+ * the NodeView, and a function to retrieve NodeView options. It returns a NodeViewConstructor that ProseMirror
147
+ * can use when rendering nodes of the specified type.
148
+ *
149
+ * @template NodeViewOptions - The type parameter that describes the shape of the options object for the NodeView.
150
+ * @param {LazyLoadingProps<NodeViewOptions>} params - Configuration parameters for lazy loading.
151
+ * @param {string} params.nodeName - The name of the node (e.g., 'table', 'tableCell', 'tableHeader', 'tableRow') for which the lazy-loaded NodeView is intended.
152
+ * @param {() => Promise<CreateReactNodeViewProps<NodeViewOptions>>} params.loader - A function that, when called, returns a promise that resolves to the actual NodeView constructor. This function typically uses dynamic `import()` to load the NodeView code.
153
+ * @param {() => NodeViewOptions} params.getNodeViewOptions - A function that returns the options to be passed to the NodeView constructor. These options can include dependencies like `portalProviderAPI`, `eventDispatcher`, and others, which are necessary for the NodeView's operation.
154
+ * @param {DispatchAnalyticsEvent} [params.dispatchAnalyticsEvent] - An optional function for dispatching analytics events, which can be used to monitor the performance and usage of the lazy-loaded NodeViews.
155
+ * @returns {NodeViewConstructor} A constructor function for creating a NodeView that ProseMirror can instantiate when it encounters a node of the specified type. This constructor is a lightweight placeholder until the actual NodeView is loaded.
156
+ *
157
+ * @example
158
+ * // Lazy load a table NodeView with specific options
159
+ * const lazyTableView = withLazyLoading({
160
+ * nodeName: 'table',
161
+ * loader: () => import('./table').then(module => module.createTableView),
162
+ * getNodeViewOptions: () => ({
163
+ * portalProviderAPI,
164
+ * eventDispatcher,
165
+ * getEditorContainerWidth,
166
+ * getEditorFeatureFlags,
167
+ * dispatchAnalyticsEvent,
168
+ * pluginInjectionApi,
169
+ * }),
170
+ * });
171
+ *
172
+ * // Then, use `lazyTableView` in ProseMirror editor setup to enhance 'table' nodes with lazy loading
173
+ */
174
+ export var withLazyLoading = function withLazyLoading(_ref) {
175
+ var nodeName = _ref.nodeName,
176
+ loader = _ref.loader,
177
+ getNodeViewOptions = _ref.getNodeViewOptions,
178
+ dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
179
+ var createLazyNodeView = function createLazyNodeView(node, view, getPos, decorations) {
180
+ var _node$type2;
181
+ var cachedMap = cachePerEditorView.get(view);
182
+ if (!cachedMap) {
183
+ cachedMap = {};
184
+ cachePerEditorView.set(view, cachedMap);
185
+ }
186
+ var wasAlreadyRequested = cachedMap.hasOwnProperty(nodeName);
187
+ if (wasAlreadyRequested) {
188
+ return new LazyNodeView(node, view, getPos);
189
+ }
190
+ loader().then(function (nodeViewFuncModule) {
191
+ cachedMap[nodeName] = function (node, view, getPos, decorations) {
192
+ return nodeViewFuncModule(node, view, getPos, decorations, getNodeViewOptions);
193
+ };
194
+ debouncedReplaceNodeviews(cachePerEditorView, view);
195
+ });
196
+ if (typeof ((_node$type2 = node.type) === null || _node$type2 === void 0 || (_node$type2 = _node$type2.spec) === null || _node$type2 === void 0 ? void 0 : _node$type2.toDOM) !== 'function') {
197
+ // TODO: Analytics ED-23982
198
+ // dispatchAnalyticsEvent({
199
+ // action: ACTION.LAZY_NODE_VIEW_ERROR,
200
+ // actionSubject: ACTION_SUBJECT.LAZY_NODE_VIEW,
201
+ // eventType: EVENT_TYPE.OPERATIONAL,
202
+ // attributes: {
203
+ // nodeName,
204
+ // error: 'No spec found',
205
+ // },
206
+ // });
207
+ }
208
+ return new LazyNodeView(node, view, getPos);
209
+ };
210
+ return createLazyNodeView;
211
+ };
@@ -19,6 +19,7 @@ var SMALL_LINK_TOOLBAR_ANALYTICS_SOURCE = 'smallLinkToolbar';
19
19
  var Dropdown = function Dropdown(_ref) {
20
20
  var onConfigureClickCallback = _ref.onConfigureClick,
21
21
  onDropdownChange = _ref.onDropdownChange,
22
+ editorView = _ref.editorView,
22
23
  testId = _ref.testId;
23
24
  var _useIntl = useIntl(),
24
25
  formatMessage = _useIntl.formatMessage;
@@ -28,20 +29,34 @@ var Dropdown = function Dropdown(_ref) {
28
29
  fireActionClickEvent = _useLinkOverlayAnalyt.fireActionClickEvent,
29
30
  fireLinkClickEvent = _useLinkOverlayAnalyt.fireLinkClickEvent,
30
31
  fireToolbarViewEvent = _useLinkOverlayAnalyt.fireToolbarViewEvent;
32
+ var focusEditor = useCallback(function () {
33
+ // Fix dropdown giving focus back to the trigger async which is then unmounted and losing focus
34
+ // this is happening deep within atlaskit dropdown as a result of this code: https://github.com/focus-trap/focus-trap/blob/master/index.js#L987
35
+ // use setTimeout to run this async after that call
36
+ setTimeout(function () {
37
+ return editorView.focus();
38
+ }, 0);
39
+ }, [editorView]);
31
40
  var onOpenChange = useCallback(function (_ref2) {
32
- var isOpen = _ref2.isOpen;
41
+ var isOpen = _ref2.isOpen,
42
+ event = _ref2.event;
33
43
  onDropdownChange === null || onDropdownChange === void 0 || onDropdownChange(isOpen);
34
44
  if (isOpen) {
35
45
  fireToolbarViewEvent();
36
46
  }
37
- }, [fireToolbarViewEvent, onDropdownChange]);
47
+ if (!isOpen && event instanceof KeyboardEvent) {
48
+ focusEditor();
49
+ }
50
+ }, [fireToolbarViewEvent, focusEditor, onDropdownChange]);
38
51
  var onGoToLinkClick = useCallback(function () {
39
52
  fireActionClickEvent('goToLink');
40
- }, [fireActionClickEvent]);
53
+ focusEditor();
54
+ }, [fireActionClickEvent, focusEditor]);
41
55
  var onConfigureClick = useCallback(function () {
42
56
  fireActionClickEvent('configureLink');
43
57
  onConfigureClickCallback === null || onConfigureClickCallback === void 0 || onConfigureClickCallback();
44
- }, [fireActionClickEvent, onConfigureClickCallback]);
58
+ focusEditor();
59
+ }, [fireActionClickEvent, focusEditor, onConfigureClickCallback]);
45
60
  return jsx(DropdownMenu, {
46
61
  trigger: function trigger(_ref3) {
47
62
  var _onClick = _ref3.onClick,
@@ -87,7 +87,8 @@ export var OverlayButton = withAnalyticsContext()(function (_ref) {
87
87
  }, showDropdown ? jsx(Dropdown, {
88
88
  testId: testId,
89
89
  onConfigureClick: handleConfigureClick,
90
- onDropdownChange: onDropdownChange
90
+ onDropdownChange: onDropdownChange,
91
+ editorView: editorView
91
92
  }) : jsx(Tooltip, {
92
93
  content: configureLinkLabel,
93
94
  hideTooltipOnClick: true,
@@ -70,6 +70,11 @@ export var helpDialogMessages = defineMessages({
70
70
  defaultMessage: 'Decrease table or media size',
71
71
  description: 'The text is shown as an shortcut description in help dialog modal, when the user uses the described shortcut, he is able to decrease the width of the selected element. Optimal characters less than 21.'
72
72
  },
73
+ openCellOptions: {
74
+ id: 'fabric.editor.openCellOptions',
75
+ defaultMessage: 'Open cell options',
76
+ description: 'Keyboard shortcut to open cell options.'
77
+ },
73
78
  focusTableResizeHandle: {
74
79
  id: 'fabric.editor.focusTableResizeHandle',
75
80
  defaultMessage: 'Focus table resize handle',
@@ -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 = "86.0.0";
10
+ var packageVersion = "86.1.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
@@ -17,7 +17,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
17
17
  import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
18
18
  import Layer from '../Layer';
19
19
  var packageName = "@atlaskit/editor-common";
20
- var packageVersion = "86.0.0";
20
+ var packageVersion = "86.1.0";
21
21
  var halfFocusRing = 1;
22
22
  var dropOffset = '0, 8';
23
23
  var DropList = /*#__PURE__*/function (_Component) {
@@ -94,7 +94,7 @@ var DropdownMenuWrapper = /*#__PURE__*/function (_PureComponent) {
94
94
  _defineProperty(_assertThisInitialized(_this), "handleCloseAndFocus", function (event) {
95
95
  var _this$state$target;
96
96
  (_this$state$target = _this.state.target) === null || _this$state$target === void 0 || (_this$state$target = _this$state$target.querySelector('button')) === null || _this$state$target === void 0 || _this$state$target.focus();
97
- if (fg('platform.editor.a11y-table-context-menu_y4c9c')) {
97
+ if (fg('platform_editor_a11y_table_context_menu')) {
98
98
  _this.handleClose(event);
99
99
  } else {
100
100
  _this.handleClose();
@@ -103,7 +103,7 @@ var DropdownMenuWrapper = /*#__PURE__*/function (_PureComponent) {
103
103
  _defineProperty(_assertThisInitialized(_this), "handleClose", function (event) {
104
104
  var onOpenChange = _this.props.onOpenChange;
105
105
  if (onOpenChange) {
106
- if (fg('platform.editor.a11y-table-context-menu_y4c9c')) {
106
+ if (fg('platform_editor_a11y_table_context_menu')) {
107
107
  onOpenChange({
108
108
  isOpen: false,
109
109
  event: event
@@ -182,7 +182,7 @@ var DropdownMenuWrapper = /*#__PURE__*/function (_PureComponent) {
182
182
  handleClickOutside: this.handleClose,
183
183
  handleEscapeKeydown: fg('platform-editor-a11y-image-border-options-dropdown') ? handleEscapeKeydown || this.handleCloseAndFocus : this.handleCloseAndFocus,
184
184
  handleEnterKeydown: function handleEnterKeydown(e) {
185
- if (fg('platform.editor.a11y-table-context-menu_y4c9c') || fg('platform-editor-a11y-image-border-options-dropdown')) {
185
+ if (fg('platform_editor_a11y_table_context_menu') || fg('platform-editor-a11y-image-border-options-dropdown')) {
186
186
  if (!allowEnterDefaultBehavior) {
187
187
  e.preventDefault();
188
188
  }
@@ -355,7 +355,7 @@ export function DropdownMenuItem(_ref) {
355
355
  item: item
356
356
  });
357
357
  },
358
- "aria-expanded": fg('platform.editor.a11y-table-context-menu_y4c9c') ? item['aria-expanded'] : undefined
358
+ "aria-expanded": fg('platform_editor_a11y_table_context_menu') ? item['aria-expanded'] : undefined
359
359
  }, item.content));
360
360
  if (item.tooltipDescription) {
361
361
  var _item$key3;
@@ -9,8 +9,10 @@ import React, { useCallback } from 'react';
9
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
10
10
  import { css, jsx } from '@emotion/react';
11
11
  import { FabricChannel } from '@atlaskit/analytics-listeners';
12
+ import { fg } from '@atlaskit/platform-feature-flags';
12
13
  import Tooltip from '@atlaskit/tooltip';
13
14
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, TOOLBAR_ACTION_SUBJECT_ID } from '../../analytics';
15
+ import { ToolTipContent } from '../../keymaps';
14
16
  import Button from './styles';
15
17
  export var TOOLBAR_BUTTON = TOOLBAR_ACTION_SUBJECT_ID;
16
18
  var buttonWrapper = css({
@@ -32,6 +34,7 @@ var ToolbarButton = /*#__PURE__*/React.forwardRef(function (props, ref) {
32
34
  children = props.children,
33
35
  hideTooltip = props.hideTooltip,
34
36
  title = props.title,
37
+ keymap = props.keymap,
35
38
  _props$titlePosition = props.titlePosition,
36
39
  titlePosition = _props$titlePosition === void 0 ? 'top' : _props$titlePosition,
37
40
  item = props.item,
@@ -92,7 +95,10 @@ var ToolbarButton = /*#__PURE__*/React.forwardRef(function (props, ref) {
92
95
  if (!title) {
93
96
  return button;
94
97
  }
95
- var tooltipContent = !hideTooltip ? title : null;
98
+ var tooltipContent = hideTooltip ? null : fg('platform_editor_a11y_table_context_menu') ? jsx(ToolTipContent, {
99
+ description: title,
100
+ keymap: keymap
101
+ }) : title;
96
102
  return jsx(Tooltip, {
97
103
  content: tooltipContent,
98
104
  hideTooltipOnClick: true,
@@ -0,0 +1,109 @@
1
+ /// <reference types="lodash" />
2
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Decoration, DecorationSource, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { DispatchAnalyticsEvent } from '../analytics';
5
+ /**
6
+ * 📢 Public Type
7
+ *
8
+ * @see {withLazyLoading}
9
+ */
10
+ export type CreateReactNodeViewProps<NodeViewOptions> = (node: PMNode, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[], getNodeViewOptions: () => NodeViewOptions) => NodeView;
11
+ /**
12
+ * 📢 Public Type
13
+ *
14
+ * @see {withLazyLoading}
15
+ */
16
+ export type LazyLoadingProps<NodeViewOptions> = {
17
+ nodeName: string;
18
+ loader: () => Promise<CreateReactNodeViewProps<NodeViewOptions>>;
19
+ getNodeViewOptions: () => NodeViewOptions;
20
+ dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
21
+ };
22
+ /**
23
+ * 🧱 Internal: Editor FE Platform
24
+ */
25
+ export type NodeViewConstructor = (node: PMNode, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView;
26
+ /**
27
+ * 🧱 Internal: Editor FE Platform
28
+ */
29
+ type LoadedReactNodeViews = Record<string, NodeViewConstructor>;
30
+ /**
31
+ * 🧱 Internal: Editor FE Platform
32
+ */
33
+ type CacheType = WeakMap<EditorView, LoadedReactNodeViews>;
34
+ /**
35
+ * 🧱 Internal: Editor FE Platform
36
+ *
37
+ * Debounces and replaces the node views in a ProseMirror editor with lazy-loaded node views.
38
+ *
39
+ * This function is used to update the `nodeViews` property of the `EditorView` after lazy-loaded
40
+ * node views have been loaded. It uses a debounced approach to ensure that the replacement does
41
+ * not happen too frequently, which can be performance-intensive.
42
+ *
43
+ * The function checks if there are any loaded node views in the cache associated with the given
44
+ * `EditorView`. If there are, it replaces the current `nodeViews` in the `EditorView` with the
45
+ * loaded node views. The replacement is scheduled using `requestIdleCallback` or
46
+ * `requestAnimationFrame` to avoid blocking the main thread, especially in Firefox where
47
+ * `requestIdleCallback` may not be supported.
48
+ *
49
+ * @param {WeakMap<EditorView, Record<string, NodeViewConstructor>>} cache - A WeakMap that stores
50
+ * the loaded node views for each `EditorView`. The key is the `EditorView`, and the value
51
+ * is a record of node type names to their corresponding `NodeViewConstructor`.
52
+ * @param {EditorView} view - The ProseMirror `EditorView` instance whose `nodeViews` property
53
+ * needs to be updated.
54
+ *
55
+ * @example
56
+ * const cache = new WeakMap();
57
+ * const view = new EditorView(...);
58
+ *
59
+ * // Assume some node views have been loaded and stored in the cache
60
+ * cache.set(view, {
61
+ * 'table': TableViewConstructor,
62
+ * 'tableCell': TableCellViewConstructor,
63
+ * });
64
+ *
65
+ * debouncedReplaceNodeviews(cache, view);
66
+ */
67
+ export declare const debouncedReplaceNodeviews: import("lodash").DebouncedFunc<(cache: CacheType, view: EditorView) => void>;
68
+ /**
69
+ * 📢 Public: Any EditorPlugin can use this function
70
+ *
71
+ * Wraps a NodeView constructor with laziness, allowing the NodeView to be loaded only when required.
72
+ *
73
+ * This higher-order function is designed to optimize the loading and rendering performance
74
+ * of ProseMirror editor nodes by deferring the loading of their associated NodeViews until they are actually needed.
75
+ * This is particularly useful for complex or heavy NodeViews, such as tables, table cells, rows, and headers within
76
+ * the ProseMirror editor. By using dynamic imports (with promises), the initial load time of the editor can be significantly
77
+ * reduced, leading to a smoother and faster user experience.
78
+ *
79
+ * The function accepts configuration parameters including the node name, a loader function that dynamically imports
80
+ * the NodeView, and a function to retrieve NodeView options. It returns a NodeViewConstructor that ProseMirror
81
+ * can use when rendering nodes of the specified type.
82
+ *
83
+ * @template NodeViewOptions - The type parameter that describes the shape of the options object for the NodeView.
84
+ * @param {LazyLoadingProps<NodeViewOptions>} params - Configuration parameters for lazy loading.
85
+ * @param {string} params.nodeName - The name of the node (e.g., 'table', 'tableCell', 'tableHeader', 'tableRow') for which the lazy-loaded NodeView is intended.
86
+ * @param {() => Promise<CreateReactNodeViewProps<NodeViewOptions>>} params.loader - A function that, when called, returns a promise that resolves to the actual NodeView constructor. This function typically uses dynamic `import()` to load the NodeView code.
87
+ * @param {() => NodeViewOptions} params.getNodeViewOptions - A function that returns the options to be passed to the NodeView constructor. These options can include dependencies like `portalProviderAPI`, `eventDispatcher`, and others, which are necessary for the NodeView's operation.
88
+ * @param {DispatchAnalyticsEvent} [params.dispatchAnalyticsEvent] - An optional function for dispatching analytics events, which can be used to monitor the performance and usage of the lazy-loaded NodeViews.
89
+ * @returns {NodeViewConstructor} A constructor function for creating a NodeView that ProseMirror can instantiate when it encounters a node of the specified type. This constructor is a lightweight placeholder until the actual NodeView is loaded.
90
+ *
91
+ * @example
92
+ * // Lazy load a table NodeView with specific options
93
+ * const lazyTableView = withLazyLoading({
94
+ * nodeName: 'table',
95
+ * loader: () => import('./table').then(module => module.createTableView),
96
+ * getNodeViewOptions: () => ({
97
+ * portalProviderAPI,
98
+ * eventDispatcher,
99
+ * getEditorContainerWidth,
100
+ * getEditorFeatureFlags,
101
+ * dispatchAnalyticsEvent,
102
+ * pluginInjectionApi,
103
+ * }),
104
+ * });
105
+ *
106
+ * // Then, use `lazyTableView` in ProseMirror editor setup to enhance 'table' nodes with lazy loading
107
+ */
108
+ export declare const withLazyLoading: <Options>({ nodeName, loader, getNodeViewOptions, dispatchAnalyticsEvent, }: LazyLoadingProps<Options>) => NodeViewConstructor;
109
+ export {};
@@ -1,10 +1,12 @@
1
1
  /// <reference types="react" />
2
+ import { type EditorView } from '@atlaskit/editor-prosemirror/view';
2
3
  export type OnDropdownChange = (isOpen: boolean) => void;
3
4
  export type DropdownProps = {
4
5
  /** Callback fired when the Configure dropdown item is clicked */
5
6
  onConfigureClick: () => void;
6
7
  /** Callback fired when the dropdown is open or close */
7
8
  onDropdownChange?: OnDropdownChange;
9
+ editorView: EditorView;
8
10
  testId: string;
9
11
  };
10
12
  declare const _default: import("react").ForwardRefExoticComponent<DropdownProps & import("@atlaskit/analytics-next").WithContextProps & import("react").RefAttributes<any>>;
@@ -69,6 +69,11 @@ export declare const helpDialogMessages: {
69
69
  defaultMessage: string;
70
70
  description: string;
71
71
  };
72
+ openCellOptions: {
73
+ id: string;
74
+ defaultMessage: string;
75
+ description: string;
76
+ };
72
77
  focusTableResizeHandle: {
73
78
  id: string;
74
79
  defaultMessage: string;
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import type { ButtonProps } from '@atlaskit/button/types';
4
4
  import type { PositionType } from '@atlaskit/tooltip';
5
5
  import { TOOLBAR_ACTION_SUBJECT_ID } from '../../analytics';
6
+ import { type Keymap } from '../../keymaps';
6
7
  import type { MenuItem } from '../DropdownMenu';
7
8
  export declare const TOOLBAR_BUTTON: typeof TOOLBAR_ACTION_SUBJECT_ID;
8
9
  export type Props = {
@@ -23,6 +24,7 @@ export type Props = {
23
24
  titlePosition?: PositionType;
24
25
  item?: MenuItem;
25
26
  testId?: string;
27
+ keymap?: Keymap;
26
28
  'aria-label'?: React.AriaAttributes['aria-label'];
27
29
  'aria-expanded'?: React.AriaAttributes['aria-expanded'];
28
30
  'aria-haspopup'?: React.AriaAttributes['aria-haspopup'];
@@ -48,6 +50,7 @@ declare const ToolbarButton: React.ForwardRefExoticComponent<{
48
50
  titlePosition?: PositionType | undefined;
49
51
  item?: MenuItem | undefined;
50
52
  testId?: string | undefined;
53
+ keymap?: Keymap | undefined;
51
54
  'aria-label'?: React.AriaAttributes['aria-label'];
52
55
  'aria-expanded'?: React.AriaAttributes['aria-expanded'];
53
56
  'aria-haspopup'?: React.AriaAttributes['aria-haspopup'];