@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
|
@@ -1,42 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.isRowDeleteButtonVisible = exports.getRowsParams = exports.getRowHeights = exports.getRowDeleteButtonParams = exports.getRowClassNames = exports.copyPreviousRow = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
13
|
-
|
|
14
10
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
15
|
-
|
|
16
11
|
var _prosemirrorUtils = require("prosemirror-utils");
|
|
17
|
-
|
|
18
12
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
19
|
-
|
|
20
13
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
21
|
-
|
|
22
14
|
var _types = require("../types");
|
|
23
|
-
|
|
24
15
|
var _consts = require("../ui/consts");
|
|
25
|
-
|
|
26
16
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
-
|
|
28
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
29
|
-
|
|
30
18
|
var getRowHeights = function getRowHeights(tableRef) {
|
|
31
19
|
var heights = [];
|
|
32
|
-
|
|
33
20
|
if (tableRef.lastChild) {
|
|
34
21
|
var rows = tableRef.lastChild.childNodes;
|
|
35
|
-
|
|
36
22
|
for (var i = 0, count = rows.length; i < count; i++) {
|
|
37
23
|
var row = rows[i];
|
|
38
|
-
heights[i] = row.getBoundingClientRect().height + 1;
|
|
24
|
+
heights[i] = row.getBoundingClientRect().height + 1;
|
|
39
25
|
|
|
26
|
+
// padding only gets applied when the container has sticky
|
|
40
27
|
if (row.classList.contains('sticky') && i === 0) {
|
|
41
28
|
var styles = window.getComputedStyle(row);
|
|
42
29
|
var paddingTop = (0, _utils2.parsePx)(styles.paddingTop || '');
|
|
@@ -44,133 +31,99 @@ var getRowHeights = function getRowHeights(tableRef) {
|
|
|
44
31
|
}
|
|
45
32
|
}
|
|
46
33
|
}
|
|
47
|
-
|
|
48
34
|
return heights;
|
|
49
35
|
};
|
|
50
|
-
|
|
51
36
|
exports.getRowHeights = getRowHeights;
|
|
52
|
-
|
|
53
37
|
var isRowDeleteButtonVisible = function isRowDeleteButtonVisible(selection) {
|
|
54
38
|
if (!(0, _utils.isTableSelected)(selection) && selection instanceof _cellSelection.CellSelection && selection.isRowSelection()) {
|
|
55
39
|
return true;
|
|
56
40
|
}
|
|
57
|
-
|
|
58
41
|
return false;
|
|
59
42
|
};
|
|
60
|
-
|
|
61
43
|
exports.isRowDeleteButtonVisible = isRowDeleteButtonVisible;
|
|
62
|
-
|
|
63
44
|
var getRowDeleteButtonParams = function getRowDeleteButtonParams(rowsHeights, selection) {
|
|
64
45
|
var offsetTop = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
65
46
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
66
|
-
|
|
67
47
|
if (!rect) {
|
|
68
48
|
return null;
|
|
69
49
|
}
|
|
70
|
-
|
|
71
50
|
var height = 0;
|
|
72
|
-
var offset = offsetTop;
|
|
73
|
-
|
|
51
|
+
var offset = offsetTop;
|
|
52
|
+
// find the rows before the selection
|
|
74
53
|
for (var i = 0; i < rect.top; i++) {
|
|
75
54
|
var rowHeight = rowsHeights[i];
|
|
76
|
-
|
|
77
55
|
if (rowHeight) {
|
|
78
56
|
offset += rowHeight - 1;
|
|
79
57
|
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
58
|
+
}
|
|
59
|
+
// these are the selected rows widths
|
|
83
60
|
var indexes = [];
|
|
84
|
-
|
|
85
61
|
for (var _i = rect.top; _i < rect.bottom; _i++) {
|
|
86
62
|
var _rowHeight = rowsHeights[_i];
|
|
87
|
-
|
|
88
63
|
if (_rowHeight) {
|
|
89
64
|
height += _rowHeight - 1;
|
|
90
65
|
indexes.push(_i);
|
|
91
66
|
}
|
|
92
67
|
}
|
|
93
|
-
|
|
94
68
|
var top = offset + height / 2 - _consts.tableDeleteButtonSize / 2;
|
|
95
69
|
return {
|
|
96
70
|
top: top,
|
|
97
71
|
indexes: indexes
|
|
98
72
|
};
|
|
99
73
|
};
|
|
100
|
-
|
|
101
74
|
exports.getRowDeleteButtonParams = getRowDeleteButtonParams;
|
|
102
|
-
|
|
103
75
|
var getRowsParams = function getRowsParams(rowsHeights) {
|
|
104
76
|
var rows = [];
|
|
105
|
-
|
|
106
77
|
for (var i = 0, count = rowsHeights.length; i < count; i++) {
|
|
107
78
|
var height = rowsHeights[i];
|
|
108
|
-
|
|
109
79
|
if (!height) {
|
|
110
80
|
continue;
|
|
111
81
|
}
|
|
112
|
-
|
|
113
82
|
var endIndex = rowsHeights.length;
|
|
114
|
-
|
|
115
83
|
for (var k = i + 1, _count = rowsHeights.length; k < _count; k++) {
|
|
116
84
|
if (rowsHeights[k]) {
|
|
117
85
|
endIndex = k;
|
|
118
86
|
break;
|
|
119
87
|
}
|
|
120
88
|
}
|
|
121
|
-
|
|
122
89
|
rows.push({
|
|
123
90
|
startIndex: i,
|
|
124
91
|
endIndex: endIndex,
|
|
125
92
|
height: height
|
|
126
93
|
});
|
|
127
94
|
}
|
|
128
|
-
|
|
129
95
|
return rows;
|
|
130
96
|
};
|
|
131
|
-
|
|
132
97
|
exports.getRowsParams = getRowsParams;
|
|
133
|
-
|
|
134
98
|
var getRowClassNames = function getRowClassNames(index, selection) {
|
|
135
99
|
var hoveredRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
136
100
|
var isInDanger = arguments.length > 3 ? arguments[3] : undefined;
|
|
137
101
|
var isResizing = arguments.length > 4 ? arguments[4] : undefined;
|
|
138
102
|
var classNames = [];
|
|
139
|
-
|
|
140
103
|
if ((0, _utils.isRowSelected)(index)(selection) || hoveredRows.indexOf(index) > -1 && !isResizing) {
|
|
141
104
|
classNames.push(_types.TableCssClassName.HOVERED_CELL_ACTIVE);
|
|
142
|
-
|
|
143
105
|
if (isInDanger) {
|
|
144
106
|
classNames.push(_types.TableCssClassName.HOVERED_CELL_IN_DANGER);
|
|
145
107
|
}
|
|
146
108
|
}
|
|
147
|
-
|
|
148
109
|
return classNames.join(' ');
|
|
149
110
|
};
|
|
150
|
-
|
|
151
111
|
exports.getRowClassNames = getRowClassNames;
|
|
152
|
-
|
|
153
112
|
var copyPreviousRow = function copyPreviousRow(schema) {
|
|
154
113
|
return function (insertNewRowIndex) {
|
|
155
114
|
return function (tr) {
|
|
156
115
|
var table = (0, _utils.findTable)(tr.selection);
|
|
157
|
-
|
|
158
116
|
if (!table) {
|
|
159
117
|
return tr;
|
|
160
118
|
}
|
|
161
|
-
|
|
162
119
|
var map = _tableMap.TableMap.get(table.node);
|
|
163
|
-
|
|
164
120
|
var copyPreviousRowIndex = insertNewRowIndex - 1;
|
|
165
|
-
|
|
166
121
|
if (insertNewRowIndex <= 0) {
|
|
167
122
|
throw Error("Row Index less or equal 0 isn't not allowed since there is not a previous to copy");
|
|
168
123
|
}
|
|
169
|
-
|
|
170
124
|
if (insertNewRowIndex > map.height) {
|
|
171
125
|
return tr;
|
|
172
126
|
}
|
|
173
|
-
|
|
174
127
|
var tableNode = table.node;
|
|
175
128
|
var tableRow = schema.nodes.tableRow;
|
|
176
129
|
var cellsInRow = map.cellsInRect({
|
|
@@ -185,27 +138,21 @@ var copyPreviousRow = function copyPreviousRow(schema) {
|
|
|
185
138
|
var cellsPositionsInNextRow = map.map.slice(offsetNextLineIndexPosition, offsetNextLineIndexPosition + map.width);
|
|
186
139
|
var cells = [];
|
|
187
140
|
var fixRowspans = [];
|
|
188
|
-
|
|
189
141
|
for (var i = 0; i < cellsPositionsInOriginalRow.length;) {
|
|
190
142
|
var pos = cellsPositionsInOriginalRow[i];
|
|
191
143
|
var documentCellPos = pos + table.start;
|
|
192
144
|
var node = tr.doc.nodeAt(documentCellPos);
|
|
193
|
-
|
|
194
145
|
if (!node) {
|
|
195
146
|
continue;
|
|
196
147
|
}
|
|
197
|
-
|
|
198
148
|
var attributes = _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
199
149
|
colspan: 1,
|
|
200
150
|
rowspan: 1
|
|
201
151
|
});
|
|
202
|
-
|
|
203
152
|
var newCell = node.type.createAndFill(attributes);
|
|
204
|
-
|
|
205
153
|
if (!newCell) {
|
|
206
154
|
return tr;
|
|
207
155
|
}
|
|
208
|
-
|
|
209
156
|
if (cellsPositionsInNextRow.indexOf(pos) > -1) {
|
|
210
157
|
fixRowspans.push({
|
|
211
158
|
pos: documentCellPos,
|
|
@@ -216,24 +163,19 @@ var copyPreviousRow = function copyPreviousRow(schema) {
|
|
|
216
163
|
var newCellWithColspanFixed = node.type.createAndFill(_objectSpread(_objectSpread({}, attributes), {}, {
|
|
217
164
|
colspan: node.attrs.colspan
|
|
218
165
|
}));
|
|
219
|
-
|
|
220
166
|
if (!newCellWithColspanFixed) {
|
|
221
167
|
return tr;
|
|
222
168
|
}
|
|
223
|
-
|
|
224
169
|
cells.push(newCellWithColspanFixed);
|
|
225
170
|
i = i + node.attrs.colspan;
|
|
226
171
|
continue;
|
|
227
172
|
}
|
|
228
|
-
|
|
229
173
|
cells.push(newCell);
|
|
230
174
|
} else {
|
|
231
175
|
cells.push(newCell);
|
|
232
176
|
}
|
|
233
|
-
|
|
234
177
|
i++;
|
|
235
178
|
}
|
|
236
|
-
|
|
237
179
|
fixRowspans.forEach(function (cell) {
|
|
238
180
|
tr.setNodeMarkup(cell.pos, undefined, _objectSpread(_objectSpread({}, cell.node.attrs), {}, {
|
|
239
181
|
rowspan: cell.node.attrs.rowspan + 1
|
|
@@ -241,14 +183,11 @@ var copyPreviousRow = function copyPreviousRow(schema) {
|
|
|
241
183
|
});
|
|
242
184
|
var cloneRow = tableNode.child(copyPreviousRowIndex);
|
|
243
185
|
var rowPos = table.start;
|
|
244
|
-
|
|
245
186
|
for (var _i2 = 0; _i2 < insertNewRowIndex; _i2++) {
|
|
246
187
|
rowPos += tableNode.child(_i2).nodeSize;
|
|
247
188
|
}
|
|
248
|
-
|
|
249
189
|
return (0, _prosemirrorUtils.safeInsert)(tableRow.createChecked(cloneRow.attrs, cells, cloneRow.marks), rowPos)(tr);
|
|
250
190
|
};
|
|
251
191
|
};
|
|
252
192
|
};
|
|
253
|
-
|
|
254
193
|
exports.copyPreviousRow = copyPreviousRow;
|
|
@@ -4,113 +4,80 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.normalizeSelection = exports.isSelectionUpdated = exports.getSelectedRowIndexes = exports.getSelectedColumnIndexes = void 0;
|
|
7
|
-
|
|
8
7
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
9
|
-
|
|
10
8
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
11
|
-
|
|
12
9
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
13
|
-
|
|
14
10
|
var isSelectionUpdated = function isSelectionUpdated(oldSelection, newSelection) {
|
|
15
11
|
return !!(!newSelection && oldSelection) || (0, _utils.isSelectionType)(oldSelection, 'cell') !== (0, _utils.isSelectionType)(newSelection, 'cell') || (0, _utils.isSelectionType)(oldSelection, 'cell') && (0, _utils.isSelectionType)(newSelection, 'cell') && oldSelection.ranges !== newSelection.ranges;
|
|
16
12
|
};
|
|
17
|
-
|
|
18
13
|
exports.isSelectionUpdated = isSelectionUpdated;
|
|
19
|
-
|
|
20
14
|
var isRectangularCellSelection = function isRectangularCellSelection(selection, rect) {
|
|
21
15
|
var table = (0, _utils.findTable)(selection);
|
|
22
|
-
|
|
23
16
|
if (!table) {
|
|
24
17
|
return true;
|
|
25
18
|
}
|
|
26
|
-
|
|
27
19
|
var _TableMap$get = _tableMap.TableMap.get(table.node),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
width = _TableMap$get.width,
|
|
21
|
+
height = _TableMap$get.height,
|
|
22
|
+
map = _TableMap$get.map;
|
|
32
23
|
var indexTop = rect.top * width + rect.left;
|
|
33
24
|
var indexLeft = indexTop;
|
|
34
25
|
var indexBottom = (rect.bottom - 1) * width + rect.left;
|
|
35
26
|
var indexRight = indexTop + (rect.right - rect.left - 1);
|
|
36
|
-
|
|
37
27
|
for (var i = rect.top; i < rect.bottom; i++) {
|
|
38
28
|
if (rect.left > 0 && map[indexLeft] === map[indexLeft - 1] || rect.right < width && map[indexRight] === map[indexRight + 1]) {
|
|
39
29
|
return false;
|
|
40
30
|
}
|
|
41
|
-
|
|
42
31
|
indexLeft += width;
|
|
43
32
|
indexRight += width;
|
|
44
33
|
}
|
|
45
|
-
|
|
46
34
|
for (var _i = rect.left; _i < rect.right; _i++) {
|
|
47
35
|
if (rect.top > 0 && map[indexTop] === map[indexTop - width] || rect.bottom < height && map[indexBottom] === map[indexBottom + width]) {
|
|
48
36
|
return false;
|
|
49
37
|
}
|
|
50
|
-
|
|
51
38
|
indexTop++;
|
|
52
39
|
indexBottom++;
|
|
53
40
|
}
|
|
54
|
-
|
|
55
41
|
return true;
|
|
56
42
|
};
|
|
57
|
-
|
|
58
43
|
var normalizeSelection = function normalizeSelection(tr) {
|
|
59
44
|
var selection = tr.selection;
|
|
60
45
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
61
|
-
|
|
62
46
|
if (!rect || !(selection instanceof _cellSelection.CellSelection) || isRectangularCellSelection(selection, rect)) {
|
|
63
47
|
return tr;
|
|
64
48
|
}
|
|
65
|
-
|
|
66
49
|
if (selection.isColSelection()) {
|
|
67
50
|
var _getSelectionRangeInC, _getSelectionRangeInC2;
|
|
68
|
-
|
|
69
51
|
var $anchor = (_getSelectionRangeInC = (0, _utils.getSelectionRangeInColumn)(rect.left)(tr)) === null || _getSelectionRangeInC === void 0 ? void 0 : _getSelectionRangeInC.$anchor;
|
|
70
52
|
var $head = (_getSelectionRangeInC2 = (0, _utils.getSelectionRangeInColumn)(rect.right - 1)(tr)) === null || _getSelectionRangeInC2 === void 0 ? void 0 : _getSelectionRangeInC2.$head;
|
|
71
|
-
|
|
72
53
|
if ($anchor && $head) {
|
|
73
54
|
return tr.setSelection(new _cellSelection.CellSelection($anchor, $head));
|
|
74
55
|
}
|
|
75
56
|
}
|
|
76
|
-
|
|
77
57
|
if (selection.isRowSelection()) {
|
|
78
58
|
var _getSelectionRangeInR, _getSelectionRangeInR2;
|
|
79
|
-
|
|
80
59
|
var _$anchor = (_getSelectionRangeInR = (0, _utils.getSelectionRangeInRow)(rect.top)(tr)) === null || _getSelectionRangeInR === void 0 ? void 0 : _getSelectionRangeInR.$anchor;
|
|
81
|
-
|
|
82
60
|
var _$head = (_getSelectionRangeInR2 = (0, _utils.getSelectionRangeInRow)(rect.bottom - 1)(tr)) === null || _getSelectionRangeInR2 === void 0 ? void 0 : _getSelectionRangeInR2.$head;
|
|
83
|
-
|
|
84
61
|
if (_$anchor && _$head) {
|
|
85
62
|
return tr.setSelection(new _cellSelection.CellSelection(_$anchor, _$head));
|
|
86
63
|
}
|
|
87
64
|
}
|
|
88
|
-
|
|
89
65
|
return tr;
|
|
90
66
|
};
|
|
91
|
-
|
|
92
67
|
exports.normalizeSelection = normalizeSelection;
|
|
93
|
-
|
|
94
68
|
var getSelectedColumnIndexes = function getSelectedColumnIndexes(selectionRect) {
|
|
95
69
|
var columnIndexes = [];
|
|
96
|
-
|
|
97
70
|
for (var i = selectionRect.left; i < selectionRect.right; i++) {
|
|
98
71
|
columnIndexes.push(i);
|
|
99
72
|
}
|
|
100
|
-
|
|
101
73
|
return columnIndexes;
|
|
102
74
|
};
|
|
103
|
-
|
|
104
75
|
exports.getSelectedColumnIndexes = getSelectedColumnIndexes;
|
|
105
|
-
|
|
106
76
|
var getSelectedRowIndexes = function getSelectedRowIndexes(selectionRect) {
|
|
107
77
|
var rowIndexes = [];
|
|
108
|
-
|
|
109
78
|
for (var i = selectionRect.top; i < selectionRect.bottom; i++) {
|
|
110
79
|
rowIndexes.push(i);
|
|
111
80
|
}
|
|
112
|
-
|
|
113
81
|
return rowIndexes;
|
|
114
82
|
};
|
|
115
|
-
|
|
116
83
|
exports.getSelectedRowIndexes = getSelectedRowIndexes;
|
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.getMergedCellsPositions = exports.colsToRect = void 0;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
13
|
-
|
|
14
10
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
15
|
-
|
|
16
11
|
var getMergedCellsPositions = function getMergedCellsPositions(tr) {
|
|
17
12
|
var table = (0, _utils.findTable)(tr.selection);
|
|
18
|
-
|
|
19
13
|
if (!table) {
|
|
20
14
|
return [];
|
|
21
15
|
}
|
|
22
|
-
|
|
23
16
|
var map = _tableMap.TableMap.get(table.node);
|
|
24
|
-
|
|
25
17
|
var cellPositions = new Set();
|
|
26
18
|
var mergedCells = [];
|
|
27
19
|
map.map.forEach(function (value) {
|
|
@@ -33,9 +25,7 @@ var getMergedCellsPositions = function getMergedCellsPositions(tr) {
|
|
|
33
25
|
});
|
|
34
26
|
return mergedCells;
|
|
35
27
|
};
|
|
36
|
-
|
|
37
28
|
exports.getMergedCellsPositions = getMergedCellsPositions;
|
|
38
|
-
|
|
39
29
|
var colsToRect = function colsToRect(cols, noOfRows) {
|
|
40
30
|
return {
|
|
41
31
|
left: Math.min.apply(Math, (0, _toConsumableArray2.default)(cols)),
|
|
@@ -44,5 +34,4 @@ var colsToRect = function colsToRect(cols, noOfRows) {
|
|
|
44
34
|
bottom: noOfRows
|
|
45
35
|
};
|
|
46
36
|
};
|
|
47
|
-
|
|
48
37
|
exports.colsToRect = colsToRect;
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.updatePluginStateDecorations = void 0;
|
|
7
|
-
|
|
8
7
|
var _plugin = require("../pm-plugins/decorations/plugin");
|
|
9
|
-
|
|
10
8
|
var _decoration = require("./decoration");
|
|
11
|
-
|
|
12
9
|
var updatePluginStateDecorations = function updatePluginStateDecorations(state, decorations, key) {
|
|
13
10
|
return (0, _decoration.updateDecorations)(state.doc, (0, _plugin.getDecorations)(state), decorations, key);
|
|
14
11
|
};
|
|
15
|
-
|
|
16
12
|
exports.updatePluginStateDecorations = updatePluginStateDecorations;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _table = _interopRequireDefault(require("./table"));
|
|
11
|
-
|
|
12
9
|
var _default = _table.default;
|
|
13
10
|
exports.default = _default;
|
package/dist/cjs/version.json
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { Selection } from 'prosemirror-state';
|
|
3
3
|
import { findCellClosestToPos, emptyCell, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
4
4
|
// #endregion
|
|
5
|
+
|
|
5
6
|
// #region Commands
|
|
6
7
|
export const clearMultipleCells = targetCellPosition => (state, dispatch) => {
|
|
7
8
|
let cursorPos;
|
|
8
9
|
let {
|
|
9
10
|
tr
|
|
10
11
|
} = state;
|
|
11
|
-
|
|
12
12
|
if (isSelectionType(tr.selection, 'cell')) {
|
|
13
13
|
const selection = tr.selection;
|
|
14
14
|
selection.forEachCell((_node, pos) => {
|
|
@@ -21,28 +21,23 @@ export const clearMultipleCells = targetCellPosition => (state, dispatch) => {
|
|
|
21
21
|
tr = emptyCell(cell, state.schema)(tr);
|
|
22
22
|
cursorPos = cell.pos;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
24
|
if (tr.docChanged && cursorPos) {
|
|
26
25
|
const $pos = tr.doc.resolve(tr.mapping.map(cursorPos));
|
|
27
26
|
const textSelection = Selection.findFrom($pos, 1, true);
|
|
28
|
-
|
|
29
27
|
if (textSelection) {
|
|
30
28
|
tr.setSelection(textSelection);
|
|
31
29
|
}
|
|
32
|
-
|
|
33
30
|
if (dispatch) {
|
|
34
31
|
dispatch(tr);
|
|
35
32
|
}
|
|
36
|
-
|
|
37
33
|
return true;
|
|
38
34
|
}
|
|
39
|
-
|
|
40
35
|
return false;
|
|
41
36
|
};
|
|
42
37
|
export const clearSelection = (state, dispatch) => {
|
|
43
38
|
if (dispatch) {
|
|
44
39
|
dispatch(state.tr.setSelection(Selection.near(state.selection.$from)).setMeta('addToHistory', false));
|
|
45
40
|
}
|
|
46
|
-
|
|
47
41
|
return true;
|
|
48
|
-
};
|
|
42
|
+
};
|
|
43
|
+
// #endregion
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { collapseSelectedTable } from '../utils/collapse';
|
|
2
2
|
export const wrapTableInExpand = (state, dispatch) => {
|
|
3
3
|
const collapseTr = collapseSelectedTable(state.tr);
|
|
4
|
-
|
|
5
4
|
if (!collapseTr) {
|
|
6
5
|
return false;
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
if (dispatch) {
|
|
10
8
|
dispatch(collapseTr);
|
|
11
9
|
}
|
|
12
|
-
|
|
13
10
|
return true;
|
|
14
11
|
};
|
|
@@ -8,11 +8,9 @@ const TAB_FORWARD_DIRECTION = 1;
|
|
|
8
8
|
const TAB_BACKWARD_DIRECTION = -1;
|
|
9
9
|
export const goToNextCell = editorAnalyticsAPI => direction => (state, dispatch) => {
|
|
10
10
|
const table = findTable(state.selection);
|
|
11
|
-
|
|
12
11
|
if (!table) {
|
|
13
12
|
return false;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
const map = TableMap.get(table.node);
|
|
17
15
|
const {
|
|
18
16
|
tableCell,
|
|
@@ -20,17 +18,18 @@ export const goToNextCell = editorAnalyticsAPI => direction => (state, dispatch)
|
|
|
20
18
|
} = state.schema.nodes;
|
|
21
19
|
const cell = findParentNodeOfType([tableCell, tableHeader])(state.selection);
|
|
22
20
|
const firstCellPos = map.positionAt(0, 0, table.node) + table.start;
|
|
23
|
-
const lastCellPos = map.positionAt(map.height - 1, map.width - 1, table.node) + table.start;
|
|
21
|
+
const lastCellPos = map.positionAt(map.height - 1, map.width - 1, table.node) + table.start;
|
|
24
22
|
|
|
23
|
+
// when tabbing backwards at first cell (top left), insert row at the start of table
|
|
25
24
|
if (firstCellPos === cell.pos && direction === TAB_BACKWARD_DIRECTION) {
|
|
26
25
|
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, {
|
|
27
26
|
index: 0,
|
|
28
27
|
moveCursorToInsertedRow: true
|
|
29
28
|
})(state, dispatch);
|
|
30
29
|
return true;
|
|
31
|
-
}
|
|
32
|
-
|
|
30
|
+
}
|
|
33
31
|
|
|
32
|
+
// when tabbing forwards at last cell (bottom right), insert row at the end of table
|
|
34
33
|
if (lastCellPos === cell.pos && direction === TAB_FORWARD_DIRECTION) {
|
|
35
34
|
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, {
|
|
36
35
|
index: map.height,
|
|
@@ -38,10 +37,8 @@ export const goToNextCell = editorAnalyticsAPI => direction => (state, dispatch)
|
|
|
38
37
|
})(state, dispatch);
|
|
39
38
|
return true;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
40
|
if (dispatch) {
|
|
43
41
|
return baseGotoNextCell(direction)(state, dispatch);
|
|
44
42
|
}
|
|
45
|
-
|
|
46
43
|
return true;
|
|
47
44
|
};
|
|
@@ -3,26 +3,23 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
3
3
|
import { findTable, getCellsInColumn, getCellsInRow } from '@atlaskit/editor-tables/utils';
|
|
4
4
|
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
5
5
|
import { TableDecorations } from '../types';
|
|
6
|
-
import { createCellHoverDecoration, createColumnLineResize, createControlsHoverDecoration, getMergedCellsPositions, updatePluginStateDecorations } from '../utils';
|
|
6
|
+
import { createCellHoverDecoration, createColumnLineResize, createControlsHoverDecoration, getMergedCellsPositions, updatePluginStateDecorations } from '../utils';
|
|
7
|
+
// #endregion
|
|
8
|
+
|
|
7
9
|
// #region Utils
|
|
10
|
+
const makeArray = n => Array.from(Array(n).keys());
|
|
11
|
+
// #endregion
|
|
8
12
|
|
|
9
|
-
const makeArray = n => Array.from(Array(n).keys()); // #endregion
|
|
10
13
|
// #region Commands
|
|
11
|
-
|
|
12
|
-
|
|
13
14
|
export const hoverMergedCells = () => createCommand(state => {
|
|
14
15
|
const mergedCellsPositions = getMergedCellsPositions(state.tr);
|
|
15
|
-
|
|
16
16
|
if (!mergedCellsPositions.length) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
19
|
const table = findTable(state.tr.selection);
|
|
21
|
-
|
|
22
20
|
if (!table) {
|
|
23
21
|
return false;
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
const mergedCells = mergedCellsPositions.map(pos => ({
|
|
27
24
|
pos: pos + table.start,
|
|
28
25
|
start: pos + table.start + 1,
|
|
@@ -38,11 +35,9 @@ export const hoverMergedCells = () => createCommand(state => {
|
|
|
38
35
|
}, tr => tr.setMeta('addToHistory', false));
|
|
39
36
|
export const hoverColumns = (hoveredColumns, isInDanger) => createCommand(state => {
|
|
40
37
|
const cells = getCellsInColumn(hoveredColumns)(state.tr.selection);
|
|
41
|
-
|
|
42
38
|
if (!cells) {
|
|
43
39
|
return false;
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
const decorations = createControlsHoverDecoration(cells, 'column', state.tr, isInDanger);
|
|
47
42
|
return {
|
|
48
43
|
type: 'HOVER_COLUMNS',
|
|
@@ -55,11 +50,9 @@ export const hoverColumns = (hoveredColumns, isInDanger) => createCommand(state
|
|
|
55
50
|
}, tr => tr.setMeta('addToHistory', false));
|
|
56
51
|
export const hoverRows = (hoveredRows, isInDanger) => createCommand(state => {
|
|
57
52
|
const cells = getCellsInRow(hoveredRows)(state.selection);
|
|
58
|
-
|
|
59
53
|
if (!cells) {
|
|
60
54
|
return false;
|
|
61
55
|
}
|
|
62
|
-
|
|
63
56
|
const decorations = createControlsHoverDecoration(cells, 'row', state.tr, isInDanger);
|
|
64
57
|
return {
|
|
65
58
|
type: 'HOVER_ROWS',
|
|
@@ -72,20 +65,16 @@ export const hoverRows = (hoveredRows, isInDanger) => createCommand(state => {
|
|
|
72
65
|
}, tr => tr.setMeta('addToHistory', false));
|
|
73
66
|
export const hoverTable = (isInDanger, isSelected) => createCommand(state => {
|
|
74
67
|
const table = findTable(state.selection);
|
|
75
|
-
|
|
76
68
|
if (!table) {
|
|
77
69
|
return false;
|
|
78
70
|
}
|
|
79
|
-
|
|
80
71
|
const map = TableMap.get(table.node);
|
|
81
72
|
const hoveredColumns = makeArray(map.width);
|
|
82
73
|
const hoveredRows = makeArray(map.height);
|
|
83
74
|
const cells = getCellsInRow(hoveredRows)(state.selection);
|
|
84
|
-
|
|
85
75
|
if (!cells) {
|
|
86
76
|
return false;
|
|
87
77
|
}
|
|
88
|
-
|
|
89
78
|
const decorations = createControlsHoverDecoration(cells, 'table', state.tr, isInDanger, isSelected);
|
|
90
79
|
return {
|
|
91
80
|
type: 'HOVER_TABLE',
|
|
@@ -115,4 +104,5 @@ export const hideResizeHandleLine = () => createCommand(state => ({
|
|
|
115
104
|
data: {
|
|
116
105
|
decorationSet: updatePluginStateDecorations(state, [], TableDecorations.COLUMN_RESIZING_HANDLE_LINE)
|
|
117
106
|
}
|
|
118
|
-
}));
|
|
107
|
+
}));
|
|
108
|
+
// #endregion
|