@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,68 +1,53 @@
|
|
|
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.createPluginState = exports.createCommand = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
|
-
|
|
14
10
|
var _pluginKey = require("./plugin-key");
|
|
15
|
-
|
|
16
11
|
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; }
|
|
17
|
-
|
|
18
12
|
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; }
|
|
19
|
-
|
|
20
13
|
var reducer = function reducer(pluginState, action) {
|
|
21
14
|
if (action.name === 'UPDATE') {
|
|
22
15
|
var updated = false;
|
|
23
16
|
var updatedState = pluginState.map(function (oldTableState) {
|
|
24
17
|
var replace = oldTableState.pos === action.state.pos;
|
|
25
|
-
|
|
26
18
|
if (replace) {
|
|
27
19
|
updated = true;
|
|
28
20
|
}
|
|
29
|
-
|
|
30
21
|
return replace ? action.state : oldTableState;
|
|
31
22
|
});
|
|
32
|
-
|
|
33
23
|
if (!updated) {
|
|
34
24
|
// new, add it
|
|
35
25
|
updatedState.push(action.state);
|
|
36
26
|
}
|
|
37
|
-
|
|
38
27
|
return updatedState;
|
|
39
28
|
} else if (action.name === 'REMOVE') {
|
|
40
29
|
return pluginState.filter(function (rowState) {
|
|
41
30
|
return rowState.pos !== action.pos;
|
|
42
31
|
});
|
|
43
32
|
}
|
|
44
|
-
|
|
45
33
|
return pluginState;
|
|
46
34
|
};
|
|
47
|
-
|
|
48
35
|
var _pluginFactory = (0, _utils.pluginFactory)(_pluginKey.pluginKey, reducer, {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
36
|
+
mapping: function mapping(tr, pluginState) {
|
|
37
|
+
if (tr.docChanged) {
|
|
38
|
+
return pluginState.map(function (rowInfo) {
|
|
39
|
+
var remapped = tr.mapping.mapResult(rowInfo.pos);
|
|
40
|
+
return remapped ? _objectSpread(_objectSpread({}, rowInfo), {}, {
|
|
41
|
+
pos: remapped.pos
|
|
42
|
+
}) : undefined;
|
|
43
|
+
}).filter(function (f) {
|
|
44
|
+
return f !== undefined;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return pluginState;
|
|
59
48
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}),
|
|
64
|
-
createPluginState = _pluginFactory.createPluginState,
|
|
65
|
-
createCommand = _pluginFactory.createCommand;
|
|
66
|
-
|
|
49
|
+
}),
|
|
50
|
+
createPluginState = _pluginFactory.createPluginState,
|
|
51
|
+
createCommand = _pluginFactory.createCommand;
|
|
67
52
|
exports.createCommand = createCommand;
|
|
68
53
|
exports.createPluginState = createPluginState;
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createPlugin = void 0;
|
|
7
|
-
|
|
8
7
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
|
-
|
|
10
8
|
var _tableRow = require("./nodeviews/tableRow");
|
|
11
|
-
|
|
12
9
|
var _pluginKey = require("./plugin-key");
|
|
13
|
-
|
|
14
10
|
var _pluginState = require("./plugin-state");
|
|
15
|
-
|
|
16
11
|
var createPlugin = function createPlugin(dispatch, eventDispatcher) {
|
|
17
12
|
var initialState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
|
|
18
13
|
return [];
|
|
@@ -30,5 +25,4 @@ var createPlugin = function createPlugin(dispatch, eventDispatcher) {
|
|
|
30
25
|
}
|
|
31
26
|
});
|
|
32
27
|
};
|
|
33
|
-
|
|
34
28
|
exports.createPlugin = createPlugin;
|
|
@@ -4,22 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.findStickyHeaderForTable = void 0;
|
|
7
|
-
|
|
8
7
|
// only worry about the first row for now
|
|
9
8
|
var findStickyHeaderForTable = function findStickyHeaderForTable(state, tablePos) {
|
|
10
9
|
if (!state || tablePos === undefined) {
|
|
11
10
|
return undefined;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
var rowInfo = state.find(function (rowInfo) {
|
|
15
13
|
return rowInfo.pos === tablePos + 1;
|
|
16
14
|
});
|
|
17
|
-
|
|
18
15
|
if (!rowInfo) {
|
|
19
16
|
return undefined;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
return rowInfo.sticky ? rowInfo : undefined;
|
|
23
19
|
};
|
|
24
|
-
|
|
25
20
|
exports.findStickyHeaderForTable = findStickyHeaderForTable;
|
|
@@ -1,48 +1,35 @@
|
|
|
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.createPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
|
-
|
|
14
10
|
var _prosemirrorState = require("prosemirror-state");
|
|
15
|
-
|
|
16
11
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
17
|
-
|
|
18
12
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
19
|
-
|
|
20
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
21
|
-
|
|
22
14
|
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; }
|
|
23
|
-
|
|
24
15
|
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; }
|
|
25
|
-
|
|
26
16
|
var pluginKey = new _prosemirrorState.PluginKey('tableLocalIdPlugin');
|
|
27
|
-
|
|
28
17
|
var getPluginState = function getPluginState(state) {
|
|
29
18
|
return state && pluginKey.getState(state);
|
|
30
19
|
};
|
|
20
|
+
|
|
31
21
|
/**
|
|
32
22
|
* Traverses a transaction's steps to see if we're inserting any tables
|
|
33
23
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
24
|
var checkIsAddingTable = function checkIsAddingTable(transaction, nodeType) {
|
|
37
25
|
return transaction.steps.some(function (step) {
|
|
38
26
|
return (0, _utils.stepAddsOneOf)(step, new Set([nodeType]));
|
|
39
27
|
});
|
|
40
28
|
};
|
|
29
|
+
|
|
41
30
|
/**
|
|
42
31
|
* Ensures uniqueness of `localId`s on tables being created or edited
|
|
43
32
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
33
|
var createPlugin = function createPlugin(dispatch) {
|
|
47
34
|
return new _safePlugin.SafePlugin({
|
|
48
35
|
key: pluginKey,
|
|
@@ -54,21 +41,17 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
54
41
|
},
|
|
55
42
|
apply: function apply(tr, pluginState) {
|
|
56
43
|
var meta = tr.getMeta(pluginKey);
|
|
57
|
-
|
|
58
44
|
if (meta) {
|
|
59
45
|
var keys = Object.keys(meta);
|
|
60
46
|
var changed = keys.some(function (key) {
|
|
61
47
|
return pluginState[key] !== meta[key];
|
|
62
48
|
});
|
|
63
|
-
|
|
64
49
|
if (changed) {
|
|
65
50
|
var newState = _objectSpread(_objectSpread({}, pluginState), meta);
|
|
66
|
-
|
|
67
51
|
dispatch(pluginKey, newState);
|
|
68
52
|
return newState;
|
|
69
53
|
}
|
|
70
54
|
}
|
|
71
|
-
|
|
72
55
|
return pluginState;
|
|
73
56
|
}
|
|
74
57
|
},
|
|
@@ -94,17 +77,13 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
94
77
|
update: function update(editorView) {
|
|
95
78
|
var state = editorView.state;
|
|
96
79
|
var pluginState = getPluginState(state);
|
|
97
|
-
|
|
98
80
|
if (!pluginState) {
|
|
99
81
|
return;
|
|
100
82
|
}
|
|
101
|
-
|
|
102
83
|
var parsed = pluginState.parsedForLocalIds;
|
|
103
|
-
|
|
104
84
|
if (parsed) {
|
|
105
85
|
return;
|
|
106
86
|
}
|
|
107
|
-
|
|
108
87
|
var table = state.schema.nodes.table;
|
|
109
88
|
(0, _rafSchd.default)(function () {
|
|
110
89
|
var tr = state.tr;
|
|
@@ -112,7 +91,6 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
112
91
|
editorView.state.doc.descendants(function (node, pos) {
|
|
113
92
|
var isTable = node.type === table;
|
|
114
93
|
var localId = node.attrs.localId;
|
|
115
|
-
|
|
116
94
|
if (isTable && !localId) {
|
|
117
95
|
tableIdWasAdded = true;
|
|
118
96
|
tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
@@ -124,11 +102,8 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
124
102
|
* Otherwise continue traversing, we can encounter tables nested in
|
|
125
103
|
* expands/bodiedExtensions
|
|
126
104
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
105
|
return true;
|
|
130
106
|
});
|
|
131
|
-
|
|
132
107
|
if (tableIdWasAdded) {
|
|
133
108
|
tr.setMeta('addToHistory', false);
|
|
134
109
|
editorView.dispatch(tr);
|
|
@@ -148,58 +123,52 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
148
123
|
transactions.forEach(function (transaction) {
|
|
149
124
|
if (!transaction.docChanged) {
|
|
150
125
|
return;
|
|
151
|
-
}
|
|
152
|
-
// to handle any extra cut cases in this plugin
|
|
153
|
-
|
|
126
|
+
}
|
|
154
127
|
|
|
128
|
+
// Don't interfere with cut as it clashes with fixTables & we don't need
|
|
129
|
+
// to handle any extra cut cases in this plugin
|
|
155
130
|
var uiEvent = transaction.getMeta('uiEvent');
|
|
156
|
-
|
|
157
131
|
if (uiEvent === 'cut') {
|
|
158
132
|
return;
|
|
159
133
|
}
|
|
160
|
-
/** Check if we're actually inserting a table, otherwise we can ignore this tr */
|
|
161
|
-
|
|
162
134
|
|
|
135
|
+
/** Check if we're actually inserting a table, otherwise we can ignore this tr */
|
|
163
136
|
var isAddingTable = checkIsAddingTable(transaction, table);
|
|
164
|
-
|
|
165
137
|
if (!isAddingTable) {
|
|
166
138
|
return;
|
|
167
|
-
}
|
|
168
|
-
|
|
139
|
+
}
|
|
169
140
|
|
|
141
|
+
// Can't simply look at changed nodes, as we could be adding a table
|
|
170
142
|
newState.doc.descendants(function (node, pos) {
|
|
171
143
|
var isTable = node.type === table;
|
|
172
|
-
var localId = node.attrs.localId;
|
|
144
|
+
var localId = node.attrs.localId;
|
|
173
145
|
|
|
146
|
+
// Dealing with a table - make sure it's a unique ID
|
|
174
147
|
if (isTable) {
|
|
175
148
|
if (localId && !idsObserved.has(localId)) {
|
|
176
|
-
idsObserved.add(localId);
|
|
149
|
+
idsObserved.add(localId);
|
|
150
|
+
// Also add a localId if it happens to not have one,
|
|
177
151
|
} else if (!localId || idsObserved.has(localId)) {
|
|
178
152
|
modified = true;
|
|
179
153
|
tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
180
154
|
localId: _adfSchema.uuid.generate()
|
|
181
155
|
}));
|
|
182
156
|
}
|
|
183
|
-
|
|
184
157
|
return false;
|
|
185
158
|
}
|
|
159
|
+
|
|
186
160
|
/**
|
|
187
161
|
* Otherwise continue traversing, we can encounter tables nested in
|
|
188
162
|
* expands/bodiedExtensions
|
|
189
163
|
*/
|
|
190
|
-
|
|
191
|
-
|
|
192
164
|
return true;
|
|
193
165
|
});
|
|
194
166
|
});
|
|
195
|
-
|
|
196
167
|
if (modified) {
|
|
197
168
|
return tr;
|
|
198
169
|
}
|
|
199
|
-
|
|
200
170
|
return;
|
|
201
171
|
}
|
|
202
172
|
});
|
|
203
173
|
};
|
|
204
|
-
|
|
205
174
|
exports.createPlugin = createPlugin;
|
|
@@ -4,81 +4,70 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.stopResizing = exports.setResizeHandlePos = exports.setLastClick = exports.setDragging = exports.scaleTable = exports.evenColumns = exports.distributeColumnsWidths = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
9
|
-
|
|
10
8
|
var _transforms = require("../../transforms");
|
|
11
|
-
|
|
12
9
|
var _pluginFactory = require("./plugin-factory");
|
|
13
|
-
|
|
14
10
|
var _utils2 = require("./utils");
|
|
15
|
-
|
|
16
11
|
// Scale the table to meet new requirements (col, layout change etc)
|
|
17
12
|
var scaleTable = function scaleTable(tableRef, options, domAtPos) {
|
|
18
13
|
return function (state, dispatch) {
|
|
19
14
|
if (!tableRef) {
|
|
20
15
|
return false;
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
var node = options.node,
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
start = options.start,
|
|
19
|
+
parentWidth = options.parentWidth,
|
|
20
|
+
layoutChanged = options.layoutChanged;
|
|
26
21
|
|
|
22
|
+
// If a table has not been resized yet, columns should be auto.
|
|
27
23
|
if ((0, _utils2.hasTableBeenResized)(node) === false) {
|
|
28
24
|
// If its not a re-sized table, we still want to re-create cols
|
|
29
25
|
// To force reflow of columns upon delete.
|
|
30
26
|
(0, _utils2.insertColgroupFromNode)(tableRef, node);
|
|
31
27
|
return false;
|
|
32
28
|
}
|
|
33
|
-
|
|
34
29
|
var resizeState;
|
|
35
|
-
|
|
36
30
|
if (parentWidth) {
|
|
37
31
|
resizeState = (0, _utils2.scaleWithParent)(tableRef, parentWidth, node, start, domAtPos);
|
|
38
32
|
} else {
|
|
39
33
|
resizeState = (0, _utils2.scale)(tableRef, options, domAtPos);
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
if (resizeState) {
|
|
43
36
|
var _tr = state.tr;
|
|
44
37
|
_tr = (0, _transforms.updateColumnWidths)(resizeState, node, start)(_tr);
|
|
45
|
-
|
|
46
38
|
if (_tr.docChanged && dispatch) {
|
|
47
|
-
_tr.setMeta('scrollIntoView', false);
|
|
39
|
+
_tr.setMeta('scrollIntoView', false);
|
|
40
|
+
// TODO: ED-8995
|
|
48
41
|
// We need to do this check to reduce the number of race conditions when working with tables.
|
|
49
42
|
// This metadata is been used in the sendTransaction function in the Collab plugin
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
/* Added !layoutChanged check here to solve unnecessary scroll bar after publish when click on breakout button multiple times and publish
|
|
44
|
+
scaleTable is only called once every time a breakout button is clicked, so it is safe not to add the meta 'scaleTable' to the tr.
|
|
45
|
+
Leaving the tr.setMeta('scaleTable', true) here for race conditions that we aren't aware of.
|
|
46
|
+
*/
|
|
47
|
+
!layoutChanged && _tr.setMeta('scaleTable', true);
|
|
54
48
|
dispatch(_tr);
|
|
55
49
|
return true;
|
|
56
50
|
}
|
|
57
51
|
}
|
|
58
|
-
|
|
59
52
|
return false;
|
|
60
53
|
};
|
|
61
54
|
};
|
|
62
|
-
|
|
63
55
|
exports.scaleTable = scaleTable;
|
|
64
|
-
|
|
65
56
|
var evenColumns = function evenColumns(_ref) {
|
|
66
57
|
var resizeState = _ref.resizeState,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
table = _ref.table,
|
|
59
|
+
start = _ref.start,
|
|
60
|
+
event = _ref.event;
|
|
70
61
|
return function (state, dispatch) {
|
|
71
62
|
if (!(0, _utils.isTableSelected)(state.selection)) {
|
|
72
63
|
return false;
|
|
73
|
-
}
|
|
74
|
-
// Note: ProseMirror's handleDoubleClick doesn't quite work with DOM mousedown event handler
|
|
75
|
-
|
|
64
|
+
}
|
|
76
65
|
|
|
66
|
+
// double click detection logic
|
|
67
|
+
// Note: ProseMirror's handleDoubleClick doesn't quite work with DOM mousedown event handler
|
|
77
68
|
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
lastClick = _getPluginState.lastClick;
|
|
80
70
|
var now = Date.now();
|
|
81
|
-
|
|
82
71
|
if (lastClick && now - lastClick.time < 500 && (0, _utils2.isClickNear)(event, lastClick)) {
|
|
83
72
|
var newState = (0, _utils2.evenAllColumnsWidths)(resizeState);
|
|
84
73
|
setLastClick(null, function (tr) {
|
|
@@ -86,7 +75,6 @@ var evenColumns = function evenColumns(_ref) {
|
|
|
86
75
|
})(state, dispatch);
|
|
87
76
|
return true;
|
|
88
77
|
}
|
|
89
|
-
|
|
90
78
|
setLastClick({
|
|
91
79
|
x: event.clientX,
|
|
92
80
|
y: event.clientY,
|
|
@@ -95,23 +83,17 @@ var evenColumns = function evenColumns(_ref) {
|
|
|
95
83
|
return false;
|
|
96
84
|
};
|
|
97
85
|
};
|
|
98
|
-
|
|
99
86
|
exports.evenColumns = evenColumns;
|
|
100
|
-
|
|
101
87
|
var distributeColumnsWidths = function distributeColumnsWidths(newResizeState, table) {
|
|
102
88
|
return function (state, dispatch) {
|
|
103
89
|
if (dispatch) {
|
|
104
90
|
var _tr2 = (0, _transforms.updateColumnWidths)(newResizeState, table.node, table.start)(state.tr);
|
|
105
|
-
|
|
106
91
|
stopResizing(_tr2)(state, dispatch);
|
|
107
92
|
}
|
|
108
|
-
|
|
109
93
|
return true;
|
|
110
94
|
};
|
|
111
95
|
};
|
|
112
|
-
|
|
113
96
|
exports.distributeColumnsWidths = distributeColumnsWidths;
|
|
114
|
-
|
|
115
97
|
var setResizeHandlePos = function setResizeHandlePos(resizeHandlePos) {
|
|
116
98
|
return (0, _pluginFactory.createCommand)({
|
|
117
99
|
type: 'SET_RESIZE_HANDLE_POSITION',
|
|
@@ -120,9 +102,7 @@ var setResizeHandlePos = function setResizeHandlePos(resizeHandlePos) {
|
|
|
120
102
|
}
|
|
121
103
|
});
|
|
122
104
|
};
|
|
123
|
-
|
|
124
105
|
exports.setResizeHandlePos = setResizeHandlePos;
|
|
125
|
-
|
|
126
106
|
var stopResizing = function stopResizing(tr) {
|
|
127
107
|
return (0, _pluginFactory.createCommand)({
|
|
128
108
|
type: 'STOP_RESIZING'
|
|
@@ -130,9 +110,7 @@ var stopResizing = function stopResizing(tr) {
|
|
|
130
110
|
return (tr || originalTr).setMeta('scrollIntoView', false);
|
|
131
111
|
});
|
|
132
112
|
};
|
|
133
|
-
|
|
134
113
|
exports.stopResizing = stopResizing;
|
|
135
|
-
|
|
136
114
|
var setDragging = function setDragging(dragging, tr) {
|
|
137
115
|
return (0, _pluginFactory.createCommand)({
|
|
138
116
|
type: 'SET_DRAGGING',
|
|
@@ -143,9 +121,7 @@ var setDragging = function setDragging(dragging, tr) {
|
|
|
143
121
|
return tr || originalTr;
|
|
144
122
|
});
|
|
145
123
|
};
|
|
146
|
-
|
|
147
124
|
exports.setDragging = setDragging;
|
|
148
|
-
|
|
149
125
|
var setLastClick = function setLastClick(lastClick, transform) {
|
|
150
126
|
return (0, _pluginFactory.createCommand)({
|
|
151
127
|
type: 'SET_LAST_CLICK',
|
|
@@ -154,5 +130,4 @@ var setLastClick = function setLastClick(lastClick, transform) {
|
|
|
154
130
|
}
|
|
155
131
|
}, transform);
|
|
156
132
|
};
|
|
157
|
-
|
|
158
133
|
exports.setLastClick = setLastClick;
|
|
@@ -4,39 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.handleMouseDown = void 0;
|
|
7
|
-
|
|
8
7
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
9
|
-
|
|
10
8
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
11
|
-
|
|
12
9
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
13
|
-
|
|
14
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
|
-
|
|
16
11
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
17
|
-
|
|
18
12
|
var _transforms = require("../../transforms");
|
|
19
|
-
|
|
20
13
|
var _utils2 = require("../../utils");
|
|
21
|
-
|
|
22
14
|
var _commands = require("./commands");
|
|
23
|
-
|
|
24
15
|
var _pluginFactory = require("./plugin-factory");
|
|
25
|
-
|
|
26
16
|
var _utils3 = require("./utils");
|
|
27
|
-
|
|
28
17
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
29
|
-
|
|
18
|
+
var _misc = require("./utils/misc");
|
|
30
19
|
var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) {
|
|
31
20
|
var state = view.state,
|
|
32
|
-
|
|
21
|
+
dispatch = view.dispatch;
|
|
33
22
|
var editorDisabled = !view.editable;
|
|
34
23
|
var domAtPos = view.domAtPos.bind(view);
|
|
35
|
-
|
|
36
24
|
if (editorDisabled || localResizeHandlePos === null || !(0, _utils3.pointsAtCell)(state.doc.resolve(localResizeHandlePos))) {
|
|
37
25
|
return false;
|
|
38
26
|
}
|
|
39
|
-
|
|
40
27
|
event.preventDefault();
|
|
41
28
|
var mouseDownTime = event.timeStamp;
|
|
42
29
|
var cell = state.doc.nodeAt(localResizeHandlePos);
|
|
@@ -44,19 +31,18 @@ var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos
|
|
|
44
31
|
var originalTable = $cell.node(-1);
|
|
45
32
|
var start = $cell.start(-1);
|
|
46
33
|
var dom = domAtPos(start).node;
|
|
47
|
-
|
|
48
34
|
if (dom && dom.nodeName !== 'TABLE') {
|
|
49
35
|
dom = dom.closest('table');
|
|
50
36
|
}
|
|
51
|
-
|
|
52
37
|
var containerWidth = getEditorContainerWidth();
|
|
53
38
|
var parentWidth = (0, _nodeWidth.getParentNodeWidth)(start, state, containerWidth);
|
|
54
|
-
var maxSize = parentWidth || (0, _utils3.getLayoutSize)(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
55
39
|
|
|
40
|
+
// TODO - refactor this logic into getParentNodeWidth() in editor-common [ED-16718]
|
|
41
|
+
var parentActualWidth = (0, _misc.getParentWidthWithoutPadding)(parentWidth, start, state);
|
|
42
|
+
var maxSize = parentActualWidth || (0, _utils3.getLayoutSize)(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
56
43
|
if (originalTable.attrs.isNumberColumnEnabled) {
|
|
57
44
|
maxSize -= _editorSharedStyles.akEditorTableNumberColumnWidth;
|
|
58
45
|
}
|
|
59
|
-
|
|
60
46
|
var resizeState = (0, _utils3.getResizeState)({
|
|
61
47
|
minWidth: _styles.tableCellMinWidth,
|
|
62
48
|
maxSize: maxSize,
|
|
@@ -65,7 +51,6 @@ var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos
|
|
|
65
51
|
start: start,
|
|
66
52
|
domAtPos: domAtPos
|
|
67
53
|
});
|
|
68
|
-
|
|
69
54
|
if ((0, _commands.evenColumns)({
|
|
70
55
|
resizeState: resizeState,
|
|
71
56
|
table: originalTable,
|
|
@@ -75,60 +60,52 @@ var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos
|
|
|
75
60
|
finish(event);
|
|
76
61
|
return true;
|
|
77
62
|
}
|
|
78
|
-
|
|
79
63
|
var width = (0, _utils3.currentColWidth)(view, localResizeHandlePos, cell.attrs);
|
|
80
64
|
(0, _commands.setDragging)({
|
|
81
65
|
startX: event.clientX,
|
|
82
66
|
startWidth: width
|
|
83
67
|
})(state, dispatch);
|
|
84
|
-
|
|
85
68
|
function finish(event) {
|
|
86
69
|
window.removeEventListener('mouseup', finish);
|
|
87
70
|
window.removeEventListener('mousemove', move);
|
|
88
71
|
var clientX = event.clientX;
|
|
89
72
|
var state = view.state,
|
|
90
|
-
|
|
91
|
-
|
|
73
|
+
dispatch = view.dispatch;
|
|
92
74
|
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
75
|
+
dragging = _getPluginState.dragging,
|
|
76
|
+
resizeHandlePos = _getPluginState.resizeHandlePos;
|
|
96
77
|
if (resizeHandlePos === null) {
|
|
97
78
|
return (0, _commands.stopResizing)()(state, dispatch);
|
|
98
79
|
}
|
|
99
|
-
|
|
100
80
|
if (!(0, _utils3.pointsAtCell)(state.doc.resolve(resizeHandlePos))) {
|
|
101
81
|
return;
|
|
102
|
-
}
|
|
82
|
+
}
|
|
83
|
+
// resizeHandlePos could be remapped via a collab change.
|
|
103
84
|
// Fetch a fresh reference of the table.
|
|
104
|
-
|
|
105
|
-
|
|
106
85
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
107
86
|
var start = $cell.start(-1);
|
|
108
|
-
var table = $cell.node(-1);
|
|
87
|
+
var table = $cell.node(-1);
|
|
109
88
|
|
|
89
|
+
// If we let go in the same place we started, dont need to do anything.
|
|
110
90
|
if (dragging && clientX === dragging.startX) {
|
|
111
91
|
return (0, _commands.stopResizing)()(state, dispatch);
|
|
112
92
|
}
|
|
113
|
-
|
|
114
93
|
var tr = state.tr;
|
|
115
|
-
|
|
116
94
|
if (dragging) {
|
|
117
|
-
var startX = dragging.startX;
|
|
95
|
+
var startX = dragging.startX;
|
|
96
|
+
|
|
97
|
+
// If the table has changed (via collab for example) don't apply column widths
|
|
118
98
|
// For example, if a table col is deleted we won't be able to reliably remap the new widths
|
|
119
99
|
// There may be a more elegant solution to this, to avoid a jarring experience.
|
|
120
|
-
|
|
121
100
|
if (table.eq(originalTable)) {
|
|
122
101
|
var map = _tableMap.TableMap.get(table);
|
|
123
|
-
|
|
124
102
|
var colIndex = map.colCount($cell.pos - start) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
|
|
125
103
|
var selectionRect = (0, _utils.getSelectionRect)(state.selection);
|
|
126
|
-
var selectedColumns = selectionRect ? (0, _utils2.getSelectedColumnIndexes)(selectionRect) : [];
|
|
127
|
-
|
|
104
|
+
var selectedColumns = selectionRect ? (0, _utils2.getSelectedColumnIndexes)(selectionRect) : [];
|
|
105
|
+
// only selected (or selected - 1) columns should be distributed
|
|
128
106
|
var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
129
107
|
var newResizeState = (0, _utils3.resizeColumn)(resizeState, colIndex, clientX - startX, dom, resizingSelectedColumns ? selectedColumns : undefined);
|
|
130
108
|
tr = (0, _transforms.updateColumnWidths)(newResizeState, table, start)(tr);
|
|
131
|
-
|
|
132
109
|
if (colIndex === map.width - 1) {
|
|
133
110
|
var mouseUpTime = event.timeStamp;
|
|
134
111
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
@@ -145,38 +122,29 @@ var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos
|
|
|
145
122
|
})(tr);
|
|
146
123
|
}
|
|
147
124
|
}
|
|
148
|
-
|
|
149
125
|
return (0, _commands.stopResizing)(tr)(state, dispatch);
|
|
150
126
|
}
|
|
151
127
|
}
|
|
152
|
-
|
|
153
128
|
function move(event) {
|
|
154
129
|
var clientX = event.clientX,
|
|
155
|
-
|
|
130
|
+
which = event.which;
|
|
156
131
|
var state = view.state;
|
|
157
|
-
|
|
158
132
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
133
|
+
dragging = _getPluginState2.dragging,
|
|
134
|
+
resizeHandlePos = _getPluginState2.resizeHandlePos;
|
|
162
135
|
if (!which || !dragging || resizeHandlePos === null || !(0, _utils3.pointsAtCell)(state.doc.resolve(resizeHandlePos))) {
|
|
163
136
|
return finish(event);
|
|
164
137
|
}
|
|
165
|
-
|
|
166
138
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
167
139
|
var table = $cell.node(-1);
|
|
168
|
-
|
|
169
140
|
var map = _tableMap.TableMap.get(table);
|
|
170
|
-
|
|
171
141
|
var colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
|
|
172
142
|
(0, _utils3.resizeColumn)(resizeState, colIndex, clientX - dragging.startX, dom);
|
|
173
143
|
(0, _utils3.updateControls)(getEditorFeatureFlags)(state);
|
|
174
144
|
(0, _utils2.updateResizeHandles)(dom);
|
|
175
145
|
}
|
|
176
|
-
|
|
177
146
|
window.addEventListener('mouseup', finish);
|
|
178
147
|
window.addEventListener('mousemove', move);
|
|
179
148
|
return true;
|
|
180
149
|
};
|
|
181
|
-
|
|
182
150
|
exports.handleMouseDown = handleMouseDown;
|
|
@@ -27,11 +27,7 @@ Object.defineProperty(exports, "scaleTable", {
|
|
|
27
27
|
return _commands.scaleTable;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
|
|
31
30
|
var _plugin = require("./plugin");
|
|
32
|
-
|
|
33
31
|
var _commands = require("./commands");
|
|
34
|
-
|
|
35
32
|
var _pluginKey = require("./plugin-key");
|
|
36
|
-
|
|
37
33
|
var _pluginFactory = require("./plugin-factory");
|