@atlaskit/editor-plugin-table 27.0.2 → 27.0.4

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 27.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 27.0.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [`ce7484d621739`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ce7484d621739) -
14
+ Fix table controls after editor remounts by refreshing stale toolbar anchors and publishing the
15
+ selected table ref before the first interaction, behind the
16
+ `platform_editor_table_toolbar_position_fix` experiment.
17
+
3
18
  ## 27.0.2
4
19
 
5
20
  ### Patch Changes
@@ -35,6 +35,7 @@ var _customize = _interopRequireDefault(require("@atlaskit/icon/core/customize")
35
35
  var _delete = _interopRequireDefault(require("@atlaskit/icon/core/delete"));
36
36
  var _shrinkHorizontal = _interopRequireDefault(require("@atlaskit/icon/core/shrink-horizontal"));
37
37
  var _tableColumnsDistribute = _interopRequireDefault(require("@atlaskit/icon/core/table-columns-distribute"));
38
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
38
39
  var _fg = require("@atlaskit/platform-feature-flags/fg");
39
40
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
40
41
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
@@ -371,7 +372,32 @@ var getTableWrapperFromParentImpl = function getTableWrapperFromParentImpl(paren
371
372
  }
372
373
  return (0, _utils.closestElement)(tableRef, ".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER)) || undefined;
373
374
  };
375
+ var cachedTableWrapperParent;
376
+ var cachedTableWrapperEditorRoot;
377
+ var cachedTableWrapper;
378
+ var getCachedTableWrapperFromParent = function getCachedTableWrapperFromParent(parent, editorView) {
379
+ var _cachedTableWrapper;
380
+ var editorRoot = editorView.dom;
381
+ if (parent && parent === cachedTableWrapperParent && editorRoot === cachedTableWrapperEditorRoot && (_cachedTableWrapper = cachedTableWrapper) !== null && _cachedTableWrapper !== void 0 && _cachedTableWrapper.isConnected && editorRoot.isConnected && editorRoot.contains(parent) && editorRoot.contains(cachedTableWrapper) && parent.contains(cachedTableWrapper) && cachedTableWrapper.querySelector('table')) {
382
+ return cachedTableWrapper;
383
+ }
384
+ cachedTableWrapperParent = parent;
385
+ cachedTableWrapperEditorRoot = editorRoot;
386
+ cachedTableWrapper = undefined;
387
+ if (!parent || !parent.isConnected || !editorRoot.isConnected || !editorRoot.contains(parent)) {
388
+ return undefined;
389
+ }
390
+ if (!(parent instanceof HTMLElement)) {
391
+ return undefined;
392
+ }
393
+ var tableWrapper = getTableWrapperFromParentImpl(parent);
394
+ if (tableWrapper !== null && tableWrapper !== void 0 && tableWrapper.isConnected && editorRoot.contains(tableWrapper) && parent.contains(tableWrapper)) {
395
+ cachedTableWrapper = tableWrapper;
396
+ }
397
+ return cachedTableWrapper;
398
+ };
374
399
 
400
+ // Remove this function when cleaning up `platform_editor_table_toolbar_position_fix`
375
401
  // Create memoized version ONCE - reused across all calls
376
402
  var getMemoizedTableWrapperFromParent = (0, _memoizeOne.default)(getTableWrapperFromParentImpl);
377
403
  var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, api, editorAnalyticsAPI, getEditorView, options) {
@@ -422,7 +448,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
422
448
  var getDomRef = function getDomRef(editorView) {
423
449
  var domAtPos = editorView.domAtPos.bind(editorView);
424
450
  var parent = (0, _utils2.findParentDomRefOfType)(nodeType, domAtPos)(state.selection);
425
- return getMemoizedTableWrapperFromParent(parent);
451
+ return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_table_toolbar_position_fix') ? getCachedTableWrapperFromParent(parent, editorView) : getMemoizedTableWrapperFromParent(parent);
426
452
  };
427
453
  var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown, areTableColumWidthsFixed);
428
454
  var alignmentMenu = config.allowTableAlignment && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI, getEditorContainerWidth, editorView, shouldUseIncreasedScalingPercent, areAnyNewToolbarFlagsEnabled, options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor) : [];
@@ -29,6 +29,7 @@ import CustomizeIcon from '@atlaskit/icon/core/customize';
29
29
  import DeleteIcon from '@atlaskit/icon/core/delete';
30
30
  import ShrinkHorizontalIcon from '@atlaskit/icon/core/shrink-horizontal';
31
31
  import TableColumnsDistributeIcon from '@atlaskit/icon/core/table-columns-distribute';
