@atlaskit/editor-plugin-table 7.11.3 → 7.11.5
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 +1734 -700
- package/dist/cjs/commands/column-resize.js +5 -1
- package/dist/cjs/nodeviews/TableComponent.js +28 -6
- package/dist/cjs/nodeviews/table.js +17 -11
- 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 +30 -7
- package/dist/es2019/nodeviews/table.js +17 -12
- 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 +28 -6
- package/dist/esm/nodeviews/table.js +17 -11
- 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 +71 -9
- package/src/nodeviews/table.tsx +34 -18
- 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
|
@@ -210,6 +210,10 @@ var changeColumnWidthByStep = exports.changeColumnWidthByStep = function changeC
|
|
|
210
210
|
layout: originalTable.attrs.layout,
|
|
211
211
|
getEditorContainerWidth: getEditorContainerWidth
|
|
212
212
|
});
|
|
213
|
+
var isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
214
|
+
if (isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
215
|
+
isTableScalingEnabledOnCurrentTable = originalTable.attrs.displayMode !== 'fixed';
|
|
216
|
+
}
|
|
213
217
|
var initialResizeState = (0, _utils3.getResizeState)({
|
|
214
218
|
minWidth: _styles.tableCellMinWidth,
|
|
215
219
|
maxSize: maxSize,
|
|
@@ -217,7 +221,7 @@ var changeColumnWidthByStep = exports.changeColumnWidthByStep = function changeC
|
|
|
217
221
|
tableRef: dom,
|
|
218
222
|
start: tableStartPosition,
|
|
219
223
|
domAtPos: domAtPos,
|
|
220
|
-
isTableScalingEnabled:
|
|
224
|
+
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable
|
|
221
225
|
});
|
|
222
226
|
(0, _utils3.updateControls)()(state);
|
|
223
227
|
var selectionRect = (0, _utils.getSelectionRect)(state.selection);
|
|
@@ -355,7 +355,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
355
355
|
this === null || this === void 0 || (_this$table = this.table) === null || _this$table === void 0 || _this$table.addEventListener('mouseenter', this.handleMouseEnter);
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
if (isTableScalingEnabled) {
|
|
358
|
+
if (isTableScalingEnabled && !(0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
359
|
+
this.handleColgroupUpdates(true);
|
|
360
|
+
}
|
|
361
|
+
if (isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button') && getNode().attrs.displayMode !== 'fixed') {
|
|
359
362
|
this.handleColgroupUpdates(true);
|
|
360
363
|
}
|
|
361
364
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
@@ -479,8 +482,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
479
482
|
var wasTableResized = (0, _colgroup.hasTableBeenResized)(this.node);
|
|
480
483
|
var isTableResized = (0, _colgroup.hasTableBeenResized)(tableNode);
|
|
481
484
|
var isColumnsDistributed = wasTableResized && !isTableResized;
|
|
482
|
-
var
|
|
483
|
-
|
|
485
|
+
var isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
486
|
+
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged;
|
|
487
|
+
if (force || !isResizing && shouldUpdateColgroup) {
|
|
488
|
+
var _this$props$options, _this$props$options2;
|
|
484
489
|
var resizeState = (0, _utils4.getResizeState)({
|
|
485
490
|
minWidth: _utils4.COLUMN_MIN_WIDTH,
|
|
486
491
|
maxSize: tableRenderWidth,
|
|
@@ -490,10 +495,17 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
490
495
|
domAtPos: view.domAtPos,
|
|
491
496
|
isTableScalingEnabled: true
|
|
492
497
|
});
|
|
498
|
+
var shouldScaleOnColgroupUpdate = false;
|
|
499
|
+
if ((_this$props$options = this.props.options) !== null && _this$props$options !== void 0 && _this$props$options.isTableScalingEnabled && !(0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
500
|
+
shouldScaleOnColgroupUpdate = true;
|
|
501
|
+
}
|
|
502
|
+
if ((_this$props$options2 = this.props.options) !== null && _this$props$options2 !== void 0 && _this$props$options2.isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button') && tableNode.attrs.displayMode !== 'fixed') {
|
|
503
|
+
shouldScaleOnColgroupUpdate = true;
|
|
504
|
+
}
|
|
493
505
|
|
|
494
506
|
// Request animation frame required for Firefox
|
|
495
507
|
requestAnimationFrame(function () {
|
|
496
|
-
(0, _utils4.updateColgroup)(resizeState, _this2.table, tableNode,
|
|
508
|
+
(0, _utils4.updateColgroup)(resizeState, _this2.table, tableNode, shouldScaleOnColgroupUpdate);
|
|
497
509
|
});
|
|
498
510
|
}
|
|
499
511
|
}
|
|
@@ -521,7 +533,17 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
521
533
|
var pluginState = (0, _pluginFactory.getPluginState)(view.state);
|
|
522
534
|
isInDanger = pluginState.isInDanger;
|
|
523
535
|
}
|
|
524
|
-
|
|
536
|
+
var shouldScale = false;
|
|
537
|
+
var shouldHandleColgroupUpdates = false;
|
|
538
|
+
if (isTableScalingEnabled && !(0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
539
|
+
shouldScale = true;
|
|
540
|
+
shouldHandleColgroupUpdates = true;
|
|
541
|
+
}
|
|
542
|
+
if (isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button') && getNode().attrs.displayMode !== 'fixed') {
|
|
543
|
+
shouldScale = true;
|
|
544
|
+
shouldHandleColgroupUpdates = true;
|
|
545
|
+
}
|
|
546
|
+
if (shouldHandleColgroupUpdates) {
|
|
525
547
|
this.handleColgroupUpdates();
|
|
526
548
|
}
|
|
527
549
|
if (isInDanger && !table) {
|
|
@@ -568,7 +590,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
568
590
|
if (shouldRecreateResizeCols) {
|
|
569
591
|
var start = getPos() || 0;
|
|
570
592
|
var depth = _view.state.doc.resolve(start).depth;
|
|
571
|
-
|
|
593
|
+
shouldScale = depth === 0 && shouldScale;
|
|
572
594
|
(0, _utils4.insertColgroupFromNode)(this.table, currentTable, shouldScale);
|
|
573
595
|
}
|
|
574
596
|
(0, _dom.updateControls)()(_view.state);
|
|
@@ -90,10 +90,9 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
90
90
|
value: function getContentDOM() {
|
|
91
91
|
var rendered = _model.DOMSerializer.renderSpec(document, toDOM(this.node, this.reactComponentProps));
|
|
92
92
|
if (rendered.dom) {
|
|
93
|
-
var _this$options;
|
|
93
|
+
var _this$options, _this$options2;
|
|
94
94
|
this.table = rendered.dom;
|
|
95
|
-
|
|
96
|
-
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.isTableScalingEnabled)) {
|
|
95
|
+
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.isTableScalingEnabled) || (_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button') && this.node.attrs.displayMode === 'fixed') {
|
|
97
96
|
var tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos());
|
|
98
97
|
if (tableInlineWidth) {
|
|
99
98
|
handleInlineTableWidth(this.table, tableInlineWidth);
|
|
@@ -106,7 +105,8 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
106
105
|
key: "setDomAttrs",
|
|
107
106
|
value: function setDomAttrs(node) {
|
|
108
107
|
var _this2 = this,
|
|
109
|
-
|
|
108
|
+
_this$options3,
|
|
109
|
+
_this$options4;
|
|
110
110
|
if (!this.table) {
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
@@ -115,11 +115,15 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
115
115
|
_this2.table.setAttribute(attr, attrs[attr]);
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
// Preserve Table Width cannot have inline width set on the table
|
|
119
|
+
if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.isTableScalingEnabled) || (_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button') && node.attrs.displayMode === 'fixed') {
|
|
120
|
+
var _tableWidthPluginKey$;
|
|
121
|
+
// handle inline style when table been resized
|
|
122
|
+
var tableInlineWidth = getInlineWidth(node, this.reactComponentProps.options, this.view.state, this.getPos());
|
|
123
|
+
var isTableResizing = (_tableWidthPluginKey$ = _tableWidth.pluginKey.getState(this.view.state)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
|
|
124
|
+
if (!isTableResizing && tableInlineWidth) {
|
|
125
|
+
handleInlineTableWidth(this.table, tableInlineWidth);
|
|
126
|
+
}
|
|
123
127
|
}
|
|
124
128
|
}
|
|
125
129
|
}, {
|
|
@@ -172,6 +176,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
172
176
|
},
|
|
173
177
|
editorView: props.view,
|
|
174
178
|
render: function render(pluginStates) {
|
|
179
|
+
var _props$options;
|
|
175
180
|
var tableResizingPluginState = pluginStates.tableResizingPluginState,
|
|
176
181
|
tableWidthPluginState = pluginStates.tableWidthPluginState,
|
|
177
182
|
pluginState = pluginStates.pluginState,
|
|
@@ -203,7 +208,8 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
203
208
|
isHeaderRowEnabled: pluginState.isHeaderRowEnabled,
|
|
204
209
|
isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
|
|
205
210
|
isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
|
|
206
|
-
isTableScalingEnabled: pluginState.isTableScalingEnabled
|
|
211
|
+
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
|
|
212
|
+
,
|
|
207
213
|
tableActive: tableActive,
|
|
208
214
|
ordering: pluginState.ordering,
|
|
209
215
|
isResizing: isResizing,
|
|
@@ -302,7 +308,7 @@ var createTableView = exports.createTableView = function createTableView(node, v
|
|
|
302
308
|
wasFullWidthModeEnabled: wasFullWidthModeEnabled,
|
|
303
309
|
isTableResizingEnabled: isTableResizingEnabled,
|
|
304
310
|
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
305
|
-
isTableScalingEnabled: isTableScalingEnabled
|
|
311
|
+
isTableScalingEnabled: isTableScalingEnabled // same as options.isTableScalingEnabled
|
|
306
312
|
},
|
|
307
313
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
308
314
|
getEditorFeatureFlags: getEditorFeatureFlags,
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -158,12 +158,13 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
158
158
|
var _ref5 = options || {},
|
|
159
159
|
fullWidthEnabled = _ref5.fullWidthEnabled,
|
|
160
160
|
tableOptions = _ref5.tableOptions,
|
|
161
|
-
getEditorFeatureFlags = _ref5.getEditorFeatureFlags
|
|
161
|
+
getEditorFeatureFlags = _ref5.getEditorFeatureFlags,
|
|
162
|
+
isTableScalingEnabled = _ref5.isTableScalingEnabled;
|
|
162
163
|
var _pluginConfig = (0, _createPluginConfig.pluginConfig)(tableOptions),
|
|
163
164
|
allowColumnResizing = _pluginConfig.allowColumnResizing;
|
|
164
165
|
return allowColumnResizing ? (0, _tableResizing.createPlugin)(dispatch, {
|
|
165
166
|
lastColumnResizable: !fullWidthEnabled
|
|
166
|
-
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, editorAnalyticsAPI) : undefined;
|
|
167
|
+
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, editorAnalyticsAPI, isTableScalingEnabled || false) : undefined;
|
|
167
168
|
}
|
|
168
169
|
}, {
|
|
169
170
|
name: 'tableEditing',
|
|
@@ -241,10 +242,10 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
241
242
|
}, {
|
|
242
243
|
name: 'tableWidth',
|
|
243
244
|
plugin: function plugin(_ref13) {
|
|
244
|
-
var _options$fullWidthEna;
|
|
245
|
+
var _options$fullWidthEna, _options$isTableScali;
|
|
245
246
|
var dispatchAnalyticsEvent = _ref13.dispatchAnalyticsEvent,
|
|
246
247
|
dispatch = _ref13.dispatch;
|
|
247
|
-
return options !== null && options !== void 0 && options.tableResizingEnabled ? (0, _tableWidth.createPlugin)(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false) : undefined;
|
|
248
|
+
return options !== null && options !== void 0 && options.tableResizingEnabled ? (0, _tableWidth.createPlugin)(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;
|
|
248
249
|
}
|
|
249
250
|
},
|
|
250
251
|
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
@@ -384,7 +385,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
384
385
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
385
386
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
386
387
|
stickyHeaders: stickyHeader,
|
|
387
|
-
pluginConfig: pluginConfig
|
|
388
|
+
pluginConfig: pluginConfig,
|
|
389
|
+
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled
|
|
388
390
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
|
|
389
391
|
editorView: editorView,
|
|
390
392
|
selection: editorView.state.selection,
|
|
@@ -416,10 +418,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
416
418
|
var _api$table;
|
|
417
419
|
// see comment on tablesPlugin.getSharedState on usage
|
|
418
420
|
var tableState = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
|
|
419
|
-
var
|
|
420
|
-
_getPluginState$isTab = _getPluginState.isTableScalingEnabled,
|
|
421
|
-
isTableScalingEnabled = _getPluginState$isTab === void 0 ? false : _getPluginState$isTab;
|
|
422
|
-
var tr = insert((0, _utils2.createTableWithWidth)(isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema));
|
|
421
|
+
var tr = insert((0, _utils2.createTableWithWidth)(options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema));
|
|
423
422
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
424
423
|
action: _analytics.ACTION.INSERTED,
|
|
425
424
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
@@ -9,6 +9,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
|
9
9
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
10
10
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
11
11
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
13
|
var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
|
|
13
14
|
var _combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
|
|
14
15
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
@@ -162,7 +163,11 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI) {
|
|
|
162
163
|
var _getTablePluginState4 = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
163
164
|
_getTablePluginState5 = _getTablePluginState4.isTableScalingEnabled,
|
|
164
165
|
isTableScalingEnabled = _getTablePluginState5 === void 0 ? false : _getTablePluginState5;
|
|
165
|
-
|
|
166
|
+
var isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
167
|
+
if (isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
168
|
+
isTableScalingEnabledOnCurrentTable = tableNode.attrs.displayMode !== 'fixed';
|
|
169
|
+
}
|
|
170
|
+
(0, _utils3.insertColgroupFromNode)(tableRef, tableNode, isTableScalingEnabledOnCurrentTable);
|
|
166
171
|
}
|
|
167
172
|
}
|
|
168
173
|
editorView.focus();
|
|
@@ -18,19 +18,16 @@ var _tableAnalytics = require("../table-analytics");
|
|
|
18
18
|
var _commands = require("./commands");
|
|
19
19
|
var _pluginFactory2 = require("./plugin-factory");
|
|
20
20
|
var _utils3 = require("./utils");
|
|
21
|
-
var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) {
|
|
21
|
+
var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled, editorAnalyticsAPI) {
|
|
22
22
|
var state = view.state,
|
|
23
23
|
dispatch = view.dispatch;
|
|
24
24
|
var editorDisabled = !view.editable;
|
|
25
25
|
var domAtPos = view.domAtPos.bind(view);
|
|
26
|
-
var _getTablePluginState = (0, _pluginFactory.getPluginState)(state),
|
|
27
|
-
_getTablePluginState$ = _getTablePluginState.isTableScalingEnabled,
|
|
28
|
-
isTableScalingEnabled = _getTablePluginState$ === void 0 ? false : _getTablePluginState$;
|
|
29
26
|
if (editorDisabled || localResizeHandlePos === null || !(0, _utils3.pointsAtCell)(state.doc.resolve(localResizeHandlePos))) {
|
|
30
27
|
return false;
|
|
31
28
|
}
|
|
32
|
-
var
|
|
33
|
-
isKeyboardResize =
|
|
29
|
+
var _getTablePluginState = (0, _pluginFactory.getPluginState)(state),
|
|
30
|
+
isKeyboardResize = _getTablePluginState.isKeyboardResize;
|
|
34
31
|
event.preventDefault();
|
|
35
32
|
var tr = view.state.tr;
|
|
36
33
|
tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
|
|
@@ -56,6 +53,9 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
56
53
|
getEditorContainerWidth: getEditorContainerWidth
|
|
57
54
|
});
|
|
58
55
|
var shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
56
|
+
if (isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
57
|
+
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
58
|
+
}
|
|
59
59
|
var resizeState = (0, _utils3.getResizeState)({
|
|
60
60
|
minWidth: _styles.tableCellMinWidth,
|
|
61
61
|
maxSize: maxSize,
|
|
@@ -92,8 +92,8 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
92
92
|
var _getPluginState = (0, _pluginFactory2.getPluginState)(state),
|
|
93
93
|
dragging = _getPluginState.dragging,
|
|
94
94
|
resizeHandlePos = _getPluginState.resizeHandlePos;
|
|
95
|
-
var
|
|
96
|
-
isTableHovered =
|
|
95
|
+
var _getTablePluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
96
|
+
isTableHovered = _getTablePluginState2.isTableHovered;
|
|
97
97
|
if (resizeHandlePos === null) {
|
|
98
98
|
return (0, _commands.stopResizing)()(state, dispatch);
|
|
99
99
|
}
|
|
@@ -138,6 +138,9 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
138
138
|
// only selected (or selected - 1) columns should be distributed
|
|
139
139
|
var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
140
140
|
var _shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
141
|
+
if (isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
142
|
+
_shouldScale = _shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
143
|
+
}
|
|
141
144
|
var newResizeState = (0, _utils3.resizeColumn)(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale);
|
|
142
145
|
var resizedDelta = clientX - startX;
|
|
143
146
|
tr = (0, _transforms.updateColumnWidths)(newResizeState, table, start)(tr);
|
|
@@ -197,8 +200,8 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
197
200
|
var _getPluginState2 = (0, _pluginFactory2.getPluginState)(state),
|
|
198
201
|
dragging = _getPluginState2.dragging,
|
|
199
202
|
resizeHandlePos = _getPluginState2.resizeHandlePos;
|
|
200
|
-
var
|
|
201
|
-
isTableHovered =
|
|
203
|
+
var _getTablePluginState3 = (0, _pluginFactory.getPluginState)(state),
|
|
204
|
+
isTableHovered = _getTablePluginState3.isTableHovered;
|
|
202
205
|
if (!which || !dragging || resizeHandlePos === null || !(0, _utils3.pointsAtCell)(state.doc.resolve(resizeHandlePos)) || !isTableHovered && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
|
|
203
206
|
return finish(event);
|
|
204
207
|
}
|
|
@@ -209,6 +212,9 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
209
212
|
var map = _tableMap.TableMap.get(table);
|
|
210
213
|
var colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
|
|
211
214
|
var shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
215
|
+
if (isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
216
|
+
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
217
|
+
}
|
|
212
218
|
(0, _utils3.resizeColumn)(resizeState, colIndex, clientX - dragging.startX, dom, table, undefined, shouldScale);
|
|
213
219
|
(0, _utils3.updateControls)()(state);
|
|
214
220
|
}
|
|
@@ -16,7 +16,7 @@ var _eventHandlers = require("./event-handlers");
|
|
|
16
16
|
var _pluginFactory2 = require("./plugin-factory");
|
|
17
17
|
var _pluginKey = require("./plugin-key");
|
|
18
18
|
var _utils = require("./utils");
|
|
19
|
-
function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) {
|
|
19
|
+
function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI, isTableScalingEnabled) {
|
|
20
20
|
var _ref$lastColumnResiza = _ref.lastColumnResizable,
|
|
21
21
|
lastColumnResizable = _ref$lastColumnResiza === void 0 ? true : _ref$lastColumnResiza;
|
|
22
22
|
return new _safePlugin.SafePlugin({
|
|
@@ -56,7 +56,7 @@ function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureF
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
if (resizeHandlePos !== null && (!dragging || isColumnKeyboardResizeStarted)) {
|
|
59
|
-
if ((0, _eventHandlers.handleMouseDown)(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI)) {
|
|
59
|
+
if ((0, _eventHandlers.handleMouseDown)(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled || false, editorAnalyticsAPI)) {
|
|
60
60
|
var _state = view.state,
|
|
61
61
|
_dispatch = view.dispatch;
|
|
62
62
|
return (0, _commands.setResizeHandlePos)(resizeHandlePos)(_state, _dispatch);
|
|
@@ -333,14 +333,19 @@ var getNewResizeStateFromSelectedColumns = exports.getNewResizeStateFromSelected
|
|
|
333
333
|
layout: layout,
|
|
334
334
|
getEditorContainerWidth: getEditorContainerWidth
|
|
335
335
|
});
|
|
336
|
-
var resizeState
|
|
336
|
+
var resizeState;
|
|
337
|
+
var isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
338
|
+
if (isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
339
|
+
isTableScalingEnabledOnCurrentTable = table.node.attrs.displayMode !== 'fixed';
|
|
340
|
+
}
|
|
341
|
+
resizeState = getResizeState({
|
|
337
342
|
minWidth: _styles.tableCellMinWidth,
|
|
338
343
|
maxSize: maxSize,
|
|
339
344
|
table: table.node,
|
|
340
345
|
tableRef: tableRef,
|
|
341
346
|
start: table.start,
|
|
342
347
|
domAtPos: domAtPos,
|
|
343
|
-
isTableScalingEnabled:
|
|
348
|
+
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable
|
|
344
349
|
});
|
|
345
350
|
var newResizeState = evenSelectedColumnsWidths(resizeState, rect);
|
|
346
351
|
var widthsBefore = resizeState.widths;
|
|
@@ -11,6 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
12
12
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
13
13
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
15
|
var _transforms = require("../../../transforms");
|
|
15
16
|
var _utils = require("../../../utils");
|
|
16
17
|
var _misc = require("../utils/misc");
|
|
@@ -23,7 +24,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
23
24
|
// Base function to trigger the actual scale on a table node.
|
|
24
25
|
// Will only resize/scale if a table has been previously resized.
|
|
25
26
|
var scale = exports.scale = function scale(tableRef, options, domAtPos) {
|
|
26
|
-
var
|
|
27
|
+
var isTableScalingEnabledOnCurrentTable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
27
28
|
var node = options.node,
|
|
28
29
|
containerWidth = options.containerWidth,
|
|
29
30
|
previousContainerWidth = options.previousContainerWidth,
|
|
@@ -59,12 +60,12 @@ var scale = exports.scale = function scale(tableRef, options, domAtPos) {
|
|
|
59
60
|
tableRef: tableRef,
|
|
60
61
|
start: start,
|
|
61
62
|
domAtPos: domAtPos,
|
|
62
|
-
isTableScalingEnabled:
|
|
63
|
+
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable
|
|
63
64
|
});
|
|
64
65
|
return scaleTableTo(resizeState, newWidth);
|
|
65
66
|
};
|
|
66
67
|
var scaleWithParent = exports.scaleWithParent = function scaleWithParent(tableRef, parentWidth, table, start, domAtPos) {
|
|
67
|
-
var
|
|
68
|
+
var isTableScalingEnabledOnCurrentTable = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
68
69
|
var resizeState = (0, _resizeState.getResizeState)({
|
|
69
70
|
minWidth: _styles.tableCellMinWidth,
|
|
70
71
|
maxSize: parentWidth,
|
|
@@ -72,7 +73,7 @@ var scaleWithParent = exports.scaleWithParent = function scaleWithParent(tableRe
|
|
|
72
73
|
tableRef: tableRef,
|
|
73
74
|
start: start,
|
|
74
75
|
domAtPos: domAtPos,
|
|
75
|
-
isTableScalingEnabled:
|
|
76
|
+
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable
|
|
76
77
|
});
|
|
77
78
|
if (table.attrs.isNumberColumnEnabled) {
|
|
78
79
|
parentWidth -= _editorSharedStyles.akEditorTableNumberColumnWidth;
|
|
@@ -116,14 +117,18 @@ var previewScaleTable = exports.previewScaleTable = function previewScaleTable(t
|
|
|
116
117
|
var width = isNumberColumnEnabled ? parentWidth - _editorSharedStyles.akEditorTableNumberColumnWidth : parentWidth;
|
|
117
118
|
tableRef.style.width = "".concat(width, "px");
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
+
var isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
121
|
+
if (isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
122
|
+
isTableScalingEnabledOnCurrentTable = isTableScalingEnabled && node.attrs.displayMode !== 'fixed';
|
|
123
|
+
}
|
|
120
124
|
// If the table hasn't been resize, the colgroup 48px width values will gracefully scale down.
|
|
121
125
|
// If we are scaling the table down with isTableScalingEnabled, the colgroup widths may be scaled to a value that is not 48px.
|
|
122
|
-
if (!(0, _colgroup.hasTableBeenResized)(node) && !
|
|
126
|
+
if (!(0, _colgroup.hasTableBeenResized)(node) && !isTableScalingEnabledOnCurrentTable) {
|
|
123
127
|
(0, _dom.syncStickyRowToTable)(tableRef);
|
|
124
128
|
return;
|
|
125
129
|
}
|
|
126
|
-
var resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, false)
|
|
130
|
+
var resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, false) // Here last value is isTableScalingEnabled = false
|
|
131
|
+
: scale(tableRef, options, domAtPos, false);
|
|
127
132
|
if (resizeState) {
|
|
128
133
|
(0, _resizeState.updateColgroup)(resizeState, tableRef, node, false);
|
|
129
134
|
}
|
|
@@ -131,7 +136,7 @@ var previewScaleTable = exports.previewScaleTable = function previewScaleTable(t
|
|
|
131
136
|
|
|
132
137
|
// Scale the table to meet new requirements (col, layout change etc)
|
|
133
138
|
var scaleTable = exports.scaleTable = function scaleTable(tableRef, options, domAtPos) {
|
|
134
|
-
var
|
|
139
|
+
var isTableScalingEnabledOnCurrentTable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
135
140
|
return function (tr) {
|
|
136
141
|
if (!tableRef) {
|
|
137
142
|
return tr;
|
|
@@ -144,7 +149,7 @@ var scaleTable = exports.scaleTable = function scaleTable(tableRef, options, dom
|
|
|
144
149
|
if ((0, _colgroup.hasTableBeenResized)(node) === false) {
|
|
145
150
|
// If its not a re-sized table, we still want to re-create cols
|
|
146
151
|
// To force reflow of columns upon delete.
|
|
147
|
-
if (!
|
|
152
|
+
if (!isTableScalingEnabledOnCurrentTable) {
|
|
148
153
|
(0, _colgroup.insertColgroupFromNode)(tableRef, node);
|
|
149
154
|
}
|
|
150
155
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -152,9 +157,9 @@ var scaleTable = exports.scaleTable = function scaleTable(tableRef, options, dom
|
|
|
152
157
|
}
|
|
153
158
|
var resizeState;
|
|
154
159
|
if (parentWidth) {
|
|
155
|
-
resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos,
|
|
160
|
+
resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos, isTableScalingEnabledOnCurrentTable);
|
|
156
161
|
} else {
|
|
157
|
-
resizeState = scale(tableRef, options, domAtPos,
|
|
162
|
+
resizeState = scale(tableRef, options, domAtPos, isTableScalingEnabledOnCurrentTable);
|
|
158
163
|
}
|
|
159
164
|
if (resizeState) {
|
|
160
165
|
tr = (0, _transforms.updateColumnWidths)(resizeState, node, start)(tr);
|
|
@@ -14,7 +14,6 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
14
14
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
15
15
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
16
16
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
17
|
-
var _pluginFactory = require("./plugin-factory");
|
|
18
17
|
var _utils2 = require("./table-resizing/utils");
|
|
19
18
|
var _excluded = ["width"];
|
|
20
19
|
/**
|
|
@@ -25,7 +24,7 @@ var _excluded = ["width"];
|
|
|
25
24
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
25
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
27
26
|
var pluginKey = exports.pluginKey = new _state.PluginKey('tableWidthPlugin');
|
|
28
|
-
var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent, fullWidthEnabled) {
|
|
27
|
+
var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent, fullWidthEnabled, isTableScalingEnabled) {
|
|
29
28
|
return new _safePlugin.SafePlugin({
|
|
30
29
|
key: pluginKey,
|
|
31
30
|
state: {
|
|
@@ -92,9 +91,6 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
|
|
|
92
91
|
var referentialityTr = transactions.find(function (tr) {
|
|
93
92
|
return tr.getMeta('referentialityTableInserted');
|
|
94
93
|
});
|
|
95
|
-
var _getPluginState = (0, _pluginFactory.getPluginState)(newState),
|
|
96
|
-
_getPluginState$isTab = _getPluginState.isTableScalingEnabled,
|
|
97
|
-
isTableScalingEnabled = _getPluginState$isTab === void 0 ? false : _getPluginState$isTab;
|
|
98
94
|
var shouldPatchTable = fullWidthEnabled && isTableScalingEnabled;
|
|
99
95
|
if (!isReplaceDocumentOperation && (!shouldPatchTable || !referentialityTr)) {
|
|
100
96
|
return null;
|
|
@@ -8,6 +8,7 @@ exports.unsort = exports.toggleSort = exports.getTableElements = exports.getSort
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _types = require("@atlaskit/editor-common/types");
|
|
11
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
12
|
var _consts = require("./consts");
|
|
12
13
|
var unsort = exports.unsort = function unsort(oldOrder, tableElement) {
|
|
13
14
|
var rows = tableElement.querySelectorAll('tr');
|
|
@@ -19,44 +20,60 @@ var unsort = exports.unsort = function unsort(oldOrder, tableElement) {
|
|
|
19
20
|
tbody === null || tbody === void 0 || tbody.appendChild(rows[item.index + 1]);
|
|
20
21
|
});
|
|
21
22
|
};
|
|
23
|
+
var getSortOrderFromTable = exports.getSortOrderFromTable = function getSortOrderFromTable(tableNode, sortIndex, direction) {
|
|
24
|
+
var tableArray = (0, _utils.convertProsemirrorTableNodeToArrayOfRows)(tableNode);
|
|
25
|
+
tableArray.shift(); // remove header row
|
|
22
26
|
|
|
23
|
-
//
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
strings.push(((_tr$querySelectorAll$ = tr.querySelectorAll('td')[sortIndex]) === null || _tr$querySelectorAll$ === void 0 ? void 0 : _tr$querySelectorAll$.textContent) || '');
|
|
27
|
+
// Keep track of the origin row index
|
|
28
|
+
var tableArrayWithIndex = tableArray.map(function (node, index) {
|
|
29
|
+
return {
|
|
30
|
+
node: node,
|
|
31
|
+
originalIndex: index
|
|
32
|
+
};
|
|
30
33
|
});
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
var compareNodesInOrder = (0, _utils.createCompareNodes)({
|
|
35
|
+
// TODO - add inline card support
|
|
36
|
+
getInlineCardTextFromStore: function getInlineCardTextFromStore() {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}, direction);
|
|
40
|
+
var order = tableArrayWithIndex.sort(function (a, b) {
|
|
41
|
+
return compareNodesInOrder(a.node[sortIndex], b.node[sortIndex]);
|
|
42
|
+
}).map(function (tableRow, index) {
|
|
35
43
|
return {
|
|
36
|
-
value:
|
|
44
|
+
value: tableRow.originalIndex,
|
|
37
45
|
index: index
|
|
38
46
|
};
|
|
39
47
|
});
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
return [
|
|
49
|
+
// Ensures the first tr is always first in the order
|
|
50
|
+
{
|
|
42
51
|
value: -1,
|
|
43
52
|
index: -1
|
|
44
53
|
}].concat((0, _toConsumableArray2.default)(order));
|
|
45
54
|
};
|
|
46
55
|
var toggleSort = exports.toggleSort = function toggleSort(view, event, pluginState) {
|
|
47
|
-
var _target$closest;
|
|
56
|
+
var _target$closest, _tableNode$type;
|
|
48
57
|
var target = event.target;
|
|
58
|
+
if (!(target instanceof HTMLElement)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
49
61
|
var widget = target.closest(".".concat(_consts.SORTING_ICON_CLASS_NAME));
|
|
50
62
|
if (widget !== null && widget !== void 0 && widget.classList.contains(_consts.IS_DISABLED_CLASS_NAME) || !widget) {
|
|
51
63
|
return;
|
|
52
64
|
}
|
|
53
|
-
var
|
|
65
|
+
var dataSortIndex = target === null || target === void 0 || (_target$closest = target.closest('.ProseMirror-widget')) === null || _target$closest === void 0 ? void 0 : _target$closest.getAttribute(_consts.SORT_INDEX_DATA_ATTRIBUTE);
|
|
54
66
|
var tr = view.state.tr;
|
|
55
67
|
var tableElement = target.closest('table');
|
|
56
|
-
if (!tableElement || !
|
|
68
|
+
if (!tableElement || !dataSortIndex) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
var tablePos = view.posAtDOM(tableElement, 0);
|
|
72
|
+
var tableNode = view.state.doc.nodeAt(tablePos - 1);
|
|
73
|
+
var tableId = tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId;
|
|
74
|
+
if (!tableId || !tableNode || (tableNode === null || tableNode === void 0 || (_tableNode$type = tableNode.type) === null || _tableNode$type === void 0 ? void 0 : _tableNode$type.name) !== 'table') {
|
|
57
75
|
return;
|
|
58
76
|
}
|
|
59
|
-
var tableId = tableElement.getAttribute('data-table-local-id') || '';
|
|
60
77
|
var _ref = (pluginState === null || pluginState === void 0 ? void 0 : pluginState[tableId]) || {},
|
|
61
78
|
index = _ref.index,
|
|
62
79
|
direction = _ref.direction,
|
|
@@ -66,7 +83,7 @@ var toggleSort = exports.toggleSort = function toggleSort(view, event, pluginSta
|
|
|
66
83
|
if (direction !== _types.SortOrder.NO_ORDER && oldOrder !== undefined) {
|
|
67
84
|
unsort(oldOrder, tableElement);
|
|
68
85
|
}
|
|
69
|
-
var sortIndex = parseInt(
|
|
86
|
+
var sortIndex = parseInt(dataSortIndex);
|
|
70
87
|
if (sortIndex === index) {
|
|
71
88
|
switch (direction) {
|
|
72
89
|
case _types.SortOrder.NO_ORDER:
|
|
@@ -82,7 +99,7 @@ var toggleSort = exports.toggleSort = function toggleSort(view, event, pluginSta
|
|
|
82
99
|
} else {
|
|
83
100
|
direction = _types.SortOrder.ASC; // default direction when a new index is clicked
|
|
84
101
|
}
|
|
85
|
-
var order = getSortOrderFromTable(
|
|
102
|
+
var order = getSortOrderFromTable(tableNode, sortIndex, direction);
|
|
86
103
|
if (direction === _types.SortOrder.NO_ORDER) {
|
|
87
104
|
tr.setMeta('tableSortMeta', (0, _defineProperty2.default)({}, tableId, {}));
|
|
88
105
|
} else {
|