@atlaskit/editor-plugin-table 7.20.1 → 7.21.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 (36) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/nodeviews/TableResizer.js +25 -2
  3. package/dist/cjs/nodeviews/TableStickyScrollbar.js +8 -1
  4. package/dist/cjs/nodeviews/lazy-node-views.js +133 -0
  5. package/dist/cjs/plugin.js +39 -4
  6. package/dist/cjs/pm-plugins/keymap.js +1 -1
  7. package/dist/cjs/pm-plugins/main.js +19 -15
  8. package/dist/cjs/ui/FloatingContextualButton/index.js +4 -2
  9. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +11 -11
  10. package/dist/es2019/nodeviews/TableResizer.js +25 -2
  11. package/dist/es2019/nodeviews/TableStickyScrollbar.js +8 -1
  12. package/dist/es2019/nodeviews/lazy-node-views.js +116 -0
  13. package/dist/es2019/plugin.js +38 -2
  14. package/dist/es2019/pm-plugins/keymap.js +1 -1
  15. package/dist/es2019/pm-plugins/main.js +19 -7
  16. package/dist/es2019/ui/FloatingContextualButton/index.js +5 -3
  17. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +11 -11
  18. package/dist/esm/nodeviews/TableResizer.js +25 -2
  19. package/dist/esm/nodeviews/TableStickyScrollbar.js +8 -1
  20. package/dist/esm/nodeviews/lazy-node-views.js +116 -0
  21. package/dist/esm/plugin.js +39 -4
  22. package/dist/esm/pm-plugins/keymap.js +1 -1
  23. package/dist/esm/pm-plugins/main.js +19 -15
  24. package/dist/esm/ui/FloatingContextualButton/index.js +5 -3
  25. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +11 -11
  26. package/dist/types/nodeviews/lazy-node-views.d.ts +26 -0
  27. package/dist/types-ts4.5/nodeviews/lazy-node-views.d.ts +26 -0
  28. package/package.json +7 -4
  29. package/src/nodeviews/TableResizer.tsx +26 -1
  30. package/src/nodeviews/TableStickyScrollbar.ts +8 -1
  31. package/src/nodeviews/lazy-node-views.ts +196 -0
  32. package/src/plugin.tsx +53 -2
  33. package/src/pm-plugins/keymap.ts +1 -1
  34. package/src/pm-plugins/main.ts +18 -19
  35. package/src/ui/FloatingContextualButton/index.tsx +7 -5
  36. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +11 -13
@@ -51,9 +51,12 @@ import {
51
51
  whenTableInFocus,
52
52
  withCellTracking,
53
53
  } from '../event-handlers';
54
- import { createTableView } from '../nodeviews/table';
55
- import TableCell from '../nodeviews/TableCell';
56
- import TableRow from '../nodeviews/TableRow';
54
+ import {
55
+ lazyTableCellView,
56
+ lazyTableHeaderView,
57
+ lazyTableRowView,
58
+ lazyTableView,
59
+ } from '../nodeviews/lazy-node-views';
57
60
  import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plugin';
58
61
  import { fixTables, replaceSelectedTable } from '../transforms';
