@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
|
@@ -7,114 +7,97 @@ import { AddColumnStep } from '@atlaskit/adf-schema/steps';
|
|
|
7
7
|
import { checkIfHeaderRowEnabled, copyPreviousRow } from '../utils';
|
|
8
8
|
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
9
9
|
import { rescaleColumns } from '../transforms/column-width';
|
|
10
|
-
|
|
11
10
|
// #endregion
|
|
11
|
+
|
|
12
12
|
function addColumnAtCustomStep(column) {
|
|
13
13
|
return tr => {
|
|
14
14
|
const table = findTable(tr.selection);
|
|
15
|
-
|
|
16
15
|
if (table) {
|
|
17
16
|
return tr.step(AddColumnStep.create(tr.doc, table.pos, column));
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
return tr;
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
export function addColumnAt(getEditorContainerWidth) {
|
|
25
22
|
return (column, allowAddColumnCustomStep = false, view) => {
|
|
26
23
|
return tr => {
|
|
27
24
|
let updatedTr = tr;
|
|
28
|
-
|
|
29
25
|
if (allowAddColumnCustomStep) {
|
|
30
26
|
updatedTr = addColumnAtCustomStep(column)(updatedTr);
|
|
31
27
|
} else {
|
|
32
28
|
updatedTr = addColumnAtPMUtils(column)(updatedTr);
|
|
33
29
|
}
|
|
34
|
-
|
|
35
30
|
const table = findTable(updatedTr.selection);
|
|
36
|
-
|
|
37
31
|
if (table) {
|
|
38
32
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
39
33
|
updatedTr = rescaleColumns(getEditorContainerWidth)(table, view)(updatedTr);
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
return updatedTr;
|
|
43
36
|
};
|
|
44
37
|
};
|
|
45
|
-
}
|
|
46
|
-
// Command to add a column before the column with the selection.
|
|
38
|
+
}
|
|
47
39
|
|
|
40
|
+
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
41
|
+
// Command to add a column before the column with the selection.
|
|
48
42
|
export const addColumnBefore = getEditorContainerWidth => (state, dispatch, view) => {
|
|
49
43
|
const table = findTable(state.selection);
|
|
50
|
-
|
|
51
44
|
if (!table) {
|
|
52
45
|
return false;
|
|
53
46
|
}
|
|
54
|
-
|
|
55
47
|
if (dispatch) {
|
|
56
48
|
let rect = selectedRect(state);
|
|
57
49
|
dispatch(addColumnAt(getEditorContainerWidth)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
58
50
|
}
|
|
59
|
-
|
|
60
51
|
return true;
|
|
61
|
-
};
|
|
62
|
-
// Command to add a column after the column with the selection.
|
|
52
|
+
};
|
|
63
53
|
|
|
54
|
+
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
55
|
+
// Command to add a column after the column with the selection.
|
|
64
56
|
export const addColumnAfter = getEditorContainerWidth => (state, dispatch, view) => {
|
|
65
57
|
const table = findTable(state.selection);
|
|
66
|
-
|
|
67
58
|
if (!table) {
|
|
68
59
|
return false;
|
|
69
60
|
}
|
|
70
|
-
|
|
71
61
|
if (dispatch) {
|
|
72
62
|
let rect = selectedRect(state);
|
|
73
63
|
dispatch(addColumnAt(getEditorContainerWidth)(rect.right, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
74
64
|
}
|
|
75
|
-
|
|
76
65
|
return true;
|
|
77
|
-
};
|
|
66
|
+
};
|
|
78
67
|
|
|
68
|
+
// #region Commands
|
|
79
69
|
export const insertColumn = getEditorContainerWidth => column => (state, dispatch, view) => {
|
|
80
70
|
let tr = addColumnAt(getEditorContainerWidth)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
81
71
|
const table = findTable(tr.selection);
|
|
82
|
-
|
|
83
72
|
if (!table) {
|
|
84
73
|
return false;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
}
|
|
75
|
+
// move the cursor to the newly created column
|
|
88
76
|
const pos = TableMap.get(table.node).positionAt(0, column, table.node);
|
|
89
|
-
|
|
90
77
|
if (dispatch) {
|
|
91
78
|
dispatch(tr.setSelection(Selection.near(tr.doc.resolve(table.start + pos))));
|
|
92
79
|
}
|
|
93
|
-
|
|
94
80
|
return true;
|
|
95
81
|
};
|
|
96
82
|
export const insertRow = (row, moveCursorToTheNewRow) => (state, dispatch) => {
|
|
97
83
|
// Don't clone the header row
|
|
98
84
|
const headerRowEnabled = checkIfHeaderRowEnabled(state.selection);
|
|
99
|
-
const clonePreviousRow = headerRowEnabled && row > 1 || !headerRowEnabled && row > 0;
|
|
100
|
-
// we should not add row on the position zero
|
|
85
|
+
const clonePreviousRow = headerRowEnabled && row > 1 || !headerRowEnabled && row > 0;
|
|
101
86
|
|
|
87
|
+
// When the table have header row
|
|
88
|
+
// we should not add row on the position zero
|
|
102
89
|
if (row === 0 && headerRowEnabled) {
|
|
103
90
|
return false;
|
|
104
91
|
}
|
|
105
|
-
|
|
106
92
|
const tr = clonePreviousRow ? copyPreviousRow(state.schema)(row)(state.tr) : addRowAt(row)(state.tr);
|
|
107
93
|
const table = findTable(tr.selection);
|
|
108
|
-
|
|
109
94
|
if (!table) {
|
|
110
95
|
return false;
|
|
111
96
|
}
|
|
112
|
-
|
|
113
97
|
if (dispatch) {
|
|
114
98
|
const {
|
|
115
99
|
selection
|
|
116
100
|
} = state;
|
|
117
|
-
|
|
118
101
|
if (moveCursorToTheNewRow) {
|
|
119
102
|
// move the cursor to the newly created row
|
|
120
103
|
const pos = TableMap.get(table.node).positionAt(row, 0, table.node);
|
|
@@ -122,20 +105,17 @@ export const insertRow = (row, moveCursorToTheNewRow) => (state, dispatch) => {
|
|
|
122
105
|
} else {
|
|
123
106
|
tr.setSelection(selection.map(tr.doc, tr.mapping));
|
|
124
107
|
}
|
|
125
|
-
|
|
126
108
|
dispatch(tr);
|
|
127
109
|
}
|
|
128
|
-
|
|
129
110
|
return true;
|
|
130
111
|
};
|
|
131
112
|
export const createTable = () => (state, dispatch) => {
|
|
132
113
|
const table = createTableNode({
|
|
133
114
|
schema: state.schema
|
|
134
115
|
});
|
|
135
|
-
|
|
136
116
|
if (dispatch) {
|
|
137
117
|
dispatch(safeInsert(table)(state.tr).scrollIntoView());
|
|
138
118
|
}
|
|
139
|
-
|
|
140
119
|
return true;
|
|
141
|
-
};
|
|
120
|
+
};
|
|
121
|
+
// #endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// #region Imports
|
|
2
|
+
|
|
2
3
|
import { Selection, TextSelection } from 'prosemirror-state';
|
|
3
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
4
5
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
@@ -11,10 +12,12 @@ import { fixAutoSizedTable } from '../transforms';
|
|
|
11
12
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
12
13
|
import { createColumnControlsDecoration, createColumnSelectedDecoration } from '../utils/decoration';
|
|
13
14
|
import { checkIfNumberColumnEnabled, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, isIsolating } from '../utils/nodes';
|
|
14
|
-
import { updatePluginStateDecorations } from '../utils/update-plugin-state-decorations';
|
|
15
|
+
import { updatePluginStateDecorations } from '../utils/update-plugin-state-decorations';
|
|
16
|
+
// #endregion
|
|
17
|
+
|
|
15
18
|
// #endregion
|
|
16
|
-
// #region Commands
|
|
17
19
|
|
|
20
|
+
// #region Commands
|
|
18
21
|
export const setEditorFocus = editorHasFocus => createCommand({
|
|
19
22
|
type: 'SET_EDITOR_FOCUS',
|
|
20
23
|
data: {
|
|
@@ -51,41 +54,36 @@ export const setCellAttr = (name, value) => (state, dispatch) => {
|
|
|
51
54
|
tr,
|
|
52
55
|
selection
|
|
53
56
|
} = state;
|
|
54
|
-
|
|
55
57
|
if (selection instanceof CellSelection) {
|
|
56
58
|
let updated = false;
|
|
57
59
|
selection.forEachCell((cell, pos) => {
|
|
58
60
|
if (cell.attrs[name] !== value) {
|
|
59
|
-
tr.setNodeMarkup(pos, cell.type, {
|
|
61
|
+
tr.setNodeMarkup(pos, cell.type, {
|
|
62
|
+
...cell.attrs,
|
|
60
63
|
[name]: value
|
|
61
64
|
});
|
|
62
65
|
updated = true;
|
|
63
66
|
}
|
|
64
67
|
});
|
|
65
|
-
|
|
66
68
|
if (updated) {
|
|
67
69
|
if (dispatch) {
|
|
68
70
|
dispatch(tr);
|
|
69
71
|
}
|
|
70
|
-
|
|
71
72
|
return true;
|
|
72
73
|
}
|
|
73
74
|
} else {
|
|
74
75
|
const cell = selectionCell(state.selection);
|
|
75
|
-
|
|
76
76
|
if (cell) {
|
|
77
77
|
if (dispatch) {
|
|
78
78
|
var _cell$nodeAfter, _cell$nodeAfter2;
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
dispatch(tr.setNodeMarkup(cell.pos, (_cell$nodeAfter = cell.nodeAfter) === null || _cell$nodeAfter === void 0 ? void 0 : _cell$nodeAfter.type, {
|
|
80
|
+
...((_cell$nodeAfter2 = cell.nodeAfter) === null || _cell$nodeAfter2 === void 0 ? void 0 : _cell$nodeAfter2.attrs),
|
|
81
81
|
[name]: value
|
|
82
82
|
}));
|
|
83
83
|
}
|
|
84
|
-
|
|
85
84
|
return true;
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
|
-
|
|
89
87
|
return false;
|
|
90
88
|
};
|
|
91
89
|
export const triggerUnlessTableHeader = command => (state, dispatch, view) => {
|
|
@@ -97,23 +95,18 @@ export const triggerUnlessTableHeader = command => (state, dispatch, view) => {
|
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
97
|
} = state;
|
|
100
|
-
|
|
101
98
|
if (selection instanceof TextSelection) {
|
|
102
99
|
const cell = findCellClosestToPos(selection.$from);
|
|
103
|
-
|
|
104
100
|
if (cell && cell.node.type !== tableHeader) {
|
|
105
101
|
return command(state, dispatch, view);
|
|
106
102
|
}
|
|
107
103
|
}
|
|
108
|
-
|
|
109
104
|
if (selection instanceof CellSelection) {
|
|
110
105
|
const rect = getSelectionRect(selection);
|
|
111
|
-
|
|
112
106
|
if (!checkIfHeaderRowEnabled(selection) || rect && rect.top > 0) {
|
|
113
107
|
return command(state, dispatch, view);
|
|
114
108
|
}
|
|
115
109
|
}
|
|
116
|
-
|
|
117
110
|
return false;
|
|
118
111
|
};
|
|
119
112
|
export const transformSliceRemoveCellBackgroundColor = (slice, schema) => {
|
|
@@ -123,12 +116,12 @@ export const transformSliceRemoveCellBackgroundColor = (slice, schema) => {
|
|
|
123
116
|
} = schema.nodes;
|
|
124
117
|
return mapSlice(slice, maybeCell => {
|
|
125
118
|
if (maybeCell.type === tableCell || maybeCell.type === tableHeader) {
|
|
126
|
-
const cellAttrs = {
|
|
119
|
+
const cellAttrs = {
|
|
120
|
+
...maybeCell.attrs
|
|
127
121
|
};
|
|
128
122
|
cellAttrs.background = undefined;
|
|
129
123
|
return maybeCell.type.createChecked(cellAttrs, maybeCell.content, maybeCell.marks);
|
|
130
124
|
}
|
|
131
|
-
|
|
132
125
|
return maybeCell;
|
|
133
126
|
});
|
|
134
127
|
};
|
|
@@ -141,7 +134,6 @@ export const transformSliceToAddTableHeaders = (slice, schema) => {
|
|
|
141
134
|
return mapSlice(slice, maybeTable => {
|
|
142
135
|
if (maybeTable.type === table) {
|
|
143
136
|
const firstRow = maybeTable.firstChild;
|
|
144
|
-
|
|
145
137
|
if (firstRow) {
|
|
146
138
|
const headerCols = [];
|
|
147
139
|
firstRow.forEach(oldCol => {
|
|
@@ -151,7 +143,6 @@ export const transformSliceToAddTableHeaders = (slice, schema) => {
|
|
|
151
143
|
return maybeTable.copy(maybeTable.content.replaceChild(0, headerRow));
|
|
152
144
|
}
|
|
153
145
|
}
|
|
154
|
-
|
|
155
146
|
return maybeTable;
|
|
156
147
|
});
|
|
157
148
|
};
|
|
@@ -165,12 +156,11 @@ export const transformSliceToRemoveColumnsWidths = (slice, schema) => {
|
|
|
165
156
|
if (!maybeCell.attrs.colwidth) {
|
|
166
157
|
return maybeCell;
|
|
167
158
|
}
|
|
168
|
-
|
|
169
|
-
|
|
159
|
+
return maybeCell.type.createChecked({
|
|
160
|
+
...maybeCell.attrs,
|
|
170
161
|
colwidth: undefined
|
|
171
162
|
}, maybeCell.content, maybeCell.marks);
|
|
172
163
|
}
|
|
173
|
-
|
|
174
164
|
return maybeCell;
|
|
175
165
|
});
|
|
176
166
|
};
|
|
@@ -178,98 +168,88 @@ export const deleteTable = (state, dispatch) => {
|
|
|
178
168
|
if (dispatch) {
|
|
179
169
|
dispatch(removeTable(state.tr));
|
|
180
170
|
}
|
|
181
|
-
|
|
182
171
|
return true;
|
|
183
172
|
};
|
|
184
173
|
export const deleteTableIfSelected = (state, dispatch) => {
|
|
185
174
|
if (isTableSelected(state.selection)) {
|
|
186
175
|
return deleteTable(state, dispatch);
|
|
187
176
|
}
|
|
188
|
-
|
|
189
177
|
return false;
|
|
190
178
|
};
|
|
191
179
|
export const convertFirstRowToHeader = schema => tr => {
|
|
192
180
|
const table = findTable(tr.selection);
|
|
193
181
|
const map = TableMap.get(table.node);
|
|
194
|
-
|
|
195
182
|
for (let i = 0; i < map.width; i++) {
|
|
196
183
|
const cell = table.node.child(0).child(i);
|
|
197
184
|
tr.setNodeMarkup(table.start + map.map[i], schema.nodes.tableHeader, cell.attrs);
|
|
198
185
|
}
|
|
199
|
-
|
|
200
186
|
return tr;
|
|
201
187
|
};
|
|
202
188
|
export const moveCursorBackward = (state, dispatch) => {
|
|
203
189
|
const {
|
|
204
190
|
$cursor
|
|
205
|
-
} = state.selection;
|
|
206
|
-
|
|
191
|
+
} = state.selection;
|
|
192
|
+
// if cursor is in the middle of a text node, do nothing
|
|
207
193
|
if (!$cursor || $cursor.parentOffset > 0) {
|
|
208
194
|
return false;
|
|
209
|
-
}
|
|
210
|
-
|
|
195
|
+
}
|
|
211
196
|
|
|
197
|
+
// find the node before the cursor
|
|
212
198
|
let before;
|
|
213
199
|
let cut;
|
|
214
|
-
|
|
215
200
|
if (!isIsolating($cursor.parent)) {
|
|
216
201
|
for (let i = $cursor.depth - 1; !before && i >= 0; i--) {
|
|
217
202
|
if ($cursor.index(i) > 0) {
|
|
218
203
|
cut = $cursor.before(i + 1);
|
|
219
204
|
before = $cursor.node(i).child($cursor.index(i) - 1);
|
|
220
205
|
}
|
|
221
|
-
|
|
222
206
|
if (isIsolating($cursor.node(i))) {
|
|
223
207
|
break;
|
|
224
208
|
}
|
|
225
209
|
}
|
|
226
|
-
}
|
|
227
|
-
|
|
210
|
+
}
|
|
228
211
|
|
|
212
|
+
// if the node before is not a table node - do nothing
|
|
229
213
|
if (!before || before.type !== state.schema.nodes.table) {
|
|
230
214
|
return false;
|
|
231
215
|
}
|
|
216
|
+
|
|
232
217
|
/*
|
|
233
218
|
ensure we're just at a top level paragraph
|
|
234
219
|
otherwise, perform regular backspace behaviour
|
|
235
220
|
*/
|
|
236
|
-
|
|
237
|
-
|
|
238
221
|
const grandparent = $cursor.node($cursor.depth - 1);
|
|
239
|
-
|
|
240
222
|
if ($cursor.parent.type !== state.schema.nodes.paragraph || grandparent && grandparent.type !== state.schema.nodes.doc) {
|
|
241
223
|
return false;
|
|
242
224
|
}
|
|
243
|
-
|
|
244
225
|
const {
|
|
245
226
|
tr
|
|
246
227
|
} = state;
|
|
247
|
-
const lastCellPos = (cut || 0) - 4;
|
|
248
|
-
|
|
228
|
+
const lastCellPos = (cut || 0) - 4;
|
|
229
|
+
// need to move cursor inside the table to be able to calculate table's offset
|
|
249
230
|
tr.setSelection(new TextSelection(state.doc.resolve(lastCellPos)));
|
|
250
231
|
const {
|
|
251
232
|
$from
|
|
252
233
|
} = tr.selection;
|
|
253
234
|
const start = $from.start(-1);
|
|
254
|
-
const pos = start + $from.parent.nodeSize - 1;
|
|
235
|
+
const pos = start + $from.parent.nodeSize - 1;
|
|
236
|
+
|
|
237
|
+
// move cursor to the last cell
|
|
255
238
|
// it doesn't join node before (last cell) with node after (content after the cursor)
|
|
256
239
|
// due to ridiculous amount of PM code that would have been required to overwrite
|
|
240
|
+
tr.setSelection(new TextSelection(state.doc.resolve(pos)));
|
|
257
241
|
|
|
258
|
-
|
|
259
|
-
|
|
242
|
+
// if we are inside an empty paragraph not at the end of the doc we delete it
|
|
260
243
|
const cursorNode = $cursor.node();
|
|
261
244
|
const docEnd = state.doc.content.size;
|
|
262
245
|
const paragraphWrapStart = $cursor.pos - 1;
|
|
263
246
|
const paragraphWrapEnd = $cursor.pos + 1;
|
|
264
|
-
|
|
265
247
|
if (cursorNode.content.size === 0 && $cursor.pos + 1 !== docEnd) {
|
|
266
248
|
tr.delete(paragraphWrapStart, paragraphWrapEnd);
|
|
267
249
|
}
|
|
268
|
-
|
|
269
250
|
if (dispatch) {
|
|
270
251
|
dispatch(tr);
|
|
271
252
|
}
|
|
272
|
-
|
|
273
253
|
return true;
|
|
274
254
|
};
|
|
275
255
|
export const setMultipleCellAttrs = (attrs, targetCellPosition) => (state, dispatch) => {
|
|
@@ -277,7 +257,6 @@ export const setMultipleCellAttrs = (attrs, targetCellPosition) => (state, dispa
|
|
|
277
257
|
let {
|
|
278
258
|
tr
|
|
279
259
|
} = state;
|
|
280
|
-
|
|
281
260
|
if (isSelectionType(tr.selection, 'cell')) {
|
|
282
261
|
const selection = tr.selection;
|
|
283
262
|
selection.forEachCell((_cell, pos) => {
|
|
@@ -290,26 +269,20 @@ export const setMultipleCellAttrs = (attrs, targetCellPosition) => (state, dispa
|
|
|
290
269
|
tr = setCellAttrs(cell, attrs)(tr);
|
|
291
270
|
cursorPos = cell.pos;
|
|
292
271
|
}
|
|
293
|
-
|
|
294
272
|
if (tr.docChanged && cursorPos !== undefined) {
|
|
295
273
|
const $pos = tr.doc.resolve(tr.mapping.map(cursorPos));
|
|
296
|
-
|
|
297
274
|
if (dispatch) {
|
|
298
275
|
dispatch(tr.setSelection(Selection.near($pos)));
|
|
299
276
|
}
|
|
300
|
-
|
|
301
277
|
return true;
|
|
302
278
|
}
|
|
303
|
-
|
|
304
279
|
return false;
|
|
305
280
|
};
|
|
306
281
|
export const selectColumn = (column, expand) => createCommand(state => {
|
|
307
282
|
const cells = getCellsInColumn(column)(state.tr.selection);
|
|
308
|
-
|
|
309
283
|
if (!cells || !cells.length || typeof cells[0].pos !== 'number') {
|
|
310
284
|
return false;
|
|
311
285
|
}
|
|
312
|
-
|
|
313
286
|
const decorations = createColumnSelectedDecoration(selectColumnTransform(column, expand)(state.tr));
|
|
314
287
|
const decorationSet = updatePluginStateDecorations(state, decorations, TableDecorations.COLUMN_SELECTED);
|
|
315
288
|
const targetCellPosition = cells[0].pos;
|
|
@@ -324,11 +297,9 @@ export const selectColumn = (column, expand) => createCommand(state => {
|
|
|
324
297
|
export const selectRow = (row, expand) => createCommand(state => {
|
|
325
298
|
let targetCellPosition;
|
|
326
299
|
const cells = getCellsInRow(row)(state.tr.selection);
|
|
327
|
-
|
|
328
300
|
if (cells && cells.length) {
|
|
329
301
|
targetCellPosition = cells[0].pos;
|
|
330
302
|
}
|
|
331
|
-
|
|
332
303
|
return {
|
|
333
304
|
type: 'SET_TARGET_CELL_POSITION',
|
|
334
305
|
data: {
|
|
@@ -358,11 +329,9 @@ export const addResizeHandleDecorations = (rowIndex, columnIndex) => createComma
|
|
|
358
329
|
allowColumnResizing
|
|
359
330
|
}
|
|
360
331
|
} = getPluginState(state);
|
|
361
|
-
|
|
362
332
|
if (!tableNode || !allowColumnResizing) {
|
|
363
333
|
return false;
|
|
364
334
|
}
|
|
365
|
-
|
|
366
335
|
return {
|
|
367
336
|
type: 'ADD_RESIZE_HANDLE_DECORATIONS',
|
|
368
337
|
data: {
|
|
@@ -383,25 +352,26 @@ export const addBoldInEmptyHeaderCells = tableCellHeader => (state, dispatch) =>
|
|
|
383
352
|
const {
|
|
384
353
|
tr
|
|
385
354
|
} = state;
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
isTextSelection(tr.selection) && tr.selection.$cursor &&
|
|
355
|
+
if (
|
|
356
|
+
// Avoid infinite loop when the current selection is not a TextSelection
|
|
357
|
+
isTextSelection(tr.selection) && tr.selection.$cursor &&
|
|
358
|
+
// When storedMark is null that means this is the initial state
|
|
389
359
|
// if the user press to remove the mark storedMark will be an empty array
|
|
390
360
|
// and we shouldn't apply the strong mark
|
|
391
|
-
tr.storedMarks == null &&
|
|
392
|
-
|
|
361
|
+
tr.storedMarks == null &&
|
|
362
|
+
// Check if the current node is a direct child from paragraph
|
|
363
|
+
tr.selection.$from.depth === tableCellHeader.depth + 1 &&
|
|
364
|
+
// this logic is applied only for empty paragraph
|
|
393
365
|
tableCellHeader.node.nodeSize === 4 && isParagraph(tableCellHeader.node.firstChild, state.schema)) {
|
|
394
366
|
const {
|
|
395
367
|
strong
|
|
396
368
|
} = state.schema.marks;
|
|
397
369
|
tr.setStoredMarks([strong.create()]).setMeta('addToHistory', false);
|
|
398
|
-
|
|
399
370
|
if (dispatch) {
|
|
400
371
|
dispatch(tr);
|
|
401
372
|
}
|
|
402
|
-
|
|
403
373
|
return true;
|
|
404
374
|
}
|
|
405
|
-
|
|
406
375
|
return false;
|
|
407
|
-
};
|
|
376
|
+
};
|
|
377
|
+
// #endregion
|