@atlaskit/editor-plugin-table 7.4.9 → 7.5.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 +12 -0
- package/dist/cjs/commands/column-resize.js +4 -2
- package/dist/cjs/commands/delete.js +2 -1
- package/dist/cjs/commands/insert.js +6 -3
- package/dist/cjs/commands-with-analytics.js +4 -2
- package/dist/cjs/event-handlers.js +2 -1
- package/dist/cjs/nodeviews/TableComponent.js +116 -47
- package/dist/cjs/nodeviews/TableContainer.js +8 -4
- package/dist/cjs/nodeviews/TableResizer.js +6 -5
- package/dist/cjs/nodeviews/table.js +12 -4
- package/dist/cjs/plugin.js +50 -47
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +9 -6
- package/dist/cjs/pm-plugins/keymap.js +6 -3
- package/dist/cjs/pm-plugins/main.js +4 -1
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +7 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +32 -11
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +24 -0
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +20 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +2 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +52 -11
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +19 -8
- package/dist/cjs/toolbar.js +17 -10
- package/dist/cjs/transforms/column-width.js +22 -7
- package/dist/cjs/transforms/delete-columns.js +2 -1
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +45 -38
- package/dist/cjs/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +7 -2
- package/dist/cjs/ui/FloatingInsertButton/index.js +5 -1
- package/dist/cjs/utils/create.js +1 -1
- package/dist/cjs/utils/drag-menu.js +4 -3
- package/dist/es2019/commands/column-resize.js +4 -3
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +6 -6
- package/dist/es2019/commands-with-analytics.js +4 -4
- package/dist/es2019/event-handlers.js +2 -2
- package/dist/es2019/nodeviews/TableComponent.js +77 -8
- package/dist/es2019/nodeviews/TableContainer.js +8 -4
- package/dist/es2019/nodeviews/TableResizer.js +6 -5
- package/dist/es2019/nodeviews/table.js +12 -4
- package/dist/es2019/plugin.js +14 -8
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +7 -4
- package/dist/es2019/pm-plugins/keymap.js +6 -3
- package/dist/es2019/pm-plugins/main.js +4 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +7 -3
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +31 -12
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +20 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +47 -10
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +19 -12
- package/dist/es2019/toolbar.js +15 -12
- package/dist/es2019/transforms/column-width.js +24 -10
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +12 -5
- package/dist/es2019/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +7 -2
- package/dist/es2019/ui/FloatingInsertButton/index.js +5 -1
- package/dist/es2019/utils/create.js +1 -1
- package/dist/es2019/utils/drag-menu.js +4 -4
- package/dist/esm/commands/column-resize.js +4 -2
- package/dist/esm/commands/delete.js +2 -1
- package/dist/esm/commands/insert.js +6 -3
- package/dist/esm/commands-with-analytics.js +4 -2
- package/dist/esm/event-handlers.js +2 -1
- package/dist/esm/nodeviews/TableComponent.js +118 -49
- package/dist/esm/nodeviews/TableContainer.js +8 -4
- package/dist/esm/nodeviews/TableResizer.js +6 -5
- package/dist/esm/nodeviews/table.js +12 -4
- package/dist/esm/plugin.js +50 -47
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +9 -6
- package/dist/esm/pm-plugins/keymap.js +6 -3
- package/dist/esm/pm-plugins/main.js +4 -1
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +7 -3
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +32 -11
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +22 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +2 -1
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +52 -11
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +19 -8
- package/dist/esm/toolbar.js +17 -10
- package/dist/esm/transforms/column-width.js +23 -8
- package/dist/esm/transforms/delete-columns.js +2 -1
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +45 -38
- package/dist/esm/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +7 -2
- package/dist/esm/ui/FloatingInsertButton/index.js +5 -1
- package/dist/esm/utils/create.js +1 -1
- package/dist/esm/utils/drag-menu.js +4 -3
- package/dist/types/commands/column-resize.d.ts +1 -1
- package/dist/types/commands/delete.d.ts +1 -1
- package/dist/types/commands/insert.d.ts +3 -3
- package/dist/types/commands-with-analytics.d.ts +2 -2
- package/dist/types/event-handlers.d.ts +1 -1
- package/dist/types/nodeviews/TableComponent.d.ts +3 -0
- package/dist/types/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types/nodeviews/table.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +3 -2
- package/dist/types/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +7 -0
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -3
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types/toolbar.d.ts +2 -2
- package/dist/types/transforms/column-width.d.ts +1 -1
- package/dist/types/transforms/delete-columns.d.ts +1 -1
- package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -2
- package/dist/types/ui/FloatingInsertButton/index.d.ts +2 -1
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
- package/dist/types-ts4.5/commands/delete.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +3 -3
- package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -2
- package/dist/types-ts4.5/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +3 -0
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +3 -2
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -3
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types-ts4.5/toolbar.d.ts +2 -2
- package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
- package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -2
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +2 -1
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/docs/0-intro.tsx +3 -2
- package/package.json +2 -2
- package/src/commands/column-resize.ts +3 -0
- package/src/commands/delete.ts +2 -1
- package/src/commands/insert.ts +15 -6
- package/src/commands-with-analytics.ts +9 -3
- package/src/event-handlers.ts +2 -0
- package/src/nodeviews/TableComponent.tsx +91 -5
- package/src/nodeviews/TableContainer.tsx +7 -1
- package/src/nodeviews/TableResizer.tsx +7 -1
- package/src/nodeviews/table.tsx +15 -10
- package/src/plugin.tsx +17 -5
- package/src/pm-plugins/drag-and-drop/plugin.ts +16 -8
- package/src/pm-plugins/keymap.ts +11 -3
- package/src/pm-plugins/main.ts +3 -0
- package/src/pm-plugins/table-resizing/event-handlers.ts +11 -1
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +49 -17
- package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
- package/src/pm-plugins/table-resizing/utils/index.ts +8 -1
- package/src/pm-plugins/table-resizing/utils/misc.ts +25 -1
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +2 -1
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +56 -11
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +24 -6
- package/src/toolbar.tsx +18 -5
- package/src/transforms/column-width.ts +33 -11
- package/src/transforms/delete-columns.ts +7 -2
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +20 -5
- package/src/ui/FloatingContextualMenu/index.tsx +2 -0
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -0
- package/src/ui/FloatingDragMenu/index.tsx +9 -1
- package/src/ui/FloatingInsertButton/index.tsx +17 -5
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +4 -1
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +4 -1
- package/src/utils/create.ts +1 -3
- package/src/utils/drag-menu.ts +4 -1
- package/tsconfig.dev.json +1 -1
package/dist/esm/plugin.js
CHANGED
|
@@ -147,8 +147,9 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
147
147
|
name: 'tableKeymap',
|
|
148
148
|
plugin: function plugin() {
|
|
149
149
|
var _ref6 = options || {},
|
|
150
|
-
dragAndDropEnabled = _ref6.dragAndDropEnabled
|
|
151
|
-
|
|
150
|
+
dragAndDropEnabled = _ref6.dragAndDropEnabled,
|
|
151
|
+
getEditorFeatureFlags = _ref6.getEditorFeatureFlags;
|
|
152
|
+
return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, dragAndDropEnabled);
|
|
152
153
|
}
|
|
153
154
|
}, {
|
|
154
155
|
name: 'tableSelectionKeymap',
|
|
@@ -189,40 +190,40 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
189
190
|
}, {
|
|
190
191
|
name: 'tableDragAndDrop',
|
|
191
192
|
plugin: function plugin(_ref10) {
|
|
192
|
-
var dispatch = _ref10.dispatch
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch,
|
|
193
|
+
var dispatch = _ref10.dispatch;
|
|
194
|
+
var _ref11 = options || {},
|
|
195
|
+
getEditorFeatureFlags = _ref11.getEditorFeatureFlags;
|
|
196
|
+
return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, getEditorFeatureFlags, editorAnalyticsAPI) : undefined;
|
|
196
197
|
}
|
|
197
198
|
}, {
|
|
198
199
|
name: 'tableLocalId',
|
|
199
|
-
plugin: function plugin(
|
|
200
|
-
var dispatch =
|
|
200
|
+
plugin: function plugin(_ref12) {
|
|
201
|
+
var dispatch = _ref12.dispatch;
|
|
201
202
|
return createTableLocalIdPlugin(dispatch);
|
|
202
203
|
}
|
|
203
204
|
}, {
|
|
204
205
|
name: 'tableWidth',
|
|
205
|
-
plugin: function plugin(
|
|
206
|
+
plugin: function plugin(_ref13) {
|
|
206
207
|
var _options$fullWidthEna;
|
|
207
|
-
var dispatchAnalyticsEvent =
|
|
208
|
-
dispatch =
|
|
208
|
+
var dispatchAnalyticsEvent = _ref13.dispatchAnalyticsEvent,
|
|
209
|
+
dispatch = _ref13.dispatch;
|
|
209
210
|
return options !== null && options !== void 0 && options.tableResizingEnabled ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false, options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) : undefined;
|
|
210
211
|
}
|
|
211
212
|
},
|
|
212
213
|
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
213
214
|
{
|
|
214
215
|
name: 'tableOverflowAnalyticsPlugin',
|
|
215
|
-
plugin: function plugin(
|
|
216
|
+
plugin: function plugin(_ref14) {
|
|
216
217
|
var _options$tableResizin;
|
|
217
|
-
var dispatch =
|
|
218
|
-
dispatchAnalyticsEvent =
|
|
218
|
+
var dispatch = _ref14.dispatch,
|
|
219
|
+
dispatchAnalyticsEvent = _ref14.dispatchAnalyticsEvent;
|
|
219
220
|
return createTableOverflowAnalyticsPlugin(dispatch, dispatchAnalyticsEvent, (_options$tableResizin = options === null || options === void 0 ? void 0 : options.tableResizingEnabled) !== null && _options$tableResizin !== void 0 ? _options$tableResizin : false);
|
|
220
221
|
}
|
|
221
222
|
}, {
|
|
222
223
|
name: 'tableAnalyticsPlugin',
|
|
223
|
-
plugin: function plugin(
|
|
224
|
-
var dispatch =
|
|
225
|
-
dispatchAnalyticsEvent =
|
|
224
|
+
plugin: function plugin(_ref15) {
|
|
225
|
+
var dispatch = _ref15.dispatch,
|
|
226
|
+
dispatchAnalyticsEvent = _ref15.dispatchAnalyticsEvent;
|
|
226
227
|
return getBooleanFF('platform.editor.table.analytics-plugin-moved-event') ? createTableAnalyticsPlugin(dispatch, dispatchAnalyticsEvent) : undefined;
|
|
227
228
|
}
|
|
228
229
|
}, {
|
|
@@ -253,12 +254,12 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
253
254
|
}
|
|
254
255
|
return plugins;
|
|
255
256
|
},
|
|
256
|
-
contentComponent: function contentComponent(
|
|
257
|
-
var editorView =
|
|
258
|
-
popupsMountPoint =
|
|
259
|
-
popupsBoundariesElement =
|
|
260
|
-
popupsScrollableElement =
|
|
261
|
-
dispatchAnalyticsEvent =
|
|
257
|
+
contentComponent: function contentComponent(_ref16) {
|
|
258
|
+
var editorView = _ref16.editorView,
|
|
259
|
+
popupsMountPoint = _ref16.popupsMountPoint,
|
|
260
|
+
popupsBoundariesElement = _ref16.popupsBoundariesElement,
|
|
261
|
+
popupsScrollableElement = _ref16.popupsScrollableElement,
|
|
262
|
+
dispatchAnalyticsEvent = _ref16.dispatchAnalyticsEvent;
|
|
262
263
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
263
264
|
component: ACTION_SUBJECT.TABLES_PLUGIN,
|
|
264
265
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
@@ -272,30 +273,30 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
272
273
|
stickyHeadersState: stickyHeadersPluginKey,
|
|
273
274
|
dragAndDropState: dragAndDropPluginKey
|
|
274
275
|
},
|
|
275
|
-
render: function render(
|
|
276
|
-
var resizingPluginState =
|
|
277
|
-
stickyHeadersState =
|
|
278
|
-
tablePluginState =
|
|
279
|
-
tableWidthPluginState =
|
|
280
|
-
dragAndDropState =
|
|
276
|
+
render: function render(_ref17) {
|
|
277
|
+
var resizingPluginState = _ref17.tableResizingPluginState,
|
|
278
|
+
stickyHeadersState = _ref17.stickyHeadersState,
|
|
279
|
+
tablePluginState = _ref17.tablePluginState,
|
|
280
|
+
tableWidthPluginState = _ref17.tableWidthPluginState,
|
|
281
|
+
dragAndDropState = _ref17.dragAndDropState;
|
|
281
282
|
var state = editorView.state;
|
|
282
283
|
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
283
284
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
284
285
|
var isResizing = isColumnResizing || isTableResizing;
|
|
285
|
-
var
|
|
286
|
-
tableNode =
|
|
287
|
-
tablePos =
|
|
288
|
-
targetCellPosition =
|
|
289
|
-
isContextualMenuOpen =
|
|
290
|
-
layout =
|
|
291
|
-
tableRef =
|
|
292
|
-
pluginConfig =
|
|
293
|
-
insertColumnButtonIndex =
|
|
294
|
-
insertRowButtonIndex =
|
|
295
|
-
isHeaderColumnEnabled =
|
|
296
|
-
isHeaderRowEnabled =
|
|
297
|
-
isDragAndDropEnabled =
|
|
298
|
-
tableWrapperTarget =
|
|
286
|
+
var _ref18 = tablePluginState,
|
|
287
|
+
tableNode = _ref18.tableNode,
|
|
288
|
+
tablePos = _ref18.tablePos,
|
|
289
|
+
targetCellPosition = _ref18.targetCellPosition,
|
|
290
|
+
isContextualMenuOpen = _ref18.isContextualMenuOpen,
|
|
291
|
+
layout = _ref18.layout,
|
|
292
|
+
tableRef = _ref18.tableRef,
|
|
293
|
+
pluginConfig = _ref18.pluginConfig,
|
|
294
|
+
insertColumnButtonIndex = _ref18.insertColumnButtonIndex,
|
|
295
|
+
insertRowButtonIndex = _ref18.insertRowButtonIndex,
|
|
296
|
+
isHeaderColumnEnabled = _ref18.isHeaderColumnEnabled,
|
|
297
|
+
isHeaderRowEnabled = _ref18.isHeaderRowEnabled,
|
|
298
|
+
isDragAndDropEnabled = _ref18.isDragAndDropEnabled,
|
|
299
|
+
tableWrapperTarget = _ref18.tableWrapperTarget;
|
|
299
300
|
var allowControls = pluginConfig.allowControls;
|
|
300
301
|
var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
|
|
301
302
|
var LayoutContent = options && !options.tableResizingEnabled && isLayoutSupported(state) && options.breakoutEnabled ? /*#__PURE__*/React.createElement(LayoutButton, {
|
|
@@ -336,7 +337,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
336
337
|
hasStickyHeaders: stickyHeader && stickyHeader.sticky,
|
|
337
338
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
338
339
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
339
|
-
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
340
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
341
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
340
342
|
}), (options === null || options === void 0 ? void 0 : options.allowContextualMenu) && /*#__PURE__*/React.createElement(FloatingContextualMenu, {
|
|
341
343
|
editorView: editorView,
|
|
342
344
|
mountPoint: popupsMountPoint,
|
|
@@ -360,7 +362,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
360
362
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
361
363
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
362
364
|
stickyHeaders: stickyHeader,
|
|
363
|
-
pluginConfig: pluginConfig
|
|
365
|
+
pluginConfig: pluginConfig,
|
|
366
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
364
367
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
365
368
|
editorView: editorView,
|
|
366
369
|
selection: editorView.state.selection,
|
|
@@ -376,8 +379,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
376
379
|
}));
|
|
377
380
|
},
|
|
378
381
|
pluginsOptions: {
|
|
379
|
-
quickInsert: function quickInsert(
|
|
380
|
-
var formatMessage =
|
|
382
|
+
quickInsert: function quickInsert(_ref19) {
|
|
383
|
+
var formatMessage = _ref19.formatMessage;
|
|
381
384
|
return [{
|
|
382
385
|
id: 'table',
|
|
383
386
|
title: formatMessage(messages.table),
|
|
@@ -17,7 +17,7 @@ import { DropTargetType } from './consts';
|
|
|
17
17
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
18
18
|
import { pluginKey } from './plugin-key';
|
|
19
19
|
import { getDraggableDataFromEvent } from './utils/monitor';
|
|
20
|
-
var destroyFn = function destroyFn(editorView, editorAnalyticsAPI) {
|
|
20
|
+
var destroyFn = function destroyFn(editorView, editorAnalyticsAPI, getEditorFeatureFlags) {
|
|
21
21
|
var editorPageScrollContainer = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
22
22
|
var rowAutoScrollers = editorPageScrollContainer ? [monitorForElements({
|
|
23
23
|
canMonitor: function canMonitor(_ref) {
|
|
@@ -147,7 +147,10 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI) {
|
|
|
147
147
|
tableRef = _getTablePluginState3.tableRef,
|
|
148
148
|
tableNode = _getTablePluginState3.tableNode;
|
|
149
149
|
if (tableRef && tableNode) {
|
|
150
|
-
|
|
150
|
+
var _ref8 = (getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags()) || {},
|
|
151
|
+
_ref8$tablePreserveWi = _ref8.tablePreserveWidth,
|
|
152
|
+
tablePreserveWidth = _ref8$tablePreserveWi === void 0 ? false : _ref8$tablePreserveWi;
|
|
153
|
+
insertColgroupFromNode(tableRef, tableNode, tablePreserveWidth);
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
editorView.focus();
|
|
@@ -155,7 +158,7 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI) {
|
|
|
155
158
|
}
|
|
156
159
|
})]));
|
|
157
160
|
};
|
|
158
|
-
export var createPlugin = function createPlugin(dispatch,
|
|
161
|
+
export var createPlugin = function createPlugin(dispatch, getEditorFeatureFlags, editorAnalyticsAPI) {
|
|
159
162
|
return new SafePlugin({
|
|
160
163
|
state: createPluginState(dispatch, function (state) {
|
|
161
164
|
return {
|
|
@@ -223,7 +226,7 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher, edito
|
|
|
223
226
|
},
|
|
224
227
|
view: function view(editorView) {
|
|
225
228
|
return {
|
|
226
|
-
destroy: destroyFn(editorView, editorAnalyticsAPI)
|
|
229
|
+
destroy: destroyFn(editorView, editorAnalyticsAPI, getEditorFeatureFlags)
|
|
227
230
|
};
|
|
228
231
|
},
|
|
229
232
|
props: {
|
|
@@ -233,7 +236,7 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher, edito
|
|
|
233
236
|
return decorationSet;
|
|
234
237
|
},
|
|
235
238
|
handleKeyDown: function handleKeyDown(view, event) {
|
|
236
|
-
var
|
|
239
|
+
var _ref9;
|
|
237
240
|
var tr = view.state.tr;
|
|
238
241
|
var keysToTrapWhen = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
|
|
239
242
|
|
|
@@ -254,7 +257,7 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher, edito
|
|
|
254
257
|
return true;
|
|
255
258
|
}
|
|
256
259
|
}
|
|
257
|
-
var isDragHandleFocused = ['drag-handle-button-row', 'drag-handle-button-column'].includes((
|
|
260
|
+
var isDragHandleFocused = ['drag-handle-button-row', 'drag-handle-button-column'].includes((_ref9 = event.target || null) === null || _ref9 === void 0 ? void 0 : _ref9.id);
|
|
258
261
|
var keysToTrap = ['Enter', ' '];
|
|
259
262
|
var _getPluginState3 = getPluginState(view.state),
|
|
260
263
|
isDragMenuOpen = _getPluginState3.isDragMenuOpen;
|
|
@@ -20,7 +20,7 @@ var createTableWithAnalytics = function createTableWithAnalytics(editorAnalytics
|
|
|
20
20
|
eventType: EVENT_TYPE.TRACK
|
|
21
21
|
})(editorAnalyticsAPI)(createTable());
|
|
22
22
|
};
|
|
23
|
-
export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled) {
|
|
23
|
+
export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, dragAndDropEnabled) {
|
|
24
24
|
var list = {};
|
|
25
25
|
bindKeymapWithCommand(nextCell.common, goToNextCell(editorAnalyticsAPI)(1), list);
|
|
26
26
|
bindKeymapWithCommand(previousCell.common, goToNextCell(editorAnalyticsAPI)(-1), list);
|
|
@@ -52,11 +52,14 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
52
52
|
bindKeymapWithCommand(deleteRow.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI), list);
|
|
53
53
|
}
|
|
54
54
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
55
|
+
var _ref = getEditorFeatureFlags ? getEditorFeatureFlags() : {},
|
|
56
|
+
_ref$tablePreserveWid = _ref.tablePreserveWidth,
|
|
57
|
+
tablePreserveWidth = _ref$tablePreserveWid === void 0 ? false : _ref$tablePreserveWid;
|
|
55
58
|
bindKeymapWithCommand(startColumnResizing.common, initiateKeyboardColumnResizing, list);
|
|
56
59
|
bindKeymapWithCommand(moveRight.common, activateNextResizeArea(1), list);
|
|
57
60
|
bindKeymapWithCommand(moveLeft.common, activateNextResizeArea(-1), list);
|
|
58
|
-
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStep(-10, getEditorContainerWidth), list);
|
|
59
|
-
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStep(10, getEditorContainerWidth), list);
|
|
61
|
+
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStep(-10, getEditorContainerWidth, tablePreserveWidth), list);
|
|
62
|
+
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStep(10, getEditorContainerWidth, tablePreserveWidth), list);
|
|
60
63
|
bindKeymapWithCommand(escape.common, stopKeyboardColumnResizing(), list);
|
|
61
64
|
}
|
|
62
65
|
return keymap(list);
|
|
@@ -88,9 +88,12 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
+
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
92
|
+
_getEditorFeatureFlag2 = _getEditorFeatureFlag.tablePreserveWidth,
|
|
93
|
+
tablePreserveWidth = _getEditorFeatureFlag2 === void 0 ? false : _getEditorFeatureFlag2;
|
|
91
94
|
if (tr) {
|
|
92
95
|
// "fixTables" removes empty rows as we don't allow that in schema
|
|
93
|
-
var updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI, editorViewRef || undefined);
|
|
96
|
+
var updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI, editorViewRef || undefined, tablePreserveWidth);
|
|
94
97
|
return fixTables(updatedTr) || updatedTr;
|
|
95
98
|
}
|
|
96
99
|
if (transactions.find(function (tr) {
|
|
@@ -19,6 +19,9 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
19
19
|
dispatch = view.dispatch;
|
|
20
20
|
var editorDisabled = !view.editable;
|
|
21
21
|
var domAtPos = view.domAtPos.bind(view);
|
|
22
|
+
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
23
|
+
_getEditorFeatureFlag2 = _getEditorFeatureFlag.tablePreserveWidth,
|
|
24
|
+
tablePreserveWidth = _getEditorFeatureFlag2 === void 0 ? false : _getEditorFeatureFlag2;
|
|
22
25
|
if (editorDisabled || localResizeHandlePos === null || !pointsAtCell(state.doc.resolve(localResizeHandlePos))) {
|
|
23
26
|
return false;
|
|
24
27
|
}
|
|
@@ -64,7 +67,8 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
64
67
|
table: originalTable,
|
|
65
68
|
tableRef: dom,
|
|
66
69
|
start: start,
|
|
67
|
-
domAtPos: domAtPos
|
|
70
|
+
domAtPos: domAtPos,
|
|
71
|
+
tablePreserveWidth: tablePreserveWidth
|
|
68
72
|
});
|
|
69
73
|
if (evenColumns({
|
|
70
74
|
resizeState: resizeState,
|
|
@@ -136,7 +140,7 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
136
140
|
var selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
137
141
|
// only selected (or selected - 1) columns should be distributed
|
|
138
142
|
var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
139
|
-
var newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, resizingSelectedColumns ? selectedColumns : undefined);
|
|
143
|
+
var newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, resizingSelectedColumns ? selectedColumns : undefined, tablePreserveWidth);
|
|
140
144
|
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
141
145
|
if (colIndex === map.width - 1) {
|
|
142
146
|
var mouseUpTime = event.timeStamp;
|
|
@@ -184,7 +188,7 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
184
188
|
var table = $cell.node(-1);
|
|
185
189
|
var map = TableMap.get(table);
|
|
186
190
|
var colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
|
|
187
|
-
resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom);
|
|
191
|
+
resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom, undefined, tablePreserveWidth);
|
|
188
192
|
updateControls()(state);
|
|
189
193
|
}
|
|
190
194
|
window.addEventListener('mouseup', finish);
|
|
@@ -4,6 +4,7 @@ import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
|
4
4
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { MAX_SCALING_PERCENT } from './consts';
|
|
7
8
|
/**
|
|
8
9
|
* This ensures the combined width of the columns (and tbody) of table is always smaller or equal
|
|
9
10
|
* than the table and table wrapper elements. This is necessary as there is no longer
|
|
@@ -13,7 +14,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
|
13
14
|
export var getColWidthFix = function getColWidthFix(colwidth, tableColumnCount) {
|
|
14
15
|
return colwidth - 1 / tableColumnCount;
|
|
15
16
|
};
|
|
16
|
-
export var generateColgroup = function generateColgroup(table) {
|
|
17
|
+
export var generateColgroup = function generateColgroup(table, tableRef) {
|
|
17
18
|
var cols = [];
|
|
18
19
|
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
19
20
|
var map = TableMap.get(table);
|
|
@@ -22,11 +23,27 @@ export var generateColgroup = function generateColgroup(table) {
|
|
|
22
23
|
if (Array.isArray(cell.attrs.colwidth)) {
|
|
23
24
|
// We slice here to guard against our colwidth array having more entries
|
|
24
25
|
// Than the we actually span. We'll patch the document at a later point.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
if (tableRef) {
|
|
27
|
+
var _tableRef$parentEleme;
|
|
28
|
+
var tableWidth = table.attrs && table.attrs.width;
|
|
29
|
+
var renderWidth = ((_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || 760;
|
|
30
|
+
var scalePercent = renderWidth / tableWidth;
|
|
31
|
+
scalePercent = Math.max(scalePercent, 1 - MAX_SCALING_PERCENT);
|
|
32
|
+
cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
|
|
33
|
+
var fixedColWidth = getColWidthFix(width, map.width);
|
|
34
|
+
var scaledWidth = fixedColWidth * Math.min(scalePercent, 1);
|
|
35
|
+
var finalWidth = Math.max(scaledWidth, tableCellMinWidth);
|
|
36
|
+
cols.push(['col', {
|
|
37
|
+
style: "width: ".concat(finalWidth, "px;")
|
|
38
|
+
}]);
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
|
|
42
|
+
cols.push(['col', {
|
|
43
|
+
style: "width: ".concat(getColWidthFix(width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth, map.width), "px;")
|
|
44
|
+
}]);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
30
47
|
} else {
|
|
31
48
|
// When we have merged cells on the first row (firstChild),
|
|
32
49
|
// We want to ensure we're creating the appropriate amount of
|
|
@@ -66,12 +83,16 @@ export var generateColgroup = function generateColgroup(table) {
|
|
|
66
83
|
return cols;
|
|
67
84
|
};
|
|
68
85
|
export var insertColgroupFromNode = function insertColgroupFromNode(tableRef, table) {
|
|
86
|
+
var tablePreserveWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
87
|
+
var shouldRemove = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
69
88
|
var colgroup = tableRef.querySelector('colgroup');
|
|
70
|
-
if (colgroup) {
|
|
89
|
+
if (colgroup && shouldRemove) {
|
|
71
90
|
tableRef.removeChild(colgroup);
|
|
72
91
|
}
|
|
73
|
-
colgroup = renderColgroupFromNode(table);
|
|
74
|
-
|
|
92
|
+
colgroup = renderColgroupFromNode(table, tablePreserveWidth ? tableRef : undefined);
|
|
93
|
+
if (shouldRemove) {
|
|
94
|
+
tableRef.insertBefore(colgroup, tableRef.firstChild);
|
|
95
|
+
}
|
|
75
96
|
return colgroup.children;
|
|
76
97
|
};
|
|
77
98
|
export var hasTableBeenResized = function hasTableBeenResized(table) {
|
|
@@ -93,8 +114,8 @@ export var isMinCellWidthTable = function isMinCellWidthTable(table) {
|
|
|
93
114
|
});
|
|
94
115
|
return isTableMinCellWidth;
|
|
95
116
|
};
|
|
96
|
-
function renderColgroupFromNode(table) {
|
|
97
|
-
var rendered = DOMSerializer.renderSpec(document, ['colgroup', {}].concat(_toConsumableArray(generateColgroup(table))));
|
|
117
|
+
function renderColgroupFromNode(table, maybeTableRef) {
|
|
118
|
+
var rendered = DOMSerializer.renderSpec(document, ['colgroup', {}].concat(_toConsumableArray(generateColgroup(table, maybeTableRef))));
|
|
98
119
|
return rendered.dom;
|
|
99
120
|
}
|
|
100
121
|
export var getColgroupChildrenLength = function getColgroupChildrenLength(table) {
|
|
@@ -3,8 +3,8 @@ export { contentWidth } from './content-width';
|
|
|
3
3
|
export { getColumnStateFromDOM, getFreeSpace, getCellsRefsInColumn, calculateColumnWidth, addContainerLeftRightPadding } from './column-state';
|
|
4
4
|
export { growColumn, shrinkColumn, reduceSpace } from './resize-logic';
|
|
5
5
|
export { getResizeState, updateColgroup, getTotalWidth, evenAllColumnsWidths, bulkColumnsResize, areColumnsEven, adjustColumnsWidths } from './resize-state';
|
|
6
|
-
export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround, getTableMaxWidth } from './misc';
|
|
6
|
+
export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround, getTableMaxWidth, getTableElementWidth, getTableContainerElement } from './misc';
|
|
7
7
|
export { updateControls, isClickNear, getResizeCellPos } from './dom';
|
|
8
8
|
export { scale, scaleWithParent, scaleTable, previewScaleTable } from './scale-table';
|
|
9
9
|
export { resizeColumn } from './resize-column';
|
|
10
|
-
export { COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH } from './consts';
|
|
10
|
+
export { COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH, TABLE_DEFAULT_WIDTH, MAX_SCALING_PERCENT } from './consts';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { getParentNodeWidth, layoutToWidth } from '@atlaskit/editor-common/node-width';
|
|
1
|
+
import { getParentNodeWidth, getTableContainerWidth, layoutToWidth } from '@atlaskit/editor-common/node-width';
|
|
2
2
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { getBreakpoint, mapBreakpointToLayoutMaxWidth } from '@atlaskit/editor-common/ui';
|
|
4
|
-
import { containsClassName } from '@atlaskit/editor-common/utils';
|
|
4
|
+
import { calcTableColumnWidths, containsClassName } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
6
6
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { hasTableBeenResized } from './colgroup';
|
|
8
|
+
|
|
7
9
|
// Translates named layouts in number values.
|
|
8
10
|
export function getLayoutSize(tableLayout) {
|
|
9
11
|
var containerWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
@@ -69,4 +71,22 @@ export var getTableMaxWidth = function getTableMaxWidth(_ref2) {
|
|
|
69
71
|
maxWidth -= akEditorTableNumberColumnWidth;
|
|
70
72
|
}
|
|
71
73
|
return maxWidth;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
* @param table
|
|
79
|
+
* @returns calculated width of <table /> element derived from sum of colwidths on tableCell or tableHeader nodes or falls back to container width
|
|
80
|
+
*/
|
|
81
|
+
export var getTableElementWidth = function getTableElementWidth(table) {
|
|
82
|
+
if (hasTableBeenResized(table)) {
|
|
83
|
+
// TODO: is there a scenario where ADF columns are SMALLER than container width?
|
|
84
|
+
return calcTableColumnWidths(table).reduce(function (sum, width) {
|
|
85
|
+
return sum + width;
|
|
86
|
+
}, 0);
|
|
87
|
+
}
|
|
88
|
+
return getTableContainerElement(table);
|
|
89
|
+
};
|
|
90
|
+
export var getTableContainerElement = function getTableContainerElement(table) {
|
|
91
|
+
return getTableContainerWidth(table);
|
|
72
92
|
};
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { growColumn, shrinkColumn } from './resize-logic';
|
|
3
3
|
import { updateColgroup } from './resize-state';
|
|
4
4
|
export var resizeColumn = function resizeColumn(resizeState, colIndex, amount, tableRef, selectedColumns) {
|
|
5
|
+
var tablePreserveWidth = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
5
6
|
var newState = amount > 0 ? growColumn(resizeState, colIndex, amount, selectedColumns) : amount < 0 ? shrinkColumn(resizeState, colIndex, amount, selectedColumns) : resizeState;
|
|
6
|
-
updateColgroup(newState, tableRef);
|
|
7
|
+
updateColgroup(newState, tableRef, tablePreserveWidth);
|
|
7
8
|
return newState;
|
|
8
9
|
};
|
|
@@ -9,13 +9,17 @@ import { getColWidthFix, hasTableBeenResized, insertColgroupFromNode } from './c
|
|
|
9
9
|
import { getCellsRefsInColumn, getColumnStateFromDOM } from './column-state';
|
|
10
10
|
import { syncStickyRowToTable } from './dom';
|
|
11
11
|
import { getTableMaxWidth } from './misc';
|
|
12
|
+
import { MAX_SCALING_PERCENT, TABLE_DEFAULT_WIDTH } from './index';
|
|
12
13
|
export var getResizeState = function getResizeState(_ref) {
|
|
13
14
|
var minWidth = _ref.minWidth,
|
|
14
15
|
maxSize = _ref.maxSize,
|
|
15
16
|
table = _ref.table,
|
|
16
17
|
tableRef = _ref.tableRef,
|
|
17
18
|
start = _ref.start,
|
|
18
|
-
domAtPos = _ref.domAtPos
|
|
19
|
+
domAtPos = _ref.domAtPos,
|
|
20
|
+
_ref$tablePreserveWid = _ref.tablePreserveWidth,
|
|
21
|
+
tablePreserveWidth = _ref$tablePreserveWid === void 0 ? false : _ref$tablePreserveWid;
|
|
22
|
+
// If the table has been resized, we can use the column widths from the table node
|
|
19
23
|
if (hasTableBeenResized(table)) {
|
|
20
24
|
var _cols = calcTableColumnWidths(table).map(function (width, index) {
|
|
21
25
|
return {
|
|
@@ -39,10 +43,22 @@ export var getResizeState = function getResizeState(_ref) {
|
|
|
39
43
|
overflow: _overflow
|
|
40
44
|
};
|
|
41
45
|
}
|
|
46
|
+
var shouldReinsertColgroup = !tablePreserveWidth;
|
|
42
47
|
|
|
43
48
|
// Getting the resize state from DOM
|
|
44
|
-
var colgroupChildren = insertColgroupFromNode(tableRef, table
|
|
49
|
+
var colgroupChildren = insertColgroupFromNode(tableRef, table, tablePreserveWidth, shouldReinsertColgroup // don't reinsert colgroup when preserving table width - this causes widths to jump
|
|
50
|
+
);
|
|
51
|
+
|
|
45
52
|
var cols = Array.from(colgroupChildren).map(function (_, index) {
|
|
53
|
+
// If the table hasn't been resized and we have a table width attribute, we can use it
|
|
54
|
+
// to calculate the widths of the columns
|
|
55
|
+
if (tablePreserveWidth && table.attrs.width) {
|
|
56
|
+
return {
|
|
57
|
+
index: index,
|
|
58
|
+
width: table.attrs.width / colgroupChildren.length,
|
|
59
|
+
minWidth: 48
|
|
60
|
+
};
|
|
61
|
+
}
|
|
46
62
|
var cellsRefs = getCellsRefsInColumn(index, table, start, domAtPos);
|
|
47
63
|
return getColumnStateFromDOM(cellsRefs, index, minWidth);
|
|
48
64
|
});
|
|
@@ -63,18 +79,41 @@ export var getResizeState = function getResizeState(_ref) {
|
|
|
63
79
|
};
|
|
64
80
|
|
|
65
81
|
// updates Colgroup DOM node with new widths
|
|
66
|
-
export var updateColgroup = function updateColgroup(state, tableRef) {
|
|
82
|
+
export var updateColgroup = function updateColgroup(state, tableRef, tablePreserveWidth) {
|
|
67
83
|
var cols = tableRef.querySelectorAll('col');
|
|
68
84
|
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
69
85
|
var columnsCount = cols.length;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
if (tablePreserveWidth) {
|
|
87
|
+
var _tableRef$dataset;
|
|
88
|
+
var tableWidth = parseInt(((_tableRef$dataset = tableRef.dataset) === null || _tableRef$dataset === void 0 ? void 0 : _tableRef$dataset.tableWidth) || ''); // TODO - get this value from the table node, not the dom
|
|
89
|
+
if (tableWidth) {
|
|
90
|
+
var _tableRef$parentEleme;
|
|
91
|
+
var renderWidth = ((_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || TABLE_DEFAULT_WIDTH;
|
|
92
|
+
var scalePercent = renderWidth / tableWidth;
|
|
93
|
+
scalePercent = Math.max(scalePercent, 1 - MAX_SCALING_PERCENT);
|
|
94
|
+
state.cols.filter(function (column) {
|
|
95
|
+
return column && !!column.width;
|
|
96
|
+
}) // if width is 0, we dont want to apply that.
|
|
97
|
+
.forEach(function (column, i) {
|
|
98
|
+
var fixedColWidth = getColWidthFix(column.width, columnsCount);
|
|
99
|
+
var scaledWidth = fixedColWidth * Math.min(scalePercent, 1);
|
|
100
|
+
var finalWidth = Math.max(scaledWidth, tableCellMinWidth);
|
|
101
|
+
// we aren't handling the remaining pixels here when the 48px min width is reached
|
|
102
|
+
if (cols[i]) {
|
|
103
|
+
cols[i].style.width = "".concat(finalWidth, "px");
|
|
104
|
+
}
|
|
105
|
+
});
|
|
76
106
|
}
|
|
77
|
-
}
|
|
107
|
+
} else {
|
|
108
|
+
state.cols.filter(function (column) {
|
|
109
|
+
return column && !!column.width;
|
|
110
|
+
}) // if width is 0, we dont want to apply that.
|
|
111
|
+
.forEach(function (column, i) {
|
|
112
|
+
if (cols[i]) {
|
|
113
|
+
cols[i].style.width = "".concat(getColWidthFix(column.width, columnsCount), "px");
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
78
117
|
} else {
|
|
79
118
|
state.cols.filter(function (column) {
|
|
80
119
|
return column && !!column.width;
|
|
@@ -262,6 +301,7 @@ export var normaliseTableLayout = function normaliseTableLayout(input) {
|
|
|
262
301
|
}
|
|
263
302
|
};
|
|
264
303
|
export var getNewResizeStateFromSelectedColumns = function getNewResizeStateFromSelectedColumns(rect, state, domAtPos, getEditorContainerWidth) {
|
|
304
|
+
var tablePreserveWidth = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
265
305
|
// Fail early so that we don't do complex calculations for no reason
|
|
266
306
|
var numColumnsSelected = rect.right - rect.left;
|
|
267
307
|
if (numColumnsSelected <= 1) {
|
|
@@ -298,7 +338,8 @@ export var getNewResizeStateFromSelectedColumns = function getNewResizeStateFrom
|
|
|
298
338
|
table: table.node,
|
|
299
339
|
tableRef: tableRef,
|
|
300
340
|
start: table.start,
|
|
301
|
-
domAtPos: domAtPos
|
|
341
|
+
domAtPos: domAtPos,
|
|
342
|
+
tablePreserveWidth: tablePreserveWidth
|
|
302
343
|
});
|
|
303
344
|
var newResizeState = evenSelectedColumnsWidths(resizeState, rect);
|
|
304
345
|
var widthsBefore = resizeState.widths;
|