59
62
  import type {
@@ -350,22 +353,18 @@ export const createPlugin = (
350
353
  return false;
351
354
  },
352
355
  nodeViews: {
353
- table: (node, view, getPos) =>
354
- createTableView(
355
- node,
356
- view,
357
- getPos,
358
- portalProviderAPI,
359
- eventDispatcher,
360
- getEditorContainerWidth,
361
- getEditorFeatureFlags,
362
- dispatchAnalyticsEvent,
363
- pluginInjectionApi,
364
- isTableAlignmentEnabled,
365
- ),
366
- tableRow: (node, view, getPos) => new TableRow(node, view, getPos, eventDispatcher),
367
- tableCell: (node, view, getPos) => new TableCell(node, view, getPos, eventDispatcher),
368
- tableHeader: (node, view, getPos) => new TableCell(node, view, getPos, eventDispatcher),
356
+ table: lazyTableView({
357
+ portalProviderAPI,
358
+ eventDispatcher,
359
+ getEditorContainerWidth,
360
+ getEditorFeatureFlags,
361
+ dispatchAnalyticsEvent,
362
+ pluginInjectionApi,
363
+ isTableAlignmentEnabled,
364
+ }),
365
+ tableRow: lazyTableRowView({ eventDispatcher }),
366
+ tableCell: lazyTableCellView({ eventDispatcher }),
367
+ tableHeader: lazyTableHeaderView({ eventDispatcher }),
369
368
  },
370
369
  handleDOMEvents: {
371
370
  focus: handleFocus,
@@ -9,6 +9,7 @@ import { injectIntl } from 'react-intl-next';
9
9
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
10
10
  import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
11
11
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
12
+ import { focusToContextMenuTrigger } from '@atlaskit/editor-common/keymaps';
12
13
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
13
14
  import { Popup } from '@atlaskit/editor-common/ui';
14
15
  import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
@@ -17,7 +18,7 @@ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
17
18
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
18
19
  import { akEditorSmallZIndex } from '@atlaskit/editor-shared-styles';
19
20
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
20
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
21
+ import { fg } from '@atlaskit/platform-feature-flags';
21
22
 
22
23
  import { toggleContextualMenu } from '../../commands';
23
24
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
@@ -73,7 +74,7 @@ const FloatingContextualButtonInner = React.memo((props: Props & WrappedComponen
73
74
  targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
74
75
 
75
76
  useEffect(() => {
76
- if (getBooleanFF('platform.editor.a11y-table-context-menu_y4c9c')) {
77
+ if (fg('platform_editor_a11y_table_context_menu')) {
77
78
  if (isCellMenuOpenByKeyboard && !isContextualMenuOpen) {
78
79
  const { state, dispatch } = editorView;
79
80
  // open the menu when the keyboard shortcut is pressed
@@ -102,13 +103,14 @@ const FloatingContextualButtonInner = React.memo((props: Props & WrappedComponen
102
103
  className={ClassName.CONTEXTUAL_MENU_BUTTON}
103
104
  selected={isContextualMenuOpen}
104
105
  title={labelCellOptions}
106
+ keymap={
107
+ fg('platform_editor_a11y_table_context_menu') ? focusToContextMenuTrigger : undefined
108
+ }
105
109
  onClick={handleClick}
106
110
  iconBefore={<ExpandIcon label="" />}
107
111
  aria-label={labelCellOptions}
108
112
  aria-expanded={
109
- getBooleanFF('platform.editor.a11y-table-context-menu_y4c9c')
110
- ? isContextualMenuOpen
111
- : undefined
113
+ fg('platform_editor_a11y_table_context_menu') ? isContextualMenuOpen : undefined
112
114
  }
113
115
  />
114
116
  </div>
@@ -117,7 +117,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
117
117
  private dropdownMenuRef = React.createRef<HTMLDivElement>();
118
118
 
119
119
  componentDidMount() {
120
- if (fg('platform.editor.a11y-table-context-menu_y4c9c')) {
120
+ if (fg('platform_editor_a11y_table_context_menu')) {
121
121
  // ArrowKeyNavigationProvider in DropdownMenu expects that menu handle will stay focused
122
122
  // until user pressed ArrowDown.
123
123
  // Behavior above fails the A11Y requirement about first item in menu should be focused immediately.
@@ -141,7 +141,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
141
141
  : this.createOriginalContextMenuItems();
142
142
  let isOpenAllowed = false;
143
143
 
144
- if (fg('platform.editor.a11y-table-context-menu_y4c9c')) {
144
+ if (fg('platform_editor_a11y_table_context_menu')) {
145
145
  isOpenAllowed = isCellMenuOpenByKeyboard ? this.state.isOpenAllowed : isOpen;
146
146
  } else {
147
147
  isOpenAllowed = isOpen;
@@ -162,7 +162,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
162
162
  disableArrowKeyNavigation:
163
163
  isCellMenuOpenByKeyboard &&
164
164
  !this.state.isSubmenuOpen &&
165
- fg('platform.editor.a11y-table-context-menu_y4c9c')
165
+ fg('platform_editor_a11y_table_context_menu')
166
166
  ? false
167
167
  : true,
168
168
  }}
@@ -177,7 +177,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
177
177
  isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth
178
178
  }
179
179
  shouldFocusFirstItem={
180
- fg('platform.editor.a11y-table-context-menu_y4c9c')
180
+ fg('platform_editor_a11y_table_context_menu')
181
181
  ? () => {
182
182
  return Boolean(isCellMenuOpenByKeyboard);
183
183
  }
@@ -187,7 +187,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
187
187
  offset={offset}
188
188
  section={isDragAndDropEnabled ? { hasSeparator: true } : undefined}
189
189
  allowEnterDefaultBehavior={
190
- fg('platform.editor.a11y-table-context-menu_y4c9c') ? this.state.isSubmenuOpen : false
190
+ fg('platform_editor_a11y_table_context_menu') ? this.state.isSubmenuOpen : false
191
191
  }
192
192
  />
193
193
  </div>
@@ -227,7 +227,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
227
227
  let selectedRowIndex;
228
228
  let selectedColumnIndex;
229
229
 
230
- if (fg('platform.editor.a11y-table-context-menu_y4c9c')) {
230
+ if (fg('platform_editor_a11y_table_context_menu')) {
231
231
  const selectedRowAndColumnFromPalette = getSelectedRowAndColumnFromPalette(
232
232
  cellBackgroundColorPalette,
233
233
  background!,
@@ -263,7 +263,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
263
263
  : ClassName.CONTEXTUAL_MENU_ICON
264
264
  }
265
265
  />
266
- {fg('platform.editor.a11y-table-context-menu_y4c9c')
266
+ {fg('platform_editor_a11y_table_context_menu')
267
267
  ? isSubmenuOpen && (
268
268
  <div
269
269
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -318,9 +318,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
318
318
  )}
319
319
  </div>
320
320
  ),
321
- 'aria-expanded': fg('platform.editor.a11y-table-context-menu_y4c9c')
322
- ? isSubmenuOpen
323
- : undefined,
321
+ 'aria-expanded': fg('platform_editor_a11y_table_context_menu') ? isSubmenuOpen : undefined,
324
322
  } as MenuItem;
325
323
  }
326
324
  };
@@ -650,7 +648,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
650
648
  isCellMenuOpenByKeyboard &&
651
649
  (item.value.name !== 'background' ||
652
650
  (item.value.name === 'background' && this.state.isSubmenuOpen)) &&
653
- fg('platform.editor.a11y-table-context-menu_y4c9c')
651
+ fg('platform_editor_a11y_table_context_menu')
654
652
  ) {
655
653
  const { tr } = state;
656
654
  tr.setMeta(tablePluginKey, {
@@ -767,7 +765,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
767
765
  if (
768
766
  isCellMenuOpenByKeyboard &&
769
767
  !this.state.isSubmenuOpen &&
770
- fg('platform.editor.a11y-table-context-menu_y4c9c')
768
+ fg('platform_editor_a11y_table_context_menu')
771
769
  ) {
772
770
  this.setState({ isSubmenuOpen: true });
773
771
  }
@@ -798,7 +796,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
798
796
  isCellMenuOpenByKeyboard,
799
797
  } = this.props;
800
798
 
801
- if (fg('platform.editor.a11y-table-context-menu_y4c9c')) {
799
+ if (fg('platform_editor_a11y_table_context_menu')) {
802
800
  if (payload) {
803
801
  const { event } = payload;
804
802
  if (event && event instanceof KeyboardEvent) {