@atlaskit/editor-plugin-table 1.1.1 → 1.1.3
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 +18 -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 +95 -191
- 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 +18 -43
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +20 -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 +16 -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 +51 -40
- 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 +17 -73
- 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 +58 -49
- 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 +10 -22
- 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 +40 -103
- 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 +14 -17
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +13 -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 +14 -3
- 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 +46 -21
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +31 -61
- 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 +60 -32
- 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 +11 -7
- 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 +95 -184
- 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 +18 -25
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +20 -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 +14 -3
- 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 +49 -26
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +17 -62
- 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 +58 -36
- 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 +9 -10
- 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/dist/types/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +7 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +2 -1
- package/dist/types/plugins/table/ui/common-styles.d.ts +1 -0
- package/package.json +8 -6
- package/src/__tests__/integration/__fixtures__/empty-layout.ts +35 -0
- package/src/__tests__/integration/__fixtures__/nested-in-expand.ts +129 -0
- package/src/__tests__/integration/horizontal-scroll.ts +489 -0
- package/src/__tests__/unit/commands/insert.ts +3 -3
- package/src/__tests__/unit/keymap.ts +3 -1
- package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +38 -0
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +5 -2
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +2 -2
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +2 -2
- package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-2-snap.png +2 -2
- package/src/__tests__/visual-regression/sticky-header.ts +2 -1
- package/src/plugins/table/nodeviews/TableComponent.tsx +16 -3
- package/src/plugins/table/pm-plugins/table-resizing/commands.ts +6 -2
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +9 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/colgroup.ts +19 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +57 -5
- package/src/plugins/table/pm-plugins/table-resizing/utils/resize-logic.ts +2 -2
- package/src/plugins/table/transforms/column-width.ts +60 -6
- package/src/plugins/table/ui/common-styles.ts +5 -2
|
@@ -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 let TableSelectionDirection;
|
|
7
|
-
|
|
8
7
|
(function (TableSelectionDirection) {
|
|
9
8
|
TableSelectionDirection["TopToBottom"] = "TopToBottom";
|
|
10
9
|
TableSelectionDirection["BottomToTop"] = "BottomToTop";
|
|
11
10
|
})(TableSelectionDirection || (TableSelectionDirection = {}));
|
|
12
|
-
|
|
13
11
|
export const arrowLeftFromTable = editorSelectionAPI => () => (state, dispatch) => {
|
|
14
12
|
const {
|
|
15
13
|
selection
|
|
16
14
|
} = state;
|
|
17
|
-
|
|
18
15
|
if (selection instanceof CellSelection) {
|
|
19
16
|
return arrowLeftFromCellSelection(editorSelectionAPI)(selection)(state, dispatch);
|
|
20
17
|
} else if (selection instanceof GapCursorSelection) {
|
|
@@ -22,14 +19,12 @@ export const arrowLeftFromTable = editorSelectionAPI => () => (state, dispatch)
|
|
|
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
|
export const arrowRightFromTable = editorSelectionAPI => () => (state, dispatch) => {
|
|
29
25
|
const {
|
|
30
26
|
selection
|
|
31
27
|
} = state;
|
|
32
|
-
|
|
33
28
|
if (selection instanceof CellSelection) {
|
|
34
29
|
return arrowRightFromCellSelection(editorSelectionAPI)(selection)(state, dispatch);
|
|
35
30
|
} else if (selection instanceof GapCursorSelection) {
|
|
@@ -37,16 +32,13 @@ export const arrowRightFromTable = editorSelectionAPI => () => (state, dispatch)
|
|
|
37
32
|
} else if (selection instanceof TextSelection) {
|
|
38
33
|
return arrowRightFromText(editorSelectionAPI)(selection)(state, dispatch);
|
|
39
34
|
}
|
|
40
|
-
|
|
41
35
|
return false;
|
|
42
36
|
};
|
|
43
|
-
|
|
44
37
|
const arrowLeftFromCellSelection = editorSelectionAPI => selection => (state, dispatch) => {
|
|
45
38
|
if (isTableSelected(state.selection) && editorSelectionAPI) {
|
|
46
39
|
const {
|
|
47
40
|
selectionRelativeToNode
|
|
48
41
|
} = editorSelectionAPI.getSelectionPluginState(state);
|
|
49
|
-
|
|
50
42
|
if (selectionRelativeToNode === RelativeSelectionPos.Start) {
|
|
51
43
|
// we have full table cell selection and want to set gap cursor selection before table
|
|
52
44
|
return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
|
|
@@ -58,16 +50,13 @@ const arrowLeftFromCellSelection = editorSelectionAPI => selection => (state, di
|
|
|
58
50
|
return setSelectionAtStartOfFirstCell(editorSelectionAPI)(selection, RelativeSelectionPos.Before)(state, dispatch);
|
|
59
51
|
}
|
|
60
52
|
}
|
|
61
|
-
|
|
62
53
|
return false;
|
|
63
54
|
};
|
|
64
|
-
|
|
65
55
|
const arrowRightFromCellSelection = editorSelectionAPI => selection => (state, dispatch) => {
|
|
66
56
|
if (isTableSelected(state.selection) && editorSelectionAPI) {
|
|
67
57
|
const {
|
|
68
58
|
selectionRelativeToNode
|
|
69
59
|
} = editorSelectionAPI.getSelectionPluginState(state);
|
|
70
|
-
|
|
71
60
|
if (selectionRelativeToNode === RelativeSelectionPos.Start) {
|
|
72
61
|
// we have full table cell selection and want to set selection at start of first cell
|
|
73
62
|
return setSelectionAtStartOfFirstCell(editorSelectionAPI)(selection)(state, dispatch);
|
|
@@ -76,10 +65,8 @@ const arrowRightFromCellSelection = editorSelectionAPI => selection => (state, d
|
|
|
76
65
|
return setGapCursorAfterTable(editorSelectionAPI)()(state, dispatch);
|
|
77
66
|
}
|
|
78
67
|
}
|
|
79
|
-
|
|
80
68
|
return false;
|
|
81
69
|
};
|
|
82
|
-
|
|
83
70
|
const arrowLeftFromGapCursor = editorSelectionAPI => selection => (state, dispatch) => {
|
|
84
71
|
const {
|
|
85
72
|
doc
|
|
@@ -89,7 +76,6 @@ const arrowLeftFromGapCursor = editorSelectionAPI => selection => (state, dispat
|
|
|
89
76
|
from,
|
|
90
77
|
side
|
|
91
78
|
} = selection;
|
|
92
|
-
|
|
93
79
|
if (side === Side.RIGHT) {
|
|
94
80
|
if ($from.nodeBefore && $from.nodeBefore.type.name === 'table') {
|
|
95
81
|
// we have a gap cursor after a table node and want to set a full table cell selection
|
|
@@ -101,12 +87,10 @@ const arrowLeftFromGapCursor = editorSelectionAPI => selection => (state, dispat
|
|
|
101
87
|
}
|
|
102
88
|
} else if (side === Side.LEFT) {
|
|
103
89
|
const table = findTable(selection);
|
|
104
|
-
|
|
105
90
|
if (table && isSelectionAtStartOfTable($from, selection) && editorSelectionAPI) {
|
|
106
91
|
const {
|
|
107
92
|
selectionRelativeToNode
|
|
108
93
|
} = editorSelectionAPI.getSelectionPluginState(state);
|
|
109
|
-
|
|
110
94
|
if (selectionRelativeToNode === RelativeSelectionPos.Before) {
|
|
111
95
|
// we have a gap cursor at start of first table cell and want to set a gap cursor selection before table
|
|
112
96
|
return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
|
|
@@ -120,10 +104,8 @@ const arrowLeftFromGapCursor = editorSelectionAPI => selection => (state, dispat
|
|
|
120
104
|
}
|
|
121
105
|
}
|
|
122
106
|
}
|
|
123
|
-
|
|
124
107
|
return false;
|
|
125
108
|
};
|
|
126
|
-
|
|
127
109
|
const arrowRightFromGapCursor = editorSelectionAPI => selection => (state, dispatch) => {
|
|
128
110
|
const {
|
|
129
111
|
$from,
|
|
@@ -131,7 +113,6 @@ const arrowRightFromGapCursor = editorSelectionAPI => selection => (state, dispa
|
|
|
131
113
|
$to,
|
|
132
114
|
side
|
|
133
115
|
} = selection;
|
|
134
|
-
|
|
135
116
|
if (side === Side.LEFT) {
|
|
136
117
|
if ($from.nodeAfter && $from.nodeAfter.type.name === 'table') {
|
|
137
118
|
// we have a gap cursor before a table node and want to set a full table cell selection
|
|
@@ -143,7 +124,6 @@ const arrowRightFromGapCursor = editorSelectionAPI => selection => (state, dispa
|
|
|
143
124
|
}
|
|
144
125
|
} else if (side === Side.RIGHT) {
|
|
145
126
|
const table = findTable(selection);
|
|
146
|
-
|
|
147
127
|
if (table && isSelectionAtEndOfTable($to, selection)) {
|
|
148
128
|
// we have a gap cursor at end of last table cell and want to set a full table cell selection
|
|
149
129
|
return selectFullTable(editorSelectionAPI)({
|
|
@@ -153,24 +133,20 @@ const arrowRightFromGapCursor = editorSelectionAPI => selection => (state, dispa
|
|
|
153
133
|
})(state, dispatch);
|
|
154
134
|
}
|
|
155
135
|
}
|
|
156
|
-
|
|
157
136
|
return false;
|
|
158
137
|
};
|
|
159
|
-
|
|
160
138
|
const arrowLeftFromText = editorSelectionAPI => selection => (state, dispatch) => {
|
|
161
139
|
const table = findTable(selection);
|
|
162
|
-
|
|
163
140
|
if (table) {
|
|
164
141
|
const {
|
|
165
142
|
$from
|
|
166
143
|
} = selection;
|
|
167
|
-
|
|
168
|
-
|
|
144
|
+
if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 &&
|
|
145
|
+
// + 3 for: row, cell & paragraph nodes
|
|
169
146
|
editorSelectionAPI) {
|
|
170
147
|
const {
|
|
171
148
|
selectionRelativeToNode
|
|
172
149
|
} = editorSelectionAPI.getSelectionPluginState(state);
|
|
173
|
-
|
|
174
150
|
if (selectionRelativeToNode === RelativeSelectionPos.Before) {
|
|
175
151
|
// we have a text selection at start of first table cell, directly inside a top level paragraph,
|
|
176
152
|
// and want to set gap cursor selection before table
|
|
@@ -186,18 +162,14 @@ const arrowLeftFromText = editorSelectionAPI => selection => (state, dispatch) =
|
|
|
186
162
|
}
|
|
187
163
|
}
|
|
188
164
|
}
|
|
189
|
-
|
|
190
165
|
return false;
|
|
191
166
|
};
|
|
192
|
-
|
|
193
167
|
const arrowRightFromText = editorSelectionAPI => selection => (state, dispatch) => {
|
|
194
168
|
const table = findTable(selection);
|
|
195
|
-
|
|
196
169
|
if (table) {
|
|
197
170
|
const {
|
|
198
171
|
$to
|
|
199
172
|
} = selection;
|
|
200
|
-
|
|
201
173
|
if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 // + 3 for: row, cell & paragraph nodes
|
|
202
174
|
) {
|
|
203
175
|
// we have a text selection at end of last table cell, directly inside a top level paragraph,
|
|
@@ -209,17 +181,15 @@ const arrowRightFromText = editorSelectionAPI => selection => (state, dispatch)
|
|
|
209
181
|
})(state, dispatch);
|
|
210
182
|
}
|
|
211
183
|
}
|
|
212
|
-
|
|
213
184
|
return false;
|
|
214
185
|
};
|
|
186
|
+
|
|
215
187
|
/**
|
|
216
188
|
* Sets a cell selection over all the cells in the table node
|
|
217
189
|
* We use this instead of selectTable from prosemirror-utils so we can control which
|
|
218
190
|
* cell is the anchor and which is the head, and also so we can set the relative selection
|
|
219
191
|
* pos in the selection plugin
|
|
220
192
|
*/
|
|
221
|
-
|
|
222
|
-
|
|
223
193
|
const selectFullTable = editorSelectionAPI => ({
|
|
224
194
|
node,
|
|
225
195
|
startPos,
|
|
@@ -235,7 +205,6 @@ const selectFullTable = editorSelectionAPI => ({
|
|
|
235
205
|
const $lastCell = doc.resolve(startPos + map[map.length - 1]);
|
|
236
206
|
let fullTableSelection;
|
|
237
207
|
let selectionRelativeToNode;
|
|
238
|
-
|
|
239
208
|
if (dir === TableSelectionDirection.TopToBottom) {
|
|
240
209
|
fullTableSelection = new CellSelection($firstCell, $lastCell);
|
|
241
210
|
selectionRelativeToNode = RelativeSelectionPos.End;
|
|
@@ -243,47 +212,40 @@ const selectFullTable = editorSelectionAPI => ({
|
|
|
243
212
|
fullTableSelection = new CellSelection($lastCell, $firstCell);
|
|
244
213
|
selectionRelativeToNode = RelativeSelectionPos.Start;
|
|
245
214
|
}
|
|
246
|
-
|
|
247
215
|
if (editorSelectionAPI) {
|
|
248
216
|
const tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
249
217
|
selectionRelativeToNode,
|
|
250
218
|
selection: fullTableSelection
|
|
251
219
|
})(state);
|
|
252
|
-
|
|
253
220
|
if (dispatch) {
|
|
254
221
|
dispatch(tr);
|
|
255
222
|
return true;
|
|
256
223
|
}
|
|
257
224
|
}
|
|
258
|
-
|
|
259
225
|
return false;
|
|
260
226
|
};
|
|
261
|
-
|
|
262
227
|
const setSelectionAtStartOfFirstCell = editorSelectionAPI => (selection, selectionRelativeToNode) => (state, dispatch) => {
|
|
263
228
|
const {
|
|
264
229
|
$anchorCell,
|
|
265
230
|
$headCell
|
|
266
231
|
} = selection;
|
|
267
232
|
const $firstCell = $anchorCell.pos < $headCell.pos ? $anchorCell : $headCell;
|
|
268
|
-
const $firstPosInsideCell = state.doc.resolve($firstCell.pos + 1);
|
|
233
|
+
const $firstPosInsideCell = state.doc.resolve($firstCell.pos + 1);
|
|
269
234
|
|
|
235
|
+
// check if first pos should have a gap cursor, otherwise find closest text selection
|
|
270
236
|
const selectionAtStartOfCell = GapCursorSelection.valid($firstPosInsideCell) ? new GapCursorSelection($firstPosInsideCell, Side.LEFT) : Selection.findFrom($firstPosInsideCell, 1);
|
|
271
|
-
|
|
272
237
|
if (editorSelectionAPI) {
|
|
273
238
|
const tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
274
239
|
selectionRelativeToNode,
|
|
275
240
|
selection: selectionAtStartOfCell
|
|
276
241
|
})(state);
|
|
277
|
-
|
|
278
242
|
if (dispatch) {
|
|
279
243
|
dispatch(tr);
|
|
280
244
|
return true;
|
|
281
245
|
}
|
|
282
246
|
}
|
|
283
|
-
|
|
284
247
|
return false;
|
|
285
248
|
};
|
|
286
|
-
|
|
287
249
|
const setSelectionAtEndOfLastCell = editorSelectionAPI => (selection, selectionRelativeToNode) => (state, dispatch) => {
|
|
288
250
|
const {
|
|
289
251
|
$anchorCell,
|
|
@@ -291,40 +253,33 @@ const setSelectionAtEndOfLastCell = editorSelectionAPI => (selection, selectionR
|
|
|
291
253
|
} = selection;
|
|
292
254
|
const $lastCell = $anchorCell.pos > $headCell.pos ? $anchorCell : $headCell;
|
|
293
255
|
const lastPosInsideCell = $lastCell.pos + ($lastCell.nodeAfter ? $lastCell.nodeAfter.content.size : 0) + 1;
|
|
294
|
-
const $lastPosInsideCell = state.doc.resolve(lastPosInsideCell);
|
|
256
|
+
const $lastPosInsideCell = state.doc.resolve(lastPosInsideCell);
|
|
295
257
|
|
|
258
|
+
// check if last pos should have a gap cursor, otherwise find closest text selection
|
|
296
259
|
const selectionAtEndOfCell = GapCursorSelection.valid($lastPosInsideCell) ? new GapCursorSelection($lastPosInsideCell, Side.RIGHT) : Selection.findFrom($lastPosInsideCell, -1);
|
|
297
|
-
|
|
298
260
|
if (editorSelectionAPI) {
|
|
299
261
|
const tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
300
262
|
selectionRelativeToNode,
|
|
301
263
|
selection: selectionAtEndOfCell
|
|
302
264
|
})(state);
|
|
303
|
-
|
|
304
265
|
if (dispatch) {
|
|
305
266
|
dispatch(tr);
|
|
306
267
|
return true;
|
|
307
268
|
}
|
|
308
269
|
}
|
|
309
|
-
|
|
310
270
|
return false;
|
|
311
271
|
};
|
|
312
|
-
|
|
313
272
|
const setGapCursorBeforeTable = editorSelectionAPI => () => (state, dispatch) => {
|
|
314
273
|
const table = findTable(state.selection);
|
|
315
|
-
|
|
316
274
|
if (table) {
|
|
317
275
|
const $beforeTablePos = state.doc.resolve(table.pos);
|
|
318
|
-
|
|
319
276
|
if (GapCursorSelection.valid($beforeTablePos)) {
|
|
320
277
|
const selectionBeforeTable = new GapCursorSelection($beforeTablePos, Side.LEFT);
|
|
321
|
-
|
|
322
278
|
if (editorSelectionAPI) {
|
|
323
279
|
const tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
324
280
|
selectionRelativeToNode: undefined,
|
|
325
281
|
selection: selectionBeforeTable
|
|
326
282
|
})(state);
|
|
327
|
-
|
|
328
283
|
if (dispatch) {
|
|
329
284
|
dispatch(tr);
|
|
330
285
|
return true;
|
|
@@ -332,38 +287,28 @@ const setGapCursorBeforeTable = editorSelectionAPI => () => (state, dispatch) =>
|
|
|
332
287
|
}
|
|
333
288
|
}
|
|
334
289
|
}
|
|
335
|
-
|
|
336
290
|
return false;
|
|
337
291
|
};
|
|
338
|
-
|
|
339
292
|
const setGapCursorAfterTable = editorSelectionAPI => () => (state, dispatch) => {
|
|
340
293
|
const table = findTable(state.selection);
|
|
341
|
-
|
|
342
294
|
if (table) {
|
|
343
295
|
const $afterTablePos = state.doc.resolve(table.pos + table.node.nodeSize);
|
|
344
|
-
|
|
345
296
|
if (GapCursorSelection.valid($afterTablePos)) {
|
|
346
297
|
const selectionAfterTable = new GapCursorSelection($afterTablePos, Side.RIGHT);
|
|
347
|
-
|
|
348
298
|
if (editorSelectionAPI) {
|
|
349
299
|
const tr = editorSelectionAPI.setSelectionRelativeToNode({
|
|
350
300
|
selectionRelativeToNode: undefined,
|
|
351
301
|
selection: selectionAfterTable
|
|
352
302
|
})(state);
|
|
353
|
-
|
|
354
303
|
if (dispatch) {
|
|
355
304
|
dispatch(tr);
|
|
356
305
|
return true;
|
|
357
306
|
}
|
|
358
307
|
}
|
|
359
|
-
|
|
360
308
|
return false;
|
|
361
309
|
}
|
|
362
310
|
}
|
|
363
|
-
|
|
364
311
|
return false;
|
|
365
312
|
};
|
|
366
|
-
|
|
367
313
|
const isSelectionAtStartOfTable = ($pos, selection) => isSelectionAtStartOfNode($pos, findTable(selection));
|
|
368
|
-
|
|
369
314
|
const isSelectionAtEndOfTable = ($pos, selection) => isSelectionAtEndOfNode($pos, findTable(selection));
|
|
@@ -5,24 +5,20 @@ 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 attrs => {
|
|
11
10
|
const {
|
|
12
11
|
data
|
|
13
12
|
} = attrs;
|
|
14
|
-
|
|
15
13
|
if (data && (data.name || data.title)) {
|
|
16
14
|
return data.name || data.title;
|
|
17
15
|
}
|
|
18
|
-
|
|
19
16
|
const {
|
|
20
17
|
url: cardUrl
|
|
21
18
|
} = attrs;
|
|
22
19
|
return cardUrl;
|
|
23
20
|
};
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
export const sortByColumn = (columnIndex, order = SortOrder.DESC) => createCommand(state => ({
|
|
27
23
|
type: 'SORT_TABLE',
|
|
28
24
|
data: {
|
|
@@ -33,34 +29,26 @@ export const sortByColumn = (columnIndex, order = SortOrder.DESC) => createComma
|
|
|
33
29
|
}
|
|
34
30
|
}), (tr, state) => {
|
|
35
31
|
const table = findTable(tr.selection);
|
|
36
|
-
|
|
37
32
|
if (!table || !table.node) {
|
|
38
33
|
return tr;
|
|
39
34
|
}
|
|
40
|
-
|
|
41
35
|
const selectionRect = isSelectionType(tr.selection, 'cell') ? getSelectionRect(tr.selection) : findCellRectClosestToPos(tr.selection.$from);
|
|
42
|
-
|
|
43
36
|
if (!selectionRect) {
|
|
44
37
|
return tr;
|
|
45
38
|
}
|
|
46
|
-
|
|
47
39
|
const tablePluginState = getPluginState(state);
|
|
48
40
|
const tableArray = convertTableNodeToArrayOfRows(table.node);
|
|
49
41
|
let headerRow;
|
|
50
|
-
|
|
51
42
|
if (tablePluginState.isHeaderRowEnabled) {
|
|
52
43
|
headerRow = tableArray.shift();
|
|
53
44
|
}
|
|
54
|
-
|
|
55
45
|
const compareNodesInOrder = createCompareNodes({
|
|
56
46
|
getInlineCardTextFromStore: createGetInlineCardTextFromStore(state)
|
|
57
47
|
}, order);
|
|
58
48
|
const sortedTable = tableArray.sort((rowA, rowB) => compareNodesInOrder(rowA[columnIndex], rowB[columnIndex]));
|
|
59
|
-
|
|
60
49
|
if (headerRow) {
|
|
61
50
|
sortedTable.unshift(headerRow);
|
|
62
51
|
}
|
|
63
|
-
|
|
64
52
|
const newTableNode = convertArrayOfRowsToTableNode(table.node, sortedTable);
|
|
65
53
|
tr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTableNode);
|
|
66
54
|
const 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.
|
|
@@ -11,7 +10,6 @@ export const splitCell = (state, dispatch) => {
|
|
|
11
10
|
tableHeader,
|
|
12
11
|
tableCell
|
|
13
12
|
} = state.schema.nodes;
|
|
14
|
-
|
|
15
13
|
if (dispatch) {
|
|
16
14
|
return splitCellWithType(({
|
|
17
15
|
row,
|
|
@@ -20,10 +18,8 @@ export const splitCell = (state, dispatch) => {
|
|
|
20
18
|
if (row === 0 && tableState.isHeaderRowEnabled || col === 0 && tableState.isHeaderColumnEnabled) {
|
|
21
19
|
return tableHeader;
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
return tableCell;
|
|
25
22
|
})(state, dispatch);
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
return true;
|
|
29
25
|
};
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
//#region Imports
|
|
2
|
+
|
|
2
3
|
import { toggleHeader } from '@atlaskit/editor-tables/utils';
|
|
3
4
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
4
|
-
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
5
|
-
|
|
5
|
+
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
6
|
+
//#endregion
|
|
6
7
|
|
|
8
|
+
// #region Utils
|
|
7
9
|
/**
|
|
8
10
|
* Table layout toggle logic
|
|
9
11
|
* default -> wide -> full-width -> default
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
13
|
export const getNextLayout = currentLayout => {
|
|
13
14
|
switch (currentLayout) {
|
|
14
15
|
case 'default':
|
|
15
16
|
return 'wide';
|
|
16
|
-
|
|
17
17
|
case 'wide':
|
|
18
18
|
return 'full-width';
|
|
19
|
-
|
|
20
19
|
case 'full-width':
|
|
21
20
|
return 'default';
|
|
22
|
-
|
|
23
21
|
default:
|
|
24
22
|
return 'default';
|
|
25
23
|
}
|
|
26
|
-
};
|
|
27
|
-
// #
|
|
24
|
+
};
|
|
25
|
+
// #endregion
|
|
28
26
|
|
|
27
|
+
// #region Actions
|
|
29
28
|
export const toggleHeaderRow = (state, dispatch) => toggleHeader('row')(state, tr => createCommand({
|
|
30
29
|
type: 'TOGGLE_HEADER_ROW'
|
|
31
30
|
}, () => tr.setMeta('scrollIntoView', false))(state, dispatch));
|
|
@@ -40,24 +39,21 @@ export const toggleNumberColumn = (state, dispatch) => {
|
|
|
40
39
|
node,
|
|
41
40
|
pos
|
|
42
41
|
} = findTable(state.selection);
|
|
43
|
-
tr.setNodeMarkup(pos, state.schema.nodes.table, {
|
|
42
|
+
tr.setNodeMarkup(pos, state.schema.nodes.table, {
|
|
43
|
+
...node.attrs,
|
|
44
44
|
isNumberColumnEnabled: !node.attrs.isNumberColumnEnabled
|
|
45
45
|
});
|
|
46
46
|
tr.setMeta('scrollIntoView', false);
|
|
47
|
-
|
|
48
47
|
if (dispatch) {
|
|
49
48
|
dispatch(tr);
|
|
50
49
|
}
|
|
51
|
-
|
|
52
50
|
return true;
|
|
53
51
|
};
|
|
54
52
|
export const toggleTableLayout = (state, dispatch) => {
|
|
55
53
|
const table = findTable(state.selection);
|
|
56
|
-
|
|
57
54
|
if (!table) {
|
|
58
55
|
return false;
|
|
59
56
|
}
|
|
60
|
-
|
|
61
57
|
const layout = getNextLayout(table.node.attrs.layout);
|
|
62
58
|
return createCommand({
|
|
63
59
|
type: 'SET_TABLE_LAYOUT',
|
|
@@ -65,7 +61,8 @@ export const toggleTableLayout = (state, dispatch) => {
|
|
|
65
61
|
layout
|
|
66
62
|
}
|
|
67
63
|
}, tr => {
|
|
68
|
-
tr.setNodeMarkup(table.pos, state.schema.nodes.table, {
|
|
64
|
+
tr.setNodeMarkup(table.pos, state.schema.nodes.table, {
|
|
65
|
+
...table.node.attrs,
|
|
69
66
|
layout
|
|
70
67
|
});
|
|
71
68
|
return tr.setMeta('scrollIntoView', false);
|
|
@@ -73,4 +70,5 @@ export const toggleTableLayout = (state, dispatch) => {
|
|
|
73
70
|
};
|
|
74
71
|
export const toggleContextualMenu = () => createCommand({
|
|
75
72
|
type: 'TOGGLE_CONTEXTUAL_MENU'
|
|
76
|
-
}, tr => tr.setMeta('addToHistory', false));
|
|
73
|
+
}, tr => tr.setMeta('addToHistory', false));
|
|
74
|
+
// #endregion
|
|
@@ -19,8 +19,9 @@ const TABLE_BREAKOUT_NAME_MAPPING = {
|
|
|
19
19
|
default: TABLE_BREAKOUT.NORMAL,
|
|
20
20
|
wide: TABLE_BREAKOUT.WIDE,
|
|
21
21
|
'full-width': TABLE_BREAKOUT.FULL_WIDTH
|
|
22
|
-
};
|
|
22
|
+
};
|
|
23
23
|
|
|
24
|
+
// #region Analytics wrappers
|
|
24
25
|
export const emptyMultipleCellsWithAnalytics = editorAnalyticsAPI => (inputMethod, targetCellPosition) => withEditorAnalyticsAPI(({
|
|
25
26
|
selection
|
|
26
27
|
}) => {
|
|
@@ -72,7 +73,6 @@ export const mergeCellsWithAnalytics = editorAnalyticsAPI => inputMethod => with
|
|
|
72
73
|
if (dispatch) {
|
|
73
74
|
dispatch(mergeCells(state.tr));
|
|
74
75
|
}
|
|
75
|
-
|
|
76
76
|
return true;
|
|
77
77
|
});
|
|
78
78
|
export const splitCellWithAnalytics = editorAnalyticsAPI => inputMethod => withEditorAnalyticsAPI(({
|
|
@@ -83,7 +83,6 @@ export const splitCellWithAnalytics = editorAnalyticsAPI => inputMethod => withE
|
|
|
83
83
|
totalColumnCount
|
|
84
84
|
} = getSelectedCellInfo(selection);
|
|
85
85
|
const cell = findCellClosestToPos(selection.$anchor);
|
|
86
|
-
|
|
87
86
|
if (cell) {
|
|
88
87
|
const {
|
|
89
88
|
rowspan: verticalCells,
|
|
@@ -104,7 +103,6 @@ export const splitCellWithAnalytics = editorAnalyticsAPI => inputMethod => withE
|
|
|
104
103
|
eventType: EVENT_TYPE.TRACK
|
|
105
104
|
};
|
|
106
105
|
}
|
|
107
|
-
|
|
108
106
|
return;
|
|
109
107
|
})(editorAnalyticsAPI)(splitCell);
|
|
110
108
|
export const setColorWithAnalytics = editorAnalyticsAPI => (inputMethod, cellColor, targetCellPosition) => withEditorAnalyticsAPI(({
|
|
@@ -141,11 +139,9 @@ export const addRowAroundSelection = editorAnalyticsAPI => side => (state, dispa
|
|
|
141
139
|
} = state;
|
|
142
140
|
const isCellSelection = selection instanceof CellSelection;
|
|
143
141
|
const rect = isCellSelection ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
144
|
-
|
|
145
142
|
if (!rect) {
|
|
146
143
|
return false;
|
|
147
144
|
}
|
|
148
|
-
|
|
149
145
|
const position = isCellSelection && side === 'TOP' ? rect.top : rect.bottom - 1;
|
|
150
146
|
const offset = side === 'BOTTOM' ? 1 : 0;
|
|
151
147
|
return insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, {
|
|
@@ -213,7 +209,6 @@ export const deleteRowsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect,
|
|
|
213
209
|
if (dispatch) {
|
|
214
210
|
dispatch(deleteRows(rect, isHeaderRowRequired)(state.tr));
|
|
215
211
|
}
|
|
216
|
-
|
|
217
212
|
return true;
|
|
218
213
|
});
|
|
219
214
|
export const deleteColumnsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect) => withEditorAnalyticsAPI(({
|
|
@@ -240,10 +235,8 @@ export const deleteColumnsWithAnalytics = editorAnalyticsAPI => (inputMethod, re
|
|
|
240
235
|
if (dispatch) {
|
|
241
236
|
dispatch(deleteColumns(rect, getAllowAddColumnCustomStep(state))(state.tr));
|
|
242
237
|
}
|
|
243
|
-
|
|
244
238
|
return true;
|
|
245
239
|
});
|
|
246
|
-
|
|
247
240
|
const getTableDeletedAnalytics = (selection, inputMethod) => {
|
|
248
241
|
const {
|
|
249
242
|
totalRowCount,
|
|
@@ -260,7 +253,6 @@ const getTableDeletedAnalytics = (selection, inputMethod) => {
|
|
|
260
253
|
eventType: EVENT_TYPE.TRACK
|
|
261
254
|
};
|
|
262
255
|
};
|
|
263
|
-
|
|
264
256
|
export const deleteTableWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsAPI(({
|
|
265
257
|
selection
|
|
266
258
|
}) => getTableDeletedAnalytics(selection, INPUT_METHOD.FLOATING_TB))(editorAnalyticsAPI)(deleteTable);
|
|
@@ -330,7 +322,6 @@ export const toggleTableLayoutWithAnalytics = editorAnalyticsAPI => withEditorAn
|
|
|
330
322
|
totalRowCount,
|
|
331
323
|
totalColumnCount
|
|
332
324
|
} = getSelectedTableInfo(state.selection);
|
|
333
|
-
|
|
334
325
|
if (table) {
|
|
335
326
|
const {
|
|
336
327
|
layout
|
|
@@ -348,7 +339,6 @@ export const toggleTableLayoutWithAnalytics = editorAnalyticsAPI => withEditorAn
|
|
|
348
339
|
eventType: EVENT_TYPE.TRACK
|
|
349
340
|
};
|
|
350
341
|
}
|
|
351
|
-
|
|
352
342
|
return;
|
|
353
343
|
})(editorAnalyticsAPI)(toggleTableLayout);
|
|
354
344
|
export const sortColumnWithAnalytics = editorAnalyticsAPI => (inputMethod, columnIndex, sortOrder) => withEditorAnalyticsAPI(state => {
|
|
@@ -390,7 +380,6 @@ export const distributeColumnsWidthsWithAnalytics = editorAnalyticsAPI => (input
|
|
|
390
380
|
if (dispatch) {
|
|
391
381
|
distributeColumnsWidths(resizeState, table)(state, dispatch);
|
|
392
382
|
}
|
|
393
|
-
|
|
394
383
|
return true;
|
|
395
384
|
});
|
|
396
385
|
};
|
|
@@ -409,4 +398,5 @@ export const wrapTableInExpandWithAnalytics = editorAnalyticsAPI => withEditorAn
|
|
|
409
398
|
},
|
|
410
399
|
eventType: EVENT_TYPE.TRACK
|
|
411
400
|
};
|
|
412
|
-
})(editorAnalyticsAPI)(wrapTableInExpand);
|
|
401
|
+
})(editorAnalyticsAPI)(wrapTableInExpand);
|
|
402
|
+
// #endregion
|