@atlaskit/editor-plugin-table 2.2.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/plugins/table/index.js +40 -34
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -3
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +6 -1
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +21 -13
- package/dist/cjs/plugins/table/nodeviews/table.js +7 -2
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +14 -5
- 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/version.json +1 -1
- package/dist/es2019/plugins/table/index.js +18 -9
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +3 -5
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +5 -1
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +26 -14
- package/dist/es2019/plugins/table/nodeviews/table.js +7 -2
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +14 -5
- 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/version.json +1 -1
- package/dist/esm/plugins/table/index.js +40 -34
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +3 -4
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +5 -1
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +21 -13
- package/dist/esm/plugins/table/nodeviews/table.js +7 -2
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +14 -5
- 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/version.json +1 -1
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +2 -2
- package/dist/types/plugins/table/pm-plugins/decorations/plugin.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/table-width.d.ts +16 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-width.d.ts +16 -0
- package/package.json +3 -3
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +66 -0
- package/src/plugins/table/index.tsx +35 -22
- package/src/plugins/table/nodeviews/TableComponent.tsx +4 -11
- package/src/plugins/table/nodeviews/TableContainer.tsx +5 -1
- package/src/plugins/table/nodeviews/TableResizer.tsx +27 -20
- package/src/plugins/table/nodeviews/table.tsx +12 -2
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +26 -4
- package/src/plugins/table/pm-plugins/{table-add-width.ts → table-width.ts} +33 -3
- package/src/plugins/table/toolbar.tsx +7 -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/tmp/api-report-tmp.d.ts +0 -106
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 2.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a9c98fc8503`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a9c98fc8503) - [ED-19028] Remove less-padding class when using table width resizer
|
|
8
|
+
|
|
9
|
+
## 2.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`464c9736dff`](https://bitbucket.org/atlassian/atlassian-frontend/commits/464c9736dff) - [ux] [ED-17626] Remove table controls during table width resizing
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 2.2.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -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");
|
|
@@ -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,
|
|
@@ -410,7 +410,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
410
410
|
tableRenderOptimization = _this$props$getEditor4.tableRenderOptimization,
|
|
411
411
|
tableOverflowShadowsOptimization = _this$props$getEditor4.tableOverflowShadowsOptimization;
|
|
412
412
|
var tableRef = this.table || undefined;
|
|
413
|
-
var isResizing = !!tableResizingPluginState && !!tableResizingPluginState.dragging;
|
|
414
413
|
var headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
|
|
415
414
|
|
|
416
415
|
//dont need to change tableHeight with tableRenderOptimization because it will be observed inside floating components
|
|
@@ -446,7 +445,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
446
445
|
}) : NOOP;
|
|
447
446
|
var isNested = (0, _utils4.isTableNested)(view.state, getPos());
|
|
448
447
|
return /*#__PURE__*/_react.default.createElement(_TableContainer.TableContainer, {
|
|
449
|
-
className: (0, _classnames2.default)(_types.TableCssClassName.TABLE_CONTAINER, (_classnames = {}, (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.WITH_CONTROLS, allowControls && tableActive), (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.TABLE_STICKY, this.state.stickyHeader && hasHeaderRow), (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.HOVERED_DELETE_BUTTON, isInDanger), (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.TABLE_SELECTED, (0, _utils.isTableSelected)(view.state.selection)),
|
|
448
|
+
className: (0, _classnames2.default)(_types.TableCssClassName.TABLE_CONTAINER, (_classnames = {}, (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.WITH_CONTROLS, allowControls && tableActive), (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.TABLE_STICKY, this.state.stickyHeader && hasHeaderRow), (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.HOVERED_DELETE_BUTTON, isInDanger), (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.TABLE_SELECTED, (0, _utils.isTableSelected)(view.state.selection)), _classnames)),
|
|
450
449
|
editorView: view,
|
|
451
450
|
getPos: getPos,
|
|
452
451
|
node: node,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
@@ -12,6 +13,8 @@ var _styles = require("@atlaskit/editor-common/styles");
|
|
|
12
13
|
var _types = require("../types");
|
|
13
14
|
var _TableResizer = require("./TableResizer");
|
|
14
15
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
16
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
18
|
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
19
|
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
20
|
var getMarginLeft = function getMarginLeft(lineLength, tableWidth) {
|
|
@@ -129,7 +132,9 @@ var TableContainer = function TableContainer(_ref3) {
|
|
|
129
132
|
var tableWidth = isBreakoutEnabled ? (0, _styles.calcTableWidth)(node.attrs.layout, editorWidth) : 'inherit';
|
|
130
133
|
return /*#__PURE__*/_react.default.createElement(InnerContainer, {
|
|
131
134
|
node: node,
|
|
132
|
-
className: className,
|
|
135
|
+
className: (0, _classnames.default)(className, {
|
|
136
|
+
'less-padding': editorWidth < _editorSharedStyles.akEditorMobileBreakoutPoint
|
|
137
|
+
}),
|
|
133
138
|
style: {
|
|
134
139
|
width: tableWidth,
|
|
135
140
|
marginLeft: getMarginLeft(lineLength, tableWidth)
|
|
@@ -13,6 +13,7 @@ var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
|
13
13
|
var _resizer = require("@atlaskit/editor-common/resizer");
|
|
14
14
|
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
15
15
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
16
|
+
var _tableWidth = require("../pm-plugins/table-width");
|
|
16
17
|
var _guidelines = require("../utils/guidelines");
|
|
17
18
|
var _snapping = require("../utils/snapping");
|
|
18
19
|
var _consts = require("../ui/consts");
|
|
@@ -70,27 +71,34 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
70
71
|
} : undefined;
|
|
71
72
|
}, [snappingEnabled]);
|
|
72
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
|
+
}));
|
|
73
79
|
setSnappingEnabled(displayGuideline(_guidelines.defaultGuidelines));
|
|
74
80
|
return width;
|
|
75
|
-
}, [width, displayGuideline]);
|
|
81
|
+
}, [width, displayGuideline, editorView]);
|
|
76
82
|
var handleResizeStop = (0, _react.useCallback)(function (originalState, delta) {
|
|
77
83
|
var newWidth = originalState.width + delta.width;
|
|
78
84
|
var state = editorView.state,
|
|
79
85
|
dispatch = editorView.dispatch;
|
|
80
86
|
var pos = getPos();
|
|
81
|
-
|
|
82
|
-
|
|
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);
|
|
83
101
|
}
|
|
84
|
-
var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
85
|
-
width: newWidth
|
|
86
|
-
}));
|
|
87
|
-
var newNode = tr.doc.nodeAt(pos);
|
|
88
|
-
tr = (0, _utils.scaleTable)(tableRef, {
|
|
89
|
-
node: newNode,
|
|
90
|
-
prevNode: node,
|
|
91
|
-
start: pos + 1,
|
|
92
|
-
parentWidth: newWidth
|
|
93
|
-
}, editorView.domAtPos.bind(editorView))(tr);
|
|
94
102
|
dispatch(tr);
|
|
95
103
|
|
|
96
104
|
// Hide guidelines when resizing stops
|
|
@@ -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,7 +141,7 @@ 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,
|
|
@@ -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
|
}
|
|
@@ -4,22 +4,45 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.createPlugin = void 0;
|
|
7
|
+
exports.pluginKey = exports.createPlugin = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
11
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
12
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
13
13
|
var _prosemirrorTransform = require("prosemirror-transform");
|
|
14
|
+
var _prosemirrorState = require("prosemirror-state");
|
|
14
15
|
var _excluded = ["width"];
|
|
15
16
|
/**
|
|
16
|
-
* A plugin for
|
|
17
|
-
*
|
|
17
|
+
* A plugin for handle table custom widths
|
|
18
|
+
* Has login to scan the document, add width value to table's width attribute when necessary
|
|
19
|
+
* Also holds resizing state to hide / show table controls
|
|
18
20
|
*/
|
|
19
21
|
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; }
|
|
20
22
|
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; }
|
|
21
|
-
var
|
|
23
|
+
var pluginKey = new _prosemirrorState.PluginKey('tableWidthPlugin');
|
|
24
|
+
exports.pluginKey = pluginKey;
|
|
25
|
+
var createPlugin = function createPlugin(dispatch, fullWidthEnabled) {
|
|
22
26
|
return new _safePlugin.SafePlugin({
|
|
27
|
+
key: pluginKey,
|
|
28
|
+
state: {
|
|
29
|
+
init: function init() {
|
|
30
|
+
return {
|
|
31
|
+
resizing: false
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
apply: function apply(tr, pluginState) {
|
|
35
|
+
var meta = tr.getMeta(pluginKey);
|
|
36
|
+
if (meta && meta.resizing !== pluginState.resizing) {
|
|
37
|
+
var newState = {
|
|
38
|
+
resizing: meta.resizing
|
|
39
|
+
};
|
|
40
|
+
dispatch(pluginKey, newState);
|
|
41
|
+
return newState;
|
|
42
|
+
}
|
|
43
|
+
return pluginState;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
23
46
|
appendTransaction: function appendTransaction(transactions, _oldState, newState) {
|
|
24
47
|
// When document first load in Confluence, initially it is an empty document
|
|
25
48
|
// and Collab service triggers a transaction to replace the empty document with the real document that should be rendered.
|
|
@@ -13,6 +13,7 @@ var _commands = require("./commands");
|
|
|
13
13
|
var _commandsWithAnalytics = require("./commands-with-analytics");
|
|
14
14
|
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
15
15
|
var _tableResizing = require("./pm-plugins/table-resizing");
|
|
16
|
+
var _tableWidth = require("./pm-plugins/table-width");
|
|
16
17
|
var _types = require("./types");
|
|
17
18
|
var _utils = require("./utils");
|
|
18
19
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
@@ -302,7 +303,11 @@ var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editor
|
|
|
302
303
|
var tableObject = (0, _utils3.findTable)(state.selection);
|
|
303
304
|
var pluginState = (0, _pluginFactory.getPluginState)(state);
|
|
304
305
|
var resizeState = _tableResizing.pluginKey.getState(state);
|
|
305
|
-
|
|
306
|
+
var tableWidthState = _tableWidth.pluginKey.getState(state);
|
|
307
|
+
|
|
308
|
+
// We don't want to show floating toolbar while resizing the table
|
|
309
|
+
var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
310
|
+
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
306
311
|
var nodeType = state.schema.nodes.table;
|
|
307
312
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
308
313
|
var _ref3 = getEditorFeatureFlags() || {},
|
package/dist/cjs/version.json
CHANGED
|
@@ -11,7 +11,7 @@ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/
|
|
|
11
11
|
import { IconTable } from '@atlaskit/editor-common/icons';
|
|
12
12
|
import { pluginConfig } from './create-plugin-config';
|
|
13
13
|
import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
|
|
14
|
-
import { createPlugin as
|
|
14
|
+
import { pluginKey as tableWidthPluginKey, createPlugin as createTableWidthPlugin } from './pm-plugins/table-width';
|
|
15
15
|
import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPlugin } from './pm-plugins/safari-delete-composition-text-issue-workaround';
|
|
16
16
|
import { createPlugin as createDecorationsPlugin } from './pm-plugins/decorations/plugin';
|
|
17
17
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
@@ -155,8 +155,13 @@ const tablesPlugin = (options, api) => {
|
|
|
155
155
|
dispatch
|
|
156
156
|
}) => createTableLocalIdPlugin(dispatch)
|
|
157
157
|
}, {
|
|
158
|
-
name: '
|
|
159
|
-
plugin: (
|
|
158
|
+
name: 'tableWidth',
|
|
159
|
+
plugin: ({
|
|
160
|
+
dispatch
|
|
161
|
+
}) => {
|
|
162
|
+
var _options$fullWidthEna;
|
|
163
|
+
return getBooleanFF('platform.editor.custom-table-width') ? createTableWidthPlugin(dispatch, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false) : undefined;
|
|
164
|
+
}
|
|
160
165
|
}, {
|
|
161
166
|
name: 'tableGetEditorViewReferencePlugin',
|
|
162
167
|
plugin: () => {
|
|
@@ -199,18 +204,22 @@ const tablesPlugin = (options, api) => {
|
|
|
199
204
|
}, /*#__PURE__*/React.createElement(WithPluginState, {
|
|
200
205
|
plugins: {
|
|
201
206
|
tablePluginState: pluginKey,
|
|
207
|
+
tableWidthPluginState: tableWidthPluginKey,
|
|
202
208
|
tableResizingPluginState: tableResizingPluginKey,
|
|
203
209
|
stickyHeadersState: stickyHeadersPluginKey
|
|
204
210
|
},
|
|
205
211
|
render: ({
|
|
206
212
|
tableResizingPluginState: resizingPluginState,
|
|
207
213
|
stickyHeadersState,
|
|
208
|
-
tablePluginState
|
|
214
|
+
tablePluginState,
|
|
215
|
+
tableWidthPluginState
|
|
209
216
|
}) => {
|
|
210
217
|
const {
|
|
211
218
|
state
|
|
212
219
|
} = editorView;
|
|
213
|
-
const
|
|
220
|
+
const isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
221
|
+
const isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
222
|
+
const isResizing = isColumnResizing || isTableResizing;
|
|
214
223
|
const {
|
|
215
224
|
tableNode,
|
|
216
225
|
tablePos,
|
|
@@ -240,7 +249,7 @@ const tablesPlugin = (options, api) => {
|
|
|
240
249
|
stickyHeader: stickyHeader,
|
|
241
250
|
editorAnalyticsAPI: editorAnalyticsAPI
|
|
242
251
|
}) : null;
|
|
243
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !
|
|
252
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
244
253
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
245
254
|
editorView: editorView,
|
|
246
255
|
tableNode: tableNode,
|
|
@@ -267,17 +276,17 @@ const tablesPlugin = (options, api) => {
|
|
|
267
276
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
268
277
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
269
278
|
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
270
|
-
}), /*#__PURE__*/React.createElement(FloatingContextualMenu, {
|
|
279
|
+
}), (options === null || options === void 0 ? void 0 : options.allowContextualMenu) && /*#__PURE__*/React.createElement(FloatingContextualMenu, {
|
|
271
280
|
editorView: editorView,
|
|
272
281
|
mountPoint: popupsMountPoint,
|
|
273
282
|
boundariesElement: popupsBoundariesElement,
|
|
274
283
|
targetCellPosition: targetCellPosition,
|
|
275
|
-
isOpen: Boolean(isContextualMenuOpen),
|
|
284
|
+
isOpen: Boolean(isContextualMenuOpen) && !isResizing,
|
|
276
285
|
pluginConfig: pluginConfig,
|
|
277
286
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
278
287
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
279
288
|
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
280
|
-
}), allowControls && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
289
|
+
}), allowControls && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
281
290
|
editorView: editorView,
|
|
282
291
|
selection: editorView.state.selection,
|
|
283
292
|
tableRef: tableRef,
|
|
@@ -6,7 +6,7 @@ import rafSchedule from 'raf-schd';
|
|
|
6
6
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
7
7
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
8
8
|
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
9
|
-
import {
|
|
9
|
+
import { akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
10
10
|
import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
|
|
11
11
|
import { autoSizeTable, clearHoverSelection } from '../commands';
|
|
12
12
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -376,7 +376,7 @@ class TableComponent extends React.Component {
|
|
|
376
376
|
const {
|
|
377
377
|
view,
|
|
378
378
|
getNode,
|
|
379
|
-
|
|
379
|
+
isResizing,
|
|
380
380
|
allowControls = true,
|
|
381
381
|
isHeaderRowEnabled,
|
|
382
382
|
ordering,
|
|
@@ -405,7 +405,6 @@ class TableComponent extends React.Component {
|
|
|
405
405
|
tableOverflowShadowsOptimization
|
|
406
406
|
} = this.props.getEditorFeatureFlags();
|
|
407
407
|
const tableRef = this.table || undefined;
|
|
408
|
-
const isResizing = !!tableResizingPluginState && !!tableResizingPluginState.dragging;
|
|
409
408
|
const headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
|
|
410
409
|
|
|
411
410
|
//dont need to change tableHeight with tableRenderOptimization because it will be observed inside floating components
|
|
@@ -443,8 +442,7 @@ class TableComponent extends React.Component {
|
|
|
443
442
|
[ClassName.WITH_CONTROLS]: allowControls && tableActive,
|
|
444
443
|
[ClassName.TABLE_STICKY]: this.state.stickyHeader && hasHeaderRow,
|
|
445
444
|
[ClassName.HOVERED_DELETE_BUTTON]: isInDanger,
|
|
446
|
-
[ClassName.TABLE_SELECTED]: isTableSelected(view.state.selection)
|
|
447
|
-
'less-padding': containerWidth.width < akEditorMobileBreakoutPoint
|
|
445
|
+
[ClassName.TABLE_SELECTED]: isTableSelected(view.state.selection)
|
|
448
446
|
}),
|
|
449
447
|
editorView: view,
|
|
450
448
|
getPos: getPos,
|
|
@@ -5,6 +5,8 @@ import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
|
5
5
|
import { TableCssClassName as ClassName } from '../types';
|
|
6
6
|
import { TableResizer } from './TableResizer';
|
|
7
7
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import { akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
8
10
|
const getMarginLeft = (lineLength, tableWidth) => {
|
|
9
11
|
let marginLeft;
|
|
10
12
|
if (tableWidth !== 'inherit' && lineLength) {
|
|
@@ -122,7 +124,9 @@ export const TableContainer = ({
|
|
|
122
124
|
const tableWidth = isBreakoutEnabled ? calcTableWidth(node.attrs.layout, editorWidth) : 'inherit';
|
|
123
125
|
return /*#__PURE__*/React.createElement(InnerContainer, {
|
|
124
126
|
node: node,
|
|
125
|
-
className: className,
|
|
127
|
+
className: classNames(className, {
|
|
128
|
+
'less-padding': editorWidth < akEditorMobileBreakoutPoint
|
|
129
|
+
}),
|
|
126
130
|
style: {
|
|
127
131
|
width: tableWidth,
|
|
128
132
|
marginLeft: getMarginLeft(lineLength, tableWidth)
|
|
@@ -3,6 +3,7 @@ import rafSchd from 'raf-schd';
|
|
|
3
3
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
4
4
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
5
5
|
import { scaleTable, previewScaleTable, getColgroupChildrenLength, COLUMN_MIN_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
6
|
+
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
6
7
|
import { defaultGuidelines, defaultGuidelineWidths } from '../utils/guidelines';
|
|
7
8
|
import { findClosestSnap } from '../utils/snapping';
|
|
8
9
|
import { TABLE_SNAP_GAP, TABLE_HIGHLIGHT_GAP } from '../ui/consts';
|
|
@@ -53,9 +54,18 @@ export const TableResizer = ({
|
|
|
53
54
|
x: defaultGuidelineWidths
|
|
54
55
|
} : undefined, [snappingEnabled]);
|
|
55
56
|
const handleResizeStart = useCallback(() => {
|
|
57
|
+
const {
|
|
58
|
+
dispatch,
|
|
59
|
+
state: {
|
|
60
|
+
tr
|
|
61
|
+
}
|
|
62
|
+
} = editorView;
|
|
63
|
+
dispatch(tr.setMeta(tableWidthPluginKey, {
|
|
64
|
+
resizing: true
|
|
65
|
+
}));
|
|
56
66
|
setSnappingEnabled(displayGuideline(defaultGuidelines));
|
|
57
67
|
return width;
|
|
58
|
-
}, [width, displayGuideline]);
|
|
68
|
+
}, [width, displayGuideline, editorView]);
|
|
59
69
|
const handleResizeStop = useCallback((originalState, delta) => {
|
|
60
70
|
const newWidth = originalState.width + delta.width;
|
|
61
71
|
const {
|
|
@@ -63,20 +73,22 @@ export const TableResizer = ({
|
|
|
63
73
|
dispatch
|
|
64
74
|
} = editorView;
|
|
65
75
|
const pos = getPos();
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
let tr = state.tr.setNodeMarkup(pos, undefined, {
|
|
70
|
-
...node.attrs,
|
|
71
|
-
width: newWidth
|
|
76
|
+
let tr = state.tr.setMeta(tableWidthPluginKey, {
|
|
77
|
+
resizing: false
|
|
72
78
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
if (typeof pos === 'number') {
|
|
80
|
+
tr = tr.setNodeMarkup(pos, undefined, {
|
|
81
|
+
...node.attrs,
|
|
82
|
+
width: newWidth
|
|
83
|
+
});
|
|
84
|
+
const newNode = tr.doc.nodeAt(pos);
|
|
85
|
+
tr = scaleTable(tableRef, {
|
|
86
|
+
node: newNode,
|
|
87
|
+
prevNode: node,
|
|
88
|
+
start: pos + 1,
|
|
89
|
+
parentWidth: newWidth
|
|
90
|
+
}, editorView.domAtPos.bind(editorView))(tr);
|
|
91
|
+
}
|
|
80
92
|
dispatch(tr);
|
|
81
93
|
|
|
82
94
|
// Hide guidelines when resizing stops
|