@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,13 +1,13 @@
|
|
|
1
1
|
import { Fragment, Slice } from 'prosemirror-model';
|
|
2
2
|
import { flatten } from 'prosemirror-utils';
|
|
3
3
|
import { flatmap, mapSlice } from '@atlaskit/editor-common/utils';
|
|
4
|
-
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
4
|
+
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
5
5
|
|
|
6
|
+
// lifts up the content of each cell, returning an array of nodes
|
|
6
7
|
export const unwrapContentFromTable = maybeTable => {
|
|
7
8
|
const {
|
|
8
9
|
schema
|
|
9
10
|
} = maybeTable.type;
|
|
10
|
-
|
|
11
11
|
if (maybeTable.type === schema.nodes.table) {
|
|
12
12
|
const content = [];
|
|
13
13
|
const {
|
|
@@ -18,12 +18,10 @@ export const unwrapContentFromTable = maybeTable => {
|
|
|
18
18
|
if (maybeCell.type === tableCell || maybeCell.type === tableHeader) {
|
|
19
19
|
content.push(...flatten(maybeCell, false).map(child => child.node));
|
|
20
20
|
}
|
|
21
|
-
|
|
22
21
|
return true;
|
|
23
22
|
});
|
|
24
23
|
return content;
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
return maybeTable;
|
|
28
26
|
};
|
|
29
27
|
export const removeTableFromFirstChild = (node, i) => {
|
|
@@ -32,12 +30,12 @@ export const removeTableFromFirstChild = (node, i) => {
|
|
|
32
30
|
export const removeTableFromLastChild = (node, i, fragment) => {
|
|
33
31
|
return i === fragment.childCount - 1 ? unwrapContentFromTable(node) : node;
|
|
34
32
|
};
|
|
33
|
+
|
|
35
34
|
/**
|
|
36
35
|
* When we copy from a table cell with a hardBreak at the end,
|
|
37
36
|
* the slice generated will come with a hardBreak outside of the table.
|
|
38
37
|
* This code will look for that pattern and fix it.
|
|
39
38
|
*/
|
|
40
|
-
|
|
41
39
|
export const transformSliceToFixHardBreakProblemOnCopyFromCell = (slice, schema) => {
|
|
42
40
|
const {
|
|
43
41
|
paragraph,
|
|
@@ -49,52 +47,50 @@ export const transformSliceToFixHardBreakProblemOnCopyFromCell = (slice, schema)
|
|
|
49
47
|
const paragraphNodeSize = emptyParagraphNode ? emptyParagraphNode.nodeSize : 0;
|
|
50
48
|
const hardBreakNodeSize = hardBreakNode ? hardBreakNode.nodeSize : 0;
|
|
51
49
|
const paragraphWithHardBreakSize = paragraphNodeSize + hardBreakNodeSize;
|
|
52
|
-
|
|
53
50
|
if (slice.content.childCount === 2 && slice.content.firstChild && slice.content.lastChild && slice.content.firstChild.type === table && slice.content.lastChild.type === paragraph && slice.content.lastChild.nodeSize === paragraphWithHardBreakSize) {
|
|
54
51
|
const nodes = unwrapContentFromTable(slice.content.firstChild);
|
|
55
|
-
|
|
56
52
|
if (nodes instanceof Array) {
|
|
57
|
-
return new Slice(Fragment.from(
|
|
53
|
+
return new Slice(Fragment.from(
|
|
54
|
+
// keep only the content and discard the hardBreak
|
|
58
55
|
nodes[0]), slice.openStart, slice.openEnd);
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
|
-
|
|
62
58
|
return slice;
|
|
63
59
|
};
|
|
64
60
|
export const transformSliceToRemoveOpenTable = (slice, schema) => {
|
|
65
61
|
var _slice$content$firstC6;
|
|
66
|
-
|
|
67
62
|
// we're removing the table, tableRow and tableCell reducing the open depth by 3
|
|
68
|
-
const depthDecrement = 3;
|
|
63
|
+
const depthDecrement = 3;
|
|
69
64
|
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
// Case 1: A slice entirely within a single CELL
|
|
66
|
+
if (
|
|
67
|
+
// starts and ends inside of a cell
|
|
68
|
+
slice.openStart >= 4 && slice.openEnd >= 4 &&
|
|
69
|
+
// slice is a table node
|
|
72
70
|
slice.content.childCount === 1 && slice.content.firstChild.type === schema.nodes.table) {
|
|
73
71
|
var _slice$content$firstC, _slice$content$firstC2, _slice$content$firstC3, _slice$content$firstC4, _slice$content$firstC5;
|
|
74
|
-
|
|
75
72
|
// prosemirror-view has a bug that it duplicates table entry when selecting multiple paragraphs in a table cell.
|
|
76
73
|
// https://github.com/ProseMirror/prosemirror/issues/1270
|
|
77
74
|
// The structure becomes
|
|
78
75
|
// table(genuine) > tableRow(genuine) > table(duplicated) > tableRow(duplicated) > tableCell/tableHeader(genuine) > contents(genuine)
|
|
79
76
|
// As we are removing wrapping table anyway, we keep duplicated table and tableRow for simplicity
|
|
80
77
|
let cleaned = slice;
|
|
81
|
-
|
|
82
78
|
if (((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : (_slice$content$firstC2 = _slice$content$firstC.content) === null || _slice$content$firstC2 === void 0 ? void 0 : (_slice$content$firstC3 = _slice$content$firstC2.firstChild) === null || _slice$content$firstC3 === void 0 ? void 0 : (_slice$content$firstC4 = _slice$content$firstC3.content) === null || _slice$content$firstC4 === void 0 ? void 0 : (_slice$content$firstC5 = _slice$content$firstC4.firstChild) === null || _slice$content$firstC5 === void 0 ? void 0 : _slice$content$firstC5.type) === schema.nodes.table) {
|
|
83
79
|
cleaned = new Slice(slice.content.firstChild.content.firstChild.content, slice.openStart - 2, slice.openEnd - 2);
|
|
84
80
|
}
|
|
85
|
-
|
|
86
81
|
return new Slice(flatmap(cleaned.content, unwrapContentFromTable), cleaned.openStart - depthDecrement, cleaned.openEnd - depthDecrement);
|
|
87
|
-
}
|
|
88
|
-
|
|
82
|
+
}
|
|
89
83
|
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
// Case 2: A slice starting within a CELL and ending outside the table
|
|
85
|
+
if (
|
|
86
|
+
// starts inside of a cell but ends outside of the starting table
|
|
87
|
+
slice.openStart >= 4 &&
|
|
88
|
+
// slice starts from a table node (and spans across more than one node)
|
|
92
89
|
slice.content.childCount > 1 && ((_slice$content$firstC6 = slice.content.firstChild) === null || _slice$content$firstC6 === void 0 ? void 0 : _slice$content$firstC6.type) === schema.nodes.table) {
|
|
93
90
|
// repoint the slice's cutting depth so that cell content where the slice starts
|
|
94
91
|
// does not get lifted out of the cell on paste
|
|
95
92
|
return new Slice(slice.content, 1, slice.openEnd);
|
|
96
93
|
}
|
|
97
|
-
|
|
98
94
|
return slice;
|
|
99
95
|
};
|
|
100
96
|
export const transformSliceToCorrectEmptyTableCells = (slice, schema) => {
|
|
@@ -106,7 +102,6 @@ export const transformSliceToCorrectEmptyTableCells = (slice, schema) => {
|
|
|
106
102
|
if (node && (node.type === tableCell || node.type === tableHeader) && !node.content.childCount) {
|
|
107
103
|
return node.type.createAndFill(node.attrs) || node;
|
|
108
104
|
}
|
|
109
|
-
|
|
110
105
|
return node;
|
|
111
106
|
});
|
|
112
107
|
};
|
|
@@ -7,14 +7,13 @@ import { TableCssClassName as ClassName } from '../types';
|
|
|
7
7
|
import { tableDeleteButtonSize } from '../ui/consts';
|
|
8
8
|
export const getRowHeights = tableRef => {
|
|
9
9
|
const heights = [];
|
|
10
|
-
|
|
11
10
|
if (tableRef.lastChild) {
|
|
12
11
|
const rows = tableRef.lastChild.childNodes;
|
|
13
|
-
|
|
14
12
|
for (let i = 0, count = rows.length; i < count; i++) {
|
|
15
13
|
const row = rows[i];
|
|
16
|
-
heights[i] = row.getBoundingClientRect().height + 1;
|
|
14
|
+
heights[i] = row.getBoundingClientRect().height + 1;
|
|
17
15
|
|
|
16
|
+
// padding only gets applied when the container has sticky
|
|
18
17
|
if (row.classList.contains('sticky') && i === 0) {
|
|
19
18
|
const styles = window.getComputedStyle(row);
|
|
20
19
|
const paddingTop = parsePx(styles.paddingTop || '');
|
|
@@ -22,46 +21,37 @@ export const getRowHeights = tableRef => {
|
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
|
-
|
|
26
24
|
return heights;
|
|
27
25
|
};
|
|
28
26
|
export const isRowDeleteButtonVisible = selection => {
|
|
29
27
|
if (!isTableSelected(selection) && selection instanceof CellSelection && selection.isRowSelection()) {
|
|
30
28
|
return true;
|
|
31
29
|
}
|
|
32
|
-
|
|
33
30
|
return false;
|
|
34
31
|
};
|
|
35
32
|
export const getRowDeleteButtonParams = (rowsHeights, selection, offsetTop = 0) => {
|
|
36
33
|
const rect = getSelectionRect(selection);
|
|
37
|
-
|
|
38
34
|
if (!rect) {
|
|
39
35
|
return null;
|
|
40
36
|
}
|
|
41
|
-
|
|
42
37
|
let height = 0;
|
|
43
|
-
let offset = offsetTop;
|
|
44
|
-
|
|
38
|
+
let offset = offsetTop;
|
|
39
|
+
// find the rows before the selection
|
|
45
40
|
for (let i = 0; i < rect.top; i++) {
|
|
46
41
|
const rowHeight = rowsHeights[i];
|
|
47
|
-
|
|
48
42
|
if (rowHeight) {
|
|
49
43
|
offset += rowHeight - 1;
|
|
50
44
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
}
|
|
46
|
+
// these are the selected rows widths
|
|
54
47
|
const indexes = [];
|
|
55
|
-
|
|
56
48
|
for (let i = rect.top; i < rect.bottom; i++) {
|
|
57
49
|
const rowHeight = rowsHeights[i];
|
|
58
|
-
|
|
59
50
|
if (rowHeight) {
|
|
60
51
|
height += rowHeight - 1;
|
|
61
52
|
indexes.push(i);
|
|
62
53
|
}
|
|
63
54
|
}
|
|
64
|
-
|
|
65
55
|
const top = offset + height / 2 - tableDeleteButtonSize / 2;
|
|
66
56
|
return {
|
|
67
57
|
top,
|
|
@@ -70,63 +60,49 @@ export const getRowDeleteButtonParams = (rowsHeights, selection, offsetTop = 0)
|
|
|
70
60
|
};
|
|
71
61
|
export const getRowsParams = rowsHeights => {
|
|
72
62
|
const rows = [];
|
|
73
|
-
|
|
74
63
|
for (let i = 0, count = rowsHeights.length; i < count; i++) {
|
|
75
64
|
const height = rowsHeights[i];
|
|
76
|
-
|
|
77
65
|
if (!height) {
|
|
78
66
|
continue;
|
|
79
67
|
}
|
|
80
|
-
|
|
81
68
|
let endIndex = rowsHeights.length;
|
|
82
|
-
|
|
83
69
|
for (let k = i + 1, count = rowsHeights.length; k < count; k++) {
|
|
84
70
|
if (rowsHeights[k]) {
|
|
85
71
|
endIndex = k;
|
|
86
72
|
break;
|
|
87
73
|
}
|
|
88
74
|
}
|
|
89
|
-
|
|
90
75
|
rows.push({
|
|
91
76
|
startIndex: i,
|
|
92
77
|
endIndex,
|
|
93
78
|
height
|
|
94
79
|
});
|
|
95
80
|
}
|
|
96
|
-
|
|
97
81
|
return rows;
|
|
98
82
|
};
|
|
99
83
|
export const getRowClassNames = (index, selection, hoveredRows = [], isInDanger, isResizing) => {
|
|
100
84
|
const classNames = [];
|
|
101
|
-
|
|
102
85
|
if (isRowSelected(index)(selection) || hoveredRows.indexOf(index) > -1 && !isResizing) {
|
|
103
86
|
classNames.push(ClassName.HOVERED_CELL_ACTIVE);
|
|
104
|
-
|
|
105
87
|
if (isInDanger) {
|
|
106
88
|
classNames.push(ClassName.HOVERED_CELL_IN_DANGER);
|
|
107
89
|
}
|
|
108
90
|
}
|
|
109
|
-
|
|
110
91
|
return classNames.join(' ');
|
|
111
92
|
};
|
|
112
93
|
export const copyPreviousRow = schema => insertNewRowIndex => tr => {
|
|
113
94
|
const table = findTable(tr.selection);
|
|
114
|
-
|
|
115
95
|
if (!table) {
|
|
116
96
|
return tr;
|
|
117
97
|
}
|
|
118
|
-
|
|
119
98
|
const map = TableMap.get(table.node);
|
|
120
99
|
const copyPreviousRowIndex = insertNewRowIndex - 1;
|
|
121
|
-
|
|
122
100
|
if (insertNewRowIndex <= 0) {
|
|
123
101
|
throw Error(`Row Index less or equal 0 isn't not allowed since there is not a previous to copy`);
|
|
124
102
|
}
|
|
125
|
-
|
|
126
103
|
if (insertNewRowIndex > map.height) {
|
|
127
104
|
return tr;
|
|
128
105
|
}
|
|
129
|
-
|
|
130
106
|
const tableNode = table.node;
|
|
131
107
|
const {
|
|
132
108
|
nodes: {
|
|
@@ -145,26 +121,22 @@ export const copyPreviousRow = schema => insertNewRowIndex => tr => {
|
|
|
145
121
|
const cellsPositionsInNextRow = map.map.slice(offsetNextLineIndexPosition, offsetNextLineIndexPosition + map.width);
|
|
146
122
|
let cells = [];
|
|
147
123
|
let fixRowspans = [];
|
|
148
|
-
|
|
149
124
|
for (let i = 0; i < cellsPositionsInOriginalRow.length;) {
|
|
150
125
|
const pos = cellsPositionsInOriginalRow[i];
|
|
151
126
|
const documentCellPos = pos + table.start;
|
|
152
127
|
const node = tr.doc.nodeAt(documentCellPos);
|
|
153
|
-
|
|
154
128
|
if (!node) {
|
|
155
129
|
continue;
|
|
156
130
|
}
|
|
157
|
-
|
|
158
|
-
|
|
131
|
+
const attributes = {
|
|
132
|
+
...node.attrs,
|
|
159
133
|
colspan: 1,
|
|
160
134
|
rowspan: 1
|
|
161
135
|
};
|
|
162
136
|
const newCell = node.type.createAndFill(attributes);
|
|
163
|
-
|
|
164
137
|
if (!newCell) {
|
|
165
138
|
return tr;
|
|
166
139
|
}
|
|
167
|
-
|
|
168
140
|
if (cellsPositionsInNextRow.indexOf(pos) > -1) {
|
|
169
141
|
fixRowspans.push({
|
|
170
142
|
pos: documentCellPos,
|
|
@@ -172,38 +144,33 @@ export const copyPreviousRow = schema => insertNewRowIndex => tr => {
|
|
|
172
144
|
});
|
|
173
145
|
} else if (cellsInRow.indexOf(pos) > -1) {
|
|
174
146
|
if (node.attrs.colspan > 1) {
|
|
175
|
-
const newCellWithColspanFixed = node.type.createAndFill({
|
|
147
|
+
const newCellWithColspanFixed = node.type.createAndFill({
|
|
148
|
+
...attributes,
|
|
176
149
|
colspan: node.attrs.colspan
|
|
177
150
|
});
|
|
178
|
-
|
|
179
151
|
if (!newCellWithColspanFixed) {
|
|
180
152
|
return tr;
|
|
181
153
|
}
|
|
182
|
-
|
|
183
154
|
cells.push(newCellWithColspanFixed);
|
|
184
155
|
i = i + node.attrs.colspan;
|
|
185
156
|
continue;
|
|
186
157
|
}
|
|
187
|
-
|
|
188
158
|
cells.push(newCell);
|
|
189
159
|
} else {
|
|
190
160
|
cells.push(newCell);
|
|
191
161
|
}
|
|
192
|
-
|
|
193
162
|
i++;
|
|
194
163
|
}
|
|
195
|
-
|
|
196
164
|
fixRowspans.forEach(cell => {
|
|
197
|
-
tr.setNodeMarkup(cell.pos, undefined, {
|
|
165
|
+
tr.setNodeMarkup(cell.pos, undefined, {
|
|
166
|
+
...cell.node.attrs,
|
|
198
167
|
rowspan: cell.node.attrs.rowspan + 1
|
|
199
168
|
});
|
|
200
169
|
});
|
|
201
170
|
const cloneRow = tableNode.child(copyPreviousRowIndex);
|
|
202
171
|
let rowPos = table.start;
|
|
203
|
-
|
|
204
172
|
for (let i = 0; i < insertNewRowIndex; i++) {
|
|
205
173
|
rowPos += tableNode.child(i).nodeSize;
|
|
206
174
|
}
|
|
207
|
-
|
|
208
175
|
return safeInsert(tableRow.createChecked(cloneRow.attrs, cells, cloneRow.marks), rowPos)(tr);
|
|
209
176
|
};
|
|
@@ -2,14 +2,11 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
2
2
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
3
3
|
import { findTable, getSelectionRangeInColumn, getSelectionRangeInRow, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
4
4
|
export const isSelectionUpdated = (oldSelection, newSelection) => !!(!newSelection && oldSelection) || isSelectionType(oldSelection, 'cell') !== isSelectionType(newSelection, 'cell') || isSelectionType(oldSelection, 'cell') && isSelectionType(newSelection, 'cell') && oldSelection.ranges !== newSelection.ranges;
|
|
5
|
-
|
|
6
5
|
const isRectangularCellSelection = (selection, rect) => {
|
|
7
6
|
const table = findTable(selection);
|
|
8
|
-
|
|
9
7
|
if (!table) {
|
|
10
8
|
return true;
|
|
11
9
|
}
|
|
12
|
-
|
|
13
10
|
const {
|
|
14
11
|
width,
|
|
15
12
|
height,
|
|
@@ -19,77 +16,59 @@ const isRectangularCellSelection = (selection, rect) => {
|
|
|
19
16
|
let indexLeft = indexTop;
|
|
20
17
|
let indexBottom = (rect.bottom - 1) * width + rect.left;
|
|
21
18
|
let indexRight = indexTop + (rect.right - rect.left - 1);
|
|
22
|
-
|
|
23
19
|
for (let i = rect.top; i < rect.bottom; i++) {
|
|
24
20
|
if (rect.left > 0 && map[indexLeft] === map[indexLeft - 1] || rect.right < width && map[indexRight] === map[indexRight + 1]) {
|
|
25
21
|
return false;
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
indexLeft += width;
|
|
29
24
|
indexRight += width;
|
|
30
25
|
}
|
|
31
|
-
|
|
32
26
|
for (let i = rect.left; i < rect.right; i++) {
|
|
33
27
|
if (rect.top > 0 && map[indexTop] === map[indexTop - width] || rect.bottom < height && map[indexBottom] === map[indexBottom + width]) {
|
|
34
28
|
return false;
|
|
35
29
|
}
|
|
36
|
-
|
|
37
30
|
indexTop++;
|
|
38
31
|
indexBottom++;
|
|
39
32
|
}
|
|
40
|
-
|
|
41
33
|
return true;
|
|
42
34
|
};
|
|
43
|
-
|
|
44
35
|
export const normalizeSelection = tr => {
|
|
45
36
|
const {
|
|
46
37
|
selection
|
|
47
38
|
} = tr;
|
|
48
39
|
const rect = getSelectionRect(selection);
|
|
49
|
-
|
|
50
40
|
if (!rect || !(selection instanceof CellSelection) || isRectangularCellSelection(selection, rect)) {
|
|
51
41
|
return tr;
|
|
52
42
|
}
|
|
53
|
-
|
|
54
43
|
if (selection.isColSelection()) {
|
|
55
44
|
var _getSelectionRangeInC, _getSelectionRangeInC2;
|
|
56
|
-
|
|
57
45
|
const $anchor = (_getSelectionRangeInC = getSelectionRangeInColumn(rect.left)(tr)) === null || _getSelectionRangeInC === void 0 ? void 0 : _getSelectionRangeInC.$anchor;
|
|
58
46
|
const $head = (_getSelectionRangeInC2 = getSelectionRangeInColumn(rect.right - 1)(tr)) === null || _getSelectionRangeInC2 === void 0 ? void 0 : _getSelectionRangeInC2.$head;
|
|
59
|
-
|
|
60
47
|
if ($anchor && $head) {
|
|
61
48
|
return tr.setSelection(new CellSelection($anchor, $head));
|
|
62
49
|
}
|
|
63
50
|
}
|
|
64
|
-
|
|
65
51
|
if (selection.isRowSelection()) {
|
|
66
52
|
var _getSelectionRangeInR, _getSelectionRangeInR2;
|
|
67
|
-
|
|
68
53
|
const $anchor = (_getSelectionRangeInR = getSelectionRangeInRow(rect.top)(tr)) === null || _getSelectionRangeInR === void 0 ? void 0 : _getSelectionRangeInR.$anchor;
|
|
69
54
|
const $head = (_getSelectionRangeInR2 = getSelectionRangeInRow(rect.bottom - 1)(tr)) === null || _getSelectionRangeInR2 === void 0 ? void 0 : _getSelectionRangeInR2.$head;
|
|
70
|
-
|
|
71
55
|
if ($anchor && $head) {
|
|
72
56
|
return tr.setSelection(new CellSelection($anchor, $head));
|
|
73
57
|
}
|
|
74
58
|
}
|
|
75
|
-
|
|
76
59
|
return tr;
|
|
77
60
|
};
|
|
78
61
|
export const getSelectedColumnIndexes = selectionRect => {
|
|
79
62
|
const columnIndexes = [];
|
|
80
|
-
|
|
81
63
|
for (let i = selectionRect.left; i < selectionRect.right; i++) {
|
|
82
64
|
columnIndexes.push(i);
|
|
83
65
|
}
|
|
84
|
-
|
|
85
66
|
return columnIndexes;
|
|
86
67
|
};
|
|
87
68
|
export const getSelectedRowIndexes = selectionRect => {
|
|
88
69
|
const rowIndexes = [];
|
|
89
|
-
|
|
90
70
|
for (let i = selectionRect.top; i < selectionRect.bottom; i++) {
|
|
91
71
|
rowIndexes.push(i);
|
|
92
72
|
}
|
|
93
|
-
|
|
94
73
|
return rowIndexes;
|
|
95
74
|
};
|
|
@@ -2,11 +2,9 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
2
2
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
3
3
|
export const getMergedCellsPositions = tr => {
|
|
4
4
|
const table = findTable(tr.selection);
|
|
5
|
-
|
|
6
5
|
if (!table) {
|
|
7
6
|
return [];
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
const map = TableMap.get(table.node);
|
|
11
9
|
const cellPositions = new Set();
|
|
12
10
|
const mergedCells = [];
|
package/dist/es2019/version.json
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
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 var clearMultipleCells = function clearMultipleCells(targetCellPosition) {
|
|
7
8
|
return function (state, dispatch) {
|
|
8
9
|
var cursorPos;
|
|
9
10
|
var tr = state.tr;
|
|
10
|
-
|
|
11
11
|
if (isSelectionType(tr.selection, 'cell')) {
|
|
12
12
|
var selection = tr.selection;
|
|
13
13
|
selection.forEachCell(function (_node, pos) {
|
|
@@ -20,22 +20,17 @@ export var clearMultipleCells = function clearMultipleCells(targetCellPosition)
|
|
|
20
20
|
tr = emptyCell(cell, state.schema)(tr);
|
|
21
21
|
cursorPos = cell.pos;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
23
|
if (tr.docChanged && cursorPos) {
|
|
25
24
|
var $pos = tr.doc.resolve(tr.mapping.map(cursorPos));
|
|
26
25
|
var textSelection = Selection.findFrom($pos, 1, true);
|
|
27
|
-
|
|
28
26
|
if (textSelection) {
|
|
29
27
|
tr.setSelection(textSelection);
|
|
30
28
|
}
|
|
31
|
-
|
|
32
29
|
if (dispatch) {
|
|
33
30
|
dispatch(tr);
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
return true;
|
|
37
33
|
}
|
|
38
|
-
|
|
39
34
|
return false;
|
|
40
35
|
};
|
|
41
36
|
};
|
|
@@ -43,6 +38,6 @@ export var clearSelection = function 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 var wrapTableInExpand = function wrapTableInExpand(state, dispatch) {
|
|
3
3
|
var 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
|
};
|
|
@@ -10,28 +10,27 @@ export var goToNextCell = function goToNextCell(editorAnalyticsAPI) {
|
|
|
10
10
|
return function (direction) {
|
|
11
11
|
return function (state, dispatch) {
|
|
12
12
|
var table = findTable(state.selection);
|
|
13
|
-
|
|
14
13
|
if (!table) {
|
|
15
14
|
return false;
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
var map = TableMap.get(table.node);
|
|
19
17
|
var _state$schema$nodes = state.schema.nodes,
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
tableCell = _state$schema$nodes.tableCell,
|
|
19
|
+
tableHeader = _state$schema$nodes.tableHeader;
|
|
22
20
|
var cell = findParentNodeOfType([tableCell, tableHeader])(state.selection);
|
|
23
21
|
var firstCellPos = map.positionAt(0, 0, table.node) + table.start;
|
|
24
|
-
var lastCellPos = map.positionAt(map.height - 1, map.width - 1, table.node) + table.start;
|
|
22
|
+
var lastCellPos = map.positionAt(map.height - 1, map.width - 1, table.node) + table.start;
|
|
25
23
|
|
|
24
|
+
// when tabbing backwards at first cell (top left), insert row at the start of table
|
|
26
25
|
if (firstCellPos === cell.pos && direction === TAB_BACKWARD_DIRECTION) {
|
|
27
26
|
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, {
|
|
28
27
|
index: 0,
|
|
29
28
|
moveCursorToInsertedRow: true
|
|
30
29
|
})(state, dispatch);
|
|
31
30
|
return true;
|
|
32
|
-
}
|
|
33
|
-
|
|
31
|
+
}
|
|
34
32
|
|
|
33
|
+
// when tabbing forwards at last cell (bottom right), insert row at the end of table
|
|
35
34
|
if (lastCellPos === cell.pos && direction === TAB_FORWARD_DIRECTION) {
|
|
36
35
|
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, {
|
|
37
36
|
index: map.height,
|
|
@@ -39,11 +38,9 @@ export var goToNextCell = function goToNextCell(editorAnalyticsAPI) {
|
|
|
39
38
|
})(state, dispatch);
|
|
40
39
|
return true;
|
|
41
40
|
}
|
|
42
|
-
|
|
43
41
|
if (dispatch) {
|
|
44
42
|
return baseGotoNextCell(direction)(state, dispatch);
|
|
45
43
|
}
|
|
46
|
-
|
|
47
44
|
return true;
|
|
48
45
|
};
|
|
49
46
|
};
|
|
@@ -3,29 +3,26 @@ 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';
|
|
7
|
-
// #
|
|
6
|
+
import { createCellHoverDecoration, createColumnLineResize, createControlsHoverDecoration, getMergedCellsPositions, updatePluginStateDecorations } from '../utils';
|
|
7
|
+
// #endregion
|
|
8
8
|
|
|
9
|
+
// #region Utils
|
|
9
10
|
var makeArray = function makeArray(n) {
|
|
10
11
|
return Array.from(Array(n).keys());
|
|
11
|
-
};
|
|
12
|
-
// #
|
|
13
|
-
|
|
12
|
+
};
|
|
13
|
+
// #endregion
|
|
14
14
|
|
|
15
|
+
// #region Commands
|
|
15
16
|
export var hoverMergedCells = function hoverMergedCells() {
|
|
16
17
|
return createCommand(function (state) {
|
|
17
18
|
var mergedCellsPositions = getMergedCellsPositions(state.tr);
|
|
18
|
-
|
|
19
19
|
if (!mergedCellsPositions.length) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
22
|
var table = findTable(state.tr.selection);
|
|
24
|
-
|
|
25
23
|
if (!table) {
|
|
26
24
|
return false;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
26
|
var mergedCells = mergedCellsPositions.map(function (pos) {
|
|
30
27
|
return {
|
|
31
28
|
pos: pos + table.start,
|
|
@@ -47,11 +44,9 @@ export var hoverMergedCells = function hoverMergedCells() {
|
|
|
47
44
|
export var hoverColumns = function hoverColumns(hoveredColumns, isInDanger) {
|
|
48
45
|
return createCommand(function (state) {
|
|
49
46
|
var cells = getCellsInColumn(hoveredColumns)(state.tr.selection);
|
|
50
|
-
|
|
51
47
|
if (!cells) {
|
|
52
48
|
return false;
|
|
53
49
|
}
|
|
54
|
-
|
|
55
50
|
var decorations = createControlsHoverDecoration(cells, 'column', state.tr, isInDanger);
|
|
56
51
|
return {
|
|
57
52
|
type: 'HOVER_COLUMNS',
|
|
@@ -68,11 +63,9 @@ export var hoverColumns = function hoverColumns(hoveredColumns, isInDanger) {
|
|
|
68
63
|
export var hoverRows = function hoverRows(hoveredRows, isInDanger) {
|
|
69
64
|
return createCommand(function (state) {
|
|
70
65
|
var cells = getCellsInRow(hoveredRows)(state.selection);
|
|
71
|
-
|
|
72
66
|
if (!cells) {
|
|
73
67
|
return false;
|
|
74
68
|
}
|
|
75
|
-
|
|
76
69
|
var decorations = createControlsHoverDecoration(cells, 'row', state.tr, isInDanger);
|
|
77
70
|
return {
|
|
78
71
|
type: 'HOVER_ROWS',
|
|
@@ -89,20 +82,16 @@ export var hoverRows = function hoverRows(hoveredRows, isInDanger) {
|
|
|
89
82
|
export var hoverTable = function hoverTable(isInDanger, isSelected) {
|
|
90
83
|
return createCommand(function (state) {
|
|
91
84
|
var table = findTable(state.selection);
|
|
92
|
-
|
|
93
85
|
if (!table) {
|
|
94
86
|
return false;
|
|
95
87
|
}
|
|
96
|
-
|
|
97
88
|
var map = TableMap.get(table.node);
|
|
98
89
|
var hoveredColumns = makeArray(map.width);
|
|
99
90
|
var hoveredRows = makeArray(map.height);
|
|
100
91
|
var cells = getCellsInRow(hoveredRows)(state.selection);
|
|
101
|
-
|
|
102
92
|
if (!cells) {
|
|
103
93
|
return false;
|
|
104
94
|
}
|
|
105
|
-
|
|
106
95
|
var decorations = createControlsHoverDecoration(cells, 'table', state.tr, isInDanger, isSelected);
|
|
107
96
|
return {
|
|
108
97
|
type: 'HOVER_TABLE',
|
|
@@ -147,4 +136,5 @@ export var hideResizeHandleLine = function hideResizeHandleLine() {
|
|
|
147
136
|
}
|
|
148
137
|
};
|
|
149
138
|
});
|
|
150
|
-
};
|
|
139
|
+
};
|
|
140
|
+
// #endregion
|