@atlaskit/editor-plugin-table 24.3.14 → 24.4.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 (73) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/nodeviews/TableResizer.js +4 -10
  3. package/dist/cjs/nodeviews/TableSSRReactContextsProvider.js +23 -0
  4. package/dist/cjs/nodeviews/table-node-views.js +1 -1
  5. package/dist/cjs/nodeviews/table.js +14 -21
  6. package/dist/cjs/pm-plugins/commands/insert.js +10 -1
  7. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +12 -25
  8. package/dist/cjs/pm-plugins/main.js +3 -1
  9. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +10 -22
  10. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +2 -1
  11. package/dist/cjs/tablePlugin.js +10 -1
  12. package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +153 -1
  13. package/dist/cjs/ui/TableMenu/cell/keys.js +19 -5
  14. package/dist/cjs/ui/TableMenu/column/getColumnMenuComponents.js +166 -1
  15. package/dist/cjs/ui/TableMenu/column/items/AddColumnRightItem.js +2 -2
  16. package/dist/cjs/ui/TableMenu/column/items/DeleteColumnItem.js +3 -3
  17. package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -2
  18. package/dist/cjs/ui/TableMenu/row/getRowMenuComponents.js +136 -1
  19. package/dist/cjs/ui/TableMenu/row/items/AddRowBelowItem.js +2 -2
  20. package/dist/cjs/ui/TableMenu/row/items/DeleteRowItem.js +3 -3
  21. package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +141 -1
  22. package/dist/cjs/ui/TableMenu/shared/selection.js +19 -0
  23. package/dist/es2019/nodeviews/TableResizer.js +4 -10
  24. package/dist/es2019/nodeviews/TableSSRReactContextsProvider.js +17 -0
  25. package/dist/es2019/nodeviews/table-node-views.js +1 -1
  26. package/dist/es2019/nodeviews/table.js +15 -22
  27. package/dist/es2019/pm-plugins/commands/insert.js +10 -1
  28. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +12 -25
  29. package/dist/es2019/pm-plugins/main.js +4 -2
  30. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +10 -22
  31. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -1
  32. package/dist/es2019/tablePlugin.js +10 -1
  33. package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +134 -2
  34. package/dist/es2019/ui/TableMenu/cell/keys.js +25 -2
  35. package/dist/es2019/ui/TableMenu/column/getColumnMenuComponents.js +144 -1
  36. package/dist/es2019/ui/TableMenu/column/items/AddColumnRightItem.js +2 -2
  37. package/dist/es2019/ui/TableMenu/column/items/DeleteColumnItem.js +3 -3
  38. package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -2
  39. package/dist/es2019/ui/TableMenu/row/getRowMenuComponents.js +118 -1
  40. package/dist/es2019/ui/TableMenu/row/items/AddRowBelowItem.js +2 -2
  41. package/dist/es2019/ui/TableMenu/row/items/DeleteRowItem.js +3 -3
  42. package/dist/es2019/ui/TableMenu/shared/getSharedItems.js +130 -4
  43. package/dist/es2019/ui/TableMenu/shared/selection.js +14 -0
  44. package/dist/esm/nodeviews/TableResizer.js +4 -10
  45. package/dist/esm/nodeviews/TableSSRReactContextsProvider.js +16 -0
  46. package/dist/esm/nodeviews/table-node-views.js +1 -1
  47. package/dist/esm/nodeviews/table.js +15 -22
  48. package/dist/esm/pm-plugins/commands/insert.js +10 -1
  49. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +12 -25
  50. package/dist/esm/pm-plugins/main.js +4 -2
  51. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +10 -22
  52. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +2 -1
  53. package/dist/esm/tablePlugin.js +10 -1
  54. package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +154 -2
  55. package/dist/esm/ui/TableMenu/cell/keys.js +16 -2
  56. package/dist/esm/ui/TableMenu/column/getColumnMenuComponents.js +166 -1
  57. package/dist/esm/ui/TableMenu/column/items/AddColumnRightItem.js +2 -2
  58. package/dist/esm/ui/TableMenu/column/items/DeleteColumnItem.js +3 -3
  59. package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -2
  60. package/dist/esm/ui/TableMenu/row/getRowMenuComponents.js +136 -1
  61. package/dist/esm/ui/TableMenu/row/items/AddRowBelowItem.js +2 -2
  62. package/dist/esm/ui/TableMenu/row/items/DeleteRowItem.js +3 -3
  63. package/dist/esm/ui/TableMenu/shared/getSharedItems.js +144 -4
  64. package/dist/esm/ui/TableMenu/shared/selection.js +14 -0
  65. package/dist/types/nodeviews/TableSSRReactContextsProvider.d.ts +8 -0
  66. package/dist/types/nodeviews/table-node-views.d.ts +2 -0
  67. package/dist/types/nodeviews/table.d.ts +3 -1
  68. package/dist/types/nodeviews/types.d.ts +2 -0
  69. package/dist/types/tablePluginType.d.ts +3 -2
  70. package/dist/types/ui/TableMenu/cell/keys.d.ts +2 -0
  71. package/dist/types/ui/TableMenu/column/getColumnMenuComponents.d.ts +1 -1
  72. package/dist/types/ui/TableMenu/shared/selection.d.ts +8 -0
  73. package/package.json +9 -3
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getMenuSelectionRect = void 0;
7
+ var _utils = require("@atlaskit/editor-tables/utils");
8
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
+ /**
10
+ * Resolve the table `Rect` for the current selection. Falls back to the closest cell's rect
11
+ * for a `TextSelection` (cell menu), where `getSelectionRect` returns `undefined`. Gated:
12
+ * with the gate off this behaves exactly like `getSelectionRect`.
13
+ */
14
+ var getMenuSelectionRect = exports.getMenuSelectionRect = function getMenuSelectionRect(selection) {
15
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_table_cell_menu_update')) {
16
+ return (0, _utils.getSelectionRect)(selection);
17
+ }
18
+ return (0, _utils.isSelectionType)(selection, 'cell') ? (0, _utils.getSelectionRect)(selection) : (0, _utils.findCellRectClosestToPos)(selection.$from);
19
+ };
@@ -246,11 +246,8 @@ export const TableResizer = ({
246
246
  };
247
247
  }, [editorView, displayGuideline, displayGapCursor]);
