@atlaskit/editor-plugin-table 1.1.1 → 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 +6 -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
|
@@ -4,113 +4,80 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.normalizeSelection = exports.isSelectionUpdated = exports.getSelectedRowIndexes = exports.getSelectedColumnIndexes = void 0;
|
|
7
|
-
|
|
8
7
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
9
|
-
|
|
10
8
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
11
|
-
|
|
12
9
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
13
|
-
|
|
14
10
|
var isSelectionUpdated = function isSelectionUpdated(oldSelection, newSelection) {
|
|
15
11
|
return !!(!newSelection && oldSelection) || (0, _utils.isSelectionType)(oldSelection, 'cell') !== (0, _utils.isSelectionType)(newSelection, 'cell') || (0, _utils.isSelectionType)(oldSelection, 'cell') && (0, _utils.isSelectionType)(newSelection, 'cell') && oldSelection.ranges !== newSelection.ranges;
|
|
16
12
|
};
|
|
17
|
-
|
|
18
13
|
exports.isSelectionUpdated = isSelectionUpdated;
|
|
19
|
-
|
|
20
14
|
var isRectangularCellSelection = function isRectangularCellSelection(selection, rect) {
|
|
21
15
|
var table = (0, _utils.findTable)(selection);
|
|
22
|
-
|
|
23
16
|
if (!table) {
|
|
24
17
|
return true;
|
|
25
18
|
}
|
|
26
|
-
|
|
27
19
|
var _TableMap$get = _tableMap.TableMap.get(table.node),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
width = _TableMap$get.width,
|
|
21
|
+
height = _TableMap$get.height,
|
|
22
|
+
map = _TableMap$get.map;
|
|
32
23
|
var indexTop = rect.top * width + rect.left;
|
|
33
24
|
var indexLeft = indexTop;
|
|
34
25
|
var indexBottom = (rect.bottom - 1) * width + rect.left;
|
|
35
26
|
var indexRight = indexTop + (rect.right - rect.left - 1);
|
|
36
|
-
|
|
37
27
|
for (var i = rect.top; i < rect.bottom; i++) {
|
|
38
28
|
if (rect.left > 0 && map[indexLeft] === map[indexLeft - 1] || rect.right < width && map[indexRight] === map[indexRight + 1]) {
|
|
39
29
|
return false;
|
|
40
30
|
}
|
|
41
|
-
|
|
42
31
|
indexLeft += width;
|
|
43
32
|
indexRight += width;
|
|
44
33
|
}
|
|
45
|
-
|
|
46
34
|
for (var _i = rect.left; _i < rect.right; _i++) {
|
|
47
35
|
if (rect.top > 0 && map[indexTop] === map[indexTop - width] || rect.bottom < height && map[indexBottom] === map[indexBottom + width]) {
|
|
48
36
|
return false;
|
|
49
37
|
}
|
|
50
|
-
|
|
51
38
|
indexTop++;
|
|
52
39
|
indexBottom++;
|
|
53
40
|
}
|
|
54
|
-
|
|
55
41
|
return true;
|
|
56
42
|
};
|
|
57
|
-
|
|
58
43
|
var normalizeSelection = function normalizeSelection(tr) {
|
|
59
44
|
var selection = tr.selection;
|
|
60
45
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
61
|
-
|
|
62
46
|
if (!rect || !(selection instanceof _cellSelection.CellSelection) || isRectangularCellSelection(selection, rect)) {
|
|
63
47
|
return tr;
|
|
64
48
|
}
|
|
65
|
-
|
|
66
49
|
if (selection.isColSelection()) {
|
|
67
50
|
var _getSelectionRangeInC, _getSelectionRangeInC2;
|
|
68
|
-
|
|
69
51
|
var $anchor = (_getSelectionRangeInC = (0, _utils.getSelectionRangeInColumn)(rect.left)(tr)) === null || _getSelectionRangeInC === void 0 ? void 0 : _getSelectionRangeInC.$anchor;
|
|
70
52
|
var $head = (_getSelectionRangeInC2 = (0, _utils.getSelectionRangeInColumn)(rect.right - 1)(tr)) === null || _getSelectionRangeInC2 === void 0 ? void 0 : _getSelectionRangeInC2.$head;
|
|
71
|
-
|
|
72
53
|
if ($anchor && $head) {
|
|
73
54
|
return tr.setSelection(new _cellSelection.CellSelection($anchor, $head));
|
|
74
55
|
}
|
|
75
56
|
}
|
|
76
|
-
|
|
77
57
|
if (selection.isRowSelection()) {
|
|
78
58
|
var _getSelectionRangeInR, _getSelectionRangeInR2;
|
|
79
|
-
|
|
80
59
|
var _$anchor = (_getSelectionRangeInR = (0, _utils.getSelectionRangeInRow)(rect.top)(tr)) === null || _getSelectionRangeInR === void 0 ? void 0 : _getSelectionRangeInR.$anchor;
|
|
81
|
-
|
|
82
60
|
var _$head = (_getSelectionRangeInR2 = (0, _utils.getSelectionRangeInRow)(rect.bottom - 1)(tr)) === null || _getSelectionRangeInR2 === void 0 ? void 0 : _getSelectionRangeInR2.$head;
|
|
83
|
-
|
|
84
61
|
if (_$anchor && _$head) {
|
|
85
62
|
return tr.setSelection(new _cellSelection.CellSelection(_$anchor, _$head));
|
|
86
63
|
}
|
|
87
64
|
}
|
|
88
|
-
|
|
89
65
|
return tr;
|
|
90
66
|
};
|
|
91
|
-
|
|
92
67
|
exports.normalizeSelection = normalizeSelection;
|
|
93
|
-
|
|
94
68
|
var getSelectedColumnIndexes = function getSelectedColumnIndexes(selectionRect) {
|
|
95
69
|
var columnIndexes = [];
|
|
96
|
-
|
|
97
70
|
for (var i = selectionRect.left; i < selectionRect.right; i++) {
|
|
98
71
|
columnIndexes.push(i);
|
|
99
72
|
}
|
|
100
|
-
|
|
101
73
|
return columnIndexes;
|
|
102
74
|
};
|
|
103
|
-
|
|
104
75
|
exports.getSelectedColumnIndexes = getSelectedColumnIndexes;
|
|
105
|
-
|
|
106
76
|
var getSelectedRowIndexes = function getSelectedRowIndexes(selectionRect) {
|
|
107
77
|
var rowIndexes = [];
|
|
108
|
-
|
|
109
78
|
for (var i = selectionRect.top; i < selectionRect.bottom; i++) {
|
|
110
79
|
rowIndexes.push(i);
|
|
111
80
|
}
|
|
112
|
-
|
|
113
81
|
return rowIndexes;
|
|
114
82
|
};
|
|
115
|
-
|
|
116
83
|
exports.getSelectedRowIndexes = getSelectedRowIndexes;
|
|
@@ -1,27 +1,19 @@
|
|
|
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.getMergedCellsPositions = exports.colsToRect = void 0;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
13
|
-
|
|
14
10
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
15
|
-
|
|
16
11
|
var getMergedCellsPositions = function getMergedCellsPositions(tr) {
|
|
17
12
|
var table = (0, _utils.findTable)(tr.selection);
|
|
18
|
-
|
|
19
13
|
if (!table) {
|
|
20
14
|
return [];
|
|
21
15
|
}
|
|
22
|
-
|
|
23
16
|
var map = _tableMap.TableMap.get(table.node);
|
|
24
|
-
|
|
25
17
|
var cellPositions = new Set();
|
|
26
18
|
var mergedCells = [];
|
|
27
19
|
map.map.forEach(function (value) {
|
|
@@ -33,9 +25,7 @@ var getMergedCellsPositions = function getMergedCellsPositions(tr) {
|
|
|
33
25
|
});
|
|
34
26
|
return mergedCells;
|
|
35
27
|
};
|
|
36
|
-
|
|
37
28
|
exports.getMergedCellsPositions = getMergedCellsPositions;
|
|
38
|
-
|
|
39
29
|
var colsToRect = function colsToRect(cols, noOfRows) {
|
|
40
30
|
return {
|
|
41
31
|
left: Math.min.apply(Math, (0, _toConsumableArray2.default)(cols)),
|
|
@@ -44,5 +34,4 @@ var colsToRect = function colsToRect(cols, noOfRows) {
|
|
|
44
34
|
bottom: noOfRows
|
|
45
35
|
};
|
|
46
36
|
};
|
|
47
|
-
|
|
48
37
|
exports.colsToRect = colsToRect;
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.updatePluginStateDecorations = void 0;
|
|
7
|
-
|
|
8
7
|
var _plugin = require("../pm-plugins/decorations/plugin");
|
|
9
|
-
|
|
10
8
|
var _decoration = require("./decoration");
|
|
11
|
-
|
|
12
9
|
var updatePluginStateDecorations = function updatePluginStateDecorations(state, decorations, key) {
|
|
13
10
|
return (0, _decoration.updateDecorations)(state.doc, (0, _plugin.getDecorations)(state), decorations, key);
|
|
14
11
|
};
|
|
15
|
-
|
|
16
12
|
exports.updatePluginStateDecorations = updatePluginStateDecorations;
|
|
@@ -1,13 +1,10 @@
|
|
|
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.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _table = _interopRequireDefault(require("./table"));
|
|
11
|
-
|
|
12
9
|
var _default = _table.default;
|
|
13
10
|
exports.default = _default;
|
package/dist/cjs/version.json
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { Selection } from 'prosemirror-state';
|
|
3
3
|
import { findCellClosestToPos, emptyCell, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
4
4
|
// #endregion
|
|
5
|
+
|
|
5
6
|
// #region Commands
|
|
6
7
|
export const clearMultipleCells = targetCellPosition => (state, dispatch) => {
|
|
7
8
|
let cursorPos;
|
|
8
9
|
let {
|
|
9
10
|
tr
|
|
10
11
|
} = state;
|
|
11
|
-
|
|
12
12
|
if (isSelectionType(tr.selection, 'cell')) {
|
|
13
13
|
const selection = tr.selection;
|
|
14
14
|
selection.forEachCell((_node, pos) => {
|
|
@@ -21,28 +21,23 @@ export const clearMultipleCells = targetCellPosition => (state, dispatch) => {
|
|
|
21
21
|
tr = emptyCell(cell, state.schema)(tr);
|
|
22
22
|
cursorPos = cell.pos;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
24
|
if (tr.docChanged && cursorPos) {
|
|
26
25
|
const $pos = tr.doc.resolve(tr.mapping.map(cursorPos));
|
|
27
26
|
const textSelection = Selection.findFrom($pos, 1, true);
|
|
28
|
-
|
|
29
27
|
if (textSelection) {
|
|
30
28
|
tr.setSelection(textSelection);
|
|
31
29
|
}
|
|
32
|
-
|
|
33
30
|
if (dispatch) {
|
|
34
31
|
dispatch(tr);
|
|
35
32
|
}
|
|
36
|
-
|
|
37
33
|
return true;
|
|
38
34
|
}
|
|
39
|
-
|
|
40
35
|
return false;
|
|
41
36
|
};
|
|
42
37
|
export const clearSelection = (state, dispatch) => {
|
|
43
38
|
if (dispatch) {
|
|
44
39
|
dispatch(state.tr.setSelection(Selection.near(state.selection.$from)).setMeta('addToHistory', false));
|
|
45
40
|
}
|
|
46
|
-
|
|
47
41
|
return true;
|
|
48
|
-
};
|
|
42
|
+
};
|
|
43
|
+
// #endregion
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { collapseSelectedTable } from '../utils/collapse';
|
|
2
2
|
export const wrapTableInExpand = (state, dispatch) => {
|
|
3
3
|
const collapseTr = collapseSelectedTable(state.tr);
|
|
4
|
-
|
|
5
4
|
if (!collapseTr) {
|
|
6
5
|
return false;
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
if (dispatch) {
|
|
10
8
|
dispatch(collapseTr);
|
|
11
9
|
}
|
|
12
|
-
|
|
13
10
|
return true;
|
|
14
11
|
};
|
|
@@ -8,11 +8,9 @@ const TAB_FORWARD_DIRECTION = 1;
|
|
|
8
8
|
const TAB_BACKWARD_DIRECTION = -1;
|
|
9
9
|
export const goToNextCell = editorAnalyticsAPI => direction => (state, dispatch) => {
|
|
10
10
|
const table = findTable(state.selection);
|
|
11
|
-
|
|
12
11
|
if (!table) {
|
|
13
12
|
return false;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
const map = TableMap.get(table.node);
|
|
17
15
|
const {
|
|
18
16
|
tableCell,
|
|
@@ -20,17 +18,18 @@ export const goToNextCell = editorAnalyticsAPI => direction => (state, dispatch)
|
|
|
20
18
|
} = state.schema.nodes;
|
|
21
19
|
const cell = findParentNodeOfType([tableCell, tableHeader])(state.selection);
|
|
22
20
|
const firstCellPos = map.positionAt(0, 0, table.node) + table.start;
|
|
23
|
-
const lastCellPos = map.positionAt(map.height - 1, map.width - 1, table.node) + table.start;
|
|
21
|
+
const lastCellPos = map.positionAt(map.height - 1, map.width - 1, table.node) + table.start;
|
|
24
22
|
|
|
23
|
+
// when tabbing backwards at first cell (top left), insert row at the start of table
|
|
25
24
|
if (firstCellPos === cell.pos && direction === TAB_BACKWARD_DIRECTION) {
|
|
26
25
|
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, {
|
|
27
26
|
index: 0,
|
|
28
27
|
moveCursorToInsertedRow: true
|
|
29
28
|
})(state, dispatch);
|
|
30
29
|
return true;
|
|
31
|
-
}
|
|
32
|
-
|
|
30
|
+
}
|
|
33
31
|
|
|
32
|
+
// when tabbing forwards at last cell (bottom right), insert row at the end of table
|
|
34
33
|
if (lastCellPos === cell.pos && direction === TAB_FORWARD_DIRECTION) {
|
|
35
34
|
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, {
|
|
36
35
|
index: map.height,
|
|
@@ -38,10 +37,8 @@ export const goToNextCell = editorAnalyticsAPI => direction => (state, dispatch)
|
|
|
38
37
|
})(state, dispatch);
|
|
39
38
|
return true;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
40
|
if (dispatch) {
|
|
43
41
|
return baseGotoNextCell(direction)(state, dispatch);
|
|
44
42
|
}
|
|
45
|
-
|
|
46
43
|
return true;
|
|
47
44
|
};
|
|
@@ -3,26 +3,23 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
3
3
|
import { findTable, getCellsInColumn, getCellsInRow } from '@atlaskit/editor-tables/utils';
|
|
4
4
|
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
5
5
|
import { TableDecorations } from '../types';
|
|
6
|
-
import { createCellHoverDecoration, createColumnLineResize, createControlsHoverDecoration, getMergedCellsPositions, updatePluginStateDecorations } from '../utils';
|
|
6
|
+
import { createCellHoverDecoration, createColumnLineResize, createControlsHoverDecoration, getMergedCellsPositions, updatePluginStateDecorations } from '../utils';
|
|
7
|
+
// #endregion
|
|
8
|
+
|
|
7
9
|
// #region Utils
|
|
10
|
+
const makeArray = n => Array.from(Array(n).keys());
|
|
11
|
+
// #endregion
|
|
8
12
|
|
|
9
|
-
const makeArray = n => Array.from(Array(n).keys()); // #endregion
|
|
10
13
|
// #region Commands
|
|
11
|
-
|
|
12
|
-
|
|
13
14
|
export const hoverMergedCells = () => createCommand(state => {
|
|
14
15
|
const mergedCellsPositions = getMergedCellsPositions(state.tr);
|
|
15
|
-
|
|
16
16
|
if (!mergedCellsPositions.length) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
19
|
const table = findTable(state.tr.selection);
|
|
21
|
-
|
|
22
20
|
if (!table) {
|
|
23
21
|
return false;
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
const mergedCells = mergedCellsPositions.map(pos => ({
|
|
27
24
|
pos: pos + table.start,
|
|
28
25
|
start: pos + table.start + 1,
|
|
@@ -38,11 +35,9 @@ export const hoverMergedCells = () => createCommand(state => {
|
|
|
38
35
|
}, tr => tr.setMeta('addToHistory', false));
|
|
39
36
|
export const hoverColumns = (hoveredColumns, isInDanger) => createCommand(state => {
|
|
40
37
|
const cells = getCellsInColumn(hoveredColumns)(state.tr.selection);
|
|
41
|
-
|
|
42
38
|
if (!cells) {
|
|
43
39
|
return false;
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
const decorations = createControlsHoverDecoration(cells, 'column', state.tr, isInDanger);
|
|
47
42
|
return {
|
|
48
43
|
type: 'HOVER_COLUMNS',
|
|
@@ -55,11 +50,9 @@ export const hoverColumns = (hoveredColumns, isInDanger) => createCommand(state
|
|
|
55
50
|
}, tr => tr.setMeta('addToHistory', false));
|
|
56
51
|
export const hoverRows = (hoveredRows, isInDanger) => createCommand(state => {
|
|
57
52
|
const cells = getCellsInRow(hoveredRows)(state.selection);
|
|
58
|
-
|
|
59
53
|
if (!cells) {
|
|
60
54
|
return false;
|
|
61
55
|
}
|
|
62
|
-
|
|
63
56
|
const decorations = createControlsHoverDecoration(cells, 'row', state.tr, isInDanger);
|
|
64
57
|
return {
|
|
65
58
|
type: 'HOVER_ROWS',
|
|
@@ -72,20 +65,16 @@ export const hoverRows = (hoveredRows, isInDanger) => createCommand(state => {
|
|
|
72
65
|
}, tr => tr.setMeta('addToHistory', false));
|
|
73
66
|
export const hoverTable = (isInDanger, isSelected) => createCommand(state => {
|
|
74
67
|
const table = findTable(state.selection);
|
|
75
|
-
|
|
76
68
|
if (!table) {
|
|
77
69
|
return false;
|
|
78
70
|
}
|
|
79
|
-
|
|
80
71
|
const map = TableMap.get(table.node);
|
|
81
72
|
const hoveredColumns = makeArray(map.width);
|
|
82
73
|
const hoveredRows = makeArray(map.height);
|
|
83
74
|
const cells = getCellsInRow(hoveredRows)(state.selection);
|
|
84
|
-
|
|
85
75
|
if (!cells) {
|
|
86
76
|
return false;
|
|
87
77
|
}
|
|
88
|
-
|
|
89
78
|
const decorations = createControlsHoverDecoration(cells, 'table', state.tr, isInDanger, isSelected);
|
|
90
79
|
return {
|
|
91
80
|
type: 'HOVER_TABLE',
|
|
@@ -115,4 +104,5 @@ export const hideResizeHandleLine = () => createCommand(state => ({
|
|
|
115
104
|
data: {
|
|
116
105
|
decorationSet: updatePluginStateDecorations(state, [], TableDecorations.COLUMN_RESIZING_HANDLE_LINE)
|
|
117
106
|
}
|
|
118
|
-
}));
|
|
107
|
+
}));
|
|
108
|
+
// #endregion
|
|
@@ -7,114 +7,97 @@ import { AddColumnStep } from '@atlaskit/adf-schema/steps';
|
|
|
7
7
|
import { checkIfHeaderRowEnabled, copyPreviousRow } from '../utils';
|
|
8
8
|
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
9
9
|
import { rescaleColumns } from '../transforms/column-width';
|
|
10
|
-
|
|
11
10
|
// #endregion
|
|
11
|
+
|
|
12
12
|
function addColumnAtCustomStep(column) {
|
|
13
13
|
return tr => {
|
|
14
14
|
const table = findTable(tr.selection);
|
|
15
|
-
|
|
16
15
|
if (table) {
|
|
17
16
|
return tr.step(AddColumnStep.create(tr.doc, table.pos, column));
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
return tr;
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
export function addColumnAt(getEditorContainerWidth) {
|
|
25
22
|
return (column, allowAddColumnCustomStep = false, view) => {
|
|
26
23
|
return tr => {
|
|
27
24
|
let updatedTr = tr;
|
|
28
|
-
|
|
29
25
|
if (allowAddColumnCustomStep) {
|
|
30
26
|
updatedTr = addColumnAtCustomStep(column)(updatedTr);
|
|
31
27
|
} else {
|
|
32
28
|
updatedTr = addColumnAtPMUtils(column)(updatedTr);
|
|
33
29
|
}
|
|
34
|
-
|
|
35
30
|
const table = findTable(updatedTr.selection);
|
|
36
|
-
|
|
37
31
|
if (table) {
|
|
38
32
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
39
33
|
updatedTr = rescaleColumns(getEditorContainerWidth)(table, view)(updatedTr);
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
return updatedTr;
|
|
43
36
|
};
|
|
44
37
|
};
|
|
45
|
-
}
|
|
46
|
-
// Command to add a column before the column with the selection.
|
|
38
|
+
}
|
|
47
39
|
|
|
40
|
+
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
41
|
+
// Command to add a column before the column with the selection.
|
|
48
42
|
export const addColumnBefore = getEditorContainerWidth => (state, dispatch, view) => {
|
|
49
43
|
const table = findTable(state.selection);
|
|
50
|
-
|
|
51
44
|
if (!table) {
|
|
52
45
|
return false;
|
|
53
46
|
}
|
|
54
|
-
|
|
55
47
|
if (dispatch) {
|
|
56
48
|
let rect = selectedRect(state);
|
|
57
49
|
dispatch(addColumnAt(getEditorContainerWidth)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
58
50
|
}
|
|
59
|
-
|
|
60
51
|
return true;
|
|
61
|
-
};
|
|
62
|
-
// Command to add a column after the column with the selection.
|
|
52
|
+
};
|
|
63
53
|
|
|
54
|
+
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
55
|
+
// Command to add a column after the column with the selection.
|
|
64
56
|
export const addColumnAfter = getEditorContainerWidth => (state, dispatch, view) => {
|
|
65
57
|
const table = findTable(state.selection);
|
|
66
|
-
|
|
67
58
|
if (!table) {
|
|
68
59
|
return false;
|
|
69
60
|
}
|
|
70
|
-
|
|
71
61
|
if (dispatch) {
|
|
72
62
|
let rect = selectedRect(state);
|
|
73
63
|
dispatch(addColumnAt(getEditorContainerWidth)(rect.right, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
74
64
|
}
|
|
75
|
-
|
|
76
65
|
return true;
|
|
77
|
-
};
|
|
66
|
+
};
|
|
78
67
|
|
|
68
|
+
// #region Commands
|
|
79
69
|
export const insertColumn = getEditorContainerWidth => column => (state, dispatch, view) => {
|
|
80
70
|
let tr = addColumnAt(getEditorContainerWidth)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
81
71
|
const table = findTable(tr.selection);
|
|
82
|
-
|
|
83
72
|
if (!table) {
|
|
84
73
|
return false;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
}
|
|
75
|
+
// move the cursor to the newly created column
|
|
88
76
|
const pos = TableMap.get(table.node).positionAt(0, column, table.node);
|
|
89
|
-
|
|
90
77
|
if (dispatch) {
|
|
91
78
|
dispatch(tr.setSelection(Selection.near(tr.doc.resolve(table.start + pos))));
|
|
92
79
|
}
|
|
93
|
-
|
|
94
80
|
return true;
|
|
95
81
|
};
|
|
96
82
|
export const insertRow = (row, moveCursorToTheNewRow) => (state, dispatch) => {
|
|
97
83
|
// Don't clone the header row
|
|
98
84
|
const headerRowEnabled = checkIfHeaderRowEnabled(state.selection);
|
|
99
|
-
const clonePreviousRow = headerRowEnabled && row > 1 || !headerRowEnabled && row > 0;
|
|
100
|
-
// we should not add row on the position zero
|
|
85
|
+
const clonePreviousRow = headerRowEnabled && row > 1 || !headerRowEnabled && row > 0;
|
|
101
86
|
|
|
87
|
+
// When the table have header row
|
|
88
|
+
// we should not add row on the position zero
|
|
102
89
|
if (row === 0 && headerRowEnabled) {
|
|
103
90
|
return false;
|
|
104
91
|
}
|
|
105
|
-
|
|
106
92
|
const tr = clonePreviousRow ? copyPreviousRow(state.schema)(row)(state.tr) : addRowAt(row)(state.tr);
|
|
107
93
|
const table = findTable(tr.selection);
|
|
108
|
-
|
|
109
94
|
if (!table) {
|
|
110
95
|
return false;
|
|
111
96
|
}
|
|
112
|
-
|
|
113
97
|
if (dispatch) {
|
|
114
98
|
const {
|
|
115
99
|
selection
|
|
116
100
|
} = state;
|
|
117
|
-
|
|
118
101
|
if (moveCursorToTheNewRow) {
|
|
119
102
|
// move the cursor to the newly created row
|
|
120
103
|
const pos = TableMap.get(table.node).positionAt(row, 0, table.node);
|
|
@@ -122,20 +105,17 @@ export const insertRow = (row, moveCursorToTheNewRow) => (state, dispatch) => {
|
|
|
122
105
|
} else {
|
|
123
106
|
tr.setSelection(selection.map(tr.doc, tr.mapping));
|
|
124
107
|
}
|
|
125
|
-
|
|
126
108
|
dispatch(tr);
|
|
127
109
|
}
|
|
128
|
-
|
|
129
110
|
return true;
|
|
130
111
|
};
|
|
131
112
|
export const createTable = () => (state, dispatch) => {
|
|
132
113
|
const table = createTableNode({
|
|
133
114
|
schema: state.schema
|
|
134
115
|
});
|
|
135
|
-
|
|
136
116
|
if (dispatch) {
|
|
137
117
|
dispatch(safeInsert(table)(state.tr).scrollIntoView());
|
|
138
118
|
}
|
|
139
|
-
|
|
140
119
|
return true;
|
|
141
|
-
};
|
|
120
|
+
};
|
|
121
|
+
// #endregion
|