@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
|
@@ -4,17 +4,14 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
4
4
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import { RelativeSelectionPos, GapCursorSelection, Side, isSelectionAtStartOfNode, isSelectionAtEndOfNode } from '@atlaskit/editor-common/selection';
|
|
6
6
|
export var TableSelectionDirection;
|
|
7
|
-
|
|
8
7
|
(function (TableSelectionDirection) {
|
|
9
8
|
TableSelectionDirection["TopToBottom"] = "TopToBottom";
|
|
10
9
|
TableSelectionDirection["BottomToTop"] = "BottomToTop";
|
|
11
10
|
})(TableSelectionDirection || (TableSelectionDirection = {}));
|
|
12
|
-
|
|
13
11
|
export var arrowLeftFromTable = function arrowLeftFromTable(editorSelectionAPI) {
|
|
14
12
|
return function () {
|
|
15
13
|
return function (state, dispatch) {
|
|
16
14
|
var selection = state.selection;
|
|
17
|
-
|
|
18
15
|
if (selection instanceof CellSelection) {
|
|
19
16
|
return arrowLeftFromCellSelection(editorSelectionAPI)(selection)(state, dispatch);
|
|
20
17
|
} else if (selection instanceof GapCursorSelection) {
|
|
@@ -22,7 +19,6 @@ export var arrowLeftFromTable = function arrowLeftFromTable(editorSelectionAPI)
|
|
|
22
19
|
} else if (selection instanceof TextSelection) {
|
|
23
20
|
return arrowLeftFromText(editorSelectionAPI)(selection)(state, dispatch);
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
return false;
|
|
27
23
|
};
|
|
28
24
|
};
|
|
@@ -31,7 +27,6 @@ export var arrowRightFromTable = function arrowRightFromTable(editorSelectionAPI
|
|
|
31
27
|
return function () {
|
|
32
28
|
return function (state, dispatch) {
|
|
33
29
|
var selection = state.selection;
|
|
34
|
-
|
|
35
30
|
if (selection instanceof CellSelection) {
|
|
36
31
|
return arrowRightFromCellSelection(editorSelectionAPI)(selection)(state, dispatch);
|
|
37
32
|
} else if (selection instanceof GapCursorSelection) {
|
|
@@ -39,19 +34,16 @@ export var arrowRightFromTable = function arrowRightFromTable(editorSelectionAPI
|
|
|
39
34
|
} else if (selection instanceof TextSelection) {
|
|
40
35
|
return arrowRightFromText(editorSelectionAPI)(selection)(state, dispatch);
|
|
41
36
|
}
|
|
42
|
-
|
|
43
37
|
return false;
|
|
44
38
|
};
|
|
45
39
|
};
|
|
46
40
|
};
|
|
47
|
-
|
|
48
41
|
var arrowLeftFromCellSelection = function arrowLeftFromCellSelection(editorSelectionAPI) {
|
|
49
42
|
return function (selection) {
|
|
50
43
|
return function (state, dispatch) {
|
|
51
44
|
if (isTableSelected(state.selection) && editorSelectionAPI) {
|
|
52
45
|
var _editorSelectionAPI$g = editorSelectionAPI.getSelectionPluginState(state),
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
selectionRelativeToNode = _editorSelectionAPI$g.selectionRelativeToNode;
|
|
55
47
|
if (selectionRelativeToNode === RelativeSelectionPos.Start) {
|
|
56
48
|
// we have full table cell selection and want to set gap cursor selection before table
|
|
57
49
|
return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
|
|
@@ -63,19 +55,16 @@ var arrowLeftFromCellSelection = function arrowLeftFromCellSelection(editorSelec
|
|
|
63
55
|
return setSelectionAtStartOfFirstCell(editorSelectionAPI)(selection, RelativeSelectionPos.Before)(state, dispatch);
|
|
64
56
|
}
|
|
65
57
|
}
|
|
66
|
-
|
|
67
58
|
return false;
|
|
68
59
|
};
|
|
69
60
|
};
|
|
70
61
|
};
|
|
71
|
-
|
|
72
62
|
var arrowRightFromCellSelection = function arrowRightFromCellSelection(editorSelectionAPI) {
|
|
73
63
|
return function (selection) {
|
|
74
64
|
return function (state, dispatch) {
|
|
75
65
|
if (isTableSelected(state.selection) && editorSelectionAPI) {
|
|
76
66
|
var _editorSelectionAPI$g2 = editorSelectionAPI.getSelectionPluginState(state),
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
selectionRelativeToNode = _editorSelectionAPI$g2.selectionRelativeToNode;
|
|
79
68
|
if (selectionRelativeToNode === RelativeSelectionPos.Start) {
|
|
80
69
|
// we have full table cell selection and want to set selection at start of first cell
|
|
81
70
|
return setSelectionAtStartOfFirstCell(editorSelectionAPI)(selection)(state, dispatch);
|
|
@@ -84,20 +73,17 @@ var arrowRightFromCellSelection = function arrowRightFromCellSelection(editorSel
|
|
|
84
73
|
return setGapCursorAfterTable(editorSelectionAPI)()(state, dispatch);
|
|
85
74
|
}
|
|
86
75
|
}
|
|
87
|
-
|
|
88
76
|
return false;
|
|
89
77
|
};
|
|
90
78
|
};
|
|
91
79
|
};
|
|
92
|
-
|
|
93
80
|
var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(editorSelectionAPI) {
|
|
94
81
|
return function (selection) {
|
|
95
82
|
return function (state, dispatch) {
|
|
96
83
|
var doc = state.doc;
|
|
97
84
|
var $from = selection.$from,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
85
|
+
from = selection.from,
|
|
86
|
+
side = selection.side;
|
|
101
87
|
if (side === Side.RIGHT) {
|
|
102
88
|
if ($from.nodeBefore && $from.nodeBefore.type.name === 'table') {
|
|
103
89
|
// we have a gap cursor after a table node and want to set a full table cell selection
|
|
@@ -109,11 +95,9 @@ var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(editorSelectionAPI)
|
|
|
109
95
|
}
|
|
110
96
|
} else if (side === Side.LEFT) {
|
|
111
97
|
var table = findTable(selection);
|
|
112
|
-
|
|
113
98
|
if (table && isSelectionAtStartOfTable($from, selection) && editorSelectionAPI) {
|
|
114
99
|
var _editorSelectionAPI$g3 = editorSelectionAPI.getSelectionPluginState(state),
|
|
115
|
-
|
|
116
|
-
|
|
100
|
+
selectionRelativeToNode = _editorSelectionAPI$g3.selectionRelativeToNode;
|
|
117
101
|
if (selectionRelativeToNode === RelativeSelectionPos.Before) {
|
|
118
102
|
// we have a gap cursor at start of first table cell and want to set a gap cursor selection before table
|
|
119
103
|
return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
|
|
@@ -127,20 +111,17 @@ var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(editorSelectionAPI)
|
|
|
127
111
|
}
|
|
128
112
|
}
|
|
129
113
|
}
|
|
130
|
-
|
|
131
114
|
return false;
|
|
132
115
|
};
|
|
133
116
|
};
|
|
134
117
|
};
|
|
135
|
-
|
|
136
118
|
var arrowRightFromGapCursor = function arrowRightFromGapCursor(editorSelectionAPI) {
|
|
137
119
|
return function (selection) {
|
|
138
120
|
return function (state, dispatch) {
|
|
139
121
|
var $from = selection.$from,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
122
|
+
from = selection.from,
|
|
123
|
+
$to = selection.$to,
|
|
124
|
+
side = selection.side;
|
|
144
125
|
if (side === Side.LEFT) {
|
|
145
126
|
if ($from.nodeAfter && $from.nodeAfter.type.name === 'table') {
|
|
146
127
|
// we have a gap cursor before a table node and want to set a full table cell selection
|
|
@@ -152,7 +133,6 @@ var arrowRightFromGapCursor = function arrowRightFromGapCursor(editorSelectionAP
|
|
|
152
133
|
}
|
|
153
134
|
} else if (side === Side.RIGHT) {
|
|
154
135
|
var table = findTable(selection);
|
|
155
|
-
|
|
156
136
|
if (table && isSelectionAtEndOfTable($to, selection)) {
|
|
157
137
|
// we have a gap cursor at end of last table cell and want to set a full table cell selection
|
|
158
138
|
return selectFullTable(editorSelectionAPI)({
|
|
@@ -162,25 +142,21 @@ var arrowRightFromGapCursor = function arrowRightFromGapCursor(editorSelectionAP
|
|
|
162
142
|
})(state, dispatch);
|
|
163
143
|
}
|
|
164
144
|
}
|
|
165
|
-
|
|
166
145
|
return false;
|
|
167
146
|
};
|
|
168
147
|
};
|
|
169
148
|
};
|
|
170
|
-
|
|
171
149
|
var arrowLeftFromText = function arrowLeftFromText(editorSelectionAPI) {
|
|
172
150
|
return function (selection) {
|
|
173
151
|
return function (state, dispatch) {
|
|
174
152
|
var table = findTable(selection);
|
|
175
|
-
|
|
176
153
|
if (table) {
|
|
177
154
|
var $from = selection.$from;
|
|
178
|
-
|
|
179
|
-
|
|
155
|
+
if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 &&
|
|
156
|
+
// + 3 for: row, cell & paragraph nodes
|
|
180
157
|
editorSelectionAPI) {
|
|
181
158
|
var _editorSelectionAPI$g4 = editorSelectionAPI.getSelectionPluginState(state),
|
|
182
|
-
|
|
183
|
-
|
|
159
|
+
selectionRelativeToNode = _editorSelectionAPI$g4.selectionRelativeToNode;
|
|
184
160
|
if (selectionRelativeToNode === RelativeSelectionPos.Before) {
|
|
185
161
|
// we have a text selection at start of first table cell, directly inside a top level paragraph,
|
|
186
162
|
// and want to set gap cursor selection before table
|
|
@@ -196,20 +172,16 @@ var arrowLeftFromText = function arrowLeftFromText(editorSelectionAPI) {
|
|
|
196
172
|
}
|
|
197
173
|
}
|
|
198
174
|
}
|
|
199
|
-
|
|
200
175
|
return false;
|
|
201
176
|
};
|
|
202
177
|
};
|
|
203
178
|
};
|
|
204
|
-
|
|
205
179
|
var arrowRightFromText = function arrowRightFromText(editorSelectionAPI) {
|
|
206
180
|
return function (selection) {
|
|
207
181
|
return function (state, dispatch) {
|
|
208
182
|
var table = findTable(selection);
|
|
209
|
-
|
|
210
183
|
if (table) {
|
|
211
184
|
var $to = selection.$to;
|
|
212
|
-
|
|
213
185
|
if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 // + 3 for: row, cell & paragraph nodes
|
|
214
186
|
) {
|
|
215
187
|
// we have a text selection at end of last table cell, directly inside a top level paragraph,
|
|
@@ -221,35 +193,30 @@ var arrowRightFromText = function arrowRightFromText(editorSelectionAPI) {
|
|
|
221
193
|
})(state, dispatch);
|
|
222
194
|
}
|
|
223
195
|
}
|
|
224
|
-
|
|
225
196
|
return false;
|
|
226
197
|
};
|
|
227
198
|
};
|
|
228
199
|
};
|
|
200
|
+
|
|
229
201
|
/**
|
|
230
202
|
* Sets a cell selection over all the cells in the table node
|
|
231
203
|
* We use this instead of selectTable from prosemirror-utils so we can control which
|
|
232
204
|
* cell is the anchor and which is the head, and also so we can set the relative selection
|
|
233
205
|
* pos in the selection plugin
|
|
234
206
|
*/
|
|
235
|
-
|
|
236
|
-
|
|
237
207
|
var selectFullTable = function selectFullTable(editorSelectionAPI) {
|
|
238
208
|
return function (_ref) {
|
|
239
209
|
var node = _ref.node,
|
|
240
|
-
|
|
241
|
-
|
|
210
|
+
startPos = _ref.startPos,
|
|
211
|
+
dir = _ref.dir;
|
|
242
212
|
return function (state, dispatch) {
|
|
243
213
|
var doc = state.doc;
|
|
244
|
-
|
|
245
214
|
var _TableMap$get = TableMap.get(node),
|
|
246
|
-
|
|
247
|
-
|
|
215
|
+
map = _TableMap$get.map;
|
|
248
216
|
var $firstCell = doc.resolve(startPos + map[0]);
|
|
249
217
|
var $lastCell = doc.resolve(startPos + map[map.length - 1]);
|
|
250
218
|
var fullTableSelection;
|
|
251
219
|
var selectionRelativeToNode;
|
|
252
|
-
|
|
253
220
|
if (dir === TableSelectionDirection.TopToBottom) {
|
|
254
221
|
fullTableSelection = new CellSelection($firstCell, $lastCell);
|
|
255
222
|
selectionRelativeToNode = RelativeSelectionPos.End;
|
|
@@ -257,96 +224,82 @@ var selectFullTable = function selectFullTable(editorSelectionAPI) {
|
|
|
257
224
|
fullTableSelection = new CellSelection($lastCell, $firstCell);
|
|
258
225
|
selectionRelativeToNode = RelativeSelectionPos.Start;
|
|
259
226
|
}
|
|
260
|
-
|
|
261
227
|
if (editorSelectionAPI) {
|
|
262
228
|
var tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
263
229
|
selectionRelativeToNode: selectionRelativeToNode,
|
|
264
230
|
selection: fullTableSelection
|
|
265
231
|
})(state);
|
|
266
|
-
|
|
267
232
|
if (dispatch) {
|
|
268
233
|
dispatch(tr);
|
|
269
234
|
return true;
|
|
270
235
|
}
|
|
271
236
|
}
|
|
272
|
-
|
|
273
237
|
return false;
|
|
274
238
|
};
|
|
275
239
|
};
|
|
276
240
|
};
|
|
277
|
-
|
|
278
241
|
var setSelectionAtStartOfFirstCell = function setSelectionAtStartOfFirstCell(editorSelectionAPI) {
|
|
279
242
|
return function (selection, selectionRelativeToNode) {
|
|
280
243
|
return function (state, dispatch) {
|
|
281
244
|
var $anchorCell = selection.$anchorCell,
|
|
282
|
-
|
|
245
|
+
$headCell = selection.$headCell;
|
|
283
246
|
var $firstCell = $anchorCell.pos < $headCell.pos ? $anchorCell : $headCell;
|
|
284
|
-
var $firstPosInsideCell = state.doc.resolve($firstCell.pos + 1);
|
|
247
|
+
var $firstPosInsideCell = state.doc.resolve($firstCell.pos + 1);
|
|
285
248
|
|
|
249
|
+
// check if first pos should have a gap cursor, otherwise find closest text selection
|
|
286
250
|
var selectionAtStartOfCell = GapCursorSelection.valid($firstPosInsideCell) ? new GapCursorSelection($firstPosInsideCell, Side.LEFT) : Selection.findFrom($firstPosInsideCell, 1);
|
|
287
|
-
|
|
288
251
|
if (editorSelectionAPI) {
|
|
289
252
|
var tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
290
253
|
selectionRelativeToNode: selectionRelativeToNode,
|
|
291
254
|
selection: selectionAtStartOfCell
|
|
292
255
|
})(state);
|
|
293
|
-
|
|
294
256
|
if (dispatch) {
|
|
295
257
|
dispatch(tr);
|
|
296
258
|
return true;
|
|
297
259
|
}
|
|
298
260
|
}
|
|
299
|
-
|
|
300
261
|
return false;
|
|
301
262
|
};
|
|
302
263
|
};
|
|
303
264
|
};
|
|
304
|
-
|
|
305
265
|
var setSelectionAtEndOfLastCell = function setSelectionAtEndOfLastCell(editorSelectionAPI) {
|
|
306
266
|
return function (selection, selectionRelativeToNode) {
|
|
307
267
|
return function (state, dispatch) {
|
|
308
268
|
var $anchorCell = selection.$anchorCell,
|
|
309
|
-
|
|
269
|
+
$headCell = selection.$headCell;
|
|
310
270
|
var $lastCell = $anchorCell.pos > $headCell.pos ? $anchorCell : $headCell;
|
|
311
271
|
var lastPosInsideCell = $lastCell.pos + ($lastCell.nodeAfter ? $lastCell.nodeAfter.content.size : 0) + 1;
|
|
312
|
-
var $lastPosInsideCell = state.doc.resolve(lastPosInsideCell);
|
|
272
|
+
var $lastPosInsideCell = state.doc.resolve(lastPosInsideCell);
|
|
313
273
|
|
|
274
|
+
// check if last pos should have a gap cursor, otherwise find closest text selection
|
|
314
275
|
var selectionAtEndOfCell = GapCursorSelection.valid($lastPosInsideCell) ? new GapCursorSelection($lastPosInsideCell, Side.RIGHT) : Selection.findFrom($lastPosInsideCell, -1);
|
|
315
|
-
|
|
316
276
|
if (editorSelectionAPI) {
|
|
317
277
|
var tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
318
278
|
selectionRelativeToNode: selectionRelativeToNode,
|
|
319
279
|
selection: selectionAtEndOfCell
|
|
320
280
|
})(state);
|
|
321
|
-
|
|
322
281
|
if (dispatch) {
|
|
323
282
|
dispatch(tr);
|
|
324
283
|
return true;
|
|
325
284
|
}
|
|
326
285
|
}
|
|
327
|
-
|
|
328
286
|
return false;
|
|
329
287
|
};
|
|
330
288
|
};
|
|
331
289
|
};
|
|
332
|
-
|
|
333
290
|
var setGapCursorBeforeTable = function setGapCursorBeforeTable(editorSelectionAPI) {
|
|
334
291
|
return function () {
|
|
335
292
|
return function (state, dispatch) {
|
|
336
293
|
var table = findTable(state.selection);
|
|
337
|
-
|
|
338
294
|
if (table) {
|
|
339
295
|
var $beforeTablePos = state.doc.resolve(table.pos);
|
|
340
|
-
|
|
341
296
|
if (GapCursorSelection.valid($beforeTablePos)) {
|
|
342
297
|
var selectionBeforeTable = new GapCursorSelection($beforeTablePos, Side.LEFT);
|
|
343
|
-
|
|
344
298
|
if (editorSelectionAPI) {
|
|
345
299
|
var tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
346
300
|
selectionRelativeToNode: undefined,
|
|
347
301
|
selection: selectionBeforeTable
|
|
348
302
|
})(state);
|
|
349
|
-
|
|
350
303
|
if (dispatch) {
|
|
351
304
|
dispatch(tr);
|
|
352
305
|
return true;
|
|
@@ -354,48 +307,38 @@ var setGapCursorBeforeTable = function setGapCursorBeforeTable(editorSelectionAP
|
|
|
354
307
|
}
|
|
355
308
|
}
|
|
356
309
|
}
|
|
357
|
-
|
|
358
310
|
return false;
|
|
359
311
|
};
|
|
360
312
|
};
|
|
361
313
|
};
|
|
362
|
-
|
|
363
314
|
var setGapCursorAfterTable = function setGapCursorAfterTable(editorSelectionAPI) {
|
|
364
315
|
return function () {
|
|
365
316
|
return function (state, dispatch) {
|
|
366
317
|
var table = findTable(state.selection);
|
|
367
|
-
|
|
368
318
|
if (table) {
|
|
369
319
|
var $afterTablePos = state.doc.resolve(table.pos + table.node.nodeSize);
|
|
370
|
-
|
|
371
320
|
if (GapCursorSelection.valid($afterTablePos)) {
|
|
372
321
|
var selectionAfterTable = new GapCursorSelection($afterTablePos, Side.RIGHT);
|
|
373
|
-
|
|
374
322
|
if (editorSelectionAPI) {
|
|
375
323
|
var tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
376
324
|
selectionRelativeToNode: undefined,
|
|
377
325
|
selection: selectionAfterTable
|
|
378
326
|
})(state);
|
|
379
|
-
|
|
380
327
|
if (dispatch) {
|
|
381
328
|
dispatch(tr);
|
|
382
329
|
return true;
|
|
383
330
|
}
|
|
384
331
|
}
|
|
385
|
-
|
|
386
332
|
return false;
|
|
387
333
|
}
|
|
388
334
|
}
|
|
389
|
-
|
|
390
335
|
return false;
|
|
391
336
|
};
|
|
392
337
|
};
|
|
393
338
|
};
|
|
394
|
-
|
|
395
339
|
var isSelectionAtStartOfTable = function isSelectionAtStartOfTable($pos, selection) {
|
|
396
340
|
return isSelectionAtStartOfNode($pos, findTable(selection));
|
|
397
341
|
};
|
|
398
|
-
|
|
399
342
|
var isSelectionAtEndOfTable = function isSelectionAtEndOfTable($pos, selection) {
|
|
400
343
|
return isSelectionAtEndOfNode($pos, findTable(selection));
|
|
401
344
|
};
|
|
@@ -5,22 +5,18 @@ import { convertArrayOfRowsToTableNode, convertTableNodeToArrayOfRows, findTable
|
|
|
5
5
|
import { createCompareNodes } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
|
|
7
7
|
import { TableSortStep, TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
|
|
8
|
-
|
|
9
8
|
function createGetInlineCardTextFromStore(state) {
|
|
10
9
|
return function (attrs) {
|
|
11
10
|
var _ref = attrs,
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
data = _ref.data;
|
|
14
12
|
if (data && (data.name || data.title)) {
|
|
15
13
|
return data.name || data.title;
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
var _ref2 = attrs,
|
|
19
|
-
|
|
16
|
+
cardUrl = _ref2.url;
|
|
20
17
|
return cardUrl;
|
|
21
18
|
};
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
export var sortByColumn = function sortByColumn(columnIndex) {
|
|
25
21
|
var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SortOrder.DESC;
|
|
26
22
|
return createCommand(function (state) {
|
|
@@ -35,36 +31,28 @@ export var sortByColumn = function sortByColumn(columnIndex) {
|
|
|
35
31
|
};
|
|
36
32
|
}, function (tr, state) {
|
|
37
33
|
var table = findTable(tr.selection);
|
|
38
|
-
|
|
39
34
|
if (!table || !table.node) {
|
|
40
35
|
return tr;
|
|
41
36
|
}
|
|
42
|
-
|
|
43
37
|
var selectionRect = isSelectionType(tr.selection, 'cell') ? getSelectionRect(tr.selection) : findCellRectClosestToPos(tr.selection.$from);
|
|
44
|
-
|
|
45
38
|
if (!selectionRect) {
|
|
46
39
|
return tr;
|
|
47
40
|
}
|
|
48
|
-
|
|
49
41
|
var tablePluginState = getPluginState(state);
|
|
50
42
|
var tableArray = convertTableNodeToArrayOfRows(table.node);
|
|
51
43
|
var headerRow;
|
|
52
|
-
|
|
53
44
|
if (tablePluginState.isHeaderRowEnabled) {
|
|
54
45
|
headerRow = tableArray.shift();
|
|
55
46
|
}
|
|
56
|
-
|
|
57
47
|
var compareNodesInOrder = createCompareNodes({
|
|
58
48
|
getInlineCardTextFromStore: createGetInlineCardTextFromStore(state)
|
|
59
49
|
}, order);
|
|
60
50
|
var sortedTable = tableArray.sort(function (rowA, rowB) {
|
|
61
51
|
return compareNodesInOrder(rowA[columnIndex], rowB[columnIndex]);
|
|
62
52
|
});
|
|
63
|
-
|
|
64
53
|
if (headerRow) {
|
|
65
54
|
sortedTable.unshift(headerRow);
|
|
66
55
|
}
|
|
67
|
-
|
|
68
56
|
var newTableNode = convertArrayOfRowsToTableNode(table.node, sortedTable);
|
|
69
57
|
tr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTableNode);
|
|
70
58
|
var pos = TableMap.get(table.node).positionAt(selectionRect.top, columnIndex, table.node);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { splitCellWithType } from '@atlaskit/editor-tables/utils';
|
|
2
2
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* We need to split cell keeping the right type of cell given current table configuration.
|
|
6
5
|
* We are using editor-tables splitCellWithType that allows you to choose what cell type should be.
|
|
@@ -8,21 +7,17 @@ import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
|
8
7
|
export var splitCell = function splitCell(state, dispatch) {
|
|
9
8
|
var tableState = getPluginState(state);
|
|
10
9
|
var _state$schema$nodes = state.schema.nodes,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
tableHeader = _state$schema$nodes.tableHeader,
|
|
11
|
+
tableCell = _state$schema$nodes.tableCell;
|
|
14
12
|
if (dispatch) {
|
|
15
13
|
return splitCellWithType(function (_ref) {
|
|
16
14
|
var row = _ref.row,
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
col = _ref.col;
|
|
19
16
|
if (row === 0 && tableState.isHeaderRowEnabled || col === 0 && tableState.isHeaderColumnEnabled) {
|
|
20
17
|
return tableHeader;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
return tableCell;
|
|
24
20
|
})(state, dispatch);
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
return true;
|
|
28
23
|
};
|
|
@@ -1,37 +1,33 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
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; }
|
|
4
|
-
|
|
5
3
|
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) { _defineProperty(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; }
|
|
6
|
-
|
|
7
4
|
//#region Imports
|
|
5
|
+
|
|
8
6
|
import { toggleHeader } from '@atlaskit/editor-tables/utils';
|
|
9
7
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
10
|
-
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
11
|
-
|
|
8
|
+
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
9
|
+
//#endregion
|
|
12
10
|
|
|
11
|
+
// #region Utils
|
|
13
12
|
/**
|
|
14
13
|
* Table layout toggle logic
|
|
15
14
|
* default -> wide -> full-width -> default
|
|
16
15
|
*/
|
|
17
|
-
|
|
18
16
|
export var getNextLayout = function getNextLayout(currentLayout) {
|
|
19
17
|
switch (currentLayout) {
|
|
20
18
|
case 'default':
|
|
21
19
|
return 'wide';
|
|
22
|
-
|
|
23
20
|
case 'wide':
|
|
24
21
|
return 'full-width';
|
|
25
|
-
|
|
26
22
|
case 'full-width':
|
|
27
23
|
return 'default';
|
|
28
|
-
|
|
29
24
|
default:
|
|
30
25
|
return 'default';
|
|
31
26
|
}
|
|
32
|
-
};
|
|
33
|
-
// #
|
|
27
|
+
};
|
|
28
|
+
// #endregion
|
|
34
29
|
|
|
30
|
+
// #region Actions
|
|
35
31
|
export var toggleHeaderRow = function toggleHeaderRow(state, dispatch) {
|
|
36
32
|
return toggleHeader('row')(state, function (tr) {
|
|
37
33
|
return createCommand({
|
|
@@ -52,29 +48,23 @@ export var toggleHeaderColumn = function toggleHeaderColumn(state, dispatch) {
|
|
|
52
48
|
};
|
|
53
49
|
export var toggleNumberColumn = function toggleNumberColumn(state, dispatch) {
|
|
54
50
|
var tr = state.tr;
|
|
55
|
-
|
|
56
51
|
var _ref = findTable(state.selection),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
node = _ref.node,
|
|
53
|
+
pos = _ref.pos;
|
|
60
54
|
tr.setNodeMarkup(pos, state.schema.nodes.table, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
61
55
|
isNumberColumnEnabled: !node.attrs.isNumberColumnEnabled
|
|
62
56
|
}));
|
|
63
57
|
tr.setMeta('scrollIntoView', false);
|
|
64
|
-
|
|
65
58
|
if (dispatch) {
|
|
66
59
|
dispatch(tr);
|
|
67
60
|
}
|
|
68
|
-
|
|
69
61
|
return true;
|
|
70
62
|
};
|
|
71
63
|
export var toggleTableLayout = function toggleTableLayout(state, dispatch) {
|
|
72
64
|
var table = findTable(state.selection);
|
|
73
|
-
|
|
74
65
|
if (!table) {
|
|
75
66
|
return false;
|
|
76
67
|
}
|
|
77
|
-
|
|
78
68
|
var layout = getNextLayout(table.node.attrs.layout);
|
|
79
69
|
return createCommand({
|
|
80
70
|
type: 'SET_TABLE_LAYOUT',
|
|
@@ -94,4 +84,5 @@ export var toggleContextualMenu = function toggleContextualMenu() {
|
|
|
94
84
|
}, function (tr) {
|
|
95
85
|
return tr.setMeta('addToHistory', false);
|
|
96
86
|
});
|
|
97
|
-
};
|
|
87
|
+
};
|
|
88
|
+
// #endregion
|