248
248
  const handleResizeStart = useCallback(() => {
249
- var _pluginInjectionApi$u;
250
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
251
- var _insm$session;
252
- (_insm$session = insm.session) === null || _insm$session === void 0 ? void 0 : _insm$session.startFeature('tableResize');
253
- }
249
+ var _insm$session, _pluginInjectionApi$u;
250
+ (_insm$session = insm.session) === null || _insm$session === void 0 ? void 0 : _insm$session.startFeature('tableResize');
254
251
  startMeasure();
255
252
  isResizing.current = true;
256
253
  const {
@@ -326,7 +323,7 @@ export const TableResizer = ({
326
323
  }, [countFrames, isCommentEditor, isChromelessEditor, isFullPageAppearance, isTableScalingEnabled, allowFixedColumnWidthOption, isFullWidthModeEnabled, excludeGuidelineConfig, tableRef, node, editorView, updateActiveGuidelines, containerWidth, lineLength, updateWidth, getPos, switchToCenterAlignment]);
327
324
  const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
328
325
  const handleResizeStop = useCallback((originalState, delta) => {
329
- var _node$attrs$localId2, _node$attrs2, _pluginInjectionApi$u3;
326
+ var _node$attrs$localId2, _node$attrs2, _pluginInjectionApi$u3, _insm$session2;
330
327
  isResizing.current = false;
331
328
  let newWidth = originalState.width + delta.width;
332
329
  const originalNewWidth = newWidth;
@@ -410,10 +407,7 @@ export const TableResizer = ({
410
407
  if (onResizeStop) {
411
408
  onResizeStop();
412
409
  }
413
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
414
- var _insm$session2;
415
- (_insm$session2 = insm.session) === null || _insm$session2 === void 0 ? void 0 : _insm$session2.endFeature('tableResize');
416
- }
410
+ (_insm$session2 = insm.session) === null || _insm$session2 === void 0 ? void 0 : _insm$session2.endFeature('tableResize');
417
411
  return newWidth;
418
412
  }, [editorView, getPos, node, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, pluginInjectionApi, attachAnalyticsEvent, tableRef, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage, isFullPageAppearance]);
419
413
  const handleTableSizeChangeOnKeypress = useCallback(step => {
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { RawIntlProvider } from 'react-intl';
3
+ import { isSSR, isSSRStreaming } from '@atlaskit/editor-common/core-utils';
4
+ export function TableSSRReactContextsProvider({
5
+ children,
6
+ intl
7
+ }) {
8
+ if (!isSSR() || !isSSRStreaming()) {
9
+ return children;
10
+ }
11
+ if (!intl) {
12
+ return children;
13
+ }
14
+ return /*#__PURE__*/React.createElement(RawIntlProvider, {
15
+ value: intl
16
+ }, children);
17
+ }
@@ -7,7 +7,7 @@ import TableRow from './TableRow';
7
7
  import TableRowNativeStickyWithFallback from './TableRowNativeStickyWithFallback';
8
8
  export const tableView = options => {
9
9
  return (node, view, getPos) => {
10
- return createTableView(node, view, getPos, options.portalProviderAPI, options.eventDispatcher, options.getEditorContainerWidth, options.getEditorFeatureFlags, options.dispatchAnalyticsEvent, options.pluginInjectionApi, options.isCommentEditor, options.isChromelessEditor, options === null || options === void 0 ? void 0 : options.allowFixedColumnWidthOption);
10
+ return createTableView(node, view, getPos, options.portalProviderAPI, options.eventDispatcher, options.getEditorContainerWidth, options.getEditorFeatureFlags, options.dispatchAnalyticsEvent, options.pluginInjectionApi, options.isCommentEditor, options.isChromelessEditor, options === null || options === void 0 ? void 0 : options.allowFixedColumnWidthOption, options.intl);
11
11
  };
12
12
  };
13
13
  export const tableCellView = options => {
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
- import { isSSR, isSSRStreaming } from '@atlaskit/editor-common/core-utils';
3
+ import { isSSRStreaming } from '@atlaskit/editor-common/core-utils';
4
4
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
5
5
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
6
6
  import { isTableInContentMode } from '@atlaskit/editor-common/table';
@@ -17,6 +17,7 @@ import { isTableNested, tablesHaveDifferentColumnWidths } from '../pm-plugins/ut
17
17
  import { isContentModeSupported } from '../pm-plugins/utils/tableMode/is-content-mode-supported';
18
18
  import { RoundedTableEdges } from './rounded-table-edges';
19
19
  import { TableComponentWithSharedState } from './TableComponentWithSharedState';
20
+ import { TableSSRReactContextsProvider } from './TableSSRReactContextsProvider';
20
21
  import { tableNodeSpecWithFixedToDOM } from './toDOM';
21
22
  const tableAttributes = node => {
22
23
  return {
@@ -62,6 +63,7 @@ export default class TableView extends ReactNodeView {
62
63
  this.eventDispatcher = props.eventDispatcher;
63
64
  this.options = props.options;
64
65
  this.getEditorFeatureFlags = props.getEditorFeatureFlags;
66
+ this.intl = props.intl;
65
67
  if (expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true)) {
66
68
  this.roundedTableEdges = new RoundedTableEdges(() => this.table, props.node);
67
69
  }
@@ -140,7 +142,11 @@ export default class TableView extends ReactNodeView {
140
142
  }
141
143
 
142
144
  // Remove the ProseMirror table DOM structure to avoid duplication, as it's replaced with the React table node.
143
- if (this.dom && this.renderedDOM) {
145
+ // In SSR streaming the portal renders via `container.innerHTML = html` (portal/common.tsx), which detaches
146
+ // `renderedDOM` from `dom` before this runs; require it to still be a child so `removeChild` doesn't throw
147
+ // `NotFoundError` (which would make EditorSSRRenderer fall back to the position-blind schema toDOM and lose
148
+ // nested detection). CSR keeps the original condition unchanged.
149
+ if (this.dom && this.renderedDOM && (!isSSRStreaming() || this.renderedDOM.parentNode === this.dom)) {
144
150
  this.dom.removeChild(this.renderedDOM);
145
151
  }
146
152
  // Move the table from the ProseMirror table structure into the React rendered table node.
@@ -232,7 +238,9 @@ export default class TableView extends ReactNodeView {
232
238
  return didUpdate;
233
239
  }
234
240
  render(props, forwardRef) {
235
- return /*#__PURE__*/React.createElement(TableComponentWithSharedState, {
241
+ return /*#__PURE__*/React.createElement(TableSSRReactContextsProvider, {
242
+ intl: this.intl
243
+ }, /*#__PURE__*/React.createElement(TableComponentWithSharedState, {
236
244
  forwardRef: forwardRef,
237
245
  getNode: this.getNode,
238
246
  view: props.view,
@@ -247,7 +255,7 @@ export default class TableView extends ReactNodeView {
247
255
  getEditorFeatureFlags: props.getEditorFeatureFlags,
248
256
  dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
249
257
  allowFixedColumnWidthOption: props.allowFixedColumnWidthOption
250
- });
258
+ }));
251
259
  }
252
260
  viewShouldUpdate(nextNode) {
253
261
  const {
@@ -315,7 +323,7 @@ export default class TableView extends ReactNodeView {
315
323
  super.destroy();
316
324
  }
317
325
  }
318
- export const createTableView = (node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isCommentEditor, isChromelessEditor, allowFixedColumnWidthOption) => {
326
+ export const createTableView = (node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isCommentEditor, isChromelessEditor, allowFixedColumnWidthOption, intl) => {
319
327
  var _pluginInjectionApi$t;
320
328
  const {
321
329
  pluginConfig,
@@ -332,22 +340,6 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
332
340
  } = getPluginConfig(pluginConfig);
333
341
  const isTableFixedColumnWidthsOptionEnabled = (fg('platform_editor_table_fixed_column_width_prop') ? allowFixedColumnWidthOption : getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags().tableWithFixedColumnWidthsOption) || false;
334
342
  const shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
335
-
336
- // In SSR use native ProseMirror spec-based render for table nodes
337
- if (isSSR() && isSSRStreaming()) {
338
- const isNested = isTableNested(view.state, typeof getPos === 'function' ? getPos() : undefined);
339
- const tableDOMStructure = tableNodeSpecWithFixedToDOM({
340
- allowColumnResizing: allowColumnResizing !== null && allowColumnResizing !== void 0 ? allowColumnResizing : false,
341
- tableResizingEnabled: allowTableResizing !== null && allowTableResizing !== void 0 ? allowTableResizing : false,
342
- getEditorContainerWidth,
343
- isTableScalingEnabled,
344
- shouldUseIncreasedScalingPercent,
345
- isCommentEditor,
346
- isChromelessEditor,
347
- isNested
348
- }).toDOM(node);
349
- return DOMSerializer.renderSpec(document, tableDOMStructure);
350
- }
351
343
  return new TableView({
352
344
  node,
353
345
  view,
@@ -371,6 +363,7 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
371
363
  getEditorFeatureFlags,
372
364
  dispatchAnalyticsEvent,
373
365
  pluginInjectionApi,
374
- allowFixedColumnWidthOption
366
+ allowFixedColumnWidthOption,
367
+ intl
375
368
  }).init();
376
369
  };
@@ -6,7 +6,9 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
7
7
  import { TableMap } from '@atlaskit/editor-tables/table-map';
8
8
  import { addColumnAt as addColumnAtPMUtils, addRowAt, findTable, selectedRect } from '@atlaskit/editor-tables/utils';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
9
10
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
10
12
  import { updateRowOrColumnMovedTransform } from '../analytics/commands';
11
13
  import { META_KEYS } from '../table-analytics';
12
14
  import { rescaleColumns } from '../transforms/column-width';
@@ -232,7 +234,14 @@ export const insertTableWithNestingSupport = ({
232
234
  }, api, analyticsPayload) => ({
233
235
  tr
234
236
  }) => {
235
- var _api$contentInsertion, _api$contentInsertion2, _tr$selection$$from$n2;
237
+ var _api$markdownMode, _api$contentInsertion, _api$contentInsertion2, _tr$selection$$from$n2;
238
+ // Delegate to the markdown plugin to insert a markdown table string at the CM cursor position.
239
+ const markdownState = api === null || api === void 0 ? void 0 : (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 ? void 0 : _api$markdownMode.sharedState.currentState();
240
+ if (markdownState !== null && markdownState !== void 0 && markdownState.isMarkdownMode && (markdownState === null || markdownState === void 0 ? void 0 : markdownState.view) === 'syntax' && expValEqualsNoExposure('cc-markdown-mode', 'isEnabled', true) && fg('platform_editor_markdown_compatible_toolbar')) {
241
+ var _api$markdownMode2;
242
+ api === null || api === void 0 ? void 0 : (_api$markdownMode2 = api.markdownMode) === null || _api$markdownMode2 === void 0 ? void 0 : _api$markdownMode2.actions.insertSourceTable(createTableProps.rowsCount, createTableProps.colsCount);
243
+ return tr;
244
+ }
236
245
  const {
237
246
  schema
238
247
  } = tr.doc.type;
@@ -35,20 +35,16 @@ const destroyFn = (editorView, editorAnalyticsAPI, isTableScalingEnabled, isTabl
35
35
  return type === 'table-row';
36
36
  },
37
37
  onDragStart() {
38
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
39
- var _insm$session;
40
- (_insm$session = insm.session) === null || _insm$session === void 0 ? void 0 : _insm$session.startFeature('tableDragAndDrop');
41
- }
38
+ var _insm$session;
39
+ (_insm$session = insm.session) === null || _insm$session === void 0 ? void 0 : _insm$session.startFeature('tableDragAndDrop');
42
40
  // auto scroller doesn't work when scroll-behavior: smooth is set, this monitor temporarily removes it via inline styles
43
41
  // Ignored via go/ees005
44
42
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
45
43
  editorPageScrollContainer.style.setProperty('scroll-behavior', 'unset');
46
44
  },
47
45
  onDrop() {
48
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
49
- var _insm$session2;
50
- (_insm$session2 = insm.session) === null || _insm$session2 === void 0 ? void 0 : _insm$session2.endFeature('tableDragAndDrop');
51
- }
46
+ var _insm$session2;
47
+ (_insm$session2 = insm.session) === null || _insm$session2 === void 0 ? void 0 : _insm$session2.endFeature('tableDragAndDrop');
52
48
  // 'null' will remove the inline style
53
49
  // Ignored via go/ees005
54
50
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -89,10 +85,8 @@ const destroyFn = (editorView, editorAnalyticsAPI, isTableScalingEnabled, isTabl
89
85
  return localId === (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId);
90
86
  },
91
87
  onDragStart: () => {
92
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
93
- var _insm$session3;
94
- (_insm$session3 = insm.session) === null || _insm$session3 === void 0 ? void 0 : _insm$session3.startFeature('tableDragAndDrop');
95
- }
88
+ var _insm$session3;
89
+ (_insm$session3 = insm.session) === null || _insm$session3 === void 0 ? void 0 : _insm$session3.startFeature('tableDragAndDrop');
96
90
  if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
97
91
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
98
92
  tr
@@ -165,13 +159,10 @@ const destroyFn = (editorView, editorAnalyticsAPI, isTableScalingEnabled, isTabl
165
159
  }
166
160
  // If no data can be found then it's most like we do not want to perform any drop action
167
161
  if (!data) {
168
- var _event$source, _event$source$data, _event$source2, _event$source2$data;
162
+ var _insm$session4, _event$source, _event$source$data, _event$source2, _event$source2$data;
169
163
  // If we're able to determine the source type of the dropped element then we should report to analytics that
170
164
  // the drop event was cancelled. Otherwise we will cancel silently.
171
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
172
- var _insm$session4;
173
- (_insm$session4 = insm.session) === null || _insm$session4 === void 0 ? void 0 : _insm$session4.endFeature('tableDragAndDrop');
174
- }
165
+ (_insm$session4 = insm.session) === null || _insm$session4 === void 0 ? void 0 : _insm$session4.endFeature('tableDragAndDrop');
175
166
  if ((event === null || event === void 0 ? void 0 : (_event$source = event.source) === null || _event$source === void 0 ? void 0 : (_event$source$data = _event$source.data) === null || _event$source$data === void 0 ? void 0 : _event$source$data.type) === 'table-row' || (event === null || event === void 0 ? void 0 : (_event$source2 = event.source) === null || _event$source2 === void 0 ? void 0 : (_event$source2$data = _event$source2.data) === null || _event$source2$data === void 0 ? void 0 : _event$source2$data.type) === 'table-column') {
176
167
  var _event$source$data2;
177
168
  return clearDropTargetWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, event.source.data.type, (_event$source$data2 = event.source.data) === null || _event$source$data2 === void 0 ? void 0 : _event$source$data2.indexes, TABLE_STATUS.CANCELLED, tr)(editorView.state, editorView.dispatch);
@@ -197,16 +188,15 @@ const destroyFn = (editorView, editorAnalyticsAPI, isTableScalingEnabled, isTabl
197
188
 
198
189
  // If the drop target index contains merged cells then we should not allow the drop to occur.
199
190
  if (hasMergedCellsInBetween([targetAdjustedIndex - 1, targetAdjustedIndex], sourceType === 'table-row' ? DropTargetType.ROW : DropTargetType.COLUMN)(editorView.state.selection)) {
191
+ var _insm$session5;
200
192
  clearDropTargetWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, sourceType, sourceIndexes,
201
193
  // This event is mrked as invalid because the user is attempting to drop an element in an area which has merged cells.
202
194
  TABLE_STATUS.INVALID, tr)(editorView.state, editorView.dispatch);
203
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
204
- var _insm$session5;
205
- (_insm$session5 = insm.session) === null || _insm$session5 === void 0 ? void 0 : _insm$session5.endFeature('tableDragAndDrop');
206
- }
195
+ (_insm$session5 = insm.session) === null || _insm$session5 === void 0 ? void 0 : _insm$session5.endFeature('tableDragAndDrop');
207
196
  return;
208
197
  }
209
198
  requestAnimationFrame(() => {
199
+ var _insm$session6;
210
200
  if (behaviour === 'clone') {
211
201
  cloneSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, sourceType, sourceIndexes, targetIndex, targetDirection, tr)(editorView.state, editorView.dispatch);
212
202
  } else {
@@ -234,10 +224,7 @@ const destroyFn = (editorView, editorAnalyticsAPI, isTableScalingEnabled, isTabl
234
224
  }
235
225
  }
236
226
  editorView.focus();
237
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
238
- var _insm$session6;
239
- (_insm$session6 = insm.session) === null || _insm$session6 === void 0 ? void 0 : _insm$session6.endFeature('tableDragAndDrop');
240
- }
227
+ (_insm$session6 = insm.session) === null || _insm$session6 === void 0 ? void 0 : _insm$session6.endFeature('tableDragAndDrop');
241
228
  });
242
229
  }
243
230
  }));
@@ -1,7 +1,7 @@
1
1
  import { bind } from 'bind-event-listener';
2
2
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { getBrowserInfo } from '@atlaskit/editor-common/browser';
4
- import { insideTable } from '@atlaskit/editor-common/core-utils';
4
+ import { insideTable, isSSRStreaming } from '@atlaskit/editor-common/core-utils';
5
5
  import { isNestedTablesSupported } from '@atlaskit/editor-common/nesting';
6
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  import { transformSliceToRemoveOpenBodiedExtension, transformSliceToRemoveOpenExpand, transformSliceToRemoveOpenLayoutNodes, transformSliceToRemoveOpenMultiBodiedExtension, transformSliceToRemoveOpenNestedExpand } from '@atlaskit/editor-common/transforms';
@@ -60,6 +60,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
60
60
  }
61
61
  return editorView.state;
62
62
  };
63
+ const intl = isSSRStreaming() ? getIntl() : undefined;
63
64
  const getNodeView = () => {
64
65
  return {
65
66
  table: tableView({
@@ -71,7 +72,8 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
71
72
  pluginInjectionApi,
72
73
  isCommentEditor,
73
74
  isChromelessEditor,
74
- allowFixedColumnWidthOption
75
+ allowFixedColumnWidthOption,
76
+ intl
75
77
  }),
76
78
  tableRow: tableRowView({
77
79
  eventDispatcher,
@@ -3,7 +3,6 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
3
3
  import { TableMap } from '@atlaskit/editor-tables/table-map';
4
4
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
5
5
  import { insm } from '@atlaskit/insm';
6
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
6
  import { stopKeyboardColumnResizing } from '../commands/column-resize';
8
7
  import { updateResizeHandleDecorations } from '../commands/misc';
9
8
  import { getPluginState as getTablePluginState } from '../plugin-factory';
@@ -19,7 +18,7 @@ import { currentColWidth, getTableMaxWidth, pointsAtCell, getScalingPercentForTa
19
18
  import { resizeColumn } from './utils/resize-column';
20
19
  import { getResizeState } from './utils/resize-state';
21
20
  export const handleMouseDown = (view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isCommentEditor) => {
22
- var _originalTable$attrs;
21
+ var _insm$session, _originalTable$attrs;
23
22
  const {
24
23
  state,
25
24
  dispatch
@@ -36,10 +35,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
36
35
  isKeyboardResize
37
36
  } = getTablePluginState(state);
38
37
  event.preventDefault();
39
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
40
- var _insm$session;
41
- (_insm$session = insm.session) === null || _insm$session === void 0 ? void 0 : _insm$session.startFeature('tableColumnResize');
42
- }
38
+ (_insm$session = insm.session) === null || _insm$session === void 0 ? void 0 : _insm$session.startFeature('tableColumnResize');
43
39
  const tr = view.state.tr;
44
40
  tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
45
41
  name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED_COLUMN
@@ -136,17 +132,13 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
136
132
  isTableHovered
137
133
  } = getTablePluginState(state);
138
134
  if (resizeHandlePos === null) {
139
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
140
- var _insm$session2;
141
- (_insm$session2 = insm.session) === null || _insm$session2 === void 0 ? void 0 : _insm$session2.endFeature('tableColumnResize');
142
- }
135
+ var _insm$session2;
136
+ (_insm$session2 = insm.session) === null || _insm$session2 === void 0 ? void 0 : _insm$session2.endFeature('tableColumnResize');
143
137
  return stopResizing()(state, dispatch);
144
138
  }
145
139
  if (!pointsAtCell(state.doc.resolve(resizeHandlePos))) {
146
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
147
- var _insm$session3;
148
- (_insm$session3 = insm.session) === null || _insm$session3 === void 0 ? void 0 : _insm$session3.endFeature('tableColumnResize');
149
- }
140
+ var _insm$session3;
141
+ (_insm$session3 = insm.session) === null || _insm$session3 === void 0 ? void 0 : _insm$session3.endFeature('tableColumnResize');
150
142
  return;
151
143
  }
152
144
  // resizeHandlePos could be remapped via a collab change.
@@ -159,10 +151,8 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
159
151
 
160
152
  // If we let go in the same place we started, don't need to do anything.
161
153
  if (dragging && clientX === dragging.startX) {
162
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
163
- var _insm$session4;
164
- (_insm$session4 = insm.session) === null || _insm$session4 === void 0 ? void 0 : _insm$session4.endFeature('tableColumnResize');
165
- }
154
+ var _insm$session4;
155
+ (_insm$session4 = insm.session) === null || _insm$session4 === void 0 ? void 0 : _insm$session4.endFeature('tableColumnResize');
166
156
  if (isKeyboardResize || !isTableHovered) {
167
157
  /** if column resize had started via keyboard but continued by mouse
168
158
  * or mouse pointer leaves the table but mouse button still pressed
@@ -176,6 +166,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
176
166
  tr
177
167
  } = state;
178
168
  if (dragging) {
169
+ var _insm$session5;
179
170
  const {
180
171
  startX
181
172
  } = dragging;
@@ -233,10 +224,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
233
224
  }
234
225
  })(tr);
235
226
  }
236
- if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
237
- var _insm$session5;
238
- (_insm$session5 = insm.session) === null || _insm$session5 === void 0 ? void 0 : _insm$session5.endFeature('tableColumnResize');
239
- }
227
+ (_insm$session5 = insm.session) === null || _insm$session5 === void 0 ? void 0 : _insm$session5.endFeature('tableColumnResize');
240
228
  if (isKeyboardResize || !isTableHovered) {
241
229
  /** if column resize had started via keyboard but continued by mouse
242
230
  * or mouse pointer leaves the table but mouse button still pressed
@@ -1,3 +1,4 @@
1
+ import { isSSRStreaming } from '@atlaskit/editor-common/core-utils';
1
2
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
2
3
  import { calcTableColumnWidths, getFragmentBackingArray } from '@atlaskit/editor-common/utils';
3
4
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
@@ -22,7 +23,7 @@ const generateColStyle = (fixedColWidth, tableWidth, isCommentEditor, isChromele
22
23
  if (hasTableBeenResized) {
23
24
  return `width: max(${fixedColWidth}px, ${tableCellMinWidth}px)`;
24
25
  }
25
- return `width: ${tableCellMinWidth}px)`;
26
+ return isSSRStreaming() ? `width: ${tableCellMinWidth}px` : `width: ${tableCellMinWidth}px)`;
26
27
  }
27
28
  if (isFullPageEditor || !isFullPageEditor && isTableHasWidth) {
28
29
  const scaledPercent = isNumberColumnEnabled ? `calc(calc(var(--ak-editor-table-width) - ${akEditorTableNumberColumnWidth}px - 1px)/${tableWidth})` : `calc(calc(var(--ak-editor-table-width) - 1px)/${tableWidth})`;
@@ -13,6 +13,7 @@ import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/ut
13
13
  import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
14
14
  import { fg } from '@atlaskit/platform-feature-flags';
15
15
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
16
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
16
17
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
17
18
  import { tableNodeSpecWithFixedToDOM } from './nodeviews/toDOM';
18
19
  import { createPlugin as createActiveCellHighlightPlugin } from './pm-plugins/active-cell-highlight/plugin';
@@ -544,7 +545,7 @@ const tablePlugin = ({
544
545
  keyshortcut: tooltip(toggleTable),
545
546
  icon: () => /*#__PURE__*/React.createElement(IconTable, null),
546
547
  action(insert, state) {
547
- var _api$table, _options$tableOptions6, _tr$selection$$from$n;
548
+ var _api$markdownMode, _api$table, _options$tableOptions6, _tr$selection$$from$n;
548
549
  if (isTableSelectorEnabled) {
549
550
  const tr = insert('');
550
551
  tr.setMeta(sizeSelectorPluginKey, {
@@ -553,6 +554,14 @@ const tablePlugin = ({
553
554
  return tr;
554
555
  }
555
556
 
557
+ // Delegate to the markdown plugin to insert a markdown table string at the CM cursor position.
558
+ const markdownState = api === null || api === void 0 ? void 0 : (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 ? void 0 : _api$markdownMode.sharedState.currentState();
559
+ if (markdownState !== null && markdownState !== void 0 && markdownState.isMarkdownMode && (markdownState === null || markdownState === void 0 ? void 0 : markdownState.view) === 'syntax' && expValEqualsNoExposure('cc-markdown-mode', 'isEnabled', true) && fg('platform_editor_markdown_compatible_toolbar')) {
560
+ var _api$markdownMode2;
561
+ api === null || api === void 0 ? void 0 : (_api$markdownMode2 = api.markdownMode) === null || _api$markdownMode2 === void 0 ? void 0 : _api$markdownMode2.actions.insertSourceTable();
562
+ return state.tr;
563
+ }
564
+
556
565
  // see comment on tablesPlugin.getSharedState on usage
557
566
  const tableState = api === null || api === void 0 ? void 0 : (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
558
567
  const tableNodeProps = {
@@ -4,14 +4,146 @@ import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
4
4
  import AlignPositionBottomIcon from '@atlaskit/icon-lab/core/align-position-bottom';
5
5
  import AlignPositionCenterVerticalIcon from '@atlaskit/icon-lab/core/align-position-center-vertical';
6
6
  import AlignPositionTopIcon from '@atlaskit/icon-lab/core/align-position-top';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { MergeCellsItem } from './items/MergeCellsItem';
8
9
  import { SplitCellItem } from './items/SplitCellItem';
9
10
  import { VerticalAlignDropdownItem } from './items/VerticalAlignDropdownItem';
10
11
  import { VerticalAlignNestedMenu } from './items/VerticalAlignNestedMenu';
11
- import { CELL_MENU, CELL_ACTION_SECTION, CELL_DANGER_SECTION, CELL_MENU_RANK, MERGE_CELLS_ITEM, SPLIT_CELL_ITEM, CELL_ACTION_SECTION_RANK, VERTICAL_ALIGN_BOTTOM_ITEM, VERTICAL_ALIGN_MENU, VERTICAL_ALIGN_MENU_RANK, VERTICAL_ALIGN_MENU_SECTION, VERTICAL_ALIGN_MENU_SECTION_RANK, VERTICAL_ALIGN_MIDDLE_ITEM, VERTICAL_ALIGN_TOP_ITEM } from './keys';
12
+ import { CELL_MENU, CELL_ACTION_SECTION, CELL_ADD_SECTION, CELL_DANGER_SECTION, CELL_MENU_RANK, MERGE_CELLS_ITEM, SPLIT_CELL_ITEM, CELL_ACTION_SECTION_RANK, CELL_ADD_SECTION_RANK, VERTICAL_ALIGN_BOTTOM_ITEM, VERTICAL_ALIGN_MENU, VERTICAL_ALIGN_MENU_RANK, VERTICAL_ALIGN_MENU_SECTION, VERTICAL_ALIGN_MENU_SECTION_RANK, VERTICAL_ALIGN_MIDDLE_ITEM, VERTICAL_ALIGN_TOP_ITEM } from './keys';
12
13
  export const getCellMenuComponents = ({
13
14
  api
14
- }) => [
15
+ }) => fg('platform_editor_table_cell_menu_update') ? [
16
+ // --- Cell menu update ON ---
17
+ // Merge/Split cells move into the Add section (alongside the shared add/distribute
18
+ // items); the danger section gains the shared Delete column/row items.
19
+
20
+ // --- Menu surface ---
21
+ {
22
+ type: CELL_MENU.type,
23
+ key: CELL_MENU.key
24
+ },
25
+ // --- Main action section (Background color, Vertical align) ---
26
+ {
27
+ type: CELL_ACTION_SECTION.type,
28
+ key: CELL_ACTION_SECTION.key,
29
+ parents: [{
30
+ type: CELL_MENU.type,
31
+ key: CELL_MENU.key,
32
+ rank: CELL_MENU_RANK[CELL_ACTION_SECTION.key]
33
+ }],
34
+ component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, props.children)
35
+ }, {
36
+ type: VERTICAL_ALIGN_MENU.type,
37
+ key: VERTICAL_ALIGN_MENU.key,
38
+ parents: [{
39
+ type: CELL_ACTION_SECTION.type,
40
+ key: CELL_ACTION_SECTION.key,
41
+ rank: CELL_ACTION_SECTION_RANK[VERTICAL_ALIGN_MENU.key]
42
+ }],
43
+ component: props => /*#__PURE__*/React.createElement(VerticalAlignNestedMenu, null, props.children)
44
+ }, {
45
+ type: VERTICAL_ALIGN_MENU_SECTION.type,
46
+ key: VERTICAL_ALIGN_MENU_SECTION.key,
47
+ parents: [{
48
+ type: VERTICAL_ALIGN_MENU.type,
49
+ key: VERTICAL_ALIGN_MENU.key,
50
+ rank: VERTICAL_ALIGN_MENU_RANK[VERTICAL_ALIGN_MENU_SECTION.key]
51
+ }],
52
+ component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, props.children)
53
+ }, {
54
+ type: VERTICAL_ALIGN_TOP_ITEM.type,
55
+ key: VERTICAL_ALIGN_TOP_ITEM.key,
56
+ parents: [{
57
+ type: VERTICAL_ALIGN_MENU_SECTION.type,
58
+ key: VERTICAL_ALIGN_MENU_SECTION.key,
59
+ rank: VERTICAL_ALIGN_MENU_SECTION_RANK[VERTICAL_ALIGN_TOP_ITEM.key]
60
+ }],
61
+ component: () => /*#__PURE__*/React.createElement(VerticalAlignDropdownItem, {
62
+ api: api,
63
+ icon: AlignPositionTopIcon,
64
+ label: messages.cellAlignmentTop,
65
+ value: "top"
66
+ })
67
+ }, {
68
+ type: VERTICAL_ALIGN_MIDDLE_ITEM.type,
69
+ key: VERTICAL_ALIGN_MIDDLE_ITEM.key,
70
+ parents: [{
71
+ type: VERTICAL_ALIGN_MENU_SECTION.type,
72
+ key: VERTICAL_ALIGN_MENU_SECTION.key,
73
+ rank: VERTICAL_ALIGN_MENU_SECTION_RANK[VERTICAL_ALIGN_MIDDLE_ITEM.key]
74
+ }],
75
+ component: () => /*#__PURE__*/React.createElement(VerticalAlignDropdownItem, {
76
+ api: api,
77
+ icon: AlignPositionCenterVerticalIcon,
78
+ label: messages.cellAlignmentMiddle,
79
+ value: "middle"
80
+ })
81
+ }, {
82
+ type: VERTICAL_ALIGN_BOTTOM_ITEM.type,
83
+ key: VERTICAL_ALIGN_BOTTOM_ITEM.key,
84
+ parents: [{
85
+ type: VERTICAL_ALIGN_MENU_SECTION.type,
86
+ key: VERTICAL_ALIGN_MENU_SECTION.key,
87
+ rank: VERTICAL_ALIGN_MENU_SECTION_RANK[VERTICAL_ALIGN_BOTTOM_ITEM.key]
88
+ }],
89
+ component: () => /*#__PURE__*/React.createElement(VerticalAlignDropdownItem, {
90
+ api: api,
91
+ icon: AlignPositionBottomIcon,
92
+ label: messages.cellAlignmentBottom,
93
+ value: "bottom"
94
+ })
95
+ },
96
+ // --- Add / Move section (shared Add column right / Add row below / Distribute
97
+ // columns are registered in `../shared/getSharedItems`; Merge/Split cells below) ---
98
+ {
99
+ type: CELL_ADD_SECTION.type,
100
+ key: CELL_ADD_SECTION.key,
101
+ parents: [{
102
+ type: CELL_MENU.type,
103
+ key: CELL_MENU.key,
104
+ rank: CELL_MENU_RANK[CELL_ADD_SECTION.key]
105
+ }],
106
+ component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
107
+ hasSeparator: true
108
+ }, props.children)
109
+ }, {
110
+ type: MERGE_CELLS_ITEM.type,
111
+ key: MERGE_CELLS_ITEM.key,
112
+ parents: [{
113
+ type: CELL_ADD_SECTION.type,
114
+ key: CELL_ADD_SECTION.key,
115
+ rank: CELL_ADD_SECTION_RANK[MERGE_CELLS_ITEM.key]
116
+ }],
117
+ component: () => /*#__PURE__*/React.createElement(MergeCellsItem, {
118
+ api: api
119
+ })
120
+ }, {
121
+ type: SPLIT_CELL_ITEM.type,
122
+ key: SPLIT_CELL_ITEM.key,
123
+ parents: [{
124
+ type: CELL_ADD_SECTION.type,
125
+ key: CELL_ADD_SECTION.key,
126
+ rank: CELL_ADD_SECTION_RANK[SPLIT_CELL_ITEM.key]
127
+ }],
128
+ component: () => /*#__PURE__*/React.createElement(SplitCellItem, {
129
+ api: api
130
+ })
131
+ },
132
+ // --- Danger section (Clear cell + shared Delete column / Delete row) ---
133
+ {
134
+ type: CELL_DANGER_SECTION.type,
135
+ key: CELL_DANGER_SECTION.key,
136
+ parents: [{
137
+ type: CELL_MENU.type,
138
+ key: CELL_MENU.key,
139
+ rank: CELL_MENU_RANK[CELL_DANGER_SECTION.key]
140
+ }],
141
+ component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
142
+ hasSeparator: true
143
+ }, props.children)
144
+ }] : [
145
+ // --- Cell menu update OFF: legacy cell menu (Merge/Split live in the action section) ---
146
+
15
147
  // --- Menu surface ---
16
148
  {
17
149
  type: CELL_MENU.type,