@atlaskit/editor-plugin-table 7.10.1 → 7.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/commands/insert.js +4 -7
- package/dist/cjs/commands/misc.js +10 -3
- package/dist/cjs/nodeviews/TableComponent.js +23 -2
- package/dist/cjs/plugin.js +7 -1
- package/dist/cjs/pm-plugins/analytics/plugin.js +17 -22
- package/dist/cjs/pm-plugins/view-mode-sort/consts.js +9 -0
- package/dist/cjs/pm-plugins/view-mode-sort/index.js +304 -0
- package/dist/cjs/pm-plugins/view-mode-sort/plugin-key.js +8 -0
- package/dist/cjs/pm-plugins/view-mode-sort/types.js +5 -0
- package/dist/cjs/pm-plugins/view-mode-sort/utils.js +106 -0
- package/dist/cjs/ui/common-styles.js +22 -15
- package/dist/es2019/commands/insert.js +4 -7
- package/dist/es2019/commands/misc.js +10 -3
- package/dist/es2019/nodeviews/TableComponent.js +24 -2
- package/dist/es2019/plugin.js +7 -1
- package/dist/es2019/pm-plugins/analytics/plugin.js +21 -26
- package/dist/es2019/pm-plugins/view-mode-sort/consts.js +3 -0
- package/dist/es2019/pm-plugins/view-mode-sort/index.js +243 -0
- package/dist/es2019/pm-plugins/view-mode-sort/plugin-key.js +2 -0
- package/dist/es2019/pm-plugins/view-mode-sort/types.js +1 -0
- package/dist/es2019/pm-plugins/view-mode-sort/utils.js +98 -0
- package/dist/es2019/ui/common-styles.js +35 -0
- package/dist/esm/commands/insert.js +4 -7
- package/dist/esm/commands/misc.js +10 -3
- package/dist/esm/nodeviews/TableComponent.js +23 -2
- package/dist/esm/plugin.js +7 -1
- package/dist/esm/pm-plugins/analytics/plugin.js +17 -22
- package/dist/esm/pm-plugins/view-mode-sort/consts.js +3 -0
- package/dist/esm/pm-plugins/view-mode-sort/index.js +299 -0
- package/dist/esm/pm-plugins/view-mode-sort/plugin-key.js +2 -0
- package/dist/esm/pm-plugins/view-mode-sort/types.js +1 -0
- package/dist/esm/pm-plugins/view-mode-sort/utils.js +99 -0
- package/dist/esm/ui/common-styles.js +15 -8
- package/dist/types/pm-plugins/view-mode-sort/consts.d.ts +3 -0
- package/dist/types/pm-plugins/view-mode-sort/index.d.ts +10 -0
- package/dist/types/pm-plugins/view-mode-sort/plugin-key.d.ts +3 -0
- package/dist/types/pm-plugins/view-mode-sort/types.d.ts +17 -0
- package/dist/types/pm-plugins/view-mode-sort/utils.d.ts +15 -0
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -4
- package/dist/types/ui/TableFloatingControls/index.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/view-mode-sort/consts.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/view-mode-sort/index.d.ts +10 -0
- package/dist/types-ts4.5/pm-plugins/view-mode-sort/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/view-mode-sort/types.d.ts +21 -0
- package/dist/types-ts4.5/pm-plugins/view-mode-sort/utils.d.ts +15 -0
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -4
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +2 -2
- package/package.json +8 -8
- package/src/commands/insert.ts +7 -13
- package/src/commands/misc.ts +14 -8
- package/src/nodeviews/TableComponent.tsx +22 -0
- package/src/plugin.tsx +12 -3
- package/src/pm-plugins/analytics/plugin.ts +24 -33
- package/src/pm-plugins/view-mode-sort/consts.ts +3 -0
- package/src/pm-plugins/view-mode-sort/index.ts +257 -0
- package/src/pm-plugins/view-mode-sort/plugin-key.ts +6 -0
- package/src/pm-plugins/view-mode-sort/types.ts +23 -0
- package/src/pm-plugins/view-mode-sort/utils.ts +120 -0
- package/src/ui/common-styles.ts +36 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#90188](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/90188) [`ac66ba300996`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ac66ba300996) - Add plugin to allow sorting tables in Live View mode
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 7.10.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#95062](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/95062) [`06171107f90c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/06171107f90c) - Cleanup analytics moved event feature flag.
|
|
18
|
+
|
|
3
19
|
## 7.10.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -12,7 +12,6 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
12
12
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
13
13
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
14
14
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
15
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
15
|
var _commands = require("../pm-plugins/analytics/commands");
|
|
17
16
|
var _tableAnalytics = require("../pm-plugins/table-analytics");
|
|
18
17
|
var _columnWidth = require("../transforms/column-width");
|
|
@@ -46,7 +45,7 @@ function addColumnAt() {
|
|
|
46
45
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
47
46
|
updatedTr = (0, _columnWidth.rescaleColumns)(isTableScalingEnabled)(table, view)(updatedTr);
|
|
48
47
|
}
|
|
49
|
-
if (
|
|
48
|
+
if (view) {
|
|
50
49
|
updatedTr = (0, _commands.updateRowOrColumnMovedTransform)({
|
|
51
50
|
type: 'column'
|
|
52
51
|
}, 'addRowOrColumn')(view.state, updatedTr);
|
|
@@ -134,11 +133,9 @@ var insertRow = exports.insertRow = function insertRow(row, moveCursorToTheNewRo
|
|
|
134
133
|
} else {
|
|
135
134
|
tr.setSelection(selection.map(tr.doc, tr.mapping));
|
|
136
135
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}, 'addRowOrColumn')(state, tr);
|
|
141
|
-
}
|
|
136
|
+
(0, _commands.updateRowOrColumnMovedTransform)({
|
|
137
|
+
type: 'row'
|
|
138
|
+
}, 'addRowOrColumn')(state, tr);
|
|
142
139
|
dispatch(tr);
|
|
143
140
|
}
|
|
144
141
|
return true;
|
|
@@ -195,9 +195,16 @@ var getTableElementMoveTypeBySlice = exports.getTableElementMoveTypeBySlice = fu
|
|
|
195
195
|
if (slice.content.childCount === 1 && slice.content.firstChild.type === tableRow) {
|
|
196
196
|
return 'row';
|
|
197
197
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
return
|
|
198
|
+
|
|
199
|
+
// `TableMap.get` can throw if the content is invalid - in which case we should just
|
|
200
|
+
// return undefined
|
|
201
|
+
try {
|
|
202
|
+
var map = _tableMap.TableMap.get(currentTable.node);
|
|
203
|
+
var slicedMap = _tableMap.TableMap.get(slice.content.firstChild);
|
|
204
|
+
return map.width === slicedMap.width ? 'row' : map.height === slicedMap.height ? 'column' : undefined;
|
|
205
|
+
} catch (e) {
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
201
208
|
};
|
|
202
209
|
var isInsideFirstCellOfRowOrColumn = exports.isInsideFirstCellOfRowOrColumn = function isInsideFirstCellOfRowOrColumn(selection, type) {
|
|
203
210
|
var table = (0, _utils2.findTable)(selection);
|
|
@@ -73,6 +73,14 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
73
73
|
scroll: 0,
|
|
74
74
|
parentWidth: undefined
|
|
75
75
|
}, (0, _defineProperty3.default)(_defineProperty2, _types.ShadowEvent.SHOW_BEFORE_SHADOW, false), (0, _defineProperty3.default)(_defineProperty2, _types.ShadowEvent.SHOW_AFTER_SHADOW, false), (0, _defineProperty3.default)(_defineProperty2, "tableWrapperWidth", undefined), (0, _defineProperty3.default)(_defineProperty2, "tableWrapperHeight", undefined), _defineProperty2));
|
|
76
|
+
(0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "handleMouseEnter", function () {
|
|
77
|
+
var node = _this.props.getNode();
|
|
78
|
+
var pos = _this.props.getPos();
|
|
79
|
+
var tr = _this.props.view.state.tr;
|
|
80
|
+
var tableId = node.attrs.localId;
|
|
81
|
+
tr.setMeta('mouseEnterTable', [tableId, node, pos]);
|
|
82
|
+
_this.props.view.dispatch(tr);
|
|
83
|
+
});
|
|
76
84
|
(0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "updateShadowState", function (shadowKey, value) {
|
|
77
85
|
if (_this.state[shadowKey] === value) {
|
|
78
86
|
return;
|
|
@@ -338,6 +346,15 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
338
346
|
getNode = _this$props7.getNode,
|
|
339
347
|
getEditorFeatureFlags = _this$props7.getEditorFeatureFlags,
|
|
340
348
|
isTableScalingEnabled = _this$props7.isTableScalingEnabled;
|
|
349
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.live-pages-sorting_4malx')) {
|
|
350
|
+
var _this$props$pluginInj;
|
|
351
|
+
var _ref = ((_this$props$pluginInj = this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 || (_this$props$pluginInj = _this$props$pluginInj.editorViewMode) === null || _this$props$pluginInj === void 0 ? void 0 : _this$props$pluginInj.sharedState.currentState()) || {},
|
|
352
|
+
mode = _ref.mode;
|
|
353
|
+
if (mode === 'view') {
|
|
354
|
+
var _this$table;
|
|
355
|
+
this === null || this === void 0 || (_this$table = this.table) === null || _this$table === void 0 || _this$table.addEventListener('mouseenter', this.handleMouseEnter);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
341
358
|
if (isTableScalingEnabled) {
|
|
342
359
|
this.handleColgroupUpdates(true);
|
|
343
360
|
}
|
|
@@ -413,6 +430,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
413
430
|
if (!(options !== null && options !== void 0 && options.isTableResizingEnabled) && allowColumnResizing) {
|
|
414
431
|
window.removeEventListener('resize', this.handleWindowResizeDebounced);
|
|
415
432
|
}
|
|
433
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.live-pages-sorting_4malx')) {
|
|
434
|
+
var _this$table2;
|
|
435
|
+
this === null || this === void 0 || (_this$table2 = this.table) === null || _this$table2 === void 0 || _this$table2.removeEventListener('mouseenter', this.handleMouseEnter);
|
|
436
|
+
}
|
|
416
437
|
if (this.overflowShadowsObserver) {
|
|
417
438
|
this.overflowShadowsObserver.dispose();
|
|
418
439
|
}
|
|
@@ -527,8 +548,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
527
548
|
var isNoOfColumnsChanged = (0, _utils5.tablesHaveDifferentNoOfColumns)(currentTable, previousTable);
|
|
528
549
|
var isNoOfRowsChanged = (0, _utils5.tablesHaveDifferentNoOfRows)(currentTable, previousTable);
|
|
529
550
|
if (isNoOfColumnsChanged || isNoOfRowsChanged) {
|
|
530
|
-
var _this$props$
|
|
531
|
-
(_this$props$
|
|
551
|
+
var _this$props$pluginInj2;
|
|
552
|
+
(_this$props$pluginInj2 = this.props.pluginInjectionApi) === null || _this$props$pluginInj2 === void 0 || (_this$props$pluginInj2 = _this$props$pluginInj2.accessibilityUtils) === null || _this$props$pluginInj2 === void 0 || _this$props$pluginInj2.actions.ariaNotify((0, _utils5.getAssistiveMessage)(previousTable, currentTable, this.props.intl), {
|
|
532
553
|
priority: 'important'
|
|
533
554
|
});
|
|
534
555
|
}
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -34,6 +34,7 @@ var _tableLocalId = require("./pm-plugins/table-local-id");
|
|
|
34
34
|
var _tableResizing = require("./pm-plugins/table-resizing");
|
|
35
35
|
var _tableSelectionKeymap = require("./pm-plugins/table-selection-keymap");
|
|
36
36
|
var _tableWidth = require("./pm-plugins/table-width");
|
|
37
|
+
var _viewModeSort = require("./pm-plugins/view-mode-sort");
|
|
37
38
|
var _toolbar = require("./toolbar");
|
|
38
39
|
var _FloatingContextualButton = _interopRequireDefault(require("./ui/FloatingContextualButton"));
|
|
39
40
|
var _FloatingContextualMenu = _interopRequireDefault(require("./ui/FloatingContextualMenu"));
|
|
@@ -226,6 +227,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
226
227
|
var dispatch = _ref11.dispatch;
|
|
227
228
|
return options !== null && options !== void 0 && options.dragAndDropEnabled ? (0, _dragAndDrop.createPlugin)(dispatch, editorAnalyticsAPI) : undefined;
|
|
228
229
|
}
|
|
230
|
+
}, {
|
|
231
|
+
name: 'tableViewModeSort',
|
|
232
|
+
plugin: function plugin() {
|
|
233
|
+
return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.live-pages-sorting_4malx') && api !== null && api !== void 0 && api.editorViewMode ? (0, _viewModeSort.createPlugin)(api.editorViewMode) : undefined;
|
|
234
|
+
}
|
|
229
235
|
}, {
|
|
230
236
|
name: 'tableLocalId',
|
|
231
237
|
plugin: function plugin(_ref12) {
|
|
@@ -255,7 +261,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
255
261
|
plugin: function plugin(_ref15) {
|
|
256
262
|
var dispatch = _ref15.dispatch,
|
|
257
263
|
dispatchAnalyticsEvent = _ref15.dispatchAnalyticsEvent;
|
|
258
|
-
return (0,
|
|
264
|
+
return (0, _plugin.createPlugin)(dispatch, dispatchAnalyticsEvent);
|
|
259
265
|
}
|
|
260
266
|
}, {
|
|
261
267
|
name: 'tableGetEditorViewReferencePlugin',
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createPlugin = void 0;
|
|
7
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
8
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
9
|
var _misc = require("../../commands/misc");
|
|
11
10
|
var _commands = require("./commands");
|
|
12
11
|
var _pluginFactory = require("./plugin-factory");
|
|
@@ -40,33 +39,29 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
|
|
|
40
39
|
handlePaste: function handlePaste(_ref, event, slice) {
|
|
41
40
|
var state = _ref.state,
|
|
42
41
|
dispatch = _ref.dispatch;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var type = (0, _misc.getTableElementMoveTypeBySlice)(slice, state);
|
|
42
|
+
var schema = state.schema;
|
|
43
|
+
var type = (0, _misc.getTableElementMoveTypeBySlice)(slice, state);
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
var count = (0, _misc.countCellsInSlice)(slice, schema, type);
|
|
52
|
-
(0, _commands.updateRowOrColumnMoved)({
|
|
53
|
-
numberOfCells: count,
|
|
54
|
-
type: type
|
|
55
|
-
}, 'pasted')(state, dispatch);
|
|
45
|
+
// if the selection wasn't in the first cell of a row or column, don't count it
|
|
46
|
+
if (!type || !(0, _misc.isInsideFirstCellOfRowOrColumn)(state.selection, type)) {
|
|
47
|
+
return;
|
|
56
48
|
}
|
|
49
|
+
var count = (0, _misc.countCellsInSlice)(slice, schema, type);
|
|
50
|
+
(0, _commands.updateRowOrColumnMoved)({
|
|
51
|
+
numberOfCells: count,
|
|
52
|
+
type: type
|
|
53
|
+
}, 'pasted')(state, dispatch);
|
|
57
54
|
},
|
|
58
55
|
transformCopied: function transformCopied(slice, _ref2) {
|
|
59
56
|
var state = _ref2.state,
|
|
60
57
|
dispatch = _ref2.dispatch;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}, 'copyOrCut')(state, dispatch);
|
|
69
|
-
}
|
|
58
|
+
var schema = state.schema;
|
|
59
|
+
var type = (0, _misc.getTableSelectionType)(state.selection);
|
|
60
|
+
var count = (0, _misc.countCellsInSlice)(slice, schema, type);
|
|
61
|
+
(0, _commands.updateRowOrColumnMoved)({
|
|
62
|
+
numberOfCells: count,
|
|
63
|
+
type: type
|
|
64
|
+
}, 'copyOrCut')(state, dispatch);
|
|
70
65
|
return slice;
|
|
71
66
|
}
|
|
72
67
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SORT_INDEX_DATA_ATTRIBUTE = exports.SORTING_ICON_CLASS_NAME = exports.IS_DISABLED_CLASS_NAME = void 0;
|
|
7
|
+
var SORTING_ICON_CLASS_NAME = exports.SORTING_ICON_CLASS_NAME = 'view-mode-sorting-icon';
|
|
8
|
+
var IS_DISABLED_CLASS_NAME = exports.IS_DISABLED_CLASS_NAME = 'is-disabled';
|
|
9
|
+
var SORT_INDEX_DATA_ATTRIBUTE = exports.SORT_INDEX_DATA_ATTRIBUTE = 'data-sort-index';
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createPlugin = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _react = require("react");
|
|
12
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
13
|
+
var _reactIntlNext = require("react-intl-next");
|
|
14
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
15
|
+
var _table3 = require("@atlaskit/editor-common/table");
|
|
16
|
+
var _types = require("@atlaskit/editor-common/types");
|
|
17
|
+
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
18
|
+
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
19
|
+
var _pluginFactory = require("../plugin-factory");
|
|
20
|
+
var _consts = require("./consts");
|
|
21
|
+
var _pluginKey = require("./plugin-key");
|
|
22
|
+
var _utils = require("./utils");
|
|
23
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
24
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
25
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
26
|
+
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; }
|
|
27
|
+
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; } /**
|
|
28
|
+
* This plugin allows sorting of table nodes in the Editor without modifying the underlying ProseMirror document.
|
|
29
|
+
* Instead of making changes to the ProseMirror document, the plugin sorts the table rows in the DOM. This allows the sorting to be
|
|
30
|
+
* visible to the user without affecting the document's content.
|
|
31
|
+
*/
|
|
32
|
+
var createPlugin = exports.createPlugin = function createPlugin(editorViewModeAPI) {
|
|
33
|
+
return new _safePlugin.SafePlugin({
|
|
34
|
+
state: {
|
|
35
|
+
init: function init() {
|
|
36
|
+
return {
|
|
37
|
+
decorations: _view.DecorationSet.empty,
|
|
38
|
+
sort: {},
|
|
39
|
+
allTables: []
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
apply: function apply(tr, pluginState, oldState) {
|
|
43
|
+
// TODO - move this mode check to plugin creation if possible. Right now it's here because the initial state
|
|
44
|
+
// does not appear correct when the plugin is created.
|
|
45
|
+
var _ref = (editorViewModeAPI === null || editorViewModeAPI === void 0 ? void 0 : editorViewModeAPI.sharedState.currentState()) || {},
|
|
46
|
+
mode = _ref.mode;
|
|
47
|
+
if (mode !== 'view') {
|
|
48
|
+
return pluginState;
|
|
49
|
+
}
|
|
50
|
+
var decorations = pluginState.decorations,
|
|
51
|
+
sort = pluginState.sort,
|
|
52
|
+
allTables = pluginState.allTables;
|
|
53
|
+
var sortMeta = tr.getMeta('tableSortMeta');
|
|
54
|
+
var hoverTableMeta = tr.getMeta('mouseEnterTable');
|
|
55
|
+
var removeTableMeta = tr.getMeta('removeTable');
|
|
56
|
+
var tableId = '';
|
|
57
|
+
|
|
58
|
+
// Remove the table from the state
|
|
59
|
+
if (removeTableMeta) {
|
|
60
|
+
allTables = allTables.filter(function (_ref2) {
|
|
61
|
+
var _ref3 = (0, _slicedToArray2.default)(_ref2, 1),
|
|
62
|
+
id = _ref3[0];
|
|
63
|
+
return id !== removeTableMeta;
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
tableId = hoverTableMeta === null || hoverTableMeta === void 0 ? void 0 : hoverTableMeta[0];
|
|
67
|
+
}
|
|
68
|
+
sort = _objectSpread(_objectSpread({}, sort), sortMeta);
|
|
69
|
+
var isTableInState = allTables.some(function (_ref4) {
|
|
70
|
+
var _ref5 = (0, _slicedToArray2.default)(_ref4, 1),
|
|
71
|
+
id = _ref5[0];
|
|
72
|
+
return id === tableId;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Update the table in the state
|
|
76
|
+
if (hoverTableMeta) {
|
|
77
|
+
allTables = allTables.filter(function (_ref6) {
|
|
78
|
+
var _ref7 = (0, _slicedToArray2.default)(_ref6, 1),
|
|
79
|
+
id = _ref7[0];
|
|
80
|
+
return id !== hoverTableMeta[0];
|
|
81
|
+
});
|
|
82
|
+
allTables.push(hoverTableMeta);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Create decorations for the sorting icons
|
|
87
|
+
*/
|
|
88
|
+
var decs = [];
|
|
89
|
+
|
|
90
|
+
// TODO - add support for keyboard only users
|
|
91
|
+
if (hoverTableMeta && !isTableInState || sortMeta) {
|
|
92
|
+
allTables.forEach(function (table) {
|
|
93
|
+
var _table = (0, _slicedToArray2.default)(table, 3),
|
|
94
|
+
tableId = _table[0],
|
|
95
|
+
_node = _table[1],
|
|
96
|
+
pos = _table[2];
|
|
97
|
+
var tableNode = tr.doc.nodeAt(tr.mapping.map(pos));
|
|
98
|
+
if (!tableNode || tableNode.type.name !== 'table') {
|
|
99
|
+
return pluginState;
|
|
100
|
+
}
|
|
101
|
+
var map = _tableMap.TableMap.get(tableNode);
|
|
102
|
+
var hasMergedCells = new Set(map.map).size !== map.map.length;
|
|
103
|
+
map.mapByRow[0].forEach(function (cell, index) {
|
|
104
|
+
// return pluginState;
|
|
105
|
+
decs.push(_view.Decoration.widget(cell + pos + 2, function () {
|
|
106
|
+
var _sort$tableId;
|
|
107
|
+
var element = document.createElement('div');
|
|
108
|
+
element.setAttribute(_consts.SORT_INDEX_DATA_ATTRIBUTE, "".concat(index));
|
|
109
|
+
element.classList.add(_consts.SORTING_ICON_CLASS_NAME);
|
|
110
|
+
if (hasMergedCells) {
|
|
111
|
+
element.classList.add(_consts.IS_DISABLED_CLASS_NAME);
|
|
112
|
+
}
|
|
113
|
+
var sortOrdered;
|
|
114
|
+
if (index === ((_sort$tableId = sort[tableId]) === null || _sort$tableId === void 0 ? void 0 : _sort$tableId.index)) {
|
|
115
|
+
var _sort$tableId2;
|
|
116
|
+
sortOrdered = (_sort$tableId2 = sort[tableId]) === null || _sort$tableId2 === void 0 ? void 0 : _sort$tableId2.direction;
|
|
117
|
+
} else {
|
|
118
|
+
sortOrdered = _types.SortOrder.NO_ORDER;
|
|
119
|
+
}
|
|
120
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(oldState),
|
|
121
|
+
getIntl = _getPluginState.getIntl;
|
|
122
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_reactIntlNext.RawIntlProvider, {
|
|
123
|
+
value: getIntl()
|
|
124
|
+
}, /*#__PURE__*/(0, _react.createElement)(_table3.SortingIcon, {
|
|
125
|
+
isSortingAllowed: !hasMergedCells,
|
|
126
|
+
sortOrdered: sortOrdered,
|
|
127
|
+
onClick: function onClick() {},
|
|
128
|
+
onKeyDown: function onKeyDown() {}
|
|
129
|
+
})), element);
|
|
130
|
+
return element;
|
|
131
|
+
}));
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
decorations = _view.DecorationSet.create(tr.doc, decs);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Map the decorations to the new document if there are changes
|
|
139
|
+
*/
|
|
140
|
+
if (tr.docChanged) {
|
|
141
|
+
decorations = decorations.map(tr.mapping, tr.doc);
|
|
142
|
+
allTables = allTables.map(function (table) {
|
|
143
|
+
return [table[0], table[1], tr.mapping.map(table[2])];
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
decorations: decorations,
|
|
148
|
+
sort: sort,
|
|
149
|
+
allTables: allTables
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
key: _pluginKey.tableViewModeSortPluginKey,
|
|
154
|
+
appendTransaction: function appendTransaction(trs, oldState, newState) {
|
|
155
|
+
var _key$getState;
|
|
156
|
+
// return newState.tr;
|
|
157
|
+
var _ref8 = (editorViewModeAPI === null || editorViewModeAPI === void 0 ? void 0 : editorViewModeAPI.sharedState.currentState()) || {},
|
|
158
|
+
mode = _ref8.mode;
|
|
159
|
+
if (mode !== 'view') {
|
|
160
|
+
return newState.tr;
|
|
161
|
+
}
|
|
162
|
+
var allTables = ((_key$getState = _pluginKey.tableViewModeSortPluginKey.getState(newState)) === null || _key$getState === void 0 ? void 0 : _key$getState.allTables) || [];
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* If incoming changes have affected a table node, remove the sorting. This prevents the
|
|
166
|
+
* table from breaking if changes like merged cells are incoming.
|
|
167
|
+
*/
|
|
168
|
+
var _iterator = _createForOfIteratorHelper(trs),
|
|
169
|
+
_step;
|
|
170
|
+
try {
|
|
171
|
+
var _loop = function _loop() {
|
|
172
|
+
var tr = _step.value;
|
|
173
|
+
var hoverTableMeta = tr.getMeta('mouseEnterTable');
|
|
174
|
+
if (hoverTableMeta) {
|
|
175
|
+
allTables = allTables.filter(function (_ref9) {
|
|
176
|
+
var _ref10 = (0, _slicedToArray2.default)(_ref9, 1),
|
|
177
|
+
id = _ref10[0];
|
|
178
|
+
return id !== hoverTableMeta[0];
|
|
179
|
+
});
|
|
180
|
+
allTables.push(hoverTableMeta);
|
|
181
|
+
}
|
|
182
|
+
var isRemote = tr.getMeta('isRemote');
|
|
183
|
+
var isDocChanged = tr.docChanged;
|
|
184
|
+
var isChangesIncoming = isRemote && isDocChanged;
|
|
185
|
+
var oldPluginState = _pluginKey.tableViewModeSortPluginKey.getState(oldState);
|
|
186
|
+
var newPluginState = _pluginKey.tableViewModeSortPluginKey.getState(newState);
|
|
187
|
+
var _iterator2 = _createForOfIteratorHelper(allTables),
|
|
188
|
+
_step2;
|
|
189
|
+
try {
|
|
190
|
+
var _loop2 = function _loop2() {
|
|
191
|
+
var _oldPluginState$sort, _newPluginState$sort;
|
|
192
|
+
var table = _step2.value;
|
|
193
|
+
var _table2 = (0, _slicedToArray2.default)(table, 3),
|
|
194
|
+
tableId = _table2[0],
|
|
195
|
+
node = _table2[1],
|
|
196
|
+
pos = _table2[2];
|
|
197
|
+
var _ref11 = (oldPluginState === null || oldPluginState === void 0 || (_oldPluginState$sort = oldPluginState.sort) === null || _oldPluginState$sort === void 0 ? void 0 : _oldPluginState$sort[tableId]) || {},
|
|
198
|
+
oldOrder = _ref11.order,
|
|
199
|
+
oldDirection = _ref11.direction,
|
|
200
|
+
oldIndex = _ref11.index;
|
|
201
|
+
if (isChangesIncoming) {
|
|
202
|
+
var _maybeTableNode$attrs;
|
|
203
|
+
var maybeTableNode = tr.doc.nodeAt(pos);
|
|
204
|
+
var isTableNodeChanged = (maybeTableNode === null || maybeTableNode === void 0 || (_maybeTableNode$attrs = maybeTableNode.attrs) === null || _maybeTableNode$attrs === void 0 ? void 0 : _maybeTableNode$attrs.localId) !== tableId || !node.eq(maybeTableNode);
|
|
205
|
+
if (isTableNodeChanged) {
|
|
206
|
+
var newtr = newState.tr;
|
|
207
|
+
newtr.setMeta('tableSortMeta', (0, _defineProperty2.default)({}, tableId, {}));
|
|
208
|
+
newtr.setMeta('removeTable', tableId);
|
|
209
|
+
|
|
210
|
+
// Unsort the table here
|
|
211
|
+
if (oldOrder !== undefined) {
|
|
212
|
+
var _getTableElements = (0, _utils.getTableElements)(tableId),
|
|
213
|
+
rows = _getTableElements.rows,
|
|
214
|
+
tbody = _getTableElements.tbody;
|
|
215
|
+
if (!rows || !tbody) {
|
|
216
|
+
return {
|
|
217
|
+
v: {
|
|
218
|
+
v: newtr
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
var sortedOrder = (0, _toConsumableArray2.default)(oldOrder).sort(function (a, b) {
|
|
223
|
+
return a.value - b.value;
|
|
224
|
+
});
|
|
225
|
+
sortedOrder.forEach(function (index, i) {
|
|
226
|
+
tbody.appendChild(rows[index.index + 1]);
|
|
227
|
+
});
|
|
228
|
+
return {
|
|
229
|
+
v: {
|
|
230
|
+
v: newtr
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Sort the table if the sort order has changed
|
|
239
|
+
*/
|
|
240
|
+
var _ref12 = (newPluginState === null || newPluginState === void 0 || (_newPluginState$sort = newPluginState.sort) === null || _newPluginState$sort === void 0 ? void 0 : _newPluginState$sort[tableId]) || {},
|
|
241
|
+
newOrder = _ref12.order,
|
|
242
|
+
newDirection = _ref12.direction,
|
|
243
|
+
newIndex = _ref12.index;
|
|
244
|
+
var orderChanged = oldDirection !== newDirection || oldIndex !== newIndex;
|
|
245
|
+
if (orderChanged) {
|
|
246
|
+
if (!isRemote && newDirection !== _types.SortOrder.NO_ORDER) {
|
|
247
|
+
var _getTableElements2 = (0, _utils.getTableElements)(tableId),
|
|
248
|
+
_rows = _getTableElements2.rows,
|
|
249
|
+
_tbody = _getTableElements2.tbody;
|
|
250
|
+
if (_rows && newOrder) {
|
|
251
|
+
newOrder.forEach(function (index, i) {
|
|
252
|
+
_tbody === null || _tbody === void 0 || _tbody.appendChild(_rows[index.value + 1]);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
_ret2;
|
|
259
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
260
|
+
_ret2 = _loop2();
|
|
261
|
+
if (_ret2) return _ret2.v;
|
|
262
|
+
}
|
|
263
|
+
} catch (err) {
|
|
264
|
+
_iterator2.e(err);
|
|
265
|
+
} finally {
|
|
266
|
+
_iterator2.f();
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
_ret;
|
|
270
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
271
|
+
_ret = _loop();
|
|
272
|
+
if (_ret) return _ret.v;
|
|
273
|
+
}
|
|
274
|
+
} catch (err) {
|
|
275
|
+
_iterator.e(err);
|
|
276
|
+
} finally {
|
|
277
|
+
_iterator.f();
|
|
278
|
+
}
|
|
279
|
+
return newState.tr;
|
|
280
|
+
},
|
|
281
|
+
props: {
|
|
282
|
+
handleDOMEvents: {
|
|
283
|
+
keydown: function keydown(view, event) {
|
|
284
|
+
// TODO - fix the focus issue here, where toggling sort with a keypress loses focus
|
|
285
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
286
|
+
var _key$getState2;
|
|
287
|
+
var pluginState = ((_key$getState2 = _pluginKey.tableViewModeSortPluginKey.getState(view.state)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.sort) || {};
|
|
288
|
+
(0, _utils.toggleSort)(view, event, pluginState);
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
click: function click(view, event) {
|
|
292
|
+
var _key$getState3;
|
|
293
|
+
var pluginState = ((_key$getState3 = _pluginKey.tableViewModeSortPluginKey.getState(view.state)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.sort) || {};
|
|
294
|
+
(0, _utils.toggleSort)(view, event, pluginState);
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
decorations: function decorations(state) {
|
|
298
|
+
var _key$getState4;
|
|
299
|
+
var decs = ((_key$getState4 = _pluginKey.tableViewModeSortPluginKey.getState(state)) === null || _key$getState4 === void 0 ? void 0 : _key$getState4.decorations) || _view.DecorationSet.empty;
|
|
300
|
+
return decs;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.tableViewModeSortPluginKey = void 0;
|
|
7
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
var tableViewModeSortPluginKey = exports.tableViewModeSortPluginKey = new _state.PluginKey('tableViewModeSortPlugin');
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.unsort = exports.toggleSort = exports.getTableElements = exports.getSortOrderFromTable = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _types = require("@atlaskit/editor-common/types");
|
|
11
|
+
var _consts = require("./consts");
|
|
12
|
+
var unsort = exports.unsort = function unsort(oldOrder, tableElement) {
|
|
13
|
+
var rows = tableElement.querySelectorAll('tr');
|
|
14
|
+
var tbody = tableElement.querySelector('tbody');
|
|
15
|
+
var sortedOrder = (0, _toConsumableArray2.default)(oldOrder).sort(function (a, b) {
|
|
16
|
+
return a.value - b.value;
|
|
17
|
+
});
|
|
18
|
+
sortedOrder.forEach(function (item) {
|
|
19
|
+
tbody === null || tbody === void 0 || tbody.appendChild(rows[item.index + 1]);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// TODO - reuse sort logic from the Renderer and support switching between ASC, DESC and NO_ORDER
|
|
24
|
+
var getSortOrderFromTable = exports.getSortOrderFromTable = function getSortOrderFromTable(tableElement, sortIndex, direction) {
|
|
25
|
+
var sortOrder = direction === _types.SortOrder.DESC ? -1 : 1;
|
|
26
|
+
var strings = [];
|
|
27
|
+
tableElement.querySelectorAll('tr:not([data-header-row="true"])').forEach(function (tr) {
|
|
28
|
+
var _tr$querySelectorAll$;
|
|
29
|
+
strings.push(((_tr$querySelectorAll$ = tr.querySelectorAll('td')[sortIndex]) === null || _tr$querySelectorAll$ === void 0 ? void 0 : _tr$querySelectorAll$.textContent) || '');
|
|
30
|
+
});
|
|
31
|
+
var order = Array.from(strings.keys()).sort(function (a, b) {
|
|
32
|
+
var string = strings[a] || '';
|
|
33
|
+
return string.localeCompare(strings[b] || '') * sortOrder;
|
|
34
|
+
}).map(function (value, index) {
|
|
35
|
+
return {
|
|
36
|
+
value: value,
|
|
37
|
+
index: index
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
// TODO - improve this. right now this is a workaround to ensure the first tr is always first in the order
|
|
41
|
+
return [{
|
|
42
|
+
value: -1,
|
|
43
|
+
index: -1
|
|
44
|
+
}].concat((0, _toConsumableArray2.default)(order));
|
|
45
|
+
};
|
|
46
|
+
var toggleSort = exports.toggleSort = function toggleSort(view, event, pluginState) {
|
|
47
|
+
var _target$closest;
|
|
48
|
+
var target = event.target;
|
|
49
|
+
var widget = target.closest(".".concat(_consts.SORTING_ICON_CLASS_NAME));
|
|
50
|
+
if (widget !== null && widget !== void 0 && widget.classList.contains(_consts.IS_DISABLED_CLASS_NAME) || !widget) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
var datasetortIndex = 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
|
+
var tr = view.state.tr;
|
|
55
|
+
var tableElement = target.closest('table');
|
|
56
|
+
if (!tableElement || !datasetortIndex) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
var tableId = tableElement.getAttribute('data-table-local-id') || '';
|
|
60
|
+
var _ref = (pluginState === null || pluginState === void 0 ? void 0 : pluginState[tableId]) || {},
|
|
61
|
+
index = _ref.index,
|
|
62
|
+
direction = _ref.direction,
|
|
63
|
+
oldOrder = _ref.order;
|
|
64
|
+
|
|
65
|
+
// Unsort if there was already a sort
|
|
66
|
+
if (direction !== _types.SortOrder.NO_ORDER && oldOrder !== undefined) {
|
|
67
|
+
unsort(oldOrder, tableElement);
|
|
68
|
+
}
|
|
69
|
+
var sortIndex = parseInt(datasetortIndex);
|
|
70
|
+
if (sortIndex === index) {
|
|
71
|
+
switch (direction) {
|
|
72
|
+
case _types.SortOrder.NO_ORDER:
|
|
73
|
+
direction = _types.SortOrder.ASC;
|
|
74
|
+
break;
|
|
75
|
+
case _types.SortOrder.ASC:
|
|
76
|
+
direction = _types.SortOrder.DESC;
|
|
77
|
+
break;
|
|
78
|
+
case _types.SortOrder.DESC:
|
|
79
|
+
direction = _types.SortOrder.NO_ORDER;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
direction = _types.SortOrder.ASC; // default direction when a new index is clicked
|
|
84
|
+
}
|
|
85
|
+
var order = getSortOrderFromTable(tableElement, sortIndex, direction);
|
|
86
|
+
if (direction === _types.SortOrder.NO_ORDER) {
|
|
87
|
+
tr.setMeta('tableSortMeta', (0, _defineProperty2.default)({}, tableId, {}));
|
|
88
|
+
} else {
|
|
89
|
+
tr.setMeta('tableSortMeta', (0, _defineProperty2.default)({}, tableId, {
|
|
90
|
+
index: sortIndex,
|
|
91
|
+
direction: direction,
|
|
92
|
+
order: order,
|
|
93
|
+
tableElement: tableElement
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
view.dispatch(tr);
|
|
97
|
+
};
|
|
98
|
+
var getTableElements = exports.getTableElements = function getTableElements(tableId) {
|
|
99
|
+
var tableElement = document.querySelector("table[data-table-local-id=\"".concat(tableId, "\"]"));
|
|
100
|
+
var tbody = tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelector('tbody');
|
|
101
|
+
var rows = tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelectorAll('tr');
|
|
102
|
+
return {
|
|
103
|
+
tbody: tbody,
|
|
104
|
+
rows: rows
|
|
105
|
+
};
|
|
106
|
+
};
|