@atlaskit/editor-plugin-table 7.11.2 → 7.11.4
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 +1731 -699
- package/dist/cjs/commands/column-resize.js +5 -1
- package/dist/cjs/nodeviews/TableComponent.js +31 -6
- package/dist/cjs/nodeviews/table.js +31 -14
- package/dist/cjs/plugin.js +8 -9
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +6 -1
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +16 -10
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +7 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +16 -11
- package/dist/cjs/pm-plugins/table-width.js +1 -5
- package/dist/cjs/pm-plugins/view-mode-sort/utils.js +37 -20
- package/dist/cjs/toolbar.js +12 -21
- package/dist/cjs/transforms/column-width.js +3 -0
- package/dist/cjs/ui/FloatingDragMenu/index.js +2 -5
- package/dist/cjs/ui/common-styles.js +8 -16
- package/dist/cjs/ui/ui-styles.js +18 -36
- package/dist/es2019/commands/column-resize.js +6 -2
- package/dist/es2019/nodeviews/TableComponent.js +33 -7
- package/dist/es2019/nodeviews/table.js +32 -15
- package/dist/es2019/plugin.js +8 -9
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +6 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +13 -7
- package/dist/es2019/pm-plugins/table-resizing/plugin.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +7 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +16 -11
- package/dist/es2019/pm-plugins/table-width.js +1 -5
- package/dist/es2019/pm-plugins/view-mode-sort/utils.js +36 -21
- package/dist/es2019/toolbar.js +7 -16
- package/dist/es2019/transforms/column-width.js +4 -1
- package/dist/es2019/ui/FloatingDragMenu/index.js +2 -5
- package/dist/es2019/ui/common-styles.js +18 -30
- package/dist/es2019/ui/ui-styles.js +88 -174
- package/dist/esm/commands/column-resize.js +5 -1
- package/dist/esm/nodeviews/TableComponent.js +31 -6
- package/dist/esm/nodeviews/table.js +31 -14
- package/dist/esm/plugin.js +8 -9
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +6 -1
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +16 -10
- package/dist/esm/pm-plugins/table-resizing/plugin.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +7 -2
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +16 -11
- package/dist/esm/pm-plugins/table-width.js +1 -5
- package/dist/esm/pm-plugins/view-mode-sort/utils.js +37 -20
- package/dist/esm/toolbar.js +12 -21
- package/dist/esm/transforms/column-width.js +3 -0
- package/dist/esm/ui/FloatingDragMenu/index.js +2 -5
- package/dist/esm/ui/common-styles.js +8 -16
- package/dist/esm/ui/ui-styles.js +18 -36
- package/dist/types/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/plugin.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
- package/dist/types/pm-plugins/table-width.d.ts +1 -1
- package/dist/types/pm-plugins/view-mode-sort/utils.d.ts +3 -1
- package/dist/types/ui/FloatingDragMenu/index.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/plugin.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/table-width.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/view-mode-sort/utils.d.ts +3 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +2 -1
- package/package.json +3 -6
- package/src/commands/column-resize.ts +11 -2
- package/src/nodeviews/TableComponent.tsx +79 -9
- package/src/nodeviews/table.tsx +49 -26
- package/src/plugin.tsx +10 -4
- package/src/pm-plugins/drag-and-drop/plugin.ts +14 -1
- package/src/pm-plugins/table-resizing/event-handlers.ts +26 -4
- package/src/pm-plugins/table-resizing/plugin.ts +2 -0
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +13 -2
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +24 -10
- package/src/pm-plugins/table-width.ts +1 -3
- package/src/pm-plugins/view-mode-sort/utils.ts +49 -23
- package/src/toolbar.tsx +7 -11
- package/src/transforms/column-width.ts +8 -1
- package/src/ui/FloatingDragMenu/index.tsx +2 -3
- package/src/ui/common-styles.ts +18 -30
- package/src/ui/ui-styles.ts +92 -183
|
@@ -340,7 +340,10 @@ class TableComponent extends React.Component {
|
|
|
340
340
|
this === null || this === void 0 ? void 0 : (_this$table = this.table) === null || _this$table === void 0 ? void 0 : _this$table.addEventListener('mouseenter', this.handleMouseEnter);
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
if (isTableScalingEnabled) {
|
|
343
|
+
if (isTableScalingEnabled && !getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
344
|
+
this.handleColgroupUpdates(true);
|
|
345
|
+
}
|
|
346
|
+
if (isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') && getNode().attrs.displayMode !== 'fixed') {
|
|
344
347
|
this.handleColgroupUpdates(true);
|
|
345
348
|
}
|
|
346
349
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
@@ -464,8 +467,10 @@ class TableComponent extends React.Component {
|
|
|
464
467
|
const wasTableResized = hasTableBeenResized(this.node);
|
|
465
468
|
const isTableResized = hasTableBeenResized(tableNode);
|
|
466
469
|
const isColumnsDistributed = wasTableResized && !isTableResized;
|
|
467
|
-
const
|
|
468
|
-
|
|
470
|
+
const isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
471
|
+
const shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged;
|
|
472
|
+
if (force || !isResizing && shouldUpdateColgroup) {
|
|
473
|
+
var _this$props$options, _this$props$options2;
|
|
469
474
|
const resizeState = getResizeState({
|
|
470
475
|
minWidth: COLUMN_MIN_WIDTH,
|
|
471
476
|
maxSize: tableRenderWidth,
|
|
@@ -475,10 +480,17 @@ class TableComponent extends React.Component {
|
|
|
475
480
|
domAtPos: view.domAtPos,
|
|
476
481
|
isTableScalingEnabled: true
|
|
477
482
|
});
|
|
483
|
+
let shouldScaleOnColgroupUpdate = false;
|
|
484
|
+
if ((_this$props$options = this.props.options) !== null && _this$props$options !== void 0 && _this$props$options.isTableScalingEnabled && !getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
485
|
+
shouldScaleOnColgroupUpdate = true;
|
|
486
|
+
}
|
|
487
|
+
if ((_this$props$options2 = this.props.options) !== null && _this$props$options2 !== void 0 && _this$props$options2.isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') && tableNode.attrs.displayMode !== 'fixed') {
|
|
488
|
+
shouldScaleOnColgroupUpdate = true;
|
|
489
|
+
}
|
|
478
490
|
|
|
479
491
|
// Request animation frame required for Firefox
|
|
480
492
|
requestAnimationFrame(() => {
|
|
481
|
-
updateColgroup(resizeState, this.table, tableNode,
|
|
493
|
+
updateColgroup(resizeState, this.table, tableNode, shouldScaleOnColgroupUpdate);
|
|
482
494
|
});
|
|
483
495
|
}
|
|
484
496
|
}
|
|
@@ -496,6 +508,7 @@ class TableComponent extends React.Component {
|
|
|
496
508
|
isResizing,
|
|
497
509
|
options,
|
|
498
510
|
isTableScalingEnabled,
|
|
511
|
+
// we could use options.isTableScalingEnabled here
|
|
499
512
|
getPos
|
|
500
513
|
} = this.props;
|
|
501
514
|
let {
|
|
@@ -506,7 +519,20 @@ class TableComponent extends React.Component {
|
|
|
506
519
|
const pluginState = getPluginState(view.state);
|
|
507
520
|
isInDanger = pluginState.isInDanger;
|
|
508
521
|
}
|
|
509
|
-
|
|
522
|
+
let shouldScale = false;
|
|
523
|
+
let shouldHandleColgroupUpdates = false;
|
|
524
|
+
if (isTableScalingEnabled && !getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
525
|
+
shouldScale = true;
|
|
526
|
+
shouldHandleColgroupUpdates = true;
|
|
527
|
+
}
|
|
528
|
+
if (isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') && getNode().attrs.displayMode !== 'fixed') {
|
|
529
|
+
shouldScale = true;
|
|
530
|
+
shouldHandleColgroupUpdates = true;
|
|
531
|
+
}
|
|
532
|
+
if (isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') && getNode().attrs.displayMode !== this.node.attrs.displayMode) {
|
|
533
|
+
shouldHandleColgroupUpdates = true;
|
|
534
|
+
}
|
|
535
|
+
if (shouldHandleColgroupUpdates) {
|
|
510
536
|
this.handleColgroupUpdates();
|
|
511
537
|
}
|
|
512
538
|
if (isInDanger && !table) {
|
|
@@ -555,7 +581,7 @@ class TableComponent extends React.Component {
|
|
|
555
581
|
if (shouldRecreateResizeCols) {
|
|
556
582
|
const start = getPos() || 0;
|
|
557
583
|
const depth = view.state.doc.resolve(start).depth;
|
|
558
|
-
|
|
584
|
+
shouldScale = depth === 0 && shouldScale;
|
|
559
585
|
insertColgroupFromNode(this.table, currentTable, shouldScale);
|
|
560
586
|
}
|
|
561
587
|
updateControls()(view.state);
|
|
@@ -611,7 +637,7 @@ class TableComponent extends React.Component {
|
|
|
611
637
|
pluginInjectionApi,
|
|
612
638
|
isDragAndDropEnabled,
|
|
613
639
|
getEditorFeatureFlags,
|
|
614
|
-
isTableScalingEnabled
|
|
640
|
+
isTableScalingEnabled // here we can use options.isTableScalingEnabled
|
|
615
641
|
} = this.props;
|
|
616
642
|
let {
|
|
617
643
|
isInDanger,
|
|
@@ -65,20 +65,31 @@ export default class TableView extends ReactNodeView {
|
|
|
65
65
|
getContentDOM() {
|
|
66
66
|
const rendered = DOMSerializer.renderSpec(document, toDOM(this.node, this.reactComponentProps));
|
|
67
67
|
if (rendered.dom) {
|
|
68
|
-
var _this$options;
|
|
69
68
|
this.table = rendered.dom;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
if (!getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
70
|
+
var _this$options;
|
|
71
|
+
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.isTableScalingEnabled)) {
|
|
72
|
+
// Preserve Table Width cannot have inline width set on the table
|
|
73
|
+
const tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos());
|
|
74
|
+
if (tableInlineWidth) {
|
|
75
|
+
handleInlineTableWidth(this.table, tableInlineWidth);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
var _this$options2;
|
|
80
|
+
if (!((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.isTableScalingEnabled) || this.node.attrs.displayMode === 'fixed') {
|
|
81
|
+
// Preserve Table Width cannot have inline width set on the table
|
|
82
|
+
const tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos());
|
|
83
|
+
if (tableInlineWidth) {
|
|
84
|
+
handleInlineTableWidth(this.table, tableInlineWidth);
|
|
85
|
+
}
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
}
|
|
78
89
|
return rendered;
|
|
79
90
|
}
|
|
80
91
|
setDomAttrs(node) {
|
|
81
|
-
var
|
|
92
|
+
var _this$options3;
|
|
82
93
|
if (!this.table) {
|
|
83
94
|
return;
|
|
84
95
|
}
|
|
@@ -87,11 +98,15 @@ export default class TableView extends ReactNodeView {
|
|
|
87
98
|
this.table.setAttribute(attr, attrs[attr]);
|
|
88
99
|
});
|
|
89
100
|
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
// Preserve Table Width cannot have inline width set on the table
|
|
102
|
+
if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.isTableScalingEnabled)) {
|
|
103
|
+
var _tableWidthPluginKey$;
|
|
104
|
+
// handle inline style when table been resized
|
|
105
|
+
const tableInlineWidth = getInlineWidth(node, this.reactComponentProps.options, this.view.state, this.getPos());
|
|
106
|
+
const isTableResizing = (_tableWidthPluginKey$ = tableWidthPluginKey.getState(this.view.state)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
|
|
107
|
+
if (!isTableResizing && tableInlineWidth) {
|
|
108
|
+
handleInlineTableWidth(this.table, tableInlineWidth);
|
|
109
|
+
}
|
|
95
110
|
}
|
|
96
111
|
}
|
|
97
112
|
render(props, forwardRef) {
|
|
@@ -141,6 +156,7 @@ export default class TableView extends ReactNodeView {
|
|
|
141
156
|
},
|
|
142
157
|
editorView: props.view,
|
|
143
158
|
render: pluginStates => {
|
|
159
|
+
var _props$options;
|
|
144
160
|
const {
|
|
145
161
|
tableResizingPluginState,
|
|
146
162
|
tableWidthPluginState,
|
|
@@ -174,7 +190,8 @@ export default class TableView extends ReactNodeView {
|
|
|
174
190
|
isHeaderRowEnabled: pluginState.isHeaderRowEnabled,
|
|
175
191
|
isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
|
|
176
192
|
isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
|
|
177
|
-
isTableScalingEnabled: pluginState.isTableScalingEnabled
|
|
193
|
+
isTableScalingEnabled: (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.isTableScalingEnabled // this.options?.isTableScalingEnabled sams as TableOptions.isTableScalingEnabled same as pluginState.isTableScalingEnabled
|
|
194
|
+
,
|
|
178
195
|
tableActive: tableActive,
|
|
179
196
|
ordering: pluginState.ordering,
|
|
180
197
|
isResizing: isResizing,
|
|
@@ -251,7 +268,7 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
251
268
|
wasFullWidthModeEnabled,
|
|
252
269
|
isTableResizingEnabled,
|
|
253
270
|
isDragAndDropEnabled,
|
|
254
|
-
isTableScalingEnabled
|
|
271
|
+
isTableScalingEnabled // same as options.isTableScalingEnabled
|
|
255
272
|
} = getPluginState(view.state);
|
|
256
273
|
const {
|
|
257
274
|
allowColumnResizing,
|
|
@@ -271,7 +288,7 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
271
288
|
wasFullWidthModeEnabled,
|
|
272
289
|
isTableResizingEnabled,
|
|
273
290
|
isDragAndDropEnabled,
|
|
274
|
-
isTableScalingEnabled
|
|
291
|
+
isTableScalingEnabled // same as options.isTableScalingEnabled
|
|
275
292
|
},
|
|
276
293
|
getEditorContainerWidth,
|
|
277
294
|
getEditorFeatureFlags,
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -151,14 +151,15 @@ const tablesPlugin = ({
|
|
|
151
151
|
const {
|
|
152
152
|
fullWidthEnabled,
|
|
153
153
|
tableOptions,
|
|
154
|
-
getEditorFeatureFlags
|
|
154
|
+
getEditorFeatureFlags,
|
|
155
|
+
isTableScalingEnabled
|
|
155
156
|
} = options || {};
|
|
156
157
|
const {
|
|
157
158
|
allowColumnResizing
|
|
158
159
|
} = pluginConfig(tableOptions);
|
|
159
160
|
return allowColumnResizing ? createFlexiResizingPlugin(dispatch, {
|
|
160
161
|
lastColumnResizable: !fullWidthEnabled
|
|
161
|
-
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, editorAnalyticsAPI) : undefined;
|
|
162
|
+
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, editorAnalyticsAPI, isTableScalingEnabled || false) : undefined;
|
|
162
163
|
}
|
|
163
164
|
}, {
|
|
164
165
|
name: 'tableEditing',
|
|
@@ -234,8 +235,8 @@ const tablesPlugin = ({
|
|
|
234
235
|
dispatchAnalyticsEvent,
|
|
235
236
|
dispatch
|
|
236
237
|
}) => {
|
|
237
|
-
var _options$fullWidthEna;
|
|
238
|
-
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) : undefined;
|
|
238
|
+
var _options$fullWidthEna, _options$isTableScali;
|
|
239
|
+
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$isTableScali = options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) !== null && _options$isTableScali !== void 0 ? _options$isTableScali : false) : undefined;
|
|
239
240
|
}
|
|
240
241
|
},
|
|
241
242
|
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
@@ -380,7 +381,8 @@ const tablesPlugin = ({
|
|
|
380
381
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
381
382
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
382
383
|
stickyHeaders: stickyHeader,
|
|
383
|
-
pluginConfig: pluginConfig
|
|
384
|
+
pluginConfig: pluginConfig,
|
|
385
|
+
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled
|
|
384
386
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
385
387
|
editorView: editorView,
|
|
386
388
|
selection: editorView.state.selection,
|
|
@@ -410,10 +412,7 @@ const tablesPlugin = ({
|
|
|
410
412
|
var _api$table;
|
|
411
413
|
// see comment on tablesPlugin.getSharedState on usage
|
|
412
414
|
const tableState = api === null || api === void 0 ? void 0 : (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
|
|
413
|
-
const
|
|
414
|
-
isTableScalingEnabled = false
|
|
415
|
-
} = getPluginState(state);
|
|
416
|
-
const tr = insert(createTableWithWidth(isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema));
|
|
415
|
+
const tr = insert(createTableWithWidth(options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema));
|
|
417
416
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
418
417
|
action: ACTION.INSERTED,
|
|
419
418
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -3,6 +3,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
3
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
5
|
import { getCellsInRow, getSelectedCellInfo } from '@atlaskit/editor-tables/utils';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
|
|
7
8
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
8
9
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
@@ -170,7 +171,11 @@ const destroyFn = (editorView, editorAnalyticsAPI) => {
|
|
|
170
171
|
const {
|
|
171
172
|
isTableScalingEnabled = false
|
|
172
173
|
} = getTablePluginState(editorView.state);
|
|
173
|
-
|
|
174
|
+
let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
175
|
+
if (isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
176
|
+
isTableScalingEnabledOnCurrentTable = tableNode.attrs.displayMode !== 'fixed';
|
|
177
|
+
}
|
|
178
|
+
insertColgroupFromNode(tableRef, tableNode, isTableScalingEnabledOnCurrentTable);
|
|
174
179
|
}
|
|
175
180
|
}
|
|
176
181
|
editorView.focus();
|
|
@@ -12,16 +12,13 @@ import { META_KEYS } from '../table-analytics';
|
|
|
12
12
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
13
13
|
import { getPluginState } from './plugin-factory';
|
|
14
14
|
import { currentColWidth, getResizeState, getTableMaxWidth, pointsAtCell, resizeColumn, updateControls } from './utils';
|
|
15
|
-
export const handleMouseDown = (view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) => {
|
|
15
|
+
export const handleMouseDown = (view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled, editorAnalyticsAPI) => {
|
|
16
16
|
const {
|
|
17
17
|
state,
|
|
18
18
|
dispatch
|
|
19
19
|
} = view;
|
|
20
20
|
const editorDisabled = !view.editable;
|
|
21
21
|
const domAtPos = view.domAtPos.bind(view);
|
|
22
|
-
const {
|
|
23
|
-
isTableScalingEnabled = false
|
|
24
|
-
} = getTablePluginState(state);
|
|
25
22
|
if (editorDisabled || localResizeHandlePos === null || !pointsAtCell(state.doc.resolve(localResizeHandlePos))) {
|
|
26
23
|
return false;
|
|
27
24
|
}
|
|
@@ -52,7 +49,10 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
52
49
|
layout: originalTable.attrs.layout,
|
|
53
50
|
getEditorContainerWidth
|
|
54
51
|
});
|
|
55
|
-
|
|
52
|
+
let shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
53
|
+
if (isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
54
|
+
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
55
|
+
}
|
|
56
56
|
const resizeState = getResizeState({
|
|
57
57
|
minWidth: tableCellMinWidth,
|
|
58
58
|
maxSize,
|
|
@@ -144,7 +144,10 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
144
144
|
const selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
145
145
|
// only selected (or selected - 1) columns should be distributed
|
|
146
146
|
const resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
147
|
-
|
|
147
|
+
let shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
148
|
+
if (isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
149
|
+
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
150
|
+
}
|
|
148
151
|
const newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, shouldScale);
|
|
149
152
|
const resizedDelta = clientX - startX;
|
|
150
153
|
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
@@ -221,7 +224,10 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
221
224
|
const tableDepth = state.doc.resolve(tablePos).depth;
|
|
222
225
|
const map = TableMap.get(table);
|
|
223
226
|
const colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
|
|
224
|
-
|
|
227
|
+
let shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
228
|
+
if (isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
229
|
+
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
230
|
+
}
|
|
225
231
|
resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom, table, undefined, shouldScale);
|
|
226
232
|
updateControls()(state);
|
|
227
233
|
}
|
|
@@ -10,7 +10,7 @@ import { pluginKey } from './plugin-key';
|
|
|
10
10
|
import { getResizeCellPos } from './utils';
|
|
11
11
|
export function createPlugin(dispatch, {
|
|
12
12
|
lastColumnResizable = true
|
|
13
|
-
}, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) {
|
|
13
|
+
}, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI, isTableScalingEnabled) {
|
|
14
14
|
return new SafePlugin({
|
|
15
15
|
key: pluginKey,
|
|
16
16
|
state: createPluginState(dispatch, {
|
|
@@ -54,7 +54,7 @@ export function createPlugin(dispatch, {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
if (resizeHandlePos !== null && (!dragging || isColumnKeyboardResizeStarted)) {
|
|
57
|
-
if (handleMouseDown(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI)) {
|
|
57
|
+
if (handleMouseDown(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled || false, editorAnalyticsAPI)) {
|
|
58
58
|
const {
|
|
59
59
|
state,
|
|
60
60
|
dispatch
|
|
@@ -304,14 +304,19 @@ export const getNewResizeStateFromSelectedColumns = (rect, state, domAtPos, getE
|
|
|
304
304
|
layout,
|
|
305
305
|
getEditorContainerWidth
|
|
306
306
|
});
|
|
307
|
-
|
|
307
|
+
let resizeState;
|
|
308
|
+
let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
309
|
+
if (isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
310
|
+
isTableScalingEnabledOnCurrentTable = table.node.attrs.displayMode !== 'fixed';
|
|
311
|
+
}
|
|
312
|
+
resizeState = getResizeState({
|
|
308
313
|
minWidth: tableCellMinWidth,
|
|
309
314
|
maxSize,
|
|
310
315
|
table: table.node,
|
|
311
316
|
tableRef,
|
|
312
317
|
start: table.start,
|
|
313
318
|
domAtPos,
|
|
314
|
-
isTableScalingEnabled
|
|
319
|
+
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable
|
|
315
320
|
});
|
|
316
321
|
const newResizeState = evenSelectedColumnsWidths(resizeState, rect);
|
|
317
322
|
const widthsBefore = resizeState.widths;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
2
2
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { updateColumnWidths } from '../../../transforms';
|
|
5
6
|
import { getTableWidth } from '../../../utils';
|
|
6
7
|
import { getLayoutSize } from '../utils/misc';
|
|
@@ -10,7 +11,7 @@ import { hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
|
10
11
|
import { syncStickyRowToTable } from './dom';
|
|
11
12
|
// Base function to trigger the actual scale on a table node.
|
|
12
13
|
// Will only resize/scale if a table has been previously resized.
|
|
13
|
-
export const scale = (tableRef, options, domAtPos,
|
|
14
|
+
export const scale = (tableRef, options, domAtPos, isTableScalingEnabledOnCurrentTable = false) => {
|
|
14
15
|
const {
|
|
15
16
|
node,
|
|
16
17
|
containerWidth,
|
|
@@ -48,11 +49,11 @@ export const scale = (tableRef, options, domAtPos, isTableScalingEnabled = false
|
|
|
48
49
|
tableRef,
|
|
49
50
|
start,
|
|
50
51
|
domAtPos,
|
|
51
|
-
isTableScalingEnabled
|
|
52
|
+
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable
|
|
52
53
|
});
|
|
53
54
|
return scaleTableTo(resizeState, newWidth);
|
|
54
55
|
};
|
|
55
|
-
export const scaleWithParent = (tableRef, parentWidth, table, start, domAtPos,
|
|
56
|
+
export const scaleWithParent = (tableRef, parentWidth, table, start, domAtPos, isTableScalingEnabledOnCurrentTable = false) => {
|
|
56
57
|
const resizeState = getResizeState({
|
|
57
58
|
minWidth: tableCellMinWidth,
|
|
58
59
|
maxSize: parentWidth,
|
|
@@ -60,7 +61,7 @@ export const scaleWithParent = (tableRef, parentWidth, table, start, domAtPos, i
|
|
|
60
61
|
tableRef,
|
|
61
62
|
start,
|
|
62
63
|
domAtPos,
|
|
63
|
-
isTableScalingEnabled
|
|
64
|
+
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable
|
|
64
65
|
});
|
|
65
66
|
if (table.attrs.isNumberColumnEnabled) {
|
|
66
67
|
parentWidth -= akEditorTableNumberColumnWidth;
|
|
@@ -109,21 +110,25 @@ export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEna
|
|
|
109
110
|
const width = isNumberColumnEnabled ? parentWidth - akEditorTableNumberColumnWidth : parentWidth;
|
|
110
111
|
tableRef.style.width = `${width}px`;
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
+
let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
114
|
+
if (isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
115
|
+
isTableScalingEnabledOnCurrentTable = isTableScalingEnabled && node.attrs.displayMode !== 'fixed';
|
|
116
|
+
}
|
|
113
117
|
// If the table hasn't been resize, the colgroup 48px width values will gracefully scale down.
|
|
114
118
|
// If we are scaling the table down with isTableScalingEnabled, the colgroup widths may be scaled to a value that is not 48px.
|
|
115
|
-
if (!hasTableBeenResized(node) && !
|
|
119
|
+
if (!hasTableBeenResized(node) && !isTableScalingEnabledOnCurrentTable) {
|
|
116
120
|
syncStickyRowToTable(tableRef);
|
|
117
121
|
return;
|
|
118
122
|
}
|
|
119
|
-
const resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, false)
|
|
123
|
+
const resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, false) // Here last value is isTableScalingEnabled = false
|
|
124
|
+
: scale(tableRef, options, domAtPos, false);
|
|
120
125
|
if (resizeState) {
|
|
121
126
|
updateColgroup(resizeState, tableRef, node, false);
|
|
122
127
|
}
|
|
123
128
|
};
|
|
124
129
|
|
|
125
130
|
// Scale the table to meet new requirements (col, layout change etc)
|
|
126
|
-
export const scaleTable = (tableRef, options, domAtPos,
|
|
131
|
+
export const scaleTable = (tableRef, options, domAtPos, isTableScalingEnabledOnCurrentTable = false) => tr => {
|
|
127
132
|
if (!tableRef) {
|
|
128
133
|
return tr;
|
|
129
134
|
}
|
|
@@ -137,7 +142,7 @@ export const scaleTable = (tableRef, options, domAtPos, isTableScalingEnabled =
|
|
|
137
142
|
if (hasTableBeenResized(node) === false) {
|
|
138
143
|
// If its not a re-sized table, we still want to re-create cols
|
|
139
144
|
// To force reflow of columns upon delete.
|
|
140
|
-
if (!
|
|
145
|
+
if (!isTableScalingEnabledOnCurrentTable) {
|
|
141
146
|
insertColgroupFromNode(tableRef, node);
|
|
142
147
|
}
|
|
143
148
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -145,9 +150,9 @@ export const scaleTable = (tableRef, options, domAtPos, isTableScalingEnabled =
|
|
|
145
150
|
}
|
|
146
151
|
let resizeState;
|
|
147
152
|
if (parentWidth) {
|
|
148
|
-
resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos,
|
|
153
|
+
resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos, isTableScalingEnabledOnCurrentTable);
|
|
149
154
|
} else {
|
|
150
|
-
resizeState = scale(tableRef, options, domAtPos,
|
|
155
|
+
resizeState = scale(tableRef, options, domAtPos, isTableScalingEnabledOnCurrentTable);
|
|
151
156
|
}
|
|
152
157
|
if (resizeState) {
|
|
153
158
|
tr = updateColumnWidths(resizeState, node, start)(tr);
|
|
@@ -11,10 +11,9 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
11
11
|
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
12
12
|
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
13
13
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
14
|
-
import { getPluginState } from './plugin-factory';
|
|
15
14
|
import { TABLE_MAX_WIDTH } from './table-resizing/utils';
|
|
16
15
|
export const pluginKey = new PluginKey('tableWidthPlugin');
|
|
17
|
-
const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled) => {
|
|
16
|
+
const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, isTableScalingEnabled) => {
|
|
18
17
|
return new SafePlugin({
|
|
19
18
|
key: pluginKey,
|
|
20
19
|
state: {
|
|
@@ -79,9 +78,6 @@ const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled) => {
|
|
|
79
78
|
return hasStepReplacingEntireDocument;
|
|
80
79
|
});
|
|
81
80
|
const referentialityTr = transactions.find(tr => tr.getMeta('referentialityTableInserted'));
|
|
82
|
-
const {
|
|
83
|
-
isTableScalingEnabled = false
|
|
84
|
-
} = getPluginState(newState);
|
|
85
81
|
const shouldPatchTable = fullWidthEnabled && isTableScalingEnabled;
|
|
86
82
|
if (!isReplaceDocumentOperation && (!shouldPatchTable || !referentialityTr)) {
|
|
87
83
|
return null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SortOrder } from '@atlaskit/editor-common/types';
|
|
2
|
+
import { convertProsemirrorTableNodeToArrayOfRows, createCompareNodes } from '@atlaskit/editor-common/utils';
|
|
2
3
|
import { IS_DISABLED_CLASS_NAME, SORT_INDEX_DATA_ATTRIBUTE, SORTING_ICON_CLASS_NAME } from './consts';
|
|
3
4
|
export const unsort = (oldOrder, tableElement) => {
|
|
4
5
|
const rows = tableElement.querySelectorAll('tr');
|
|
@@ -8,42 +9,56 @@ export const unsort = (oldOrder, tableElement) => {
|
|
|
8
9
|
tbody === null || tbody === void 0 ? void 0 : tbody.appendChild(rows[item.index + 1]);
|
|
9
10
|
});
|
|
10
11
|
};
|
|
12
|
+
export const getSortOrderFromTable = (tableNode, sortIndex, direction) => {
|
|
13
|
+
const tableArray = convertProsemirrorTableNodeToArrayOfRows(tableNode);
|
|
14
|
+
tableArray.shift(); // remove header row
|
|
11
15
|
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
// Keep track of the origin row index
|
|
17
|
+
const tableArrayWithIndex = tableArray.map((node, index) => ({
|
|
18
|
+
node,
|
|
19
|
+
originalIndex: index
|
|
20
|
+
}));
|
|
21
|
+
const compareNodesInOrder = createCompareNodes({
|
|
22
|
+
// TODO - add inline card support
|
|
23
|
+
getInlineCardTextFromStore() {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}, direction);
|
|
27
|
+
const order = tableArrayWithIndex.sort((a, b) => {
|
|
28
|
+
return compareNodesInOrder(a.node[sortIndex], b.node[sortIndex]);
|
|
29
|
+
}).map((tableRow, index) => ({
|
|
30
|
+
value: tableRow.originalIndex,
|
|
25
31
|
index
|
|
26
32
|
}));
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
return [
|
|
34
|
+
// Ensures the first tr is always first in the order
|
|
35
|
+
{
|
|
29
36
|
value: -1,
|
|
30
37
|
index: -1
|
|
31
38
|
}, ...order];
|
|
32
39
|
};
|
|
33
40
|
export const toggleSort = (view, event, pluginState) => {
|
|
34
|
-
var _target$closest;
|
|
41
|
+
var _target$closest, _tableNode$type;
|
|
35
42
|
const target = event.target;
|
|
43
|
+
if (!(target instanceof HTMLElement)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
36
46
|
const widget = target.closest(`.${SORTING_ICON_CLASS_NAME}`);
|
|
37
47
|
if (widget !== null && widget !== void 0 && widget.classList.contains(IS_DISABLED_CLASS_NAME) || !widget) {
|
|
38
48
|
return;
|
|
39
49
|
}
|
|
40
|
-
let
|
|
50
|
+
let dataSortIndex = target === null || target === void 0 ? void 0 : (_target$closest = target.closest('.ProseMirror-widget')) === null || _target$closest === void 0 ? void 0 : _target$closest.getAttribute(SORT_INDEX_DATA_ATTRIBUTE);
|
|
41
51
|
const tr = view.state.tr;
|
|
42
52
|
const tableElement = target.closest('table');
|
|
43
|
-
if (!tableElement || !
|
|
53
|
+
if (!tableElement || !dataSortIndex) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const tablePos = view.posAtDOM(tableElement, 0);
|
|
57
|
+
const tableNode = view.state.doc.nodeAt(tablePos - 1);
|
|
58
|
+
const tableId = tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId;
|
|
59
|
+
if (!tableId || !tableNode || (tableNode === null || tableNode === void 0 ? void 0 : (_tableNode$type = tableNode.type) === null || _tableNode$type === void 0 ? void 0 : _tableNode$type.name) !== 'table') {
|
|
44
60
|
return;
|
|
45
61
|
}
|
|
46
|
-
const tableId = tableElement.getAttribute('data-table-local-id') || '';
|
|
47
62
|
let {
|
|
48
63
|
index,
|
|
49
64
|
direction,
|
|
@@ -54,7 +69,7 @@ export const toggleSort = (view, event, pluginState) => {
|
|
|
54
69
|
if (direction !== SortOrder.NO_ORDER && oldOrder !== undefined) {
|
|
55
70
|
unsort(oldOrder, tableElement);
|
|
56
71
|
}
|
|
57
|
-
const sortIndex = parseInt(
|
|
72
|
+
const sortIndex = parseInt(dataSortIndex);
|
|
58
73
|
if (sortIndex === index) {
|
|
59
74
|
switch (direction) {
|
|
60
75
|
case SortOrder.NO_ORDER:
|
|
@@ -70,7 +85,7 @@ export const toggleSort = (view, event, pluginState) => {
|
|
|
70
85
|
} else {
|
|
71
86
|
direction = SortOrder.ASC; // default direction when a new index is clicked
|
|
72
87
|
}
|
|
73
|
-
const order = getSortOrderFromTable(
|
|
88
|
+
const order = getSortOrderFromTable(tableNode, sortIndex, direction);
|
|
74
89
|
if (direction === SortOrder.NO_ORDER) {
|
|
75
90
|
tr.setMeta('tableSortMeta', {
|
|
76
91
|
[tableId]: {}
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -311,13 +311,10 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
311
311
|
// We don't want to show floating toolbar while resizing the table
|
|
312
312
|
const isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
313
313
|
const {
|
|
314
|
-
isTableScalingEnabled,
|
|
315
314
|
widthToWidest
|
|
316
315
|
} = pluginState;
|
|
317
316
|
const currentTableNodeLocalId = (_tableObject$node$att = tableObject === null || tableObject === void 0 ? void 0 : (_tableObject$node = tableObject.node) === null || _tableObject$node === void 0 ? void 0 : (_tableObject$node$att2 = _tableObject$node.attrs) === null || _tableObject$node$att2 === void 0 ? void 0 : _tableObject$node$att2.localId) !== null && _tableObject$node$att !== void 0 ? _tableObject$node$att : '';
|
|
318
|
-
if (isTableScalingEnabled &&
|
|
319
|
-
// TODO ED-21670: check if need options.isTableScalingEnabled
|
|
320
|
-
isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
|
|
317
|
+
if (options !== null && options !== void 0 && options.isTableScalingEnabled && isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
|
|
321
318
|
const {
|
|
322
319
|
stickyScrollbar
|
|
323
320
|
} = getEditorFeatureFlags();
|
|
@@ -364,14 +361,10 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
364
361
|
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
365
362
|
const nodeType = state.schema.nodes.table;
|
|
366
363
|
const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
367
|
-
const {
|
|
368
|
-
isTableScalingEnabled = false
|
|
369
|
-
} = getPluginState(state); // TODO ED-21670: check if we need options.isTableScalingEnabled and not an acutual state of displayNode attr on the table
|
|
370
|
-
|
|
371
364
|
let cellItems;
|
|
372
|
-
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled);
|
|
365
|
+
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled);
|
|
373
366
|
let columnSettingsItems;
|
|
374
|
-
columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options
|
|
367
|
+
columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) : [];
|
|
375
368
|
const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI, getEditorView);
|
|
376
369
|
|
|
377
370
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -489,18 +482,17 @@ export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI,
|
|
|
489
482
|
// fixed column button should be in this function call in the future
|
|
490
483
|
const getColumnSettingItems = (editorState, editorView, {
|
|
491
484
|
formatMessage
|
|
492
|
-
}, getEditorContainerWidth, editorAnalyticsAPI,
|
|
485
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => {
|
|
493
486
|
var _newResizeStateWithAn2, _pluginState$pluginCo3;
|
|
494
487
|
const pluginState = getPluginState(editorState);
|
|
495
488
|
const selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
|
|
496
489
|
if (!selectionOrTableRect || !editorView) {
|
|
497
490
|
return [];
|
|
498
491
|
}
|
|
499
|
-
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled
|
|
500
|
-
);
|
|
492
|
+
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
501
493
|
const wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
|
|
502
494
|
const items = [];
|
|
503
|
-
const isTableScalingLockBtnEnabled =
|
|
495
|
+
const isTableScalingLockBtnEnabled = isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
|
|
504
496
|
if (isTableScalingLockBtnEnabled) {
|
|
505
497
|
var _pluginState$tableNod;
|
|
506
498
|
const areColumnWidthsLocked = (pluginState === null || pluginState === void 0 ? void 0 : (_pluginState$tableNod = pluginState.tableNode) === null || _pluginState$tableNod === void 0 ? void 0 : _pluginState$tableNod.attrs.displayMode) === 'fixed';
|
|
@@ -524,8 +516,7 @@ const getColumnSettingItems = (editorState, editorView, {
|
|
|
524
516
|
type: 'button',
|
|
525
517
|
title: formatMessage(messages.distributeColumns),
|
|
526
518
|
icon: DistributeColumnIcon,
|
|
527
|
-
onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled
|
|
528
|
-
)(state, dispatch, view),
|
|
519
|
+
onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled)(state, dispatch, view),
|
|
529
520
|
disabled: !wouldChange
|
|
530
521
|
});
|
|
531
522
|
}
|