32
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
32
33
  import { fg } from '@atlaskit/platform-feature-flags/fg';
33
34
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
34
35
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -354,7 +355,32 @@ const getTableWrapperFromParentImpl = parent => {
354
355
  }
355
356
  return closestElement(tableRef, `.${TableCssClassName.TABLE_NODE_WRAPPER}`) || undefined;
356
357
  };
358
+ let cachedTableWrapperParent;
359
+ let cachedTableWrapperEditorRoot;
360
+ let cachedTableWrapper;
361
+ const getCachedTableWrapperFromParent = (parent, editorView) => {
362
+ var _cachedTableWrapper;
363
+ const editorRoot = editorView.dom;
364
+ if (parent && parent === cachedTableWrapperParent && editorRoot === cachedTableWrapperEditorRoot && (_cachedTableWrapper = cachedTableWrapper) !== null && _cachedTableWrapper !== void 0 && _cachedTableWrapper.isConnected && editorRoot.isConnected && editorRoot.contains(parent) && editorRoot.contains(cachedTableWrapper) && parent.contains(cachedTableWrapper) && cachedTableWrapper.querySelector('table')) {
365
+ return cachedTableWrapper;
366
+ }
367
+ cachedTableWrapperParent = parent;
368
+ cachedTableWrapperEditorRoot = editorRoot;
369
+ cachedTableWrapper = undefined;
370
+ if (!parent || !parent.isConnected || !editorRoot.isConnected || !editorRoot.contains(parent)) {
371
+ return undefined;
372
+ }
373
+ if (!(parent instanceof HTMLElement)) {
374
+ return undefined;
375
+ }
376
+ const tableWrapper = getTableWrapperFromParentImpl(parent);
377
+ if (tableWrapper !== null && tableWrapper !== void 0 && tableWrapper.isConnected && editorRoot.contains(tableWrapper) && parent.contains(tableWrapper)) {
378
+ cachedTableWrapper = tableWrapper;
379
+ }
380
+ return cachedTableWrapper;
381
+ };
357
382
 
383
+ // Remove this function when cleaning up `platform_editor_table_toolbar_position_fix`
358
384
  // Create memoized version ONCE - reused across all calls
359
385
  const getMemoizedTableWrapperFromParent = memoizeOne(getTableWrapperFromParentImpl);
360
386
  export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAPI, getEditorView, options, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => config => (state, intl) => {
@@ -400,7 +426,7 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
400
426
  const getDomRef = editorView => {
401
427
  const domAtPos = editorView.domAtPos.bind(editorView);
402
428
  const parent = findParentDomRefOfType(nodeType, domAtPos)(state.selection);
403
- return getMemoizedTableWrapperFromParent(parent);
429
+ return isExperimentEnabled('platform_editor_table_toolbar_position_fix') ? getCachedTableWrapperFromParent(parent, editorView) : getMemoizedTableWrapperFromParent(parent);
404
430
  };
405
431
  const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown, areTableColumWidthsFixed);
406
432
  const alignmentMenu = config.allowTableAlignment && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI, getEditorContainerWidth, editorView, shouldUseIncreasedScalingPercent, areAnyNewToolbarFlagsEnabled, options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor) : [];
@@ -35,6 +35,7 @@ import CustomizeIcon from '@atlaskit/icon/core/customize';
35
35
  import DeleteIcon from '@atlaskit/icon/core/delete';
36
36
  import ShrinkHorizontalIcon from '@atlaskit/icon/core/shrink-horizontal';
37
37
  import TableColumnsDistributeIcon from '@atlaskit/icon/core/table-columns-distribute';
38
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
38
39
  import { fg } from '@atlaskit/platform-feature-flags/fg';
39
40
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
40
41
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -364,7 +365,32 @@ var getTableWrapperFromParentImpl = function getTableWrapperFromParentImpl(paren
364
365
  }
365
366
  return closestElement(tableRef, ".".concat(TableCssClassName.TABLE_NODE_WRAPPER)) || undefined;
366
367
  };
368
+ var cachedTableWrapperParent;
369
+ var cachedTableWrapperEditorRoot;
370
+ var cachedTableWrapper;
371
+ var getCachedTableWrapperFromParent = function getCachedTableWrapperFromParent(parent, editorView) {
372
+ var _cachedTableWrapper;
373
+ var editorRoot = editorView.dom;
374
+ if (parent && parent === cachedTableWrapperParent && editorRoot === cachedTableWrapperEditorRoot && (_cachedTableWrapper = cachedTableWrapper) !== null && _cachedTableWrapper !== void 0 && _cachedTableWrapper.isConnected && editorRoot.isConnected && editorRoot.contains(parent) && editorRoot.contains(cachedTableWrapper) && parent.contains(cachedTableWrapper) && cachedTableWrapper.querySelector('table')) {
375
+ return cachedTableWrapper;
376
+ }
377
+ cachedTableWrapperParent = parent;
378
+ cachedTableWrapperEditorRoot = editorRoot;
379
+ cachedTableWrapper = undefined;
380
+ if (!parent || !parent.isConnected || !editorRoot.isConnected || !editorRoot.contains(parent)) {
381
+ return undefined;
382
+ }
383
+ if (!(parent instanceof HTMLElement)) {
384
+ return undefined;
385
+ }
386
+ var tableWrapper = getTableWrapperFromParentImpl(parent);
387
+ if (tableWrapper !== null && tableWrapper !== void 0 && tableWrapper.isConnected && editorRoot.contains(tableWrapper) && parent.contains(tableWrapper)) {
388
+ cachedTableWrapper = tableWrapper;
389
+ }
390
+ return cachedTableWrapper;
391
+ };
367
392
 
393
+ // Remove this function when cleaning up `platform_editor_table_toolbar_position_fix`
368
394
  // Create memoized version ONCE - reused across all calls
369
395
  var getMemoizedTableWrapperFromParent = memoizeOne(getTableWrapperFromParentImpl);
370
396
  export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, api, editorAnalyticsAPI, getEditorView, options) {
@@ -415,7 +441,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
415
441
  var getDomRef = function getDomRef(editorView) {
416
442
  var domAtPos = editorView.domAtPos.bind(editorView);
417
443
  var parent = findParentDomRefOfType(nodeType, domAtPos)(state.selection);
418
- return getMemoizedTableWrapperFromParent(parent);
444
+ return isExperimentEnabled('platform_editor_table_toolbar_position_fix') ? getCachedTableWrapperFromParent(parent, editorView) : getMemoizedTableWrapperFromParent(parent);
419
445
  };
420
446
  var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown, areTableColumWidthsFixed);
421
447
  var alignmentMenu = config.allowTableAlignment && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI, getEditorContainerWidth, editorView, shouldUseIncreasedScalingPercent, areAnyNewToolbarFlagsEnabled, options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor) : [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "27.0.2",
3
+ "version": "27.0.4",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,7 +29,7 @@
29
29
  "@atlaskit/editor-plugin-batch-attribute-updates": "^15.0.0",
30
30
  "@atlaskit/editor-plugin-content-insertion": "^15.0.0",
31
31
  "@atlaskit/editor-plugin-editor-viewmode": "^17.0.0",
32
- "@atlaskit/editor-plugin-extension": "18.0.1",
32
+ "@atlaskit/editor-plugin-extension": "18.0.2",
33
33
  "@atlaskit/editor-plugin-guideline": "^15.0.0",
34
34
  "@atlaskit/editor-plugin-interaction": "^26.0.0",
35
35
  "@atlaskit/editor-plugin-limited-mode": "^12.0.0",
@@ -42,7 +42,7 @@
42
42
  "@atlaskit/editor-shared-styles": "^4.0.0",
43
43
  "@atlaskit/editor-tables": "^3.0.0",
44
44
  "@atlaskit/editor-toolbar": "^2.4.0",
45
- "@atlaskit/editor-ui-control-model": "^2.6.0",
45
+ "@atlaskit/editor-ui-control-model": "^2.7.0",
46
46
  "@atlaskit/icon": "^37.3.0",
47
47
  "@atlaskit/icon-lab": "^7.5.0",
48
48
  "@atlaskit/insm": "^2.0.0",
@@ -53,7 +53,7 @@
53
53
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^3.0.0",
54
54
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^2.0.0",
55
55
  "@atlaskit/primitives": "^22.2.0",
56
- "@atlaskit/tmp-editor-statsig": "^147.1.0",
56
+ "@atlaskit/tmp-editor-statsig": "^148.0.0",
57
57
  "@atlaskit/toggle": "^17.1.0",
58
58
  "@atlaskit/tokens": "^16.7.0",
59
59
  "@atlaskit/tooltip": "^24.0.0",
@@ -68,7 +68,7 @@
68
68
  "uuid": "^3.1.0"
69
69
  },
70
70
  "peerDependencies": {
71
- "@atlaskit/editor-common": "^119.4.0",
71
+ "@atlaskit/editor-common": "^119.5.0",
72
72
  "react": "^18.2.0 || ^19.2.0",
73
73
  "react-dom": "^18.2.0 || ^19.2.0",
74
74
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"