@atlaskit/editor-plugin-table 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/plugins/table/commands/clear.js +4 -16
- package/dist/cjs/plugins/table/commands/collapse.js +0 -6
- package/dist/cjs/plugins/table/commands/go-to-next-cell.js +7 -18
- package/dist/cjs/plugins/table/commands/hover.js +7 -37
- package/dist/cjs/plugins/table/commands/index.js +0 -8
- package/dist/cjs/plugins/table/commands/insert.js +17 -56
- package/dist/cjs/plugins/table/commands/misc.js +36 -132
- package/dist/cjs/plugins/table/commands/referentiality.js +0 -4
- package/dist/cjs/plugins/table/commands/selection.js +21 -87
- package/dist/cjs/plugins/table/commands/sort.js +2 -23
- package/dist/cjs/plugins/table/commands/split-cell.js +3 -11
- package/dist/cjs/plugins/table/commands/toggle.js +8 -34
- package/dist/cjs/plugins/table/commands-with-analytics.js +50 -139
- package/dist/cjs/plugins/table/create-plugin-config.js +0 -6
- package/dist/cjs/plugins/table/event-handlers.js +58 -160
- package/dist/cjs/plugins/table/handlers.js +10 -39
- package/dist/cjs/plugins/table/index.js +47 -91
- package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -41
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +82 -188
- package/dist/cjs/plugins/table/nodeviews/table.js +12 -70
- package/dist/cjs/plugins/table/nodeviews/tableCell.js +15 -39
- package/dist/cjs/plugins/table/nodeviews/update-overflow-shadows.js +3 -15
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +0 -18
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -27
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-resizing.js +8 -20
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +1 -3
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/index.js +0 -3
- package/dist/cjs/plugins/table/pm-plugins/keymap.js +2 -15
- package/dist/cjs/plugins/table/pm-plugins/main.js +20 -72
- package/dist/cjs/plugins/table/pm-plugins/plugin-factory.js +25 -42
- package/dist/cjs/plugins/table/pm-plugins/plugin-key.js +0 -2
- package/dist/cjs/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -8
- package/dist/cjs/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +4 -23
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/commands.js +0 -5
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/index.js +0 -5
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -13
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +56 -138
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-key.js +0 -2
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-state.js +15 -30
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +0 -6
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/util.js +0 -5
- package/dist/cjs/plugins/table/pm-plugins/table-local-id.js +13 -44
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/commands.js +12 -42
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -52
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/index.js +0 -4
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-factory.js +0 -10
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-key.js +0 -2
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin.js +5 -19
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/reducer.js +0 -10
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -15
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -28
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/content-width.js +3 -23
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +4 -46
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/index.js +0 -9
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +15 -36
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-column.js +1 -4
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +15 -71
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +34 -82
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +12 -36
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.js +0 -2
- package/dist/cjs/plugins/table/pm-plugins/table-selection-keymap.js +0 -5
- package/dist/cjs/plugins/table/reducer.js +0 -24
- package/dist/cjs/plugins/table/toolbar.js +14 -94
- package/dist/cjs/plugins/table/transforms/column-width.js +12 -45
- package/dist/cjs/plugins/table/transforms/delete-columns.js +11 -76
- package/dist/cjs/plugins/table/transforms/delete-rows.js +4 -42
- package/dist/cjs/plugins/table/transforms/fix-tables.js +24 -61
- package/dist/cjs/plugins/table/transforms/index.js +0 -7
- package/dist/cjs/plugins/table/transforms/merge.js +14 -90
- package/dist/cjs/plugins/table/transforms/metadata.js +0 -5
- package/dist/cjs/plugins/table/transforms/replace-table.js +2 -13
- package/dist/cjs/plugins/table/transforms/split.js +18 -32
- package/dist/cjs/plugins/table/types.js +0 -11
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +10 -51
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/styles.js +0 -12
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +46 -145
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +12 -35
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/styles.js +0 -11
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +5 -12
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +3 -16
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +19 -89
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +6 -31
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +5 -22
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +25 -80
- package/dist/cjs/plugins/table/ui/LayoutButton/index.js +16 -64
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +14 -47
- package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +20 -48
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +10 -43
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +33 -74
- package/dist/cjs/plugins/table/ui/common-styles.js +6 -19
- package/dist/cjs/plugins/table/ui/consts.js +3 -8
- package/dist/cjs/plugins/table/ui/messages.js +0 -3
- package/dist/cjs/plugins/table/ui/ui-styles.js +0 -32
- package/dist/cjs/plugins/table/utils/analytics.js +4 -19
- package/dist/cjs/plugins/table/utils/collapse.js +4 -21
- package/dist/cjs/plugins/table/utils/column-controls.js +25 -61
- package/dist/cjs/plugins/table/utils/decoration.js +46 -114
- package/dist/cjs/plugins/table/utils/dom.js +4 -51
- package/dist/cjs/plugins/table/utils/get-allow-add-column-custom-step.js +0 -2
- package/dist/cjs/plugins/table/utils/index.js +0 -10
- package/dist/cjs/plugins/table/utils/nodes.js +5 -48
- package/dist/cjs/plugins/table/utils/paste.js +22 -47
- package/dist/cjs/plugins/table/utils/row-controls.js +6 -67
- package/dist/cjs/plugins/table/utils/selection.js +3 -36
- package/dist/cjs/plugins/table/utils/table.js +0 -11
- package/dist/cjs/plugins/table/utils/update-plugin-state-decorations.js +0 -4
- package/dist/cjs/plugins/table-plugin.js +0 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/commands/clear.js +3 -8
- package/dist/es2019/plugins/table/commands/collapse.js +0 -3
- package/dist/es2019/plugins/table/commands/go-to-next-cell.js +4 -7
- package/dist/es2019/plugins/table/commands/hover.js +7 -17
- package/dist/es2019/plugins/table/commands/insert.js +16 -36
- package/dist/es2019/plugins/table/commands/misc.js +37 -67
- package/dist/es2019/plugins/table/commands/selection.js +7 -62
- package/dist/es2019/plugins/table/commands/sort.js +0 -12
- package/dist/es2019/plugins/table/commands/split-cell.js +0 -4
- package/dist/es2019/plugins/table/commands/toggle.js +13 -15
- package/dist/es2019/plugins/table/commands-with-analytics.js +4 -14
- package/dist/es2019/plugins/table/event-handlers.js +14 -62
- package/dist/es2019/plugins/table/handlers.js +16 -26
- package/dist/es2019/plugins/table/index.js +12 -25
- package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -40
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +27 -100
- package/dist/es2019/plugins/table/nodeviews/table.js +3 -33
- package/dist/es2019/plugins/table/nodeviews/tableCell.js +7 -16
- package/dist/es2019/plugins/table/nodeviews/update-overflow-shadows.js +3 -10
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +0 -5
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +4 -13
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-resizing.js +0 -3
- package/dist/es2019/plugins/table/pm-plugins/keymap.js +2 -3
- package/dist/es2019/plugins/table/pm-plugins/main.js +19 -43
- package/dist/es2019/plugins/table/pm-plugins/plugin-factory.js +2 -6
- package/dist/es2019/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -3
- package/dist/es2019/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +0 -12
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -9
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +55 -130
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin-state.js +2 -9
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/util.js +0 -3
- package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +20 -39
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/commands.js +7 -15
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -27
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -4
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin.js +2 -5
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/reducer.js +8 -8
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -4
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -11
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/content-width.js +4 -21
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/dom.js +3 -22
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +10 -18
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +29 -59
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +54 -51
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +9 -14
- package/dist/es2019/plugins/table/reducer.js +26 -30
- package/dist/es2019/plugins/table/toolbar.js +5 -48
- package/dist/es2019/plugins/table/transforms/column-width.js +16 -28
- package/dist/es2019/plugins/table/transforms/delete-columns.js +17 -58
- package/dist/es2019/plugins/table/transforms/delete-rows.js +8 -25
- package/dist/es2019/plugins/table/transforms/fix-tables.js +25 -42
- package/dist/es2019/plugins/table/transforms/merge.js +22 -70
- package/dist/es2019/plugins/table/transforms/metadata.js +3 -2
- package/dist/es2019/plugins/table/transforms/replace-table.js +0 -2
- package/dist/es2019/plugins/table/transforms/split.js +16 -19
- package/dist/es2019/plugins/table/types.js +2 -4
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +2 -16
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +8 -54
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +4 -13
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +0 -2
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +2 -11
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +13 -49
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +0 -8
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +16 -24
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +3 -31
- package/dist/es2019/plugins/table/ui/LayoutButton/index.js +2 -29
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +0 -12
- package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +6 -12
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +0 -9
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -19
- package/dist/es2019/plugins/table/ui/common-styles.js +6 -5
- package/dist/es2019/plugins/table/ui/consts.js +4 -3
- package/dist/es2019/plugins/table/ui/ui-styles.js +0 -10
- package/dist/es2019/plugins/table/utils/analytics.js +0 -8
- package/dist/es2019/plugins/table/utils/collapse.js +3 -14
- package/dist/es2019/plugins/table/utils/column-controls.js +22 -37
- package/dist/es2019/plugins/table/utils/decoration.js +13 -51
- package/dist/es2019/plugins/table/utils/dom.js +3 -19
- package/dist/es2019/plugins/table/utils/nodes.js +2 -15
- package/dist/es2019/plugins/table/utils/paste.js +17 -22
- package/dist/es2019/plugins/table/utils/row-controls.js +12 -45
- package/dist/es2019/plugins/table/utils/selection.js +0 -21
- package/dist/es2019/plugins/table/utils/table.js +0 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/commands/clear.js +3 -8
- package/dist/esm/plugins/table/commands/collapse.js +0 -3
- package/dist/esm/plugins/table/commands/go-to-next-cell.js +6 -9
- package/dist/esm/plugins/table/commands/hover.js +8 -18
- package/dist/esm/plugins/table/commands/insert.js +16 -36
- package/dist/esm/plugins/table/commands/misc.js +39 -78
- package/dist/esm/plugins/table/commands/selection.js +21 -78
- package/dist/esm/plugins/table/commands/sort.js +2 -14
- package/dist/esm/plugins/table/commands/split-cell.js +3 -8
- package/dist/esm/plugins/table/commands/toggle.js +11 -20
- package/dist/esm/plugins/table/commands-with-analytics.js +50 -85
- package/dist/esm/plugins/table/create-plugin-config.js +0 -3
- package/dist/esm/plugins/table/event-handlers.js +58 -123
- package/dist/esm/plugins/table/handlers.js +11 -29
- package/dist/esm/plugins/table/index.js +47 -60
- package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -44
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +82 -181
- package/dist/esm/plugins/table/nodeviews/table.js +12 -52
- package/dist/esm/plugins/table/nodeviews/tableCell.js +15 -33
- package/dist/esm/plugins/table/nodeviews/update-overflow-shadows.js +3 -10
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +0 -5
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -19
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-resizing.js +8 -13
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/keymap.js +2 -3
- package/dist/esm/plugins/table/pm-plugins/main.js +20 -47
- package/dist/esm/plugins/table/pm-plugins/plugin-factory.js +25 -37
- package/dist/esm/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -3
- package/dist/esm/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +3 -15
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -9
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +58 -147
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin-state.js +15 -27
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/util.js +0 -3
- package/dist/esm/plugins/table/pm-plugins/table-local-id.js +14 -37
- package/dist/esm/plugins/table/pm-plugins/table-resizing/commands.js +12 -24
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -36
- package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin-factory.js +0 -6
- package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin.js +5 -8
- package/dist/esm/plugins/table/pm-plugins/table-resizing/reducer.js +0 -7
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -4
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -12
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/content-width.js +5 -22
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/dom.js +4 -23
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +15 -23
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +15 -60
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +34 -55
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +12 -24
- package/dist/esm/plugins/table/reducer.js +0 -20
- package/dist/esm/plugins/table/toolbar.js +13 -63
- package/dist/esm/plugins/table/transforms/column-width.js +12 -32
- package/dist/esm/plugins/table/transforms/delete-columns.js +11 -62
- package/dist/esm/plugins/table/transforms/delete-rows.js +4 -30
- package/dist/esm/plugins/table/transforms/fix-tables.js +24 -49
- package/dist/esm/plugins/table/transforms/merge.js +16 -75
- package/dist/esm/plugins/table/transforms/metadata.js +3 -2
- package/dist/esm/plugins/table/transforms/replace-table.js +2 -6
- package/dist/esm/plugins/table/transforms/split.js +18 -29
- package/dist/esm/plugins/table/types.js +0 -6
- package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +10 -31
- package/dist/esm/plugins/table/ui/FloatingContextualButton/styles.js +0 -2
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +46 -126
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +13 -24
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/styles.js +0 -2
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +5 -7
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +3 -13
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +19 -68
- package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +6 -14
- package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +5 -18
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +25 -57
- package/dist/esm/plugins/table/ui/LayoutButton/index.js +16 -47
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +14 -35
- package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +20 -38
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +10 -29
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +33 -62
- package/dist/esm/plugins/table/ui/common-styles.js +6 -7
- package/dist/esm/plugins/table/ui/consts.js +4 -3
- package/dist/esm/plugins/table/ui/ui-styles.js +0 -12
- package/dist/esm/plugins/table/utils/analytics.js +4 -13
- package/dist/esm/plugins/table/utils/collapse.js +4 -15
- package/dist/esm/plugins/table/utils/column-controls.js +25 -41
- package/dist/esm/plugins/table/utils/decoration.js +46 -88
- package/dist/esm/plugins/table/utils/dom.js +4 -20
- package/dist/esm/plugins/table/utils/nodes.js +5 -18
- package/dist/esm/plugins/table/utils/paste.js +24 -29
- package/dist/esm/plugins/table/utils/row-controls.js +6 -46
- package/dist/esm/plugins/table/utils/selection.js +3 -26
- package/dist/esm/plugins/table/utils/table.js +0 -2
- package/dist/esm/version.json +1 -1
- package/package.json +2 -2
- package/src/__tests__/visual-regression/cell-options-menu.ts +1 -12
|
@@ -1,117 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.deleteColumns = void 0;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
10
|
var _prosemirrorState = require("prosemirror-state");
|
|
15
|
-
|
|
16
11
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
17
|
-
|
|
18
12
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
19
|
-
|
|
20
13
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
21
|
-
|
|
22
14
|
var _metadata = require("./metadata");
|
|
23
|
-
|
|
24
15
|
var _split = require("./split");
|
|
25
|
-
|
|
26
16
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
-
|
|
28
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
29
|
-
|
|
30
18
|
var deleteColumnsCustomStep = function deleteColumnsCustomStep(rect) {
|
|
31
19
|
return function (tr) {
|
|
32
20
|
var table = (0, _utils.findTable)(tr.selection);
|
|
33
|
-
|
|
34
21
|
if (!table) {
|
|
35
22
|
return tr;
|
|
36
|
-
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Need to split all the merge in the ranges (this is the current behaviour)
|
|
37
26
|
// Maybe is better to split only the last column?
|
|
38
27
|
// TODO: After talking with Roto about this behaviour, he likes when we dont split the columns, I am keeping this for consistency of the current implementation.
|
|
28
|
+
(0, _split.splitCellsInColumns)(tr, table.pos, rect.left, rect.right);
|
|
39
29
|
|
|
40
|
-
|
|
41
|
-
(0, _split.splitCellsInColumns)(tr, table.pos, rect.left, rect.right); // Delete the columns
|
|
42
|
-
|
|
30
|
+
// Delete the columns
|
|
43
31
|
var mapStart = tr.mapping.maps.length;
|
|
44
32
|
var originalDoc = tr.doc;
|
|
45
33
|
var deletedColumns = [];
|
|
46
|
-
|
|
47
34
|
for (var i = rect.left; i < rect.right; i++) {
|
|
48
35
|
var step = _steps.AddColumnStep.create(originalDoc, table.pos, i, true);
|
|
49
|
-
|
|
50
36
|
deletedColumns.push(i);
|
|
51
37
|
tr.step(step.map(tr.mapping.slice(mapStart)));
|
|
52
38
|
}
|
|
53
|
-
|
|
54
39
|
var tablePosResult = tr.mapping.mapResult(table.pos);
|
|
55
|
-
|
|
56
40
|
if (tablePosResult.deleted) {
|
|
57
41
|
var pos = Math.min(tablePosResult.pos, tr.doc.nodeSize - 1);
|
|
58
42
|
tr.setSelection(_prosemirrorState.Selection.near(tr.doc.resolve(pos)));
|
|
59
43
|
} else {
|
|
60
44
|
var newTable = tr.doc.nodeAt(tablePosResult.pos);
|
|
61
|
-
|
|
62
45
|
if (newTable) {
|
|
63
46
|
var cursorPos = getNextCursorPos(newTable, deletedColumns);
|
|
64
47
|
tr.setSelection(_prosemirrorState.Selection.near(tr.doc.resolve(table.pos + cursorPos)));
|
|
65
48
|
}
|
|
66
49
|
}
|
|
67
|
-
|
|
68
50
|
return tr;
|
|
69
51
|
};
|
|
70
52
|
};
|
|
71
|
-
|
|
72
53
|
var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
|
|
73
54
|
return function (tr) {
|
|
74
55
|
var table = (0, _utils.findTable)(tr.selection);
|
|
75
|
-
|
|
76
56
|
if (!table) {
|
|
77
57
|
return tr;
|
|
78
58
|
}
|
|
79
|
-
|
|
80
59
|
var columnsToDelete = [];
|
|
81
|
-
|
|
82
60
|
for (var i = rect.left; i < rect.right; i++) {
|
|
83
61
|
columnsToDelete.push(i);
|
|
84
62
|
}
|
|
85
|
-
|
|
86
63
|
if (!columnsToDelete.length) {
|
|
87
64
|
return tr;
|
|
88
65
|
}
|
|
89
|
-
|
|
90
66
|
var map = _tableMap.TableMap.get(table.node);
|
|
91
|
-
|
|
92
67
|
var rows = [];
|
|
93
68
|
var seen = {};
|
|
94
69
|
var deletedCells = {};
|
|
95
|
-
|
|
96
70
|
for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
97
71
|
var rowCells = [];
|
|
98
72
|
var row = table.node.child(rowIndex);
|
|
99
|
-
|
|
100
73
|
var _loop = function _loop(colIndex) {
|
|
101
74
|
var cellPos = map.map[rowIndex * map.width + colIndex];
|
|
102
75
|
var cell = table.node.nodeAt(cellPos);
|
|
103
|
-
|
|
104
76
|
if (!cell) {
|
|
105
77
|
return "continue";
|
|
106
78
|
}
|
|
107
|
-
|
|
108
79
|
var cellsInColumn = map.cellsInRect({
|
|
109
80
|
left: colIndex,
|
|
110
81
|
top: 0,
|
|
111
82
|
right: colIndex + 1,
|
|
112
83
|
bottom: map.height
|
|
113
84
|
});
|
|
114
|
-
|
|
115
85
|
if (columnsToDelete.indexOf(colIndex) === -1) {
|
|
116
86
|
// decrement colspans for col-spanning cells that overlap deleted columns
|
|
117
87
|
if (cellsInColumn.indexOf(cellPos) > -1 && !seen[cellPos]) {
|
|
@@ -121,12 +91,10 @@ var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
|
|
|
121
91
|
overlappingCols += 1;
|
|
122
92
|
}
|
|
123
93
|
});
|
|
124
|
-
|
|
125
94
|
if (overlappingCols > 0) {
|
|
126
95
|
var attrs = _objectSpread(_objectSpread({}, cell.attrs), {}, {
|
|
127
96
|
colspan: cell.attrs.colspan - overlappingCols
|
|
128
97
|
});
|
|
129
|
-
|
|
130
98
|
if (cell.attrs.colwidth) {
|
|
131
99
|
var minColIndex = Math.min.apply(Math, columnsToDelete);
|
|
132
100
|
var pos = minColIndex > 0 ? minColIndex - map.colCount(cellPos) : 0;
|
|
@@ -134,7 +102,6 @@ var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
|
|
|
134
102
|
colwidth.splice(pos, overlappingCols);
|
|
135
103
|
attrs.colwidth = colwidth;
|
|
136
104
|
}
|
|
137
|
-
|
|
138
105
|
var newCell = cell.type.createChecked(attrs, cell.content, cell.marks);
|
|
139
106
|
rowCells.push(newCell);
|
|
140
107
|
seen[cellPos] = true;
|
|
@@ -146,20 +113,16 @@ var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
|
|
|
146
113
|
colspan: 1,
|
|
147
114
|
rowspan: 1
|
|
148
115
|
});
|
|
149
|
-
|
|
150
116
|
if (cell.attrs.colwidth) {
|
|
151
117
|
var _pos = colIndex > 0 ? colIndex - map.colCount(cellPos) : 0;
|
|
152
|
-
|
|
153
118
|
_attrs.colwidth = cell.attrs.colwidth.slice().splice(_pos, 1);
|
|
154
119
|
}
|
|
155
|
-
|
|
156
120
|
var _newCell = cell.type.createChecked(_attrs, cell.type.schema.nodes.paragraph.createChecked(), cell.marks);
|
|
157
|
-
|
|
158
121
|
rowCells.push(_newCell);
|
|
159
122
|
return "continue";
|
|
160
|
-
}
|
|
161
|
-
|
|
123
|
+
}
|
|
162
124
|
|
|
125
|
+
// normal cells that we want to keep
|
|
163
126
|
if (!seen[cellPos]) {
|
|
164
127
|
seen[cellPos] = true;
|
|
165
128
|
rowCells.push(cell);
|
|
@@ -168,126 +131,98 @@ var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
|
|
|
168
131
|
deletedCells[cellPos] = true;
|
|
169
132
|
}
|
|
170
133
|
};
|
|
171
|
-
|
|
172
134
|
for (var colIndex = 0; colIndex < map.width; colIndex++) {
|
|
173
135
|
var _ret = _loop(colIndex);
|
|
174
|
-
|
|
175
136
|
if (_ret === "continue") continue;
|
|
176
137
|
}
|
|
177
|
-
|
|
178
138
|
if (rowCells.length) {
|
|
179
139
|
rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
|
|
180
140
|
}
|
|
181
141
|
}
|
|
182
|
-
|
|
183
142
|
if (!rows.length) {
|
|
184
143
|
return (0, _metadata.setMeta)({
|
|
185
144
|
type: 'DELETE_COLUMNS',
|
|
186
145
|
problem: 'EMPTY_TABLE'
|
|
187
146
|
})(tr);
|
|
188
147
|
}
|
|
189
|
-
|
|
190
148
|
var newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
|
|
191
149
|
var fixedTable = fixRowSpans(newTable);
|
|
192
|
-
|
|
193
150
|
if (fixedTable === null) {
|
|
194
151
|
return (0, _metadata.setMeta)({
|
|
195
152
|
type: 'DELETE_COLUMNS',
|
|
196
153
|
problem: 'FIX_ROWSPANS'
|
|
197
154
|
})(tr);
|
|
198
155
|
}
|
|
199
|
-
|
|
200
156
|
var cursorPos = getNextCursorPos(newTable, columnsToDelete);
|
|
201
157
|
return (0, _metadata.setMeta)({
|
|
202
158
|
type: 'DELETE_COLUMNS'
|
|
203
|
-
})(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
|
|
159
|
+
})(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
|
|
160
|
+
// move cursor to the left of the deleted columns if possible, otherwise - to the first column
|
|
204
161
|
.setSelection(_prosemirrorState.Selection.near(tr.doc.resolve(table.pos + cursorPos))));
|
|
205
162
|
};
|
|
206
163
|
};
|
|
207
|
-
|
|
208
164
|
function getNextCursorPos(table, deletedColumns) {
|
|
209
165
|
var minColumn = Math.min.apply(Math, (0, _toConsumableArray2.default)(deletedColumns));
|
|
210
166
|
var nextColumnWithCursor = minColumn > 0 ? minColumn - 1 : 0;
|
|
211
|
-
|
|
212
167
|
var map = _tableMap.TableMap.get(table);
|
|
213
|
-
|
|
214
168
|
return map.map[nextColumnWithCursor];
|
|
215
|
-
}
|
|
216
|
-
|
|
169
|
+
}
|
|
217
170
|
|
|
171
|
+
// returns an array of numbers, each number indicates the minimum rowSpan in each row
|
|
218
172
|
function getMinRowSpans(table) {
|
|
219
173
|
var minRowSpans = [];
|
|
220
|
-
|
|
221
174
|
for (var rowIndex = 0; rowIndex < table.childCount; rowIndex++) {
|
|
222
175
|
var rowSpans = [];
|
|
223
176
|
var row = table.child(rowIndex);
|
|
224
|
-
|
|
225
177
|
for (var colIndex = 0; colIndex < row.childCount; colIndex++) {
|
|
226
178
|
var cell = row.child(colIndex);
|
|
227
179
|
rowSpans.push(cell.attrs.rowspan);
|
|
228
180
|
}
|
|
229
|
-
|
|
230
181
|
minRowSpans[rowIndex] = Math.min.apply(Math, rowSpans);
|
|
231
182
|
}
|
|
232
|
-
|
|
233
183
|
return minRowSpans;
|
|
234
184
|
}
|
|
235
|
-
|
|
236
185
|
function fixRowSpans(table) {
|
|
237
186
|
var map = _tableMap.TableMap.get(table);
|
|
238
|
-
|
|
239
187
|
var minRowSpans = getMinRowSpans(table);
|
|
240
|
-
|
|
241
188
|
if (!minRowSpans.some(function (rowspan) {
|
|
242
189
|
return rowspan > 1;
|
|
243
190
|
})) {
|
|
244
191
|
return table;
|
|
245
192
|
}
|
|
246
|
-
|
|
247
193
|
var rows = [];
|
|
248
|
-
|
|
249
194
|
for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
250
195
|
var row = table.child(rowIndex);
|
|
251
|
-
|
|
252
196
|
if (minRowSpans[rowIndex] === 1) {
|
|
253
197
|
rows.push(row);
|
|
254
198
|
} else {
|
|
255
199
|
var rowCells = [];
|
|
256
|
-
|
|
257
200
|
for (var colIndex = 0; colIndex < row.childCount; colIndex++) {
|
|
258
201
|
var cell = row.child(colIndex);
|
|
259
202
|
var rowspan = cell.attrs.rowspan - minRowSpans[rowIndex] + 1;
|
|
260
|
-
|
|
261
203
|
if (rowspan < 1) {
|
|
262
204
|
return null;
|
|
263
205
|
}
|
|
264
|
-
|
|
265
206
|
var newCell = cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
|
|
266
207
|
rowspan: rowspan
|
|
267
208
|
}), cell.content, cell.marks);
|
|
268
209
|
rowCells.push(newCell);
|
|
269
210
|
}
|
|
270
|
-
|
|
271
211
|
rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
|
|
272
212
|
}
|
|
273
213
|
}
|
|
274
|
-
|
|
275
214
|
if (!rows.length) {
|
|
276
215
|
return null;
|
|
277
216
|
}
|
|
278
|
-
|
|
279
217
|
return table.type.createChecked(table.attrs, rows, table.marks);
|
|
280
218
|
}
|
|
281
|
-
|
|
282
219
|
var deleteColumns = function deleteColumns(rect) {
|
|
283
220
|
var allowAddColumnCustomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
284
221
|
return function (tr) {
|
|
285
222
|
if (allowAddColumnCustomStep) {
|
|
286
223
|
return deleteColumnsCustomStep(rect)(tr);
|
|
287
224
|
}
|
|
288
|
-
|
|
289
225
|
return deleteColumnsLegacy(rect)(tr);
|
|
290
226
|
};
|
|
291
227
|
};
|
|
292
|
-
|
|
293
228
|
exports.deleteColumns = deleteColumns;
|
|
@@ -1,48 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.deleteRows = void 0;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
10
|
var _prosemirrorState = require("prosemirror-state");
|
|
15
|
-
|
|
16
11
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
17
|
-
|
|
18
12
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
19
|
-
|
|
20
13
|
var _merge = require("./merge");
|
|
21
|
-
|
|
22
14
|
var _metadata = require("./metadata");
|
|
23
|
-
|
|
24
15
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
-
|
|
26
16
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
-
|
|
28
17
|
var deleteRows = function deleteRows(rect) {
|
|
29
18
|
var isHeaderRowRequired = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
30
19
|
return function (tr) {
|
|
31
20
|
var table = (0, _utils.findTable)(tr.selection);
|
|
32
|
-
|
|
33
21
|
if (!table) {
|
|
34
22
|
return tr;
|
|
35
23
|
}
|
|
36
|
-
|
|
37
24
|
var rowsToDelete = [];
|
|
38
|
-
|
|
39
25
|
var map = _tableMap.TableMap.get(table.node);
|
|
40
|
-
|
|
41
26
|
for (var i = rect.top; i < rect.bottom; i++) {
|
|
42
27
|
// skip header row if its required
|
|
43
28
|
if (isHeaderRowRequired) {
|
|
44
29
|
var cell = table.node.nodeAt(map.map[i * map.width]);
|
|
45
|
-
|
|
46
30
|
if (cell && cell.type !== cell.type.schema.nodes.tableHeader) {
|
|
47
31
|
rowsToDelete.push(i);
|
|
48
32
|
}
|
|
@@ -50,34 +34,27 @@ var deleteRows = function deleteRows(rect) {
|
|
|
50
34
|
rowsToDelete.push(i);
|
|
51
35
|
}
|
|
52
36
|
}
|
|
53
|
-
|
|
54
37
|
if (!rowsToDelete.length) {
|
|
55
38
|
return tr;
|
|
56
39
|
}
|
|
57
|
-
|
|
58
40
|
var rows = [];
|
|
59
41
|
var seen = {};
|
|
60
42
|
var deletedCells = {};
|
|
61
|
-
|
|
62
43
|
var _loop = function _loop(rowIndex) {
|
|
63
44
|
var rowCells = [];
|
|
64
45
|
var row = table.node.child(rowIndex);
|
|
65
|
-
|
|
66
46
|
var _loop2 = function _loop2(colIndex) {
|
|
67
47
|
var cellPos = map.map[rowIndex * map.width + colIndex];
|
|
68
48
|
var cell = table.node.nodeAt(cellPos);
|
|
69
|
-
|
|
70
49
|
if (!cell) {
|
|
71
50
|
return "continue";
|
|
72
51
|
}
|
|
73
|
-
|
|
74
52
|
var cellsInRow = map.cellsInRect({
|
|
75
53
|
left: 0,
|
|
76
54
|
top: rowIndex,
|
|
77
55
|
right: map.width,
|
|
78
56
|
bottom: rowIndex + 1
|
|
79
57
|
});
|
|
80
|
-
|
|
81
58
|
if (rowsToDelete.indexOf(rowIndex) === -1 && !seen[cellPos]) {
|
|
82
59
|
// decrement rowspans for row-spanning cells that overlap deleted rows
|
|
83
60
|
if (cellsInRow.indexOf(cellPos) > -1) {
|
|
@@ -87,7 +64,6 @@ var deleteRows = function deleteRows(rect) {
|
|
|
87
64
|
overlappingRows += 1;
|
|
88
65
|
}
|
|
89
66
|
});
|
|
90
|
-
|
|
91
67
|
if (overlappingRows > 0) {
|
|
92
68
|
var newCell = cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
|
|
93
69
|
rowspan: cell.attrs.rowspan - overlappingRows
|
|
@@ -102,19 +78,16 @@ var deleteRows = function deleteRows(rect) {
|
|
|
102
78
|
colspan: 1,
|
|
103
79
|
rowspan: 1
|
|
104
80
|
});
|
|
105
|
-
|
|
106
81
|
if (cell.attrs.colwidth) {
|
|
107
82
|
var pos = colIndex > 0 ? colIndex - map.colCount(cellPos) : 0;
|
|
108
83
|
attrs.colwidth = cell.attrs.colwidth.slice().splice(pos, 1);
|
|
109
84
|
}
|
|
110
|
-
|
|
111
85
|
var _newCell = cell.type.createChecked(attrs, cell.type.schema.nodes.paragraph.createChecked(), cell.marks);
|
|
112
|
-
|
|
113
86
|
rowCells.push(_newCell);
|
|
114
87
|
return "continue";
|
|
115
|
-
}
|
|
116
|
-
|
|
88
|
+
}
|
|
117
89
|
|
|
90
|
+
// normal cells that we want to keep
|
|
118
91
|
if (!seen[cellPos]) {
|
|
119
92
|
seen[cellPos] = true;
|
|
120
93
|
rowCells.push(cell);
|
|
@@ -123,54 +96,43 @@ var deleteRows = function deleteRows(rect) {
|
|
|
123
96
|
deletedCells[cellPos] = true;
|
|
124
97
|
}
|
|
125
98
|
};
|
|
126
|
-
|
|
127
99
|
for (var colIndex = 0; colIndex < map.width; colIndex++) {
|
|
128
100
|
var _ret = _loop2(colIndex);
|
|
129
|
-
|
|
130
101
|
if (_ret === "continue") continue;
|
|
131
102
|
}
|
|
132
|
-
|
|
133
103
|
if (rowCells.length) {
|
|
134
104
|
rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
|
|
135
105
|
}
|
|
136
106
|
};
|
|
137
|
-
|
|
138
107
|
for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
139
108
|
_loop(rowIndex);
|
|
140
109
|
}
|
|
141
|
-
|
|
142
110
|
if (!rows.length) {
|
|
143
111
|
return (0, _metadata.setMeta)({
|
|
144
112
|
type: 'DELETE_ROWS',
|
|
145
113
|
problem: 'EMPTY_TABLE'
|
|
146
114
|
})(tr);
|
|
147
115
|
}
|
|
148
|
-
|
|
149
116
|
var newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
|
|
150
117
|
var fixedTable = (0, _merge.removeEmptyColumns)(newTable);
|
|
151
|
-
|
|
152
118
|
if (fixedTable === null) {
|
|
153
119
|
return (0, _metadata.setMeta)({
|
|
154
120
|
type: 'DELETE_ROWS',
|
|
155
121
|
problem: 'REMOVE_EMPTY_COLUMNS'
|
|
156
122
|
})(tr);
|
|
157
123
|
}
|
|
158
|
-
|
|
159
124
|
var cursorPos = getNextCursorPos(newTable, rowsToDelete);
|
|
160
125
|
return (0, _metadata.setMeta)({
|
|
161
126
|
type: 'DELETE_ROWS'
|
|
162
|
-
})(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
|
|
127
|
+
})(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
|
|
128
|
+
// move cursor before the deleted rows if possible, otherwise - to the first row
|
|
163
129
|
.setSelection(_prosemirrorState.Selection.near(tr.doc.resolve(table.pos + cursorPos))));
|
|
164
130
|
};
|
|
165
131
|
};
|
|
166
|
-
|
|
167
132
|
exports.deleteRows = deleteRows;
|
|
168
|
-
|
|
169
133
|
function getNextCursorPos(table, deletedRows) {
|
|
170
134
|
var minRow = Math.min.apply(Math, (0, _toConsumableArray2.default)(deletedRows));
|
|
171
135
|
var nextRowWithCursor = minRow > 0 ? minRow - 1 : 0;
|
|
172
|
-
|
|
173
136
|
var map = _tableMap.TableMap.get(table);
|
|
174
|
-
|
|
175
137
|
return map.map[nextRowWithCursor * map.width];
|
|
176
138
|
}
|