@atlaskit/editor-plugin-table 22.4.14 → 22.4.16
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 +17 -0
- package/dist/cjs/nodeviews/TableComponent.js +2 -2
- package/dist/cjs/nodeviews/table.js +2 -2
- package/dist/cjs/nodeviews/toDOM.js +2 -2
- package/dist/cjs/pm-plugins/commands/active-table-menu.js +51 -0
- package/dist/cjs/pm-plugins/commands/commands-with-analytics.js +42 -10
- package/dist/cjs/pm-plugins/commands/index.js +13 -0
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +2 -0
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +4 -0
- package/dist/cjs/pm-plugins/handlers.js +8 -1
- package/dist/cjs/pm-plugins/main.js +4 -3
- package/dist/cjs/pm-plugins/reducer.js +2 -0
- package/dist/cjs/pm-plugins/table-width.js +2 -2
- package/dist/cjs/pm-plugins/transforms/content-mode.js +3 -2
- package/dist/cjs/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.js +70 -0
- package/dist/cjs/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.js +41 -0
- package/dist/cjs/pm-plugins/utils/tableMode/is-content-mode-supported.js +12 -0
- package/dist/cjs/pm-plugins/utils/tableMode/measure-table-with-auto-layout.js +113 -0
- package/dist/cjs/pm-plugins/utils/tableMode/smart-adjust/constants.js +10 -0
- package/dist/cjs/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.js +83 -0
- package/dist/cjs/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.js +56 -0
- package/dist/cjs/tablePlugin.js +1 -0
- package/dist/cjs/ui/ContentComponent.js +1 -1
- package/dist/cjs/ui/FloatingContextualButton/index.js +28 -9
- package/dist/cjs/ui/FloatingContextualMenu/CellMenuPopup.js +58 -73
- package/dist/cjs/ui/FloatingContextualMenu/index.js +26 -12
- package/dist/cjs/ui/FloatingDragMenu/index.js +21 -8
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +13 -5
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +14 -5
- package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +8 -3
- package/dist/cjs/ui/TableMenu/cell/items/MergeCellsItem.js +16 -1
- package/dist/cjs/ui/TableMenu/cell/items/SplitCellItem.js +16 -1
- package/dist/cjs/ui/TableMenu/column/items/AddColumnLeftItem.js +4 -4
- package/dist/cjs/ui/TableMenu/column/items/AddColumnRightItem.js +4 -4
- package/dist/cjs/ui/TableMenu/column/items/DeleteColumnItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/HeaderColumnToggleItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnLeftItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/SortDecreasingItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/SortIncreasingItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/AddRowAboveItem.js +4 -4
- package/dist/cjs/ui/TableMenu/row/items/AddRowBelowItem.js +4 -4
- package/dist/cjs/ui/TableMenu/row/items/DeleteRowItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/HeaderRowToggleItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/MoveRowDownItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/MoveRowUpItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/NumberedRowsToggleItem.js +4 -3
- package/dist/cjs/ui/TableMenu/shared/TableMenu.compiled.css +0 -2
- package/dist/cjs/ui/TableMenu/shared/TableMenu.js +8 -9
- package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +3 -1
- package/dist/cjs/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
- package/dist/cjs/ui/TableMenu/shared/items/BackgroundColorItem.js +30 -4
- package/dist/cjs/ui/TableMenu/shared/items/ClearCellsItem.js +4 -3
- package/dist/cjs/ui/toolbar.js +4 -3
- package/dist/es2019/nodeviews/TableComponent.js +1 -1
- package/dist/es2019/nodeviews/table.js +1 -1
- package/dist/es2019/nodeviews/toDOM.js +1 -1
- package/dist/es2019/pm-plugins/commands/active-table-menu.js +39 -0
- package/dist/es2019/pm-plugins/commands/commands-with-analytics.js +31 -2
- package/dist/es2019/pm-plugins/commands/index.js +1 -0
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +2 -0
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +4 -0
- package/dist/es2019/pm-plugins/handlers.js +8 -1
- package/dist/es2019/pm-plugins/main.js +2 -1
- package/dist/es2019/pm-plugins/reducer.js +5 -0
- package/dist/es2019/pm-plugins/table-width.js +1 -1
- package/dist/es2019/pm-plugins/transforms/content-mode.js +2 -1
- package/dist/es2019/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.js +70 -0
- package/dist/es2019/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.js +38 -0
- package/dist/es2019/pm-plugins/utils/tableMode/is-content-mode-supported.js +7 -0
- package/dist/es2019/pm-plugins/utils/tableMode/measure-table-with-auto-layout.js +97 -0
- package/dist/es2019/pm-plugins/utils/tableMode/smart-adjust/constants.js +4 -0
- package/dist/es2019/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.js +63 -0
- package/dist/es2019/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.js +47 -0
- package/dist/es2019/tablePlugin.js +1 -0
- package/dist/es2019/ui/ContentComponent.js +1 -1
- package/dist/es2019/ui/FloatingContextualButton/index.js +29 -9
- package/dist/es2019/ui/FloatingContextualMenu/CellMenuPopup.js +60 -77
- package/dist/es2019/ui/FloatingContextualMenu/index.js +27 -12
- package/dist/es2019/ui/FloatingDragMenu/index.js +22 -8
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -4
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +13 -4
- package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +9 -3
- package/dist/es2019/ui/TableMenu/cell/items/MergeCellsItem.js +18 -2
- package/dist/es2019/ui/TableMenu/cell/items/SplitCellItem.js +18 -2
- package/dist/es2019/ui/TableMenu/column/items/AddColumnLeftItem.js +3 -3
- package/dist/es2019/ui/TableMenu/column/items/AddColumnRightItem.js +3 -3
- package/dist/es2019/ui/TableMenu/column/items/DeleteColumnItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/HeaderColumnToggleItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnLeftItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/SortDecreasingItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/SortIncreasingItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/AddRowAboveItem.js +3 -3
- package/dist/es2019/ui/TableMenu/row/items/AddRowBelowItem.js +3 -3
- package/dist/es2019/ui/TableMenu/row/items/DeleteRowItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/HeaderRowToggleItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/MoveRowDownItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/MoveRowUpItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/NumberedRowsToggleItem.js +3 -2
- package/dist/es2019/ui/TableMenu/shared/TableMenu.compiled.css +0 -2
- package/dist/es2019/ui/TableMenu/shared/TableMenu.js +8 -9
- package/dist/es2019/ui/TableMenu/shared/getSharedItems.js +3 -1
- package/dist/es2019/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
- package/dist/es2019/ui/TableMenu/shared/items/BackgroundColorItem.js +33 -4
- package/dist/es2019/ui/TableMenu/shared/items/ClearCellsItem.js +4 -3
- package/dist/es2019/ui/toolbar.js +2 -1
- package/dist/esm/nodeviews/TableComponent.js +1 -1
- package/dist/esm/nodeviews/table.js +1 -1
- package/dist/esm/nodeviews/toDOM.js +1 -1
- package/dist/esm/pm-plugins/commands/active-table-menu.js +45 -0
- package/dist/esm/pm-plugins/commands/commands-with-analytics.js +41 -10
- package/dist/esm/pm-plugins/commands/index.js +1 -0
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +2 -0
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +4 -0
- package/dist/esm/pm-plugins/handlers.js +8 -1
- package/dist/esm/pm-plugins/main.js +2 -1
- package/dist/esm/pm-plugins/reducer.js +2 -0
- package/dist/esm/pm-plugins/table-width.js +1 -1
- package/dist/esm/pm-plugins/transforms/content-mode.js +2 -1
- package/dist/esm/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.js +65 -0
- package/dist/esm/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.js +36 -0
- package/dist/esm/pm-plugins/utils/tableMode/is-content-mode-supported.js +6 -0
- package/dist/esm/pm-plugins/utils/tableMode/measure-table-with-auto-layout.js +107 -0
- package/dist/esm/pm-plugins/utils/tableMode/smart-adjust/constants.js +4 -0
- package/dist/esm/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.js +77 -0
- package/dist/esm/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.js +49 -0
- package/dist/esm/tablePlugin.js +1 -0
- package/dist/esm/ui/ContentComponent.js +1 -1
- package/dist/esm/ui/FloatingContextualButton/index.js +29 -10
- package/dist/esm/ui/FloatingContextualMenu/CellMenuPopup.js +60 -75
- package/dist/esm/ui/FloatingContextualMenu/index.js +26 -12
- package/dist/esm/ui/FloatingDragMenu/index.js +21 -8
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -4
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +13 -4
- package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +8 -3
- package/dist/esm/ui/TableMenu/cell/items/MergeCellsItem.js +16 -2
- package/dist/esm/ui/TableMenu/cell/items/SplitCellItem.js +16 -2
- package/dist/esm/ui/TableMenu/column/items/AddColumnLeftItem.js +4 -4
- package/dist/esm/ui/TableMenu/column/items/AddColumnRightItem.js +4 -4
- package/dist/esm/ui/TableMenu/column/items/DeleteColumnItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/HeaderColumnToggleItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/MoveColumnLeftItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/SortDecreasingItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/SortIncreasingItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/AddRowAboveItem.js +4 -4
- package/dist/esm/ui/TableMenu/row/items/AddRowBelowItem.js +4 -4
- package/dist/esm/ui/TableMenu/row/items/DeleteRowItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/HeaderRowToggleItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/MoveRowDownItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/MoveRowUpItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/NumberedRowsToggleItem.js +4 -3
- package/dist/esm/ui/TableMenu/shared/TableMenu.compiled.css +0 -2
- package/dist/esm/ui/TableMenu/shared/TableMenu.js +8 -9
- package/dist/esm/ui/TableMenu/shared/getSharedItems.js +3 -1
- package/dist/esm/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
- package/dist/esm/ui/TableMenu/shared/items/BackgroundColorItem.js +30 -4
- package/dist/esm/ui/TableMenu/shared/items/ClearCellsItem.js +4 -3
- package/dist/esm/ui/toolbar.js +2 -1
- package/dist/types/entry-points/types.d.ts +1 -1
- package/dist/types/pm-plugins/commands/active-table-menu.d.ts +6 -0
- package/dist/types/pm-plugins/commands/commands-with-analytics.d.ts +3 -1
- package/dist/types/pm-plugins/commands/index.d.ts +1 -0
- package/dist/types/pm-plugins/transforms/content-mode.d.ts +1 -0
- package/dist/types/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.d.ts +8 -0
- package/dist/types/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.d.ts +6 -0
- package/dist/types/pm-plugins/utils/tableMode/is-content-mode-supported.d.ts +7 -0
- package/dist/types/pm-plugins/utils/tableMode/measure-table-with-auto-layout.d.ts +2 -0
- package/dist/types/pm-plugins/utils/tableMode/smart-adjust/constants.d.ts +4 -0
- package/dist/types/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.d.ts +8 -0
- package/dist/types/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.d.ts +7 -0
- package/dist/types/types/index.d.ts +21 -1
- package/dist/types/ui/FloatingContextualButton/index.d.ts +2 -0
- package/dist/types/ui/FloatingContextualMenu/CellMenuPopup.d.ts +7 -5
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +0 -1
- package/dist/types/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -1
- package/dist/types/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/getColumnMenuComponents.d.ts +1 -1
- package/dist/types/ui/TableMenu/shared/TableMenuContext.d.ts +2 -0
- package/dist/types/ui/TableMenu/shared/items/BackgroundColorItem.d.ts +2 -1
- package/dist/types-ts4.5/entry-points/types.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/commands/active-table-menu.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/commands/commands-with-analytics.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/commands/index.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/transforms/content-mode.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/is-content-mode-supported.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/measure-table-with-auto-layout.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/smart-adjust/constants.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.d.ts +7 -0
- package/dist/types-ts4.5/types/index.d.ts +21 -1
- package/dist/types-ts4.5/ui/FloatingContextualButton/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/FloatingContextualMenu/CellMenuPopup.d.ts +7 -5
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/getColumnMenuComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/TableMenuContext.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableMenu/shared/items/BackgroundColorItem.d.ts +2 -1
- package/package.json +10 -7
- package/dist/cjs/pm-plugins/utils/tableMode.js +0 -162
- package/dist/es2019/pm-plugins/utils/tableMode.js +0 -158
- package/dist/esm/pm-plugins/utils/tableMode.js +0 -156
- package/dist/types/pm-plugins/utils/tableMode.d.ts +0 -26
- package/dist/types-ts4.5/pm-plugins/utils/tableMode.d.ts +0 -26
|
@@ -12,7 +12,6 @@ var _runtime = require("@compiled/react/runtime");
|
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
15
|
-
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
16
15
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
17
16
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
18
17
|
var _editorUiControlModel = require("@atlaskit/editor-ui-control-model");
|
|
@@ -24,9 +23,8 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
24
23
|
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; }
|
|
25
24
|
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; }
|
|
26
25
|
var tableMenuContainerStyles = {
|
|
27
|
-
container: "_2rko1qi0
|
|
26
|
+
container: "_2rko1qi0 _1bsb1178 _16qs130s _bfhk1bhr"
|
|
28
27
|
};
|
|
29
|
-
var EMPTY_CONTEXT = {};
|
|
30
28
|
var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
31
29
|
var api = _ref.api,
|
|
32
30
|
editorView = _ref.editorView,
|
|
@@ -46,11 +44,14 @@ var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
46
44
|
selection = _useSharedPluginState.selection;
|
|
47
45
|
var tableMenuContext = (0, _react.useMemo)(function () {
|
|
48
46
|
if (!selection || !tableNode) {
|
|
49
|
-
return
|
|
47
|
+
return {
|
|
48
|
+
editorView: editorView
|
|
49
|
+
};
|
|
50
50
|
}
|
|
51
51
|
var tableMap = _tableMap.TableMap.get(tableNode);
|
|
52
52
|
var selectionRect = (0, _utils.getSelectionRect)(selection);
|
|
53
53
|
var cellOps = {
|
|
54
|
+
editorView: editorView,
|
|
54
55
|
canMergeCells: (0, _merge.canMergeCellSelection)(selection),
|
|
55
56
|
canSplitCell: (0, _splitCell.canSplitCellSelection)(selection),
|
|
56
57
|
hasMergedCellsInTable: tableMap.hasMergedCells()
|
|
@@ -66,13 +67,11 @@ var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
66
67
|
isLastColumn: selectionRect.right === tableMap.width,
|
|
67
68
|
selectedColumnCount: selectionRect.right - selectionRect.left
|
|
68
69
|
});
|
|
69
|
-
}, [selection, tableNode]);
|
|
70
|
+
}, [editorView, selection, tableNode]);
|
|
70
71
|
if (components.length === 0) {
|
|
71
72
|
return null;
|
|
72
73
|
}
|
|
73
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
74
|
-
editorView: editorView !== null && editorView !== void 0 ? editorView : null
|
|
75
|
-
}, /*#__PURE__*/_react.default.createElement(_TableMenuContext.TableMenuProvider, {
|
|
74
|
+
return /*#__PURE__*/_react.default.createElement(_TableMenuContext.TableMenuProvider, {
|
|
76
75
|
value: tableMenuContext
|
|
77
76
|
}, /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
78
77
|
xcss: tableMenuContainerStyles.container,
|
|
@@ -80,6 +79,6 @@ var TableMenu = exports.TableMenu = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
80
79
|
}, /*#__PURE__*/_react.default.createElement(_editorUiControlModel.SurfaceRenderer, {
|
|
81
80
|
surface: surface,
|
|
82
81
|
components: components
|
|
83
|
-
})))
|
|
82
|
+
})));
|
|
84
83
|
});
|
|
85
84
|
TableMenu.displayName = 'TableMenu';
|
|
@@ -31,7 +31,9 @@ var getSharedItems = exports.getSharedItems = function getSharedItems(_ref) {
|
|
|
31
31
|
rank: _keys.CELL_ACTION_SECTION_RANK[_keys4.BACKGROUND_COLOR_ITEM.key]
|
|
32
32
|
}],
|
|
33
33
|
component: function component() {
|
|
34
|
-
return /*#__PURE__*/_react.default.createElement(_BackgroundColorItem.BackgroundColorItem,
|
|
34
|
+
return /*#__PURE__*/_react.default.createElement(_BackgroundColorItem.BackgroundColorItem, {
|
|
35
|
+
api: api
|
|
36
|
+
});
|
|
35
37
|
}
|
|
36
38
|
}, {
|
|
37
39
|
type: _keys4.CLEAR_CELLS_ITEM.type,
|
|
@@ -11,5 +11,5 @@ var _getColumnMenuComponents = require("../column/getColumnMenuComponents");
|
|
|
11
11
|
var _getRowMenuComponents = require("../row/getRowMenuComponents");
|
|
12
12
|
var _getSharedItems = require("./getSharedItems");
|
|
13
13
|
var getTableMenuComponents = exports.getTableMenuComponents = function getTableMenuComponents(params) {
|
|
14
|
-
return [].concat((0, _toConsumableArray2.default)((0, _getRowMenuComponents.getRowMenuComponents)(params)), (0, _toConsumableArray2.default)((0, _getColumnMenuComponents.getColumnMenuComponents)(params)), (0, _toConsumableArray2.default)((0, _getCellMenuComponents.getCellMenuComponents)()), (0, _toConsumableArray2.default)((0, _getSharedItems.getSharedItems)(params)));
|
|
14
|
+
return [].concat((0, _toConsumableArray2.default)((0, _getRowMenuComponents.getRowMenuComponents)(params)), (0, _toConsumableArray2.default)((0, _getColumnMenuComponents.getColumnMenuComponents)(params)), (0, _toConsumableArray2.default)((0, _getCellMenuComponents.getCellMenuComponents)(params)), (0, _toConsumableArray2.default)((0, _getSharedItems.getSharedItems)(params)));
|
|
15
15
|
};
|
|
@@ -10,11 +10,16 @@ require("./BackgroundColorItem.compiled.css");
|
|
|
10
10
|
var _runtime = require("@compiled/react/runtime");
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _reactIntl = require("react-intl");
|
|
13
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
14
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
15
|
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
15
16
|
var _editorPalette = require("@atlaskit/editor-palette");
|
|
16
17
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
17
18
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
19
|
+
var _commands = require("../../../../pm-plugins/commands");
|
|
20
|
+
var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
|
|
21
|
+
var _pluginFactory = require("../../../../pm-plugins/plugin-factory");
|
|
22
|
+
var _TableMenuContext = require("../TableMenuContext");
|
|
18
23
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
19
24
|
var colorPaletteColumns = 7;
|
|
20
25
|
var colorPaletteStyles = {
|
|
@@ -22,16 +27,37 @@ var colorPaletteStyles = {
|
|
|
22
27
|
elemAfter: "_zulp1b66 _1e0c1txw _4cvr1h6o",
|
|
23
28
|
colorPreview: "_2rko12b0 _1h6d1l7x _1dqonqa1 _189ee4h9 _1bsbdlk8 _4t3idlk8 _1o9zidpf"
|
|
24
29
|
};
|
|
25
|
-
var BackgroundColorItem = exports.BackgroundColorItem = function BackgroundColorItem() {
|
|
30
|
+
var BackgroundColorItem = exports.BackgroundColorItem = function BackgroundColorItem(_ref) {
|
|
31
|
+
var _useTableMenuContext, _api$analytics2;
|
|
32
|
+
var api = _ref.api;
|
|
33
|
+
var _ref2 = (_useTableMenuContext = (0, _TableMenuContext.useTableMenuContext)()) !== null && _useTableMenuContext !== void 0 ? _useTableMenuContext : {},
|
|
34
|
+
editorView = _ref2.editorView;
|
|
26
35
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
27
36
|
formatMessage = _useIntl.formatMessage;
|
|
28
|
-
var
|
|
37
|
+
var selectedColor = (0, _react.useMemo)(function () {
|
|
38
|
+
var _node$attrs;
|
|
39
|
+
if (!editorView) {
|
|
40
|
+
return '#ffffff';
|
|
41
|
+
}
|
|
42
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
43
|
+
targetCellPosition = _getPluginState.targetCellPosition;
|
|
44
|
+
var node = targetCellPosition ? editorView.state.doc.nodeAt(targetCellPosition) : null;
|
|
45
|
+
return (0, _editorPalette.hexToEditorBackgroundPaletteColor)((node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
46
|
+
}, [editorView]);
|
|
47
|
+
var onClick = (0, _react.useCallback)(function (color) {
|
|
48
|
+
var _api$analytics;
|
|
49
|
+
if (!editorView) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
(0, _commandsWithAnalytics.setColorWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, color, editorView)(editorView.state, editorView.dispatch);
|
|
53
|
+
(0, _commands.closeActiveTableMenu)()(editorView.state, editorView.dispatch);
|
|
54
|
+
}, [api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, editorView]);
|
|
29
55
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
30
56
|
var colorPreviewStyle = (0, _react.useMemo)(function () {
|
|
31
57
|
return {
|
|
32
|
-
backgroundColor:
|
|
58
|
+
backgroundColor: selectedColor
|
|
33
59
|
};
|
|
34
|
-
}, []);
|
|
60
|
+
}, [selectedColor]);
|
|
35
61
|
var paletteOptions = (0, _react.useMemo)(function () {
|
|
36
62
|
return {
|
|
37
63
|
palette: _uiColor.cellBackgroundColorPalette,
|
|
@@ -10,17 +10,17 @@ var _reactIntl = require("react-intl");
|
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
12
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
|
-
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
14
13
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
14
|
+
var _commands = require("../../../../pm-plugins/commands");
|
|
15
15
|
var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
|
|
16
16
|
var _pluginFactory = require("../../../../pm-plugins/plugin-factory");
|
|
17
17
|
var _TableMenuContext = require("../TableMenuContext");
|
|
18
18
|
var ClearCellsItem = exports.ClearCellsItem = function ClearCellsItem(_ref) {
|
|
19
19
|
var _tableMenuContext$sel, _tableMenuContext$sel2, _tooltip;
|
|
20
20
|
var api = _ref.api;
|
|
21
|
-
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
22
|
-
editorView = _useEditorToolbar.editorView;
|
|
23
21
|
var tableMenuContext = (0, _TableMenuContext.useTableMenuContext)();
|
|
22
|
+
var _ref2 = tableMenuContext !== null && tableMenuContext !== void 0 ? tableMenuContext : {},
|
|
23
|
+
editorView = _ref2.editorView;
|
|
24
24
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
25
25
|
formatMessage = _useIntl.formatMessage;
|
|
26
26
|
var selectedCellCount = Math.max((_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1, (_tableMenuContext$sel2 = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedRowCount) !== null && _tableMenuContext$sel2 !== void 0 ? _tableMenuContext$sel2 : 1);
|
|
@@ -32,6 +32,7 @@ var ClearCellsItem = exports.ClearCellsItem = function ClearCellsItem(_ref) {
|
|
|
32
32
|
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
33
33
|
targetCellPosition = _getPluginState.targetCellPosition;
|
|
34
34
|
(0, _commandsWithAnalytics.emptyMultipleCellsWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, targetCellPosition)(editorView.state, editorView.dispatch);
|
|
35
|
+
(0, _commands.closeActiveTableMenu)()(editorView.state, editorView.dispatch);
|
|
35
36
|
};
|
|
36
37
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
37
38
|
onClick: handleClick,
|
package/dist/cjs/ui/toolbar.js
CHANGED
|
@@ -50,7 +50,8 @@ var _alignment = require("../pm-plugins/utils/alignment");
|
|
|
50
50
|
var _nodes = require("../pm-plugins/utils/nodes");
|
|
51
51
|
var _selection = require("../pm-plugins/utils/selection");
|
|
52
52
|
var _table = require("../pm-plugins/utils/table");
|
|
53
|
-
var
|
|
53
|
+
var _applyMeasuredWidthToSelectedTable = require("../pm-plugins/utils/tableMode/apply-measured-width-to-selected-table");
|
|
54
|
+
var _isContentModeSupported = require("../pm-plugins/utils/tableMode/is-content-mode-supported");
|
|
54
55
|
var _types = require("../types");
|
|
55
56
|
var _FloatingAlignmentButtons = require("./FloatingAlignmentButtons/FloatingAlignmentButtons");
|
|
56
57
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -459,7 +460,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
459
460
|
var isLimitedModeEnabled = (_api$limitedMode$shar = api === null || api === void 0 || (_api$limitedMode = api.limitedMode) === null || _api$limitedMode === void 0 || (_api$limitedMode = _api$limitedMode.sharedState.currentState()) === null || _api$limitedMode === void 0 ? void 0 : _api$limitedMode.enabled) !== null && _api$limitedMode$shar !== void 0 ? _api$limitedMode$shar : false;
|
|
460
461
|
var columnSettingsItems = getColumnSettingItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor, isLimitedModeEnabled);
|
|
461
462
|
var colorPicker = !areAnyNewToolbarFlagsEnabled ? getColorPicker(state, menu, intl, editorAnalyticsAPI, getEditorView) : [];
|
|
462
|
-
var fitToContentButton = (0,
|
|
463
|
+
var fitToContentButton = (0, _isContentModeSupported.isContentModeSupported)({
|
|
463
464
|
allowColumnResizing: !!pluginState.pluginConfig.allowColumnResizing,
|
|
464
465
|
allowTableResizing: !!pluginState.pluginConfig.allowTableResizing,
|
|
465
466
|
isFullPageEditor: !pluginState.isChromelessEditor && !pluginState.isCommentEditor
|
|
@@ -475,7 +476,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
475
476
|
},
|
|
476
477
|
onClick: function onClick(_state, _dispatch, view) {
|
|
477
478
|
if (view) {
|
|
478
|
-
(0,
|
|
479
|
+
(0, _applyMeasuredWidthToSelectedTable.applyMeasuredWidthToSelectedTable)(view, api !== null && api !== void 0 ? api : undefined);
|
|
479
480
|
}
|
|
480
481
|
return true;
|
|
481
482
|
}
|
|
@@ -28,7 +28,7 @@ import { getResizeState, updateColgroup } from '../pm-plugins/table-resizing/uti
|
|
|
28
28
|
import { scaleTable } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
29
29
|
import { containsHeaderRow, isTableNested, isTableNestedInMoreThanOneNode, isTableNestedUnderBodiedSyncBlock, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows } from '../pm-plugins/utils/nodes';
|
|
30
30
|
import { getAssistiveMessage } from '../pm-plugins/utils/table';
|
|
31
|
-
import { isContentModeSupported } from '../pm-plugins/utils/tableMode';
|
|
31
|
+
import { isContentModeSupported } from '../pm-plugins/utils/tableMode/is-content-mode-supported';
|
|
32
32
|
import { TableCssClassName as ClassName } from '../types';
|
|
33
33
|
import { handleMouseOut, handleMouseOver, isTableInFocus, withCellTracking } from '../ui/event-handlers';
|
|
34
34
|
import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
|
|
@@ -13,7 +13,7 @@ import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-con
|
|
|
13
13
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
14
14
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
15
15
|
import { isTableNested, tablesHaveDifferentColumnWidths } from '../pm-plugins/utils/nodes';
|
|
16
|
-
import { isContentModeSupported } from '../pm-plugins/utils/tableMode';
|
|
16
|
+
import { isContentModeSupported } from '../pm-plugins/utils/tableMode/is-content-mode-supported';
|
|
17
17
|
import { TableComponentWithSharedState } from './TableComponentWithSharedState';
|
|
18
18
|
import { tableNodeSpecWithFixedToDOM } from './toDOM';
|
|
19
19
|
const tableAttributes = node => {
|
|
@@ -7,7 +7,7 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
7
7
|
import { generateColgroupFromNode, getResizerMinWidth } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
8
8
|
import { TABLE_MAX_WIDTH, TABLE_FULL_WIDTH } from '../pm-plugins/table-resizing/utils/consts';
|
|
9
9
|
import { getTableResizerContainerMaxWidthInCSS, getTableResizerContainerForFullPageWidthInCSS, getTableResizerItemWidthInCSS } from '../pm-plugins/table-resizing/utils/misc';
|
|
10
|
-
import { isContentModeSupported } from '../pm-plugins/utils/tableMode';
|
|
10
|
+
import { isContentModeSupported } from '../pm-plugins/utils/tableMode/is-content-mode-supported';
|
|
11
11
|
import { getAlignmentStyle } from './table-container-styles';
|
|
12
12
|
export const tableNodeSpecWithFixedToDOM = config => {
|
|
13
13
|
const tableNode = config.isNestingSupported ? tableWithNestedTable : table;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createCommand, getPluginState } from '../plugin-factory';
|
|
2
|
+
export const closeActiveTableMenu = () => createCommand(state => {
|
|
3
|
+
const {
|
|
4
|
+
activeTableMenu
|
|
5
|
+
} = getPluginState(state);
|
|
6
|
+
if (!activeTableMenu || activeTableMenu.type === 'none') {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
type: 'SET_ACTIVE_TABLE_MENU',
|
|
11
|
+
data: {
|
|
12
|
+
activeTableMenu: {
|
|
13
|
+
type: 'none'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}, tr => tr.setMeta('addToHistory', false));
|
|
18
|
+
const isSameActiveTableMenu = (current, next) => {
|
|
19
|
+
if (!current || current.type !== next.type) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (current.type === 'row' || current.type === 'column') {
|
|
23
|
+
return next.type === current.type && current.index === next.index;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
27
|
+
export const toggleActiveTableMenu = activeTableMenu => createCommand(state => {
|
|
28
|
+
const {
|
|
29
|
+
activeTableMenu: currentActiveTableMenu
|
|
30
|
+
} = getPluginState(state);
|
|
31
|
+
return {
|
|
32
|
+
type: 'SET_ACTIVE_TABLE_MENU',
|
|
33
|
+
data: {
|
|
34
|
+
activeTableMenu: isSameActiveTableMenu(currentActiveTableMenu, activeTableMenu) ? {
|
|
35
|
+
type: 'none'
|
|
36
|
+
} : activeTableMenu
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, tr => tr.setMeta('addToHistory', false));
|
|
@@ -10,6 +10,7 @@ import { deleteRows } from '../transforms/delete-rows';
|
|
|
10
10
|
import { mergeCells } from '../transforms/merge';
|
|
11
11
|
import { withEditorAnalyticsAPI, getSelectedCellInfo, getSelectedTableInfo } from '../utils/analytics';
|
|
12
12
|
import { checkIfNumberColumnEnabled } from '../utils/nodes';
|
|
13
|
+
import { toggleActiveTableMenu } from './active-table-menu';
|
|
13
14
|
import { clearMultipleCells } from './clear';
|
|
14
15
|
import { wrapTableInExpand } from './collapse';
|
|
15
16
|
import { changeColumnWidthByStep } from './column-resize';
|
|
@@ -20,8 +21,36 @@ import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleC
|
|
|
20
21
|
import { sortByColumn } from './sort';
|
|
21
22
|
import { splitCell } from './split-cell';
|
|
22
23
|
import { toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn } from './toggle';
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
export const toggleActiveTableMenuWithAnalytics = editorAnalyticsAPI => (direction, index, trigger = 'mouse') => {
|
|
25
|
+
return withEditorAnalyticsAPI(state => {
|
|
26
|
+
const {
|
|
27
|
+
activeTableMenu: previousActiveTableMenu
|
|
28
|
+
} = getPluginState(state);
|
|
29
|
+
const isSameActiveMenu = (previousActiveTableMenu === null || previousActiveTableMenu === void 0 ? void 0 : previousActiveTableMenu.type) === direction && previousActiveTableMenu.index === index;
|
|
30
|
+
if (isSameActiveMenu) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
action: TABLE_ACTION.DRAG_MENU_OPENED,
|
|
35
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
36
|
+
actionSubjectId: null,
|
|
37
|
+
eventType: EVENT_TYPE.TRACK,
|
|
38
|
+
attributes: {
|
|
39
|
+
inputMethod: trigger === 'keyboard' ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE,
|
|
40
|
+
direction
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
})(editorAnalyticsAPI)((state, dispatch) => {
|
|
44
|
+
if (dispatch) {
|
|
45
|
+
toggleActiveTableMenu({
|
|
46
|
+
type: direction,
|
|
47
|
+
index,
|
|
48
|
+
openedBy: trigger
|
|
49
|
+
})(state, dispatch);
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
});
|
|
53
|
+
};
|
|
25
54
|
export const emptyMultipleCellsWithAnalytics = editorAnalyticsAPI => (inputMethod, targetCellPosition) => withEditorAnalyticsAPI(({
|
|
26
55
|
selection
|
|
27
56
|
}) => {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine, setTableHovered } from './hover';
|
|
5
5
|
export { insertColumn, insertRow, createTable } from './insert';
|
|
6
6
|
export { getNextLayout, toggleContextualMenu, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout } from './toggle';
|
|
7
|
+
export { closeActiveTableMenu, toggleActiveTableMenu } from './active-table-menu';
|
|
7
8
|
export { clearMultipleCells } from './clear';
|
|
8
9
|
export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectColumns, selectRow, selectRows, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations, updateWidthToWidest, setFocusToCellMenu } from './misc';
|
|
9
10
|
export { sortByColumn } from './sort';
|
|
@@ -141,6 +141,8 @@ export const cloneSourceWithAnalytics = editorAnalyticsAPI => (inputMethod, sour
|
|
|
141
141
|
return true;
|
|
142
142
|
});
|
|
143
143
|
};
|
|
144
|
+
|
|
145
|
+
// remove when 'platform_editor_table_menu_updates' is cleaned up
|
|
144
146
|
export const toggleDragMenuWithAnalytics = editorAnalyticsAPI => (isDragMenuOpen, direction, index, trigger = 'mouse') => {
|
|
145
147
|
return withEditorAnalyticsAPI(state => {
|
|
146
148
|
const {
|
|
@@ -8,6 +8,7 @@ import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-sc
|
|
|
8
8
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
9
9
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
10
10
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
|
+
import { closeActiveTableMenu } from '../commands/active-table-menu';
|
|
11
12
|
import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
12
13
|
import { pluginKey as tablePluginKey } from '../plugin-key';
|
|
13
14
|
import { insertColgroupFromNode } from '../table-resizing/utils/colgroup';
|
|
@@ -94,6 +95,9 @@ const destroyFn = (editorView, editorAnalyticsAPI, isTableScalingEnabled, isTabl
|
|
|
94
95
|
(_insm$session3 = insm.session) === null || _insm$session3 === void 0 ? void 0 : _insm$session3.startFeature('tableDragAndDrop');
|
|
95
96
|
}
|
|
96
97
|
toggleDragMenu(false)(editorView.state, editorView.dispatch);
|
|
98
|
+
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
99
|
+
closeActiveTableMenu()(editorView.state, editorView.dispatch);
|
|
100
|
+
}
|
|
97
101
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('dragging'));
|
|
98
102
|
},
|
|
99
103
|
onDrag(event) {
|
|
@@ -6,6 +6,7 @@ import { isTextInput } from '@atlaskit/editor-common/utils';
|
|
|
6
6
|
|
|
7
7
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
8
8
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
9
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
10
|
import { defaultTableSelection } from './default-table-selection';
|
|
10
11
|
import { pluginKey as tableResizingPluginKey } from './table-resizing/plugin-key';
|
|
11
12
|
import { isTableCollapsible } from './utils/collapse';
|
|
@@ -40,9 +41,15 @@ const updateTargetCellPosition = ({
|
|
|
40
41
|
if (pluginState.targetCellPosition === targetCellPosition) {
|
|
41
42
|
return pluginState;
|
|
42
43
|
}
|
|
44
|
+
|
|
45
|
+
// The updated table menu is anchored to the current target cell. When selection moves
|
|
46
|
+
// to another cell, close the active menu so render state cannot point at a stale anchor.
|
|
43
47
|
return {
|
|
44
48
|
...pluginState,
|
|
45
|
-
targetCellPosition
|
|
49
|
+
targetCellPosition,
|
|
50
|
+
activeTableMenu: pluginState.activeTableMenu != null && pluginState.activeTableMenu.type !== 'none' && expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? {
|
|
51
|
+
type: 'none'
|
|
52
|
+
} : pluginState.activeTableMenu
|
|
46
53
|
};
|
|
47
54
|
};
|
|
48
55
|
const updateTableNodePluginState = ({
|
|
@@ -25,7 +25,8 @@ import { fixTables } from './transforms/fix-tables';
|
|
|
25
25
|
import { replaceSelectedTable } from './transforms/replace-table';
|
|
26
26
|
import { findControlsHoverDecoration } from './utils/decoration';
|
|
27
27
|
import { transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, transformSliceToRemoveOpenTable, transformSliceToRemoveNestedTables, isHeaderRowRequired, transformSliceTableLayoutDefaultToCenter } from './utils/paste';
|
|
28
|
-
import { applyMeasuredWidthToAllTables
|
|
28
|
+
import { applyMeasuredWidthToAllTables } from './utils/tableMode/apply-measured-width-to-all-tables';
|
|
29
|
+
import { isContentModeSupported } from './utils/tableMode/is-content-mode-supported';
|
|
29
30
|
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, fullWidthModeEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, allowFixedColumnWidthOption) => {
|
|
30
31
|
var _accessibilityUtils;
|
|
31
32
|
const state = createPluginState(dispatch, {
|
|
@@ -34,6 +34,11 @@ export default ((pluginState, action) => {
|
|
|
34
34
|
...pluginState,
|
|
35
35
|
isContextualMenuOpen: !pluginState.isContextualMenuOpen
|
|
36
36
|
};
|
|
37
|
+
case 'SET_ACTIVE_TABLE_MENU':
|
|
38
|
+
return {
|
|
39
|
+
...pluginState,
|
|
40
|
+
...action.data
|
|
41
|
+
};
|
|
37
42
|
case 'SHOW_INSERT_ROW_BUTTON':
|
|
38
43
|
if (action.data.insertRowButtonIndex === pluginState.insertRowButtonIndex) {
|
|
39
44
|
return pluginState;
|
|
@@ -13,7 +13,7 @@ import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorMaxWi
|
|
|
13
13
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
14
|
import { TABLE_MAX_WIDTH, TABLE_FULL_WIDTH } from './table-resizing/utils/consts';
|
|
15
15
|
import { ALIGN_START } from './utils/alignment';
|
|
16
|
-
import { isContentModeSupported } from './utils/tableMode';
|
|
16
|
+
import { isContentModeSupported } from './utils/tableMode/is-content-mode-supported';
|
|
17
17
|
export const pluginKey = new PluginKey('tableWidthPlugin');
|
|
18
18
|
const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, maxWidthEnabled, isTableScalingEnabled, isTableAlignmentEnabled, isCommentEditor) => {
|
|
19
19
|
return new SafePlugin({
|
|
@@ -2,10 +2,11 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
|
2
2
|
import { akEditorFullWidthLayoutWidth, akEditorMaxLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
3
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
4
|
import { updateCellsMarkup } from './table-transform-utils';
|
|
5
|
-
const
|
|
5
|
+
export const clampToEditorMaxWidth = contentWidth => {
|
|
6
6
|
const maxEditorWidth = expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true) ? akEditorMaxLayoutWidth : akEditorFullWidthLayoutWidth;
|
|
7
7
|
return Math.min(maxEditorWidth, contentWidth);
|
|
8
8
|
};
|
|
9
|
+
const tableWidth = clampToEditorMaxWidth;
|
|
9
10
|
export const getTableMeasurement = tableRef => {
|
|
10
11
|
const colWidths = getRenderedColgroupColumnWidths(tableRef);
|
|
11
12
|
const totalContentWidth = colWidths.reduce((acc, current) => acc + current, 0);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
3
|
+
import { hasTableBeenResized } from '@atlaskit/editor-common/table';
|
|
4
|
+
import { applyTableMeasurement, getTableMeasurement } from '../../transforms/content-mode';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Iterates all top-level tables in the document, and for those in content mode,
|
|
8
|
+
* measures rendered column widths and sets colwidth + table width attributes
|
|
9
|
+
* in a single batched transaction.
|
|
10
|
+
*/
|
|
11
|
+
export const applyMeasuredWidthToAllTables = (view, pluginInjectionApi) => {
|
|
12
|
+
const {
|
|
13
|
+
state: {
|
|
14
|
+
doc,
|
|
15
|
+
schema
|
|
16
|
+
}
|
|
17
|
+
} = view;
|
|
18
|
+
let tr = view.state.tr;
|
|
19
|
+
const {
|
|
20
|
+
table
|
|
21
|
+
} = schema.nodes;
|
|
22
|
+
let modified = false;
|
|
23
|
+
const measuredTables = [];
|
|
24
|
+
|
|
25
|
+
// modify only top-level tables
|
|
26
|
+
doc.forEach((node, offset) => {
|
|
27
|
+
if (node.type !== table || hasTableBeenResized(node) && node.attrs.layout !== 'align-start') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const domNode = view.domAtPos(offset + 1).node;
|
|
31
|
+
const tableWrapper = domNode instanceof HTMLElement ? domNode.closest(`.${TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP}`) : null;
|
|
32
|
+
const tableRef = tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.querySelector('table');
|
|
33
|
+
if (!tableRef) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
measuredTables.push({
|
|
37
|
+
node,
|
|
38
|
+
offset,
|
|
39
|
+
measurement: getTableMeasurement(tableRef)
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
measuredTables.forEach(({
|
|
43
|
+
node,
|
|
44
|
+
offset,
|
|
45
|
+
measurement
|
|
46
|
+
}) => {
|
|
47
|
+
tr = applyTableMeasurement(tr, node, measurement, offset);
|
|
48
|
+
modified = true;
|
|
49
|
+
});
|
|
50
|
+
if (modified) {
|
|
51
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$w, _pluginInjectionApi$w2, _pluginInjectionApi$w3;
|
|
52
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : (_pluginInjectionApi$a2 = _pluginInjectionApi$a.actions) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.attachAnalyticsEvent({
|
|
53
|
+
action: TABLE_ACTION.FIT_TO_CONTENT_AUTO_CONVERTED,
|
|
54
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
55
|
+
actionSubjectId: null,
|
|
56
|
+
eventType: EVENT_TYPE.TRACK,
|
|
57
|
+
attributes: {
|
|
58
|
+
editorContainerWidth: (_pluginInjectionApi$w = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$w2 = pluginInjectionApi.width) === null || _pluginInjectionApi$w2 === void 0 ? void 0 : (_pluginInjectionApi$w3 = _pluginInjectionApi$w2.sharedState.currentState()) === null || _pluginInjectionApi$w3 === void 0 ? void 0 : _pluginInjectionApi$w3.width) !== null && _pluginInjectionApi$w !== void 0 ? _pluginInjectionApi$w : 0,
|
|
59
|
+
totalTablesResized: measuredTables.length,
|
|
60
|
+
measurements: measuredTables.map(({
|
|
61
|
+
measurement
|
|
62
|
+
}) => ({
|
|
63
|
+
tableWidth: measurement.tableWidth,
|
|
64
|
+
totalColumnCount: measurement.colWidths.length
|
|
65
|
+
}))
|
|
66
|
+
}
|
|
67
|
+
})(tr);
|
|
68
|
+
view.dispatch(tr.setMeta('addToHistory', false));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
3
|
+
import { applyTableMeasurement } from '../../transforms/content-mode';
|
|
4
|
+
import { measureTableWithAutoLayout } from './measure-table-with-auto-layout';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Used to measure a selected table width with it's content being laid out natively by the browser
|
|
8
|
+
*/
|
|
9
|
+
export const applyMeasuredWidthToSelectedTable = (view, api) => {
|
|
10
|
+
var _api$width, _api$width$sharedStat, _api$analytics, _api$analytics$action, _api$width$sharedStat2, _api$width2, _api$width2$sharedSta;
|
|
11
|
+
const tableObject = findTable(view.state.selection);
|
|
12
|
+
if (!tableObject) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const {
|
|
16
|
+
node,
|
|
17
|
+
pos
|
|
18
|
+
} = tableObject;
|
|
19
|
+
const tableState = api === null || api === void 0 ? void 0 : api.table.sharedState.currentState();
|
|
20
|
+
if (!(tableState !== null && tableState !== void 0 && tableState.tableRef)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const editorContainerWidth = api === null || api === void 0 ? void 0 : (_api$width = api.width) === null || _api$width === void 0 ? void 0 : (_api$width$sharedStat = _api$width.sharedState.currentState()) === null || _api$width$sharedStat === void 0 ? void 0 : _api$width$sharedStat.width;
|
|
24
|
+
const measurement = measureTableWithAutoLayout(tableState.tableRef, editorContainerWidth);
|
|
25
|
+
const tr = applyTableMeasurement(view.state.tr, node, measurement, pos);
|
|
26
|
+
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.attachAnalyticsEvent({
|
|
27
|
+
action: TABLE_ACTION.FIT_TO_CONTENT_ON_DEMAND,
|
|
28
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
29
|
+
actionSubjectId: null,
|
|
30
|
+
eventType: EVENT_TYPE.TRACK,
|
|
31
|
+
attributes: {
|
|
32
|
+
editorContainerWidth: (_api$width$sharedStat2 = api === null || api === void 0 ? void 0 : (_api$width2 = api.width) === null || _api$width2 === void 0 ? void 0 : (_api$width2$sharedSta = _api$width2.sharedState.currentState()) === null || _api$width2$sharedSta === void 0 ? void 0 : _api$width2$sharedSta.width) !== null && _api$width$sharedStat2 !== void 0 ? _api$width$sharedStat2 : 0,
|
|
33
|
+
tableWidth: measurement.tableWidth,
|
|
34
|
+
totalColumnCount: measurement.colWidths.length
|
|
35
|
+
}
|
|
36
|
+
})(tr);
|
|
37
|
+
view.dispatch(tr);
|
|
38
|
+
};
|