@atlaskit/editor-plugin-table 2.1.7 → 2.3.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 +20 -0
- package/dist/cjs/plugins/table/handlers.js +1 -0
- package/dist/cjs/plugins/table/index.js +41 -35
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +5 -4
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +50 -47
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +72 -28
- package/dist/cjs/plugins/table/nodeviews/table.js +12 -5
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +14 -5
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
- package/dist/cjs/plugins/table/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-factory.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/{table-add-width.js → table-width.js} +27 -4
- package/dist/cjs/plugins/table/toolbar.js +6 -1
- package/dist/cjs/plugins/table/ui/consts.js +6 -2
- package/dist/cjs/plugins/table/utils/collapse.js +2 -0
- package/dist/cjs/plugins/table/utils/decoration.js +2 -0
- package/dist/cjs/plugins/table/utils/guidelines.js +12 -0
- package/dist/cjs/plugins/table/utils/snapping.js +37 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/handlers.js +1 -0
- package/dist/es2019/plugins/table/index.js +19 -10
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +5 -4
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +25 -23
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +71 -29
- package/dist/es2019/plugins/table/nodeviews/table.js +12 -5
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +18 -6
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/main.js +2 -2
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/{table-add-width.js → table-width.js} +25 -3
- package/dist/es2019/plugins/table/toolbar.js +6 -1
- package/dist/es2019/plugins/table/ui/consts.js +3 -1
- package/dist/es2019/plugins/table/utils/collapse.js +2 -0
- package/dist/es2019/plugins/table/utils/decoration.js +2 -0
- package/dist/es2019/plugins/table/utils/guidelines.js +4 -0
- package/dist/es2019/plugins/table/utils/snapping.js +27 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/handlers.js +1 -0
- package/dist/esm/plugins/table/index.js +41 -35
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +5 -4
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +50 -47
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +69 -28
- package/dist/esm/plugins/table/nodeviews/table.js +12 -5
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +18 -6
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/main.js +2 -2
- package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/{table-add-width.js → table-width.js} +25 -3
- package/dist/esm/plugins/table/toolbar.js +6 -1
- package/dist/esm/plugins/table/ui/consts.js +3 -1
- package/dist/esm/plugins/table/utils/collapse.js +2 -0
- package/dist/esm/plugins/table/utils/decoration.js +2 -0
- package/dist/esm/plugins/table/utils/guidelines.js +4 -0
- package/dist/esm/plugins/table/utils/snapping.js +30 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/index.d.ts +3 -1
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +3 -2
- package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +5 -2
- package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +3 -1
- package/dist/types/plugins/table/nodeviews/table.d.ts +2 -1
- package/dist/types/plugins/table/nodeviews/types.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/decorations/plugin.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/table/pm-plugins/table-width.d.ts +16 -0
- package/dist/types/plugins/table/types.d.ts +3 -0
- package/dist/types/plugins/table/ui/consts.d.ts +2 -0
- package/dist/types/plugins/table/utils/guidelines.d.ts +3 -0
- package/dist/types/plugins/table/utils/snapping.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +3 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +5 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-width.d.ts +16 -0
- package/dist/types-ts4.5/plugins/table/types.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/utils/guidelines.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/utils/snapping.d.ts +8 -0
- package/package.json +4 -3
- package/report.api.md +2 -0
- package/src/__tests__/unit/analytics.ts +2 -0
- package/src/__tests__/unit/collab.ts +2 -0
- package/src/__tests__/unit/commands/go-to-next-cell.ts +2 -0
- package/src/__tests__/unit/commands/insert.ts +2 -0
- package/src/__tests__/unit/commands/misc.ts +2 -0
- package/src/__tests__/unit/commands/sort.ts +4 -0
- package/src/__tests__/unit/commands.ts +2 -0
- package/src/__tests__/unit/copy-paste.ts +2 -0
- package/src/__tests__/unit/event-handlers/index.ts +3 -0
- package/src/__tests__/unit/event-handlers.ts +3 -0
- package/src/__tests__/unit/fix-tables.ts +2 -0
- package/src/__tests__/unit/get-toolbar-config.ts +2 -0
- package/src/__tests__/unit/handlers.ts +2 -0
- package/src/__tests__/unit/hover-selection.ts +2 -0
- package/src/__tests__/unit/index.ts +2 -0
- package/src/__tests__/unit/layout.ts +2 -0
- package/src/__tests__/unit/nodeviews/cell.ts +2 -0
- package/src/__tests__/unit/nodeviews/table.ts +2 -0
- package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +2 -0
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +68 -0
- package/src/__tests__/unit/pm-plugins/main.ts +2 -0
- package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +2 -0
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +3 -0
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +2 -0
- package/src/__tests__/unit/sort-column.ts +2 -0
- package/src/__tests__/unit/toolbar.ts +2 -0
- package/src/__tests__/unit/transforms/delete-columns.ts +2 -0
- package/src/__tests__/unit/transforms/delete-rows.ts +2 -0
- package/src/__tests__/unit/transforms/merging.ts +2 -0
- package/src/__tests__/unit/ui/ContextualMenu.tsx +2 -0
- package/src/__tests__/unit/ui/CornerControls.tsx +2 -0
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +2 -0
- package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +2 -0
- package/src/__tests__/unit/ui/RowControls.tsx +2 -0
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +2 -0
- package/src/__tests__/unit/undo-redo.ts +2 -0
- package/src/__tests__/unit/utils/collapse.ts +2 -0
- package/src/__tests__/unit/utils/nodes.ts +2 -0
- package/src/__tests__/unit/utils/row-controls.ts +2 -0
- package/src/__tests__/unit/utils.ts +2 -0
- package/src/plugins/table/handlers.ts +1 -0
- package/src/plugins/table/index.tsx +38 -23
- package/src/plugins/table/nodeviews/TableComponent.tsx +6 -5
- package/src/plugins/table/nodeviews/TableContainer.tsx +31 -22
- package/src/plugins/table/nodeviews/TableResizer.tsx +107 -34
- package/src/plugins/table/nodeviews/table.tsx +16 -2
- package/src/plugins/table/nodeviews/types.ts +2 -0
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +27 -4
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +1 -0
- package/src/plugins/table/pm-plugins/decorations/utils/types.ts +1 -0
- package/src/plugins/table/pm-plugins/main.ts +3 -0
- package/src/plugins/table/pm-plugins/table-resizing/plugin-factory.ts +1 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +1 -0
- package/src/plugins/table/pm-plugins/{table-add-width.ts → table-width.ts} +33 -3
- package/src/plugins/table/toolbar.tsx +7 -1
- package/src/plugins/table/types.ts +4 -0
- package/src/plugins/table/ui/consts.ts +3 -0
- package/src/plugins/table/utils/collapse.ts +1 -0
- package/src/plugins/table/utils/decoration.ts +1 -0
- package/src/plugins/table/utils/guidelines.ts +17 -0
- package/src/plugins/table/utils/snapping.ts +38 -0
- package/tmp/api-report-tmp.d.ts +3 -1
- package/dist/types/plugins/table/pm-plugins/table-add-width.d.ts +0 -7
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-add-width.d.ts +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 2.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`464c9736dff`](https://bitbucket.org/atlassian/atlassian-frontend/commits/464c9736dff) - [ux] [ED-17626] Remove table controls during table width resizing
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 2.2.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- [`464745a92e6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/464745a92e6) - [ux] Updated the Editor Table plugin to use the new guidelines plugin when custom-table-widths FF is enabled
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 2.1.7
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -16,6 +16,7 @@ var _steps = require("@atlaskit/adf-schema/steps");
|
|
|
16
16
|
var _nodes = require("./utils/nodes");
|
|
17
17
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
18
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } // #region Imports
|
|
19
|
+
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
19
20
|
// #endregion
|
|
20
21
|
var nextTableSorting = function nextTableSorting(tr, table) {
|
|
21
22
|
var tableSortStep = tr.steps.find(function (step) {
|
|
@@ -18,7 +18,7 @@ var _messages = require("@atlaskit/editor-common/messages");
|
|
|
18
18
|
var _icons = require("@atlaskit/editor-common/icons");
|
|
19
19
|
var _createPluginConfig = require("./create-plugin-config");
|
|
20
20
|
var _tableLocalId = require("./pm-plugins/table-local-id");
|
|
21
|
-
var
|
|
21
|
+
var _tableWidth = require("./pm-plugins/table-width");
|
|
22
22
|
var _safariDeleteCompositionTextIssueWorkaround = require("./pm-plugins/safari-delete-composition-text-issue-workaround");
|
|
23
23
|
var _plugin = require("./pm-plugins/decorations/plugin");
|
|
24
24
|
var _keymap = require("./pm-plugins/keymap");
|
|
@@ -103,7 +103,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
103
103
|
breakoutEnabled = _ref2.breakoutEnabled,
|
|
104
104
|
tableOptions = _ref2.tableOptions,
|
|
105
105
|
getEditorFeatureFlags = _ref2.getEditorFeatureFlags;
|
|
106
|
-
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI);
|
|
106
|
+
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api);
|
|
107
107
|
}
|
|
108
108
|
}, {
|
|
109
109
|
name: 'tablePMColResizing',
|
|
@@ -172,9 +172,11 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
172
172
|
return (0, _tableLocalId.createPlugin)(dispatch);
|
|
173
173
|
}
|
|
174
174
|
}, {
|
|
175
|
-
name: '
|
|
176
|
-
plugin: function plugin() {
|
|
177
|
-
|
|
175
|
+
name: 'tableWidth',
|
|
176
|
+
plugin: function plugin(_ref8) {
|
|
177
|
+
var _options$fullWidthEna;
|
|
178
|
+
var dispatch = _ref8.dispatch;
|
|
179
|
+
return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? (0, _tableWidth.createPlugin)(dispatch, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false) : undefined;
|
|
178
180
|
}
|
|
179
181
|
}, {
|
|
180
182
|
name: 'tableGetEditorViewReferencePlugin',
|
|
@@ -204,12 +206,12 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
204
206
|
}
|
|
205
207
|
return plugins;
|
|
206
208
|
},
|
|
207
|
-
contentComponent: function contentComponent(
|
|
208
|
-
var editorView =
|
|
209
|
-
popupsMountPoint =
|
|
210
|
-
popupsBoundariesElement =
|
|
211
|
-
popupsScrollableElement =
|
|
212
|
-
dispatchAnalyticsEvent =
|
|
209
|
+
contentComponent: function contentComponent(_ref9) {
|
|
210
|
+
var editorView = _ref9.editorView,
|
|
211
|
+
popupsMountPoint = _ref9.popupsMountPoint,
|
|
212
|
+
popupsBoundariesElement = _ref9.popupsBoundariesElement,
|
|
213
|
+
popupsScrollableElement = _ref9.popupsScrollableElement,
|
|
214
|
+
dispatchAnalyticsEvent = _ref9.dispatchAnalyticsEvent;
|
|
213
215
|
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
214
216
|
component: _analytics.ACTION_SUBJECT.TABLES_PLUGIN,
|
|
215
217
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
@@ -217,28 +219,32 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
217
219
|
}, /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
|
|
218
220
|
plugins: {
|
|
219
221
|
tablePluginState: _pluginKey.pluginKey,
|
|
222
|
+
tableWidthPluginState: _tableWidth.pluginKey,
|
|
220
223
|
tableResizingPluginState: _tableResizing.pluginKey,
|
|
221
224
|
stickyHeadersState: _stickyHeaders.pluginKey
|
|
222
225
|
},
|
|
223
|
-
render: function render(
|
|
224
|
-
var resizingPluginState =
|
|
225
|
-
stickyHeadersState =
|
|
226
|
-
tablePluginState =
|
|
226
|
+
render: function render(_ref10) {
|
|
227
|
+
var resizingPluginState = _ref10.tableResizingPluginState,
|
|
228
|
+
stickyHeadersState = _ref10.stickyHeadersState,
|
|
229
|
+
tablePluginState = _ref10.tablePluginState,
|
|
230
|
+
tableWidthPluginState = _ref10.tableWidthPluginState;
|
|
227
231
|
var state = editorView.state;
|
|
228
|
-
var
|
|
229
|
-
var
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
232
|
+
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
233
|
+
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
234
|
+
var isResizing = isColumnResizing || isTableResizing;
|
|
235
|
+
var _ref11 = tablePluginState,
|
|
236
|
+
tableNode = _ref11.tableNode,
|
|
237
|
+
tablePos = _ref11.tablePos,
|
|
238
|
+
targetCellPosition = _ref11.targetCellPosition,
|
|
239
|
+
isContextualMenuOpen = _ref11.isContextualMenuOpen,
|
|
240
|
+
layout = _ref11.layout,
|
|
241
|
+
tableRef = _ref11.tableRef,
|
|
242
|
+
pluginConfig = _ref11.pluginConfig,
|
|
243
|
+
insertColumnButtonIndex = _ref11.insertColumnButtonIndex,
|
|
244
|
+
insertRowButtonIndex = _ref11.insertRowButtonIndex,
|
|
245
|
+
isHeaderColumnEnabled = _ref11.isHeaderColumnEnabled,
|
|
246
|
+
isHeaderRowEnabled = _ref11.isHeaderRowEnabled,
|
|
247
|
+
tableWrapperTarget = _ref11.tableWrapperTarget;
|
|
242
248
|
var allowControls = pluginConfig.allowControls;
|
|
243
249
|
var stickyHeader = stickyHeadersState ? (0, _stickyHeaders.findStickyHeaderForTable)(stickyHeadersState, tablePos) : undefined;
|
|
244
250
|
var LayoutContent = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? null : (0, _utils3.isLayoutSupported)(state) && options && options.breakoutEnabled ? /*#__PURE__*/_react.default.createElement(_LayoutButton.default, {
|
|
@@ -252,7 +258,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
252
258
|
stickyHeader: stickyHeader,
|
|
253
259
|
editorAnalyticsAPI: editorAnalyticsAPI
|
|
254
260
|
}) : null;
|
|
255
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, targetCellPosition && tableRef && !
|
|
261
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, targetCellPosition && tableRef && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/_react.default.createElement(_FloatingContextualButton.default, {
|
|
256
262
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
257
263
|
editorView: editorView,
|
|
258
264
|
tableNode: tableNode,
|
|
@@ -279,17 +285,17 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
279
285
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
280
286
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
281
287
|
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
282
|
-
}), /*#__PURE__*/_react.default.createElement(_FloatingContextualMenu.default, {
|
|
288
|
+
}), (options === null || options === void 0 ? void 0 : options.allowContextualMenu) && /*#__PURE__*/_react.default.createElement(_FloatingContextualMenu.default, {
|
|
283
289
|
editorView: editorView,
|
|
284
290
|
mountPoint: popupsMountPoint,
|
|
285
291
|
boundariesElement: popupsBoundariesElement,
|
|
286
292
|
targetCellPosition: targetCellPosition,
|
|
287
|
-
isOpen: Boolean(isContextualMenuOpen),
|
|
293
|
+
isOpen: Boolean(isContextualMenuOpen) && !isResizing,
|
|
288
294
|
pluginConfig: pluginConfig,
|
|
289
295
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
290
296
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
291
297
|
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
292
|
-
}), allowControls && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
|
|
298
|
+
}), allowControls && !isResizing && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
|
|
293
299
|
editorView: editorView,
|
|
294
300
|
selection: editorView.state.selection,
|
|
295
301
|
tableRef: tableRef,
|
|
@@ -304,8 +310,8 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
304
310
|
}));
|
|
305
311
|
},
|
|
306
312
|
pluginsOptions: {
|
|
307
|
-
quickInsert: function quickInsert(
|
|
308
|
-
var formatMessage =
|
|
313
|
+
quickInsert: function quickInsert(_ref12) {
|
|
314
|
+
var formatMessage = _ref12.formatMessage;
|
|
309
315
|
return [{
|
|
310
316
|
id: 'table',
|
|
311
317
|
title: formatMessage(_messages.toolbarInsertBlockMessages.table),
|
|
@@ -384,7 +384,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
384
384
|
var _this$props8 = this.props,
|
|
385
385
|
view = _this$props8.view,
|
|
386
386
|
getNode = _this$props8.getNode,
|
|
387
|
-
|
|
387
|
+
isResizing = _this$props8.isResizing,
|
|
388
388
|
_this$props8$allowCon = _this$props8.allowControls,
|
|
389
389
|
allowControls = _this$props8$allowCon === void 0 ? true : _this$props8$allowCon,
|
|
390
390
|
isHeaderRowEnabled = _this$props8.isHeaderRowEnabled,
|
|
@@ -393,7 +393,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
393
393
|
tableActive = _this$props8.tableActive,
|
|
394
394
|
containerWidth = _this$props8.containerWidth,
|
|
395
395
|
options = _this$props8.options,
|
|
396
|
-
getPos = _this$props8.getPos
|
|
396
|
+
getPos = _this$props8.getPos,
|
|
397
|
+
pluginInjectionApi = _this$props8.pluginInjectionApi;
|
|
397
398
|
var _this$state = this.state,
|
|
398
399
|
isLoading = _this$state.isLoading,
|
|
399
400
|
showBeforeShadow = _this$state.showBeforeShadow,
|
|
@@ -409,7 +410,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
409
410
|
tableRenderOptimization = _this$props$getEditor4.tableRenderOptimization,
|
|
410
411
|
tableOverflowShadowsOptimization = _this$props$getEditor4.tableOverflowShadowsOptimization;
|
|
411
412
|
var tableRef = this.table || undefined;
|
|
412
|
-
var isResizing = !!tableResizingPluginState && !!tableResizingPluginState.dragging;
|
|
413
413
|
var headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
|
|
414
414
|
|
|
415
415
|
//dont need to change tableHeight with tableRenderOptimization because it will be observed inside floating components
|
|
@@ -453,7 +453,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
453
453
|
containerWidth: containerWidth,
|
|
454
454
|
isFullWidthModeEnabled: options === null || options === void 0 ? void 0 : options.isFullWidthModeEnabled,
|
|
455
455
|
isBreakoutEnabled: options === null || options === void 0 ? void 0 : options.isBreakoutEnabled,
|
|
456
|
-
isNested: isNested
|
|
456
|
+
isNested: isNested,
|
|
457
|
+
pluginInjectionApi: pluginInjectionApi
|
|
457
458
|
}, stickyHeadersOptimization && /*#__PURE__*/_react.default.createElement("div", {
|
|
458
459
|
className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
459
460
|
"data-testid": "sticky-sentinel-top"
|
|
@@ -14,9 +14,7 @@ var _TableResizer = require("./TableResizer");
|
|
|
14
14
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
15
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
var getMarginLeft = function getMarginLeft(
|
|
18
|
-
var lineLength = _ref.lineLength,
|
|
19
|
-
tableWidth = _ref.tableWidth;
|
|
17
|
+
var getMarginLeft = function getMarginLeft(lineLength, tableWidth) {
|
|
20
18
|
var marginLeft;
|
|
21
19
|
if (tableWidth !== 'inherit' && lineLength) {
|
|
22
20
|
var containerWidth = tableWidth;
|
|
@@ -26,11 +24,11 @@ var getMarginLeft = function getMarginLeft(_ref) {
|
|
|
26
24
|
}
|
|
27
25
|
return marginLeft;
|
|
28
26
|
};
|
|
29
|
-
var InnerContainer = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
30
|
-
var className =
|
|
31
|
-
style =
|
|
32
|
-
node =
|
|
33
|
-
children =
|
|
27
|
+
var InnerContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
28
|
+
var className = _ref.className,
|
|
29
|
+
style = _ref.style,
|
|
30
|
+
node = _ref.node,
|
|
31
|
+
children = _ref.children;
|
|
34
32
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
35
33
|
ref: ref,
|
|
36
34
|
style: style,
|
|
@@ -41,42 +39,47 @@ var InnerContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
41
39
|
}, children);
|
|
42
40
|
});
|
|
43
41
|
exports.InnerContainer = InnerContainer;
|
|
44
|
-
var ResizableTableContainer = function ResizableTableContainer(
|
|
45
|
-
var children =
|
|
46
|
-
className =
|
|
47
|
-
node =
|
|
48
|
-
lineLength =
|
|
49
|
-
containerWidth =
|
|
50
|
-
editorView =
|
|
51
|
-
getPos =
|
|
52
|
-
tableRef =
|
|
42
|
+
var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
43
|
+
var children = _ref2.children,
|
|
44
|
+
className = _ref2.className,
|
|
45
|
+
node = _ref2.node,
|
|
46
|
+
lineLength = _ref2.lineLength,
|
|
47
|
+
containerWidth = _ref2.containerWidth,
|
|
48
|
+
editorView = _ref2.editorView,
|
|
49
|
+
getPos = _ref2.getPos,
|
|
50
|
+
tableRef = _ref2.tableRef,
|
|
51
|
+
pluginInjectionApi = _ref2.pluginInjectionApi;
|
|
53
52
|
var containerRef = (0, _react.useRef)(null);
|
|
54
53
|
var innerContainerRef = (0, _react.useRef)(null);
|
|
54
|
+
var marginLeftRef = (0, _react.useRef)(0);
|
|
55
55
|
var updateWidth = (0, _react.useCallback)(function (width) {
|
|
56
56
|
if (!containerRef.current || !innerContainerRef.current) {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
-
var marginLeft = getMarginLeft(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
var marginLeft = getMarginLeft(lineLength, width);
|
|
60
|
+
if (marginLeftRef.current !== marginLeft) {
|
|
61
|
+
marginLeftRef.current = marginLeft;
|
|
62
|
+
if (Number.isFinite(marginLeft)) {
|
|
63
|
+
containerRef.current.style.marginLeft = "".concat(marginLeft, "px");
|
|
64
|
+
}
|
|
65
65
|
}
|
|
66
66
|
}, [lineLength]);
|
|
67
|
+
var displayGuideline = (0, _react.useCallback)(function (guidelines) {
|
|
68
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
69
|
+
return (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : (_pluginInjectionApi$d3 = _pluginInjectionApi$d2.guideline) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.actions) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.displayGuideline(editorView)({
|
|
70
|
+
guidelines: guidelines
|
|
71
|
+
})) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : false;
|
|
72
|
+
}, [pluginInjectionApi, editorView]);
|
|
67
73
|
var tableWidth = (0, _nodeWidth.getTableContainerWidth)(node);
|
|
68
74
|
|
|
69
75
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
70
76
|
var responsiveContainerWidth = containerWidth - 76;
|
|
71
77
|
var width = Math.min(tableWidth, responsiveContainerWidth);
|
|
72
|
-
|
|
73
|
-
lineLength: lineLength,
|
|
74
|
-
tableWidth: width
|
|
75
|
-
});
|
|
78
|
+
marginLeftRef.current = getMarginLeft(lineLength, width);
|
|
76
79
|
var maxResizerWidth = Math.min(responsiveContainerWidth, _utils.TABLE_MAX_WIDTH);
|
|
77
80
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
78
81
|
style: {
|
|
79
|
-
marginLeft:
|
|
82
|
+
marginLeft: marginLeftRef.current,
|
|
80
83
|
width: width
|
|
81
84
|
},
|
|
82
85
|
className: _types.TableCssClassName.TABLE_RESIZER_CONTAINER,
|
|
@@ -88,7 +91,8 @@ var ResizableTableContainer = function ResizableTableContainer(_ref3) {
|
|
|
88
91
|
editorView: editorView,
|
|
89
92
|
getPos: getPos,
|
|
90
93
|
node: node,
|
|
91
|
-
tableRef: tableRef
|
|
94
|
+
tableRef: tableRef,
|
|
95
|
+
displayGuideline: displayGuideline
|
|
92
96
|
}, /*#__PURE__*/_react.default.createElement(InnerContainer, {
|
|
93
97
|
ref: innerContainerRef,
|
|
94
98
|
className: className,
|
|
@@ -96,19 +100,20 @@ var ResizableTableContainer = function ResizableTableContainer(_ref3) {
|
|
|
96
100
|
}, children)));
|
|
97
101
|
};
|
|
98
102
|
exports.ResizableTableContainer = ResizableTableContainer;
|
|
99
|
-
var TableContainer = function TableContainer(
|
|
100
|
-
var children =
|
|
101
|
-
node =
|
|
102
|
-
className =
|
|
103
|
-
|
|
104
|
-
lineLength =
|
|
105
|
-
editorWidth =
|
|
106
|
-
isFullWidthModeEnabled =
|
|
107
|
-
isBreakoutEnabled =
|
|
108
|
-
editorView =
|
|
109
|
-
getPos =
|
|
110
|
-
tableRef =
|
|
111
|
-
isNested =
|
|
103
|
+
var TableContainer = function TableContainer(_ref3) {
|
|
104
|
+
var children = _ref3.children,
|
|
105
|
+
node = _ref3.node,
|
|
106
|
+
className = _ref3.className,
|
|
107
|
+
_ref3$containerWidth = _ref3.containerWidth,
|
|
108
|
+
lineLength = _ref3$containerWidth.lineLength,
|
|
109
|
+
editorWidth = _ref3$containerWidth.width,
|
|
110
|
+
isFullWidthModeEnabled = _ref3.isFullWidthModeEnabled,
|
|
111
|
+
isBreakoutEnabled = _ref3.isBreakoutEnabled,
|
|
112
|
+
editorView = _ref3.editorView,
|
|
113
|
+
getPos = _ref3.getPos,
|
|
114
|
+
tableRef = _ref3.tableRef,
|
|
115
|
+
isNested = _ref3.isNested,
|
|
116
|
+
pluginInjectionApi = _ref3.pluginInjectionApi;
|
|
112
117
|
if ((isFullWidthModeEnabled || isBreakoutEnabled) && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') && !isNested) {
|
|
113
118
|
return /*#__PURE__*/_react.default.createElement(ResizableTableContainer, {
|
|
114
119
|
className: className,
|
|
@@ -117,7 +122,8 @@ var TableContainer = function TableContainer(_ref4) {
|
|
|
117
122
|
containerWidth: editorWidth,
|
|
118
123
|
editorView: editorView,
|
|
119
124
|
getPos: getPos,
|
|
120
|
-
tableRef: tableRef
|
|
125
|
+
tableRef: tableRef,
|
|
126
|
+
pluginInjectionApi: pluginInjectionApi
|
|
121
127
|
}, children);
|
|
122
128
|
}
|
|
123
129
|
var tableWidth = isBreakoutEnabled ? (0, _styles.calcTableWidth)(node.attrs.layout, editorWidth) : 'inherit';
|
|
@@ -126,10 +132,7 @@ var TableContainer = function TableContainer(_ref4) {
|
|
|
126
132
|
className: className,
|
|
127
133
|
style: {
|
|
128
134
|
width: tableWidth,
|
|
129
|
-
marginLeft: getMarginLeft(
|
|
130
|
-
lineLength: lineLength,
|
|
131
|
-
tableWidth: tableWidth
|
|
132
|
-
})
|
|
135
|
+
marginLeft: getMarginLeft(lineLength, tableWidth)
|
|
133
136
|
}
|
|
134
137
|
}, children);
|
|
135
138
|
};
|
|
@@ -1,15 +1,24 @@
|
|
|
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.TableResizer = void 0;
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
12
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
11
13
|
var _resizer = require("@atlaskit/editor-common/resizer");
|
|
14
|
+
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
12
15
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
16
|
+
var _tableWidth = require("../pm-plugins/table-width");
|
|
17
|
+
var _guidelines = require("../utils/guidelines");
|
|
18
|
+
var _snapping = require("../utils/snapping");
|
|
19
|
+
var _consts = require("../ui/consts");
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
23
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
24
|
var handles = {
|
|
@@ -24,7 +33,8 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
24
33
|
editorView = _ref.editorView,
|
|
25
34
|
getPos = _ref.getPos,
|
|
26
35
|
node = _ref.node,
|
|
27
|
-
tableRef = _ref.tableRef
|
|
36
|
+
tableRef = _ref.tableRef,
|
|
37
|
+
displayGuideline = _ref.displayGuideline;
|
|
28
38
|
var currentColumnCount = (0, _utils.getColgroupChildrenLength)(node);
|
|
29
39
|
var minColumnWidth = currentColumnCount <= 3 ? currentColumnCount * _utils.COLUMN_MIN_WIDTH : 3 * _utils.COLUMN_MIN_WIDTH;
|
|
30
40
|
var tableHeight = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight;
|
|
@@ -42,15 +52,67 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
42
52
|
} else if (tableHeight && tableHeight >= 96) {
|
|
43
53
|
handleHeightSize = 'large';
|
|
44
54
|
}
|
|
55
|
+
var currentGap = (0, _react.useRef)(0);
|
|
56
|
+
var _useState = (0, _react.useState)(false),
|
|
57
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
58
|
+
snappingEnabled = _useState2[0],
|
|
59
|
+
setSnappingEnabled = _useState2[1];
|
|
60
|
+
var updateActiveGuidelines = (0, _react.useCallback)(function (_ref2) {
|
|
61
|
+
var gap = _ref2.gap,
|
|
62
|
+
keys = _ref2.keys;
|
|
63
|
+
if (gap !== currentGap.current) {
|
|
64
|
+
currentGap.current = gap;
|
|
65
|
+
displayGuideline((0, _guideline.getGuidelinesWithHighlights)(gap, _consts.TABLE_SNAP_GAP, keys, _guidelines.defaultGuidelines));
|
|
66
|
+
}
|
|
67
|
+
}, [displayGuideline]);
|
|
68
|
+
var guidelineSnaps = (0, _react.useMemo)(function () {
|
|
69
|
+
return snappingEnabled ? {
|
|
70
|
+
x: _guidelines.defaultGuidelineWidths
|
|
71
|
+
} : undefined;
|
|
72
|
+
}, [snappingEnabled]);
|
|
73
|
+
var handleResizeStart = (0, _react.useCallback)(function () {
|
|
74
|
+
var dispatch = editorView.dispatch,
|
|
75
|
+
tr = editorView.state.tr;
|
|
76
|
+
dispatch(tr.setMeta(_tableWidth.pluginKey, {
|
|
77
|
+
resizing: true
|
|
78
|
+
}));
|
|
79
|
+
setSnappingEnabled(displayGuideline(_guidelines.defaultGuidelines));
|
|
80
|
+
return width;
|
|
81
|
+
}, [width, displayGuideline, editorView]);
|
|
82
|
+
var handleResizeStop = (0, _react.useCallback)(function (originalState, delta) {
|
|
83
|
+
var newWidth = originalState.width + delta.width;
|
|
84
|
+
var state = editorView.state,
|
|
85
|
+
dispatch = editorView.dispatch;
|
|
86
|
+
var pos = getPos();
|
|
87
|
+
var tr = state.tr.setMeta(_tableWidth.pluginKey, {
|
|
88
|
+
resizing: false
|
|
89
|
+
});
|
|
90
|
+
if (typeof pos === 'number') {
|
|
91
|
+
tr = tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
92
|
+
width: newWidth
|
|
93
|
+
}));
|
|
94
|
+
var newNode = tr.doc.nodeAt(pos);
|
|
95
|
+
tr = (0, _utils.scaleTable)(tableRef, {
|
|
96
|
+
node: newNode,
|
|
97
|
+
prevNode: node,
|
|
98
|
+
start: pos + 1,
|
|
99
|
+
parentWidth: newWidth
|
|
100
|
+
}, editorView.domAtPos.bind(editorView))(tr);
|
|
101
|
+
}
|
|
102
|
+
dispatch(tr);
|
|
103
|
+
|
|
104
|
+
// Hide guidelines when resizing stops
|
|
105
|
+
displayGuideline([]);
|
|
106
|
+
updateWidth(newWidth);
|
|
107
|
+
return newWidth;
|
|
108
|
+
}, [updateWidth, editorView, getPos, node, tableRef, displayGuideline]);
|
|
45
109
|
return /*#__PURE__*/_react.default.createElement(_resizer.ResizerNext, {
|
|
46
110
|
enable: handles,
|
|
47
111
|
width: width,
|
|
48
112
|
handleAlignmentMethod: "sticky",
|
|
49
113
|
handleHeightSize: handleHeightSize,
|
|
50
114
|
handleMarginTop: tableHandleMarginTop,
|
|
51
|
-
handleResizeStart:
|
|
52
|
-
return width;
|
|
53
|
-
},
|
|
115
|
+
handleResizeStart: handleResizeStart,
|
|
54
116
|
handleResize: (0, _rafSchd.default)(function (originalState, delta) {
|
|
55
117
|
var newWidth = originalState.width + delta.width;
|
|
56
118
|
var pos = getPos();
|
|
@@ -63,34 +125,16 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
63
125
|
start: pos + 1,
|
|
64
126
|
parentWidth: newWidth
|
|
65
127
|
}, editorView.domAtPos.bind(editorView));
|
|
128
|
+
updateActiveGuidelines((0, _snapping.findClosestSnap)(newWidth, _guidelines.defaultGuidelineWidths, _guidelines.defaultGuidelines, _consts.TABLE_HIGHLIGHT_GAP));
|
|
66
129
|
updateWidth(newWidth);
|
|
67
130
|
return newWidth;
|
|
68
131
|
}),
|
|
69
|
-
handleResizeStop:
|
|
70
|
-
var newWidth = originalState.width + delta.width;
|
|
71
|
-
var state = editorView.state,
|
|
72
|
-
dispatch = editorView.dispatch;
|
|
73
|
-
var pos = getPos();
|
|
74
|
-
if (typeof pos !== 'number') {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
78
|
-
width: newWidth
|
|
79
|
-
}));
|
|
80
|
-
var newNode = tr.doc.nodeAt(pos);
|
|
81
|
-
tr = (0, _utils.scaleTable)(tableRef, {
|
|
82
|
-
node: newNode,
|
|
83
|
-
prevNode: node,
|
|
84
|
-
start: pos + 1,
|
|
85
|
-
parentWidth: newWidth
|
|
86
|
-
}, editorView.domAtPos.bind(editorView))(tr);
|
|
87
|
-
dispatch(tr);
|
|
88
|
-
updateWidth(newWidth);
|
|
89
|
-
return newWidth;
|
|
90
|
-
},
|
|
132
|
+
handleResizeStop: handleResizeStop,
|
|
91
133
|
resizeRatio: 2,
|
|
92
134
|
minWidth: minColumnWidth,
|
|
93
|
-
maxWidth: maxWidth
|
|
135
|
+
maxWidth: maxWidth,
|
|
136
|
+
snapGap: _consts.TABLE_SNAP_GAP,
|
|
137
|
+
snap: guidelineSnaps
|
|
94
138
|
}, children);
|
|
95
139
|
};
|
|
96
140
|
exports.TableResizer = TableResizer;
|
|
@@ -23,6 +23,7 @@ var _createPluginConfig = require("../create-plugin-config");
|
|
|
23
23
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
24
24
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
25
25
|
var _tableResizing = require("../pm-plugins/table-resizing");
|
|
26
|
+
var _tableWidth = require("../pm-plugins/table-width");
|
|
26
27
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
27
28
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
28
29
|
var _TableComponent = _interopRequireDefault(require("./TableComponent"));
|
|
@@ -114,16 +115,20 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
114
115
|
plugins: {
|
|
115
116
|
pluginState: _pluginKey.pluginKey,
|
|
116
117
|
tableResizingPluginState: _tableResizing.pluginKey,
|
|
118
|
+
tableWidthPluginState: _tableWidth.pluginKey,
|
|
117
119
|
widthPlugin: fakePluginKey,
|
|
118
120
|
mediaState: fakeMediaPluginKey
|
|
119
121
|
},
|
|
120
122
|
editorView: props.view,
|
|
121
123
|
render: function render(pluginStates) {
|
|
122
124
|
var tableResizingPluginState = pluginStates.tableResizingPluginState,
|
|
125
|
+
tableWidthPluginState = pluginStates.tableWidthPluginState,
|
|
123
126
|
pluginState = pluginStates.pluginState,
|
|
124
127
|
mediaState = pluginStates.mediaState;
|
|
125
|
-
var tableActive = props.getPos() === pluginState.tablePos;
|
|
126
128
|
var containerWidth = props.getEditorContainerWidth();
|
|
129
|
+
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
130
|
+
var isResizing = Boolean((tableResizingPluginState === null || tableResizingPluginState === void 0 ? void 0 : tableResizingPluginState.dragging) || isTableResizing);
|
|
131
|
+
var tableActive = props.getPos() === pluginState.tablePos && !isTableResizing;
|
|
127
132
|
return /*#__PURE__*/_react.default.createElement(_TableComponent.default, {
|
|
128
133
|
view: props.view,
|
|
129
134
|
allowColumnResizing: props.allowColumnResizing,
|
|
@@ -136,11 +141,12 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
136
141
|
isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
|
|
137
142
|
tableActive: tableActive,
|
|
138
143
|
ordering: pluginState.ordering,
|
|
139
|
-
|
|
144
|
+
isResizing: isResizing,
|
|
140
145
|
getNode: _this3.getNode,
|
|
141
146
|
containerWidth: containerWidth,
|
|
142
147
|
contentDOM: forwardRef,
|
|
143
|
-
getEditorFeatureFlags: props.getEditorFeatureFlags
|
|
148
|
+
getEditorFeatureFlags: props.getEditorFeatureFlags,
|
|
149
|
+
pluginInjectionApi: props.pluginInjectionApi
|
|
144
150
|
});
|
|
145
151
|
}
|
|
146
152
|
});
|
|
@@ -209,7 +215,7 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
209
215
|
return TableView;
|
|
210
216
|
}(_reactNodeView.default);
|
|
211
217
|
exports.default = TableView;
|
|
212
|
-
var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, options, getEditorContainerWidth, getEditorFeatureFlags) {
|
|
218
|
+
var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, options, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi) {
|
|
213
219
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(view.state),
|
|
214
220
|
pluginConfig = _getPluginState2.pluginConfig;
|
|
215
221
|
var _getPluginConfig = (0, _createPluginConfig.pluginConfig)(pluginConfig),
|
|
@@ -228,7 +234,8 @@ var createTableView = function createTableView(node, view, getPos, portalProvide
|
|
|
228
234
|
tableRenderOptimization: tableRenderOptimization,
|
|
229
235
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
230
236
|
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
231
|
-
hasIntlContext: hasIntlContext
|
|
237
|
+
hasIntlContext: hasIntlContext,
|
|
238
|
+
pluginInjectionApi: pluginInjectionApi
|
|
232
239
|
}).init();
|
|
233
240
|
};
|
|
234
241
|
exports.createTableView = createTableView;
|
|
@@ -9,6 +9,7 @@ var _prosemirrorState = require("prosemirror-state");
|
|
|
9
9
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
10
10
|
var _prosemirrorView = require("prosemirror-view");
|
|
11
11
|
var _pluginKey = require("../plugin-key");
|
|
12
|
+
var _tableWidth = require("../table-width");
|
|
12
13
|
var _utils = require("./utils");
|
|
13
14
|
var pluginKey = new _prosemirrorState.PluginKey('tableDecorationsPlugin');
|
|
14
15
|
exports.pluginKey = pluginKey;
|
|
@@ -16,8 +17,16 @@ var getDecorations = function getDecorations(state) {
|
|
|
16
17
|
return pluginKey.getState(state);
|
|
17
18
|
};
|
|
18
19
|
exports.getDecorations = getDecorations;
|
|
19
|
-
var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr, decorationSet, oldState) {
|
|
20
|
-
|
|
20
|
+
var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr, decorationSet, oldState, newState) {
|
|
21
|
+
var _tableWidthPluginKey$, _tableWidthPluginKey$2;
|
|
22
|
+
var isResizing = (_tableWidthPluginKey$ = _tableWidth.pluginKey.getState(newState)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
|
|
23
|
+
var wasResizing = (_tableWidthPluginKey$2 = _tableWidth.pluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
|
|
24
|
+
var changedResizing = isResizing !== wasResizing;
|
|
25
|
+
|
|
26
|
+
// Remove column controls when resizing
|
|
27
|
+
if (isResizing) {
|
|
28
|
+
return _prosemirrorView.DecorationSet.empty;
|
|
29
|
+
} else if (tr.docChanged || tr.selection instanceof _cellSelection.CellSelection || changedResizing) {
|
|
21
30
|
return (0, _utils.buildColumnControlsDecorations)({
|
|
22
31
|
decorationSet: decorationSet,
|
|
23
32
|
tr: tr
|
|
@@ -40,15 +49,15 @@ var createPlugin = function createPlugin() {
|
|
|
40
49
|
init: function init() {
|
|
41
50
|
return _prosemirrorView.DecorationSet.empty;
|
|
42
51
|
},
|
|
43
|
-
apply: function apply(tr, decorationSet, oldState) {
|
|
52
|
+
apply: function apply(tr, decorationSet, oldState, newState) {
|
|
44
53
|
var pluginState = decorationSet;
|
|
45
54
|
var meta = tr.getMeta(_pluginKey.pluginKey);
|
|
46
55
|
if (meta && meta.data && meta.data.decorationSet) {
|
|
47
56
|
pluginState = meta.data.decorationSet;
|
|
48
57
|
}
|
|
49
|
-
if (tr.docChanged || tr.selectionSet) {
|
|
58
|
+
if (tr.docChanged || tr.selectionSet || tr.getMeta(_tableWidth.pluginKey)) {
|
|
50
59
|
pluginState = pluginState.map(tr.mapping, tr.doc);
|
|
51
|
-
return handleDocOrSelectionChanged(tr, pluginState, oldState);
|
|
60
|
+
return handleDocOrSelectionChanged(tr, pluginState, oldState, newState);
|
|
52
61
|
}
|
|
53
62
|
return pluginState;
|
|
54
63
|
}
|
|
@@ -9,6 +9,8 @@ var _utils = require("@atlaskit/editor-tables/utils");
|
|
|
9
9
|
var _types = require("../../../types");
|
|
10
10
|
var _decoration = require("../../../utils/decoration");
|
|
11
11
|
var _composeDecorations = require("./compose-decorations");
|
|
12
|
+
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
13
|
+
|
|
12
14
|
var isColumnSelected = function isColumnSelected(tr) {
|
|
13
15
|
return tr.selection instanceof _cellSelection.CellSelection && tr.selection.isColSelection();
|
|
14
16
|
};
|