@atlaskit/editor-plugin-table 10.1.3 → 10.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 10.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#119765](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/119765)
8
+ [`5a27b842be965`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5a27b842be965) -
9
+ Add deprecated label to `forceStaticToolbar` in floating toolbar property and remove its usage
10
+ across plugins
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
16
+ ## 10.1.4
17
+
18
+ ### Patch Changes
19
+
20
+ - [#115629](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/115629)
21
+ [`4c512c4a6282c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4c512c4a6282c) -
22
+ [ux] [ED-26544] Fix issue where sorting decorations were not being removed on edit mode on live
23
+ pages. Also ensured sorting decorations are reapplied in view mode. Added live page option to
24
+ integration testing page.
25
+
3
26
  ## 10.1.3
4
27
 
5
28
  ### Patch Changes
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.createPlugin = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _react = require("react");
12
12
  var _reactIntlNext = require("react-intl-next");
13
13
  var _v = _interopRequireDefault(require("uuid/v4"));
@@ -15,6 +15,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
15
15
  var _types = require("@atlaskit/editor-common/types");
16
16
  var _view = require("@atlaskit/editor-prosemirror/view");
17
17
  var _tableMap = require("@atlaskit/editor-tables/table-map");
18
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
19
  var _SortingIconWrapper = require("../../ui/icons/SortingIconWrapper");
19
20
  var _pluginFactory = require("../plugin-factory");
20
21
  var _consts = require("./consts");
@@ -46,7 +47,13 @@ var createPlugin = exports.createPlugin = function createPlugin(api, nodeViewPor
46
47
  var _ref = ((_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState()) || {},
47
48
  mode = _ref.mode;
48
49
  if (mode !== 'view') {
49
- return pluginState;
50
+ var _pluginState$decorati, _pluginState$decorati2;
51
+ var _sortingDecorations = pluginState === null || pluginState === void 0 || (_pluginState$decorati = pluginState.decorations) === null || _pluginState$decorati === void 0 ? void 0 : _pluginState$decorati.find(undefined, undefined, function (s) {
52
+ return (s === null || s === void 0 ? void 0 : s.type) === 'sorting-decoration';
53
+ });
54
+ return (0, _platformFeatureFlags.fg)('platform_editor_sort_decoration_fix_on_live_page') ? _objectSpread(_objectSpread({}, pluginState), {}, {
55
+ decorations: pluginState === null || pluginState === void 0 || (_pluginState$decorati2 = pluginState.decorations) === null || _pluginState$decorati2 === void 0 ? void 0 : _pluginState$decorati2.remove(_sortingDecorations)
56
+ }) : pluginState;
50
57
  }
51
58
  var decorations = pluginState.decorations,
52
59
  sort = pluginState.sort,
@@ -87,9 +94,12 @@ var createPlugin = exports.createPlugin = function createPlugin(api, nodeViewPor
87
94
  * Create decorations for the sorting icons
88
95
  */
89
96
  var decs = [];
97
+ var sortingDecorations = pluginState.decorations.find(undefined, undefined, function (spec) {
98
+ return spec.tableId === tableId && spec.type === 'sorting-decoration';
99
+ });
90
100
 
91
101
  // TODO - add support for keyboard only users
92
- if (hoverTableMeta && !isTableInState || sortMeta) {
102
+ if (hoverTableMeta && !isTableInState || sortMeta || isTableInState && !sortingDecorations.length && (0, _platformFeatureFlags.fg)('platform_editor_sort_decoration_fix_on_live_page')) {
93
103
  allTables.forEach(function (table) {
94
104
  var _table = (0, _slicedToArray2.default)(table, 3),
95
105
  tableId = _table[0],
@@ -135,7 +145,9 @@ var createPlugin = exports.createPlugin = function createPlugin(api, nodeViewPor
135
145
  }, {
136
146
  destroy: function destroy(node) {
137
147
  nodeViewPortalProviderAPI.remove(decorationRenderKey);
138
- }
148
+ },
149
+ type: 'sorting-decoration',
150
+ tableId: tableId
139
151
  }));
140
152
  });
141
153
  });
@@ -1,16 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
8
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _react = _interopRequireDefault(require("react"));
10
+ var _react = _interopRequireWildcard(require("react"));
10
11
  var _adfSchema = require("@atlaskit/adf-schema");
11
12
  var _analytics = require("@atlaskit/editor-common/analytics");
12
13
  var _browser = require("@atlaskit/editor-common/browser");
13
14
  var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
15
+ var _hooks = require("@atlaskit/editor-common/hooks");
14
16
  var _icons = require("@atlaskit/editor-common/icons");
15
17
  var _keymaps = require("@atlaskit/editor-common/keymaps");
16
18
  var _messages = require("@atlaskit/editor-common/messages");
@@ -58,6 +60,8 @@ var _FloatingToolbarLabel = require("./ui/FloatingToolbarLabel/FloatingToolbarLa
58
60
  var _globalStyles = require("./ui/global-styles");
59
61
  var _TableFullWidthLabel = require("./ui/TableFullWidthLabel");
60
62
  var _toolbar = require("./ui/toolbar");
63
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
64
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
61
65
  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; }
62
66
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // Ignored via go/ees005
63
67
  // eslint-disable-next-line import/no-named-as-default
@@ -607,6 +611,21 @@ var tablesPlugin = function tablesPlugin(_ref) {
607
611
  floatingToolbar: (0, _toolbar.getToolbarConfig)(defaultGetEditorContainerWidth, api, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
608
612
  return editorViewRef.current;
609
613
  }, options, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
614
+ },
615
+ usePluginHook: function usePluginHook(_ref23) {
616
+ var editorView = _ref23.editorView;
617
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['editorViewMode']),
618
+ editorViewModeState = _useSharedPluginState.editorViewModeState;
619
+ var mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
620
+ (0, _react.useEffect)(function () {
621
+ var state = editorView.state,
622
+ dispatch = editorView.dispatch;
623
+ var tr = state.tr;
624
+ tr.setMeta('viewModeState', mode);
625
+ if (dispatch) {
626
+ dispatch(tr);
627
+ }
628
+ }, [editorView, mode]);
610
629
  }
611
630
  };
612
631
  };
@@ -464,7 +464,6 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
464
464
  },
465
465
  zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex + 1,
466
466
  // Place the context menu slightly above the others
467
- forceStaticToolbar: true,
468
467
  items: [menu, separator(menu.hidden)].concat((0, _toConsumableArray2.default)(alignmentMenu), [separator(alignmentMenu.length === 0)], (0, _toConsumableArray2.default)(cellItems), (0, _toConsumableArray2.default)(columnSettingsItems), (0, _toConsumableArray2.default)(colorPicker), [
469
468
  // TODO: editor controls to move to overflow menu
470
469
  {
@@ -11,6 +11,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
11
11
  import { SortOrder } from '@atlaskit/editor-common/types';
12
12
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
13
13
  import { TableMap } from '@atlaskit/editor-tables/table-map';
14
+ import { fg } from '@atlaskit/platform-feature-flags';
14
15
  import { SortingIconWrapper } from '../../ui/icons/SortingIconWrapper';
15
16
  import { getPluginState } from '../plugin-factory';
16
17
  import { IS_DISABLED_CLASS_NAME, SORT_INDEX_DATA_ATTRIBUTE, SORTING_ICON_CLASS_NAME } from './consts';
@@ -32,7 +33,12 @@ export const createPlugin = (api, nodeViewPortalProviderAPI) => {
32
33
  mode
33
34
  } = ((_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState()) || {};
34
35
  if (mode !== 'view') {
35
- return pluginState;
36
+ var _pluginState$decorati, _pluginState$decorati2;
37
+ const sortingDecorations = pluginState === null || pluginState === void 0 ? void 0 : (_pluginState$decorati = pluginState.decorations) === null || _pluginState$decorati === void 0 ? void 0 : _pluginState$decorati.find(undefined, undefined, s => (s === null || s === void 0 ? void 0 : s.type) === 'sorting-decoration');
38
+ return fg('platform_editor_sort_decoration_fix_on_live_page') ? {
39
+ ...pluginState,
40
+ decorations: pluginState === null || pluginState === void 0 ? void 0 : (_pluginState$decorati2 = pluginState.decorations) === null || _pluginState$decorati2 === void 0 ? void 0 : _pluginState$decorati2.remove(sortingDecorations)
41
+ } : pluginState;
36
42
  }
37
43
  let {
38
44
  decorations,
@@ -66,9 +72,10 @@ export const createPlugin = (api, nodeViewPortalProviderAPI) => {
66
72
  * Create decorations for the sorting icons
67
73
  */
68
74
  const decs = [];
75
+ const sortingDecorations = pluginState.decorations.find(undefined, undefined, spec => spec.tableId === tableId && spec.type === 'sorting-decoration');
69
76
 
70
77
  // TODO - add support for keyboard only users
71
- if (hoverTableMeta && !isTableInState || sortMeta) {
78
+ if (hoverTableMeta && !isTableInState || sortMeta || isTableInState && !sortingDecorations.length && fg('platform_editor_sort_decoration_fix_on_live_page')) {
72
79
  allTables.forEach(table => {
73
80
  const [tableId, _node, pos] = table;
74
81
  const tableNode = tr.doc.nodeAt(tr.mapping.map(pos));
@@ -110,7 +117,9 @@ export const createPlugin = (api, nodeViewPortalProviderAPI) => {
110
117
  }, {
111
118
  destroy: node => {
112
119
  nodeViewPortalProviderAPI.remove(decorationRenderKey);
113
- }
120
+ },
121
+ type: 'sorting-decoration',
122
+ tableId
114
123
  }));
115
124
  });
116
125
  });
@@ -1,8 +1,9 @@
1
- import React from 'react';
1
+ import React, { useEffect } from 'react';
2
2
  import { tableCell, tableCellWithNestedTable, tableHeader, tableHeaderWithNestedTable, tableRow, tableRowWithNestedTable } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
4
4
  import { browser } from '@atlaskit/editor-common/browser';
5
5
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
6
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
7
  import { IconTable } from '@atlaskit/editor-common/icons';
7
8
  import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
8
9
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
@@ -603,6 +604,25 @@ const tablesPlugin = ({
603
604
  }
604
605
  }],
605
606
  floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, api, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current, options, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
607
+ },
608
+ usePluginHook({
609
+ editorView
610
+ }) {
611
+ const {
612
+ editorViewModeState
613
+ } = useSharedPluginState(api, ['editorViewMode']);
614
+ const mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
615
+ useEffect(() => {
616
+ const {
617
+ state,
618
+ dispatch
619
+ } = editorView;
620
+ const tr = state.tr;
621
+ tr.setMeta('viewModeState', mode);
622
+ if (dispatch) {
623
+ dispatch(tr);
624
+ }
625
+ }, [editorView, mode]);
606
626
  }
607
627
  };
608
628
  };
@@ -436,7 +436,6 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
436
436
  },
437
437
  zIndex: akEditorFloatingPanelZIndex + 1,
438
438
  // Place the context menu slightly above the others
439
- forceStaticToolbar: true,
440
439
  items: [menu, separator(menu.hidden), ...alignmentMenu, separator(alignmentMenu.length === 0), ...cellItems, ...columnSettingsItems, ...colorPicker,
441
440
  // TODO: editor controls to move to overflow menu
442
441
  {
@@ -1,6 +1,6 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
5
5
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
6
6
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
@@ -19,6 +19,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
19
19
  import { SortOrder } from '@atlaskit/editor-common/types';
20
20
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
21
21
  import { TableMap } from '@atlaskit/editor-tables/table-map';
22
+ import { fg } from '@atlaskit/platform-feature-flags';
22
23
  import { SortingIconWrapper } from '../../ui/icons/SortingIconWrapper';
23
24
  import { getPluginState } from '../plugin-factory';
24
25
  import { IS_DISABLED_CLASS_NAME, SORT_INDEX_DATA_ATTRIBUTE, SORTING_ICON_CLASS_NAME } from './consts';
@@ -41,7 +42,13 @@ export var createPlugin = function createPlugin(api, nodeViewPortalProviderAPI)
41
42
  var _ref = ((_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState()) || {},
42
43
  mode = _ref.mode;
43
44
  if (mode !== 'view') {
44
- return pluginState;
45
+ var _pluginState$decorati, _pluginState$decorati2;
46
+ var _sortingDecorations = pluginState === null || pluginState === void 0 || (_pluginState$decorati = pluginState.decorations) === null || _pluginState$decorati === void 0 ? void 0 : _pluginState$decorati.find(undefined, undefined, function (s) {
47
+ return (s === null || s === void 0 ? void 0 : s.type) === 'sorting-decoration';
48
+ });
49
+ return fg('platform_editor_sort_decoration_fix_on_live_page') ? _objectSpread(_objectSpread({}, pluginState), {}, {
50
+ decorations: pluginState === null || pluginState === void 0 || (_pluginState$decorati2 = pluginState.decorations) === null || _pluginState$decorati2 === void 0 ? void 0 : _pluginState$decorati2.remove(_sortingDecorations)
51
+ }) : pluginState;
45
52
  }
46
53
  var decorations = pluginState.decorations,
47
54
  sort = pluginState.sort,
@@ -82,9 +89,12 @@ export var createPlugin = function createPlugin(api, nodeViewPortalProviderAPI)
82
89
  * Create decorations for the sorting icons
83
90
  */
84
91
  var decs = [];
92
+ var sortingDecorations = pluginState.decorations.find(undefined, undefined, function (spec) {
93
+ return spec.tableId === tableId && spec.type === 'sorting-decoration';
94
+ });
85
95
 
86
96
  // TODO - add support for keyboard only users
87
- if (hoverTableMeta && !isTableInState || sortMeta) {
97
+ if (hoverTableMeta && !isTableInState || sortMeta || isTableInState && !sortingDecorations.length && fg('platform_editor_sort_decoration_fix_on_live_page')) {
88
98
  allTables.forEach(function (table) {
89
99
  var _table = _slicedToArray(table, 3),
90
100
  tableId = _table[0],
@@ -130,7 +140,9 @@ export var createPlugin = function createPlugin(api, nodeViewPortalProviderAPI)
130
140
  }, {
131
141
  destroy: function destroy(node) {
132
142
  nodeViewPortalProviderAPI.remove(decorationRenderKey);
133
- }
143
+ },
144
+ type: 'sorting-decoration',
145
+ tableId: tableId
134
146
  }));
135
147
  });
136
148
  });
@@ -1,11 +1,12 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
3
3
  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; }
4
- import React from 'react';
4
+ import React, { useEffect } from 'react';
5
5
  import { tableCell, tableCellWithNestedTable, tableHeader, tableHeaderWithNestedTable, tableRow, tableRowWithNestedTable } from '@atlaskit/adf-schema';
6
6
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
7
7
  import { browser } from '@atlaskit/editor-common/browser';
8
8
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
9
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
9
10
  import { IconTable } from '@atlaskit/editor-common/icons';
10
11
  import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
11
12
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
@@ -601,6 +602,21 @@ var tablesPlugin = function tablesPlugin(_ref) {
601
602
  floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, api, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
602
603
  return editorViewRef.current;
603
604
  }, options, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
605
+ },
606
+ usePluginHook: function usePluginHook(_ref23) {
607
+ var editorView = _ref23.editorView;
608
+ var _useSharedPluginState = useSharedPluginState(api, ['editorViewMode']),
609
+ editorViewModeState = _useSharedPluginState.editorViewModeState;
610
+ var mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
611
+ useEffect(function () {
612
+ var state = editorView.state,
613
+ dispatch = editorView.dispatch;
614
+ var tr = state.tr;
615
+ tr.setMeta('viewModeState', mode);
616
+ if (dispatch) {
617
+ dispatch(tr);
618
+ }
619
+ }, [editorView, mode]);
604
620
  }
605
621
  };
606
622
  };
@@ -456,7 +456,6 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
456
456
  },
457
457
  zIndex: akEditorFloatingPanelZIndex + 1,
458
458
  // Place the context menu slightly above the others
459
- forceStaticToolbar: true,
460
459
  items: [menu, separator(menu.hidden)].concat(_toConsumableArray(alignmentMenu), [separator(alignmentMenu.length === 0)], _toConsumableArray(cellItems), _toConsumableArray(columnSettingsItems), _toConsumableArray(colorPicker), [
461
460
  // TODO: editor controls to move to overflow menu
462
461
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "10.1.3",
3
+ "version": "10.2.0",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,7 +30,7 @@
30
30
  "@atlaskit/adf-schema": "^47.2.1",
31
31
  "@atlaskit/button": "^21.1.0",
32
32
  "@atlaskit/custom-steps": "^0.10.0",
33
- "@atlaskit/editor-common": "^100.2.0",
33
+ "@atlaskit/editor-common": "^100.3.0",
34
34
  "@atlaskit/editor-palette": "2.0.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^2.0.0",
@@ -51,7 +51,7 @@
51
51
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
52
52
  "@atlaskit/primitives": "^14.1.0",
53
53
  "@atlaskit/theme": "^17.0.0",
54
- "@atlaskit/tmp-editor-statsig": "^3.2.0",
54
+ "@atlaskit/tmp-editor-statsig": "^3.3.0",
55
55
  "@atlaskit/toggle": "^15.0.0",
56
56
  "@atlaskit/tokens": "^4.2.0",
57
57
  "@atlaskit/tooltip": "^20.0.0",
@@ -179,6 +179,9 @@
179
179
  },
180
180
  "platform_editor_nested_tables_sticky_header_bug": {
181
181
  "type": "boolean"
182
+ },
183
+ "platform_editor_sort_decoration_fix_on_live_page": {
184
+ "type": "boolean"
182
185
  }
183
186
  }
184
187
  }
@@ -15,6 +15,7 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
15
15
  import { SortOrder } from '@atlaskit/editor-common/types';
16
16
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
17
17
  import { TableMap } from '@atlaskit/editor-tables/table-map';
18
+ import { fg } from '@atlaskit/platform-feature-flags';
18
19
 
19
20
  import type tablePlugin from '../../tablePlugin';
20
21
  import { SortingIconWrapper } from '../../ui/icons/SortingIconWrapper';
@@ -45,7 +46,18 @@ export const createPlugin = (
45
46
  // does not appear correct when the plugin is created.
46
47
  const { mode } = api.editorViewMode?.sharedState.currentState() || {};
47
48
  if (mode !== 'view') {
48
- return pluginState;
49
+ const sortingDecorations = pluginState?.decorations?.find(
50
+ undefined,
51
+ undefined,
52
+ (s) => s?.type === 'sorting-decoration',
53
+ );
54
+
55
+ return fg('platform_editor_sort_decoration_fix_on_live_page')
56
+ ? {
57
+ ...pluginState,
58
+ decorations: pluginState?.decorations?.remove(sortingDecorations),
59
+ }
60
+ : pluginState;
49
61
  }
50
62
  let { decorations, sort, allTables } = pluginState;
51
63
 
@@ -77,8 +89,20 @@ export const createPlugin = (
77
89
  */
78
90
  const decs: Decoration[] = [];
79
91
 
92
+ const sortingDecorations = pluginState.decorations.find(
93
+ undefined,
94
+ undefined,
95
+ (spec) => spec.tableId === tableId && spec.type === 'sorting-decoration',
96
+ );
97
+
80
98
  // TODO - add support for keyboard only users
81
- if ((hoverTableMeta && !isTableInState) || sortMeta) {
99
+ if (
100
+ (hoverTableMeta && !isTableInState) ||
101
+ sortMeta ||
102
+ (isTableInState &&
103
+ !sortingDecorations.length &&
104
+ fg('platform_editor_sort_decoration_fix_on_live_page'))
105
+ ) {
82
106
  allTables.forEach((table) => {
83
107
  const [tableId, _node, pos] = table;
84
108
  const tableNode = tr.doc.nodeAt(tr.mapping.map(pos));
@@ -132,6 +156,8 @@ export const createPlugin = (
132
156
  destroy: (node) => {
133
157
  nodeViewPortalProviderAPI.remove(decorationRenderKey);
134
158
  },
159
+ type: 'sorting-decoration',
160
+ tableId,
135
161
  },
136
162
  ),
137
163
  );
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useEffect } from 'react';
2
2
 
3
3
  import {
4
4
  tableCell,
@@ -18,6 +18,7 @@ import {
18
18
  } from '@atlaskit/editor-common/analytics';
19
19
  import { browser } from '@atlaskit/editor-common/browser';
20
20
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
21
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
21
22
  import { IconTable } from '@atlaskit/editor-common/icons';
22
23
  import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
23
24
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
@@ -770,6 +771,19 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
770
771
  shouldUseIncreasedScalingPercent,
771
772
  )(pluginConfig(options?.tableOptions)),
772
773
  },
774
+ usePluginHook({ editorView }) {
775
+ const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode']);
776
+ const mode = editorViewModeState?.mode;
777
+
778
+ useEffect(() => {
779
+ const { state, dispatch } = editorView;
780
+ const tr = state.tr;
781
+ tr.setMeta('viewModeState', mode);
782
+ if (dispatch) {
783
+ dispatch(tr);
784
+ }
785
+ }, [editorView, mode]);
786
+ },
773
787
  };
774
788
  };
775
789
 
@@ -639,7 +639,6 @@ export const getToolbarConfig =
639
639
  offset: [0, 18],
640
640
  absoluteOffset: { top: -6 },
641
641
  zIndex: akEditorFloatingPanelZIndex + 1, // Place the context menu slightly above the others
642
- forceStaticToolbar: true,
643
642
  items: [
644
643
  menu,
645
644
  separator(menu.hidden),