@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
|
@@ -3,14 +3,11 @@ export var findStickyHeaderForTable = function findStickyHeaderForTable(state, t
|
|
|
3
3
|
if (!state || tablePos === undefined) {
|
|
4
4
|
return undefined;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
6
|
var rowInfo = state.find(function (rowInfo) {
|
|
8
7
|
return rowInfo.pos === tablePos + 1;
|
|
9
8
|
});
|
|
10
|
-
|
|
11
9
|
if (!rowInfo) {
|
|
12
10
|
return undefined;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
return rowInfo.sticky ? rowInfo : undefined;
|
|
16
13
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
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; }
|
|
4
|
-
|
|
5
3
|
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) { _defineProperty(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; }
|
|
6
|
-
|
|
7
4
|
/**
|
|
8
5
|
* A plugin for ensuring tables always have unique local IDs, and to
|
|
9
6
|
* preserve/not regenerate them when they are being cut and paste around the
|
|
@@ -16,31 +13,29 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
13
|
* TODO: https://product-fabric.atlassian.net/browse/ED-12714
|
|
17
14
|
*
|
|
18
15
|
*/
|
|
16
|
+
|
|
19
17
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
20
18
|
import { PluginKey } from 'prosemirror-state';
|
|
21
19
|
import rafSchedule from 'raf-schd';
|
|
22
20
|
import { uuid } from '@atlaskit/adf-schema';
|
|
23
21
|
import { stepAddsOneOf } from '@atlaskit/editor-common/utils';
|
|
24
22
|
var pluginKey = new PluginKey('tableLocalIdPlugin');
|
|
25
|
-
|
|
26
23
|
var getPluginState = function getPluginState(state) {
|
|
27
24
|
return state && pluginKey.getState(state);
|
|
28
25
|
};
|
|
26
|
+
|
|
29
27
|
/**
|
|
30
28
|
* Traverses a transaction's steps to see if we're inserting any tables
|
|
31
29
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
30
|
var checkIsAddingTable = function checkIsAddingTable(transaction, nodeType) {
|
|
35
31
|
return transaction.steps.some(function (step) {
|
|
36
32
|
return stepAddsOneOf(step, new Set([nodeType]));
|
|
37
33
|
});
|
|
38
34
|
};
|
|
35
|
+
|
|
39
36
|
/**
|
|
40
37
|
* Ensures uniqueness of `localId`s on tables being created or edited
|
|
41
38
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
39
|
var createPlugin = function createPlugin(dispatch) {
|
|
45
40
|
return new SafePlugin({
|
|
46
41
|
key: pluginKey,
|
|
@@ -52,21 +47,17 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
52
47
|
},
|
|
53
48
|
apply: function apply(tr, pluginState) {
|
|
54
49
|
var meta = tr.getMeta(pluginKey);
|
|
55
|
-
|
|
56
50
|
if (meta) {
|
|
57
51
|
var keys = Object.keys(meta);
|
|
58
52
|
var changed = keys.some(function (key) {
|
|
59
53
|
return pluginState[key] !== meta[key];
|
|
60
54
|
});
|
|
61
|
-
|
|
62
55
|
if (changed) {
|
|
63
56
|
var newState = _objectSpread(_objectSpread({}, pluginState), meta);
|
|
64
|
-
|
|
65
57
|
dispatch(pluginKey, newState);
|
|
66
58
|
return newState;
|
|
67
59
|
}
|
|
68
60
|
}
|
|
69
|
-
|
|
70
61
|
return pluginState;
|
|
71
62
|
}
|
|
72
63
|
},
|
|
@@ -92,17 +83,13 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
92
83
|
update: function update(editorView) {
|
|
93
84
|
var state = editorView.state;
|
|
94
85
|
var pluginState = getPluginState(state);
|
|
95
|
-
|
|
96
86
|
if (!pluginState) {
|
|
97
87
|
return;
|
|
98
88
|
}
|
|
99
|
-
|
|
100
89
|
var parsed = pluginState.parsedForLocalIds;
|
|
101
|
-
|
|
102
90
|
if (parsed) {
|
|
103
91
|
return;
|
|
104
92
|
}
|
|
105
|
-
|
|
106
93
|
var table = state.schema.nodes.table;
|
|
107
94
|
rafSchedule(function () {
|
|
108
95
|
var tr = state.tr;
|
|
@@ -110,7 +97,6 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
110
97
|
editorView.state.doc.descendants(function (node, pos) {
|
|
111
98
|
var isTable = node.type === table;
|
|
112
99
|
var localId = node.attrs.localId;
|
|
113
|
-
|
|
114
100
|
if (isTable && !localId) {
|
|
115
101
|
tableIdWasAdded = true;
|
|
116
102
|
tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
@@ -122,11 +108,8 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
122
108
|
* Otherwise continue traversing, we can encounter tables nested in
|
|
123
109
|
* expands/bodiedExtensions
|
|
124
110
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
111
|
return true;
|
|
128
112
|
});
|
|
129
|
-
|
|
130
113
|
if (tableIdWasAdded) {
|
|
131
114
|
tr.setMeta('addToHistory', false);
|
|
132
115
|
editorView.dispatch(tr);
|
|
@@ -146,58 +129,52 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
146
129
|
transactions.forEach(function (transaction) {
|
|
147
130
|
if (!transaction.docChanged) {
|
|
148
131
|
return;
|
|
149
|
-
}
|
|
150
|
-
// to handle any extra cut cases in this plugin
|
|
151
|
-
|
|
132
|
+
}
|
|
152
133
|
|
|
134
|
+
// Don't interfere with cut as it clashes with fixTables & we don't need
|
|
135
|
+
// to handle any extra cut cases in this plugin
|
|
153
136
|
var uiEvent = transaction.getMeta('uiEvent');
|
|
154
|
-
|
|
155
137
|
if (uiEvent === 'cut') {
|
|
156
138
|
return;
|
|
157
139
|
}
|
|
158
|
-
/** Check if we're actually inserting a table, otherwise we can ignore this tr */
|
|
159
|
-
|
|
160
140
|
|
|
141
|
+
/** Check if we're actually inserting a table, otherwise we can ignore this tr */
|
|
161
142
|
var isAddingTable = checkIsAddingTable(transaction, table);
|
|
162
|
-
|
|
163
143
|
if (!isAddingTable) {
|
|
164
144
|
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
145
|
+
}
|
|
167
146
|
|
|
147
|
+
// Can't simply look at changed nodes, as we could be adding a table
|
|
168
148
|
newState.doc.descendants(function (node, pos) {
|
|
169
149
|
var isTable = node.type === table;
|
|
170
|
-
var localId = node.attrs.localId;
|
|
150
|
+
var localId = node.attrs.localId;
|
|
171
151
|
|
|
152
|
+
// Dealing with a table - make sure it's a unique ID
|
|
172
153
|
if (isTable) {
|
|
173
154
|
if (localId && !idsObserved.has(localId)) {
|
|
174
|
-
idsObserved.add(localId);
|
|
155
|
+
idsObserved.add(localId);
|
|
156
|
+
// Also add a localId if it happens to not have one,
|
|
175
157
|
} else if (!localId || idsObserved.has(localId)) {
|
|
176
158
|
modified = true;
|
|
177
159
|
tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
178
160
|
localId: uuid.generate()
|
|
179
161
|
}));
|
|
180
162
|
}
|
|
181
|
-
|
|
182
163
|
return false;
|
|
183
164
|
}
|
|
165
|
+
|
|
184
166
|
/**
|
|
185
167
|
* Otherwise continue traversing, we can encounter tables nested in
|
|
186
168
|
* expands/bodiedExtensions
|
|
187
169
|
*/
|
|
188
|
-
|
|
189
|
-
|
|
190
170
|
return true;
|
|
191
171
|
});
|
|
192
172
|
});
|
|
193
|
-
|
|
194
173
|
if (modified) {
|
|
195
174
|
return tr;
|
|
196
175
|
}
|
|
197
|
-
|
|
198
176
|
return;
|
|
199
177
|
}
|
|
200
178
|
});
|
|
201
179
|
};
|
|
202
|
-
|
|
203
180
|
export { createPlugin };
|
|
@@ -8,63 +8,59 @@ export var scaleTable = function scaleTable(tableRef, options, domAtPos) {
|
|
|
8
8
|
if (!tableRef) {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
var node = options.node,
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
start = options.start,
|
|
13
|
+
parentWidth = options.parentWidth,
|
|
14
|
+
layoutChanged = options.layoutChanged;
|
|
15
15
|
|
|
16
|
+
// If a table has not been resized yet, columns should be auto.
|
|
16
17
|
if (hasTableBeenResized(node) === false) {
|
|
17
18
|
// If its not a re-sized table, we still want to re-create cols
|
|
18
19
|
// To force reflow of columns upon delete.
|
|
19
20
|
recreateResizeColsByNode(tableRef, node);
|
|
20
21
|
return false;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
23
|
var resizeState;
|
|
24
|
-
|
|
25
24
|
if (parentWidth) {
|
|
26
25
|
resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos);
|
|
27
26
|
} else {
|
|
28
27
|
resizeState = scale(tableRef, options, domAtPos);
|
|
29
28
|
}
|
|
30
|
-
|
|
31
29
|
if (resizeState) {
|
|
32
30
|
var _tr = state.tr;
|
|
33
31
|
_tr = updateColumnWidths(resizeState, node, start)(_tr);
|
|
34
|
-
|
|
35
32
|
if (_tr.docChanged && dispatch) {
|
|
36
|
-
_tr.setMeta('scrollIntoView', false);
|
|
33
|
+
_tr.setMeta('scrollIntoView', false);
|
|
34
|
+
// TODO: ED-8995
|
|
37
35
|
// We need to do this check to reduce the number of race conditions when working with tables.
|
|
38
36
|
// This metadata is been used in the sendTransaction function in the Collab plugin
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
/* Added !layoutChanged check here to solve unnecessary scroll bar after publish when click on breakout button multiple times and publish
|
|
38
|
+
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.
|
|
39
|
+
Leaving the tr.setMeta('scaleTable', true) here for race conditions that we aren't aware of.
|
|
40
|
+
*/
|
|
41
|
+
!layoutChanged && _tr.setMeta('scaleTable', true);
|
|
43
42
|
dispatch(_tr);
|
|
44
43
|
return true;
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
|
-
|
|
48
46
|
return false;
|
|
49
47
|
};
|
|
50
48
|
};
|
|
51
49
|
export var evenColumns = function evenColumns(_ref) {
|
|
52
50
|
var resizeState = _ref.resizeState,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
table = _ref.table,
|
|
52
|
+
start = _ref.start,
|
|
53
|
+
event = _ref.event;
|
|
56
54
|
return function (state, dispatch) {
|
|
57
55
|
if (!isTableSelected(state.selection)) {
|
|
58
56
|
return false;
|
|
59
|
-
}
|
|
60
|
-
// Note: ProseMirror's handleDoubleClick doesn't quite work with DOM mousedown event handler
|
|
61
|
-
|
|
57
|
+
}
|
|
62
58
|
|
|
59
|
+
// double click detection logic
|
|
60
|
+
// Note: ProseMirror's handleDoubleClick doesn't quite work with DOM mousedown event handler
|
|
63
61
|
var _getPluginState = getPluginState(state),
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
lastClick = _getPluginState.lastClick;
|
|
66
63
|
var now = Date.now();
|
|
67
|
-
|
|
68
64
|
if (lastClick && now - lastClick.time < 500 && isClickNear(event, lastClick)) {
|
|
69
65
|
var newState = evenAllColumnsWidths(resizeState);
|
|
70
66
|
setLastClick(null, function (tr) {
|
|
@@ -72,7 +68,6 @@ export var evenColumns = function evenColumns(_ref) {
|
|
|
72
68
|
})(state, dispatch);
|
|
73
69
|
return true;
|
|
74
70
|
}
|
|
75
|
-
|
|
76
71
|
setLastClick({
|
|
77
72
|
x: event.clientX,
|
|
78
73
|
y: event.clientY,
|
|
@@ -85,10 +80,8 @@ export var distributeColumnsWidths = function distributeColumnsWidths(newResizeS
|
|
|
85
80
|
return function (state, dispatch) {
|
|
86
81
|
if (dispatch) {
|
|
87
82
|
var _tr2 = updateColumnWidths(newResizeState, table.node, table.start)(state.tr);
|
|
88
|
-
|
|
89
83
|
stopResizing(_tr2)(state, dispatch);
|
|
90
84
|
}
|
|
91
|
-
|
|
92
85
|
return true;
|
|
93
86
|
};
|
|
94
87
|
};
|
|
@@ -9,16 +9,15 @@ import { evenColumns, setDragging, stopResizing } from './commands';
|
|
|
9
9
|
import { getPluginState } from './plugin-factory';
|
|
10
10
|
import { currentColWidth, getLayoutSize, getResizeState, pointsAtCell, resizeColumn, updateControls } from './utils';
|
|
11
11
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
12
|
+
import { getParentWidthWithoutPadding } from './utils/misc';
|
|
12
13
|
export var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) {
|
|
13
14
|
var state = view.state,
|
|
14
|
-
|
|
15
|
+
dispatch = view.dispatch;
|
|
15
16
|
var editorDisabled = !view.editable;
|
|
16
17
|
var domAtPos = view.domAtPos.bind(view);
|
|
17
|
-
|
|
18
18
|
if (editorDisabled || localResizeHandlePos === null || !pointsAtCell(state.doc.resolve(localResizeHandlePos))) {
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
21
|
event.preventDefault();
|
|
23
22
|
var mouseDownTime = event.timeStamp;
|
|
24
23
|
var cell = state.doc.nodeAt(localResizeHandlePos);
|
|
@@ -26,19 +25,18 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
26
25
|
var originalTable = $cell.node(-1);
|
|
27
26
|
var start = $cell.start(-1);
|
|
28
27
|
var dom = domAtPos(start).node;
|
|
29
|
-
|
|
30
28
|
if (dom && dom.nodeName !== 'TABLE') {
|
|
31
29
|
dom = dom.closest('table');
|
|
32
30
|
}
|
|
33
|
-
|
|
34
31
|
var containerWidth = getEditorContainerWidth();
|
|
35
32
|
var parentWidth = getParentNodeWidth(start, state, containerWidth);
|
|
36
|
-
var maxSize = parentWidth || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
37
33
|
|
|
34
|
+
// TODO - refactor this logic into getParentNodeWidth() in editor-common [ED-16718]
|
|
35
|
+
var parentActualWidth = getParentWidthWithoutPadding(parentWidth, start, state);
|
|
36
|
+
var maxSize = parentActualWidth || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
38
37
|
if (originalTable.attrs.isNumberColumnEnabled) {
|
|
39
38
|
maxSize -= akEditorTableNumberColumnWidth;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
40
|
var resizeState = getResizeState({
|
|
43
41
|
minWidth: tableCellMinWidth,
|
|
44
42
|
maxSize: maxSize,
|
|
@@ -47,7 +45,6 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
47
45
|
start: start,
|
|
48
46
|
domAtPos: domAtPos
|
|
49
47
|
});
|
|
50
|
-
|
|
51
48
|
if (evenColumns({
|
|
52
49
|
resizeState: resizeState,
|
|
53
50
|
table: originalTable,
|
|
@@ -57,59 +54,52 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
57
54
|
finish(event);
|
|
58
55
|
return true;
|
|
59
56
|
}
|
|
60
|
-
|
|
61
57
|
var width = currentColWidth(view, localResizeHandlePos, cell.attrs);
|
|
62
58
|
setDragging({
|
|
63
59
|
startX: event.clientX,
|
|
64
60
|
startWidth: width
|
|
65
61
|
})(state, dispatch);
|
|
66
|
-
|
|
67
62
|
function finish(event) {
|
|
68
63
|
window.removeEventListener('mouseup', finish);
|
|
69
64
|
window.removeEventListener('mousemove', move);
|
|
70
65
|
var clientX = event.clientX;
|
|
71
66
|
var state = view.state,
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
dispatch = view.dispatch;
|
|
74
68
|
var _getPluginState = getPluginState(state),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
dragging = _getPluginState.dragging,
|
|
70
|
+
resizeHandlePos = _getPluginState.resizeHandlePos;
|
|
78
71
|
if (resizeHandlePos === null) {
|
|
79
72
|
return stopResizing()(state, dispatch);
|
|
80
73
|
}
|
|
81
|
-
|
|
82
74
|
if (!pointsAtCell(state.doc.resolve(resizeHandlePos))) {
|
|
83
75
|
return;
|
|
84
|
-
}
|
|
76
|
+
}
|
|
77
|
+
// resizeHandlePos could be remapped via a collab change.
|
|
85
78
|
// Fetch a fresh reference of the table.
|
|
86
|
-
|
|
87
|
-
|
|
88
79
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
89
80
|
var start = $cell.start(-1);
|
|
90
|
-
var table = $cell.node(-1);
|
|
81
|
+
var table = $cell.node(-1);
|
|
91
82
|
|
|
83
|
+
// If we let go in the same place we started, dont need to do anything.
|
|
92
84
|
if (dragging && clientX === dragging.startX) {
|
|
93
85
|
return stopResizing()(state, dispatch);
|
|
94
86
|
}
|
|
95
|
-
|
|
96
87
|
var tr = state.tr;
|
|
97
|
-
|
|
98
88
|
if (dragging) {
|
|
99
|
-
var startX = dragging.startX;
|
|
89
|
+
var startX = dragging.startX;
|
|
90
|
+
|
|
91
|
+
// If the table has changed (via collab for example) don't apply column widths
|
|
100
92
|
// For example, if a table col is deleted we won't be able to reliably remap the new widths
|
|
101
93
|
// There may be a more elegant solution to this, to avoid a jarring experience.
|
|
102
|
-
|
|
103
94
|
if (table.eq(originalTable)) {
|
|
104
95
|
var map = TableMap.get(table);
|
|
105
96
|
var colIndex = map.colCount($cell.pos - start) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
|
|
106
97
|
var selectionRect = getSelectionRect(state.selection);
|
|
107
|
-
var selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
108
|
-
|
|
98
|
+
var selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
99
|
+
// only selected (or selected - 1) columns should be distributed
|
|
109
100
|
var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
110
101
|
var newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, resizingSelectedColumns ? selectedColumns : undefined);
|
|
111
102
|
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
112
|
-
|
|
113
103
|
if (colIndex === map.width - 1) {
|
|
114
104
|
var mouseUpTime = event.timeStamp;
|
|
115
105
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
@@ -126,24 +116,19 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
126
116
|
})(tr);
|
|
127
117
|
}
|
|
128
118
|
}
|
|
129
|
-
|
|
130
119
|
return stopResizing(tr)(state, dispatch);
|
|
131
120
|
}
|
|
132
121
|
}
|
|
133
|
-
|
|
134
122
|
function move(event) {
|
|
135
123
|
var clientX = event.clientX,
|
|
136
|
-
|
|
124
|
+
which = event.which;
|
|
137
125
|
var state = view.state;
|
|
138
|
-
|
|
139
126
|
var _getPluginState2 = getPluginState(state),
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
127
|
+
dragging = _getPluginState2.dragging,
|
|
128
|
+
resizeHandlePos = _getPluginState2.resizeHandlePos;
|
|
143
129
|
if (!which || !dragging || resizeHandlePos === null || !pointsAtCell(state.doc.resolve(resizeHandlePos))) {
|
|
144
130
|
return finish(event);
|
|
145
131
|
}
|
|
146
|
-
|
|
147
132
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
148
133
|
var table = $cell.node(-1);
|
|
149
134
|
var map = TableMap.get(table);
|
|
@@ -152,7 +137,6 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
152
137
|
updateControls(getEditorFeatureFlags)(state);
|
|
153
138
|
updateResizeHandles(dom);
|
|
154
139
|
}
|
|
155
|
-
|
|
156
140
|
window.addEventListener('mouseup', finish);
|
|
157
141
|
window.addEventListener('mousemove', move);
|
|
158
142
|
return true;
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
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; }
|
|
4
|
-
|
|
5
3
|
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) { _defineProperty(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; }
|
|
6
|
-
|
|
7
4
|
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
8
5
|
import { pluginKey } from './plugin-key';
|
|
9
6
|
import reducer from './reducer';
|
|
10
|
-
|
|
11
7
|
function mapping(tr, pluginState) {
|
|
12
8
|
if (pluginState && pluginState.resizeHandlePos !== null) {
|
|
13
9
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
14
10
|
resizeHandlePos: tr.mapping.map(pluginState.resizeHandlePos)
|
|
15
11
|
});
|
|
16
12
|
}
|
|
17
|
-
|
|
18
13
|
return pluginState;
|
|
19
14
|
}
|
|
20
|
-
|
|
21
15
|
var factory = pluginFactory(pluginKey, reducer, {
|
|
22
16
|
mapping: mapping
|
|
23
17
|
});
|
|
@@ -9,7 +9,7 @@ import { pluginKey } from './plugin-key';
|
|
|
9
9
|
import { getResizeCellPos } from './utils';
|
|
10
10
|
export function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) {
|
|
11
11
|
var _ref$lastColumnResiza = _ref.lastColumnResizable,
|
|
12
|
-
|
|
12
|
+
lastColumnResizable = _ref$lastColumnResiza === void 0 ? true : _ref$lastColumnResiza;
|
|
13
13
|
return new SafePlugin({
|
|
14
14
|
key: pluginKey,
|
|
15
15
|
state: createPluginState(dispatch, {
|
|
@@ -21,7 +21,6 @@ export function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorF
|
|
|
21
21
|
props: {
|
|
22
22
|
attributes: function attributes(state) {
|
|
23
23
|
var _classnames;
|
|
24
|
-
|
|
25
24
|
var pluginState = getPluginState(state);
|
|
26
25
|
return {
|
|
27
26
|
class: classnames(ClassName.RESIZING_PLUGIN, (_classnames = {}, _defineProperty(_classnames, ClassName.RESIZE_CURSOR, pluginState.resizeHandlePos !== null), _defineProperty(_classnames, ClassName.IS_RESIZING, !!pluginState.dragging), _classnames))
|
|
@@ -30,20 +29,18 @@ export function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorF
|
|
|
30
29
|
handleDOMEvents: {
|
|
31
30
|
mousedown: function mousedown(view, event) {
|
|
32
31
|
var state = view.state;
|
|
33
|
-
var resizeHandlePos =
|
|
32
|
+
var resizeHandlePos =
|
|
33
|
+
// we're setting `resizeHandlePos` via command in unit tests
|
|
34
34
|
getPluginState(state).resizeHandlePos || getResizeCellPos(view, event, lastColumnResizable);
|
|
35
|
-
|
|
36
35
|
var _getPluginState = getPluginState(state),
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
dragging = _getPluginState.dragging;
|
|
39
37
|
if (resizeHandlePos !== null && !dragging) {
|
|
40
38
|
if (handleMouseDown(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI)) {
|
|
41
39
|
var _state = view.state,
|
|
42
|
-
|
|
40
|
+
_dispatch = view.dispatch;
|
|
43
41
|
return setResizeHandlePos(resizeHandlePos)(_state, _dispatch);
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
|
-
|
|
47
44
|
return false;
|
|
48
45
|
}
|
|
49
46
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
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; }
|
|
4
|
-
|
|
5
3
|
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) { _defineProperty(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; }
|
|
6
|
-
|
|
7
4
|
export default (function (pluginState, action) {
|
|
8
5
|
switch (action.type) {
|
|
9
6
|
case 'STOP_RESIZING':
|
|
@@ -11,24 +8,20 @@ export default (function (pluginState, action) {
|
|
|
11
8
|
resizeHandlePos: null,
|
|
12
9
|
dragging: null
|
|
13
10
|
});
|
|
14
|
-
|
|
15
11
|
case 'SET_RESIZE_HANDLE_POSITION':
|
|
16
12
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
17
13
|
resizeHandlePos: action.data.resizeHandlePos
|
|
18
14
|
});
|
|
19
|
-
|
|
20
15
|
case 'SET_DRAGGING':
|
|
21
16
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
22
17
|
dragging: action.data.dragging
|
|
23
18
|
});
|
|
24
|
-
|
|
25
19
|
case 'SET_LAST_CLICK':
|
|
26
20
|
var lastClick = action.data.lastClick;
|
|
27
21
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
28
22
|
lastClick: lastClick,
|
|
29
23
|
resizeHandlePos: lastClick ? pluginState.resizeHandlePos : null
|
|
30
24
|
});
|
|
31
|
-
|
|
32
25
|
default:
|
|
33
26
|
return pluginState;
|
|
34
27
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import { DOMSerializer } from 'prosemirror-model';
|
|
3
3
|
import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
4
|
+
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
4
5
|
export var generateColgroup = function generateColgroup(table) {
|
|
5
6
|
var cols = [];
|
|
6
7
|
table.content.firstChild.content.forEach(function (cell) {
|
|
7
8
|
var colspan = cell.attrs.colspan || 1;
|
|
8
|
-
|
|
9
9
|
if (Array.isArray(cell.attrs.colwidth)) {
|
|
10
10
|
// We slice here to guard against our colwidth array having more entries
|
|
11
11
|
// Than the we actually span. We'll patch the document at a later point.
|
|
@@ -29,11 +29,9 @@ export var generateColgroup = function generateColgroup(table) {
|
|
|
29
29
|
};
|
|
30
30
|
export var insertColgroupFromNode = function insertColgroupFromNode(tableRef, table) {
|
|
31
31
|
var colgroup = tableRef.querySelector('colgroup');
|
|
32
|
-
|
|
33
32
|
if (colgroup) {
|
|
34
33
|
tableRef.removeChild(colgroup);
|
|
35
34
|
}
|
|
36
|
-
|
|
37
35
|
colgroup = renderColgroupFromNode(table);
|
|
38
36
|
tableRef.insertBefore(colgroup, tableRef.firstChild);
|
|
39
37
|
return colgroup.children;
|
|
@@ -44,6 +42,19 @@ export var hasTableBeenResized = function hasTableBeenResized(table) {
|
|
|
44
42
|
});
|
|
45
43
|
};
|
|
46
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Check if a table has all the column width set to tableCellMinWidth(48px) or null
|
|
47
|
+
*
|
|
48
|
+
* @param table
|
|
49
|
+
* @returns true if all column width is equal to tableCellMinWidth or null, false otherwise
|
|
50
|
+
*/
|
|
51
|
+
export var isMinCellWidthTable = function isMinCellWidthTable(table) {
|
|
52
|
+
var cellArray = getFragmentBackingArray(table.content.firstChild.content);
|
|
53
|
+
var isTableMinCellWidth = cellArray.every(function (cell) {
|
|
54
|
+
return cell.attrs.colwidth && cell.attrs.colwidth[0] === tableCellMinWidth || cell.attrs.colwidth === null;
|
|
55
|
+
});
|
|
56
|
+
return isTableMinCellWidth;
|
|
57
|
+
};
|
|
47
58
|
function renderColgroupFromNode(table) {
|
|
48
59
|
var rendered = DOMSerializer.renderSpec(document, ['colgroup', {}].concat(_toConsumableArray(generateColgroup(table))));
|
|
49
60
|
return rendered.dom;
|
|
@@ -6,7 +6,8 @@ import { unitToNumber } from './unit-to-number';
|
|
|
6
6
|
// Reads `width` and `minWidth` of each column from DOM and returns `ColumnState` containing those values
|
|
7
7
|
export var getColumnStateFromDOM = function getColumnStateFromDOM(cells, index, minWidth) {
|
|
8
8
|
var width = calculateColumnWidth(cells, calculateColumnWidthCallback);
|
|
9
|
-
var minColumnWidth = width < minWidth ?
|
|
9
|
+
var minColumnWidth = width < minWidth ?
|
|
10
|
+
// for newly created column (where width < minWidth) we set minWidth = tableNewColumnMinWidth (140px atm)
|
|
10
11
|
tableNewColumnMinWidth : calculateColumnWidth(cells, calculateColumnMinWidthCallback(minWidth));
|
|
11
12
|
return {
|
|
12
13
|
index: index,
|
|
@@ -16,8 +17,9 @@ export var getColumnStateFromDOM = function getColumnStateFromDOM(cells, index,
|
|
|
16
17
|
};
|
|
17
18
|
export var getFreeSpace = function getFreeSpace(state) {
|
|
18
19
|
return Math.max(state.width - state.minWidth, 0);
|
|
19
|
-
};
|
|
20
|
+
};
|
|
20
21
|
|
|
22
|
+
// Returns DOM refs of all cells in a column by `columnIndex`
|
|
21
23
|
export var getCellsRefsInColumn = function getCellsRefsInColumn(columnIndex, table, tableStart, domAtPos) {
|
|
22
24
|
var map = TableMap.get(table);
|
|
23
25
|
var cellsPositions = map.cellsInRect({
|
|
@@ -29,26 +31,24 @@ export var getCellsRefsInColumn = function getCellsRefsInColumn(columnIndex, tab
|
|
|
29
31
|
var cells = [];
|
|
30
32
|
cellsPositions.forEach(function (pos) {
|
|
31
33
|
var col = findDomRefAtPos(pos + tableStart, domAtPos);
|
|
32
|
-
|
|
33
34
|
if (col) {
|
|
34
35
|
cells.push(col);
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
38
|
return cells;
|
|
38
|
-
};
|
|
39
|
+
};
|
|
39
40
|
|
|
41
|
+
// calculates column widths based on `cells` DOM refs
|
|
40
42
|
export var calculateColumnWidth = function calculateColumnWidth(cells, calculateColumnWidthCb) {
|
|
41
43
|
var maxColWidth = 0;
|
|
42
44
|
var colSpanWidth = 0;
|
|
43
45
|
cells.forEach(function (cellRef) {
|
|
44
46
|
var css = getComputedStyle(cellRef);
|
|
45
47
|
var colspan = Number(cellRef.getAttribute('colspan') || 1);
|
|
46
|
-
|
|
47
48
|
if (colspan > 1) {
|
|
48
49
|
colSpanWidth = calculateColumnWidthCb(css, cellRef, colspan);
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
52
|
if (css) {
|
|
53
53
|
var colWidth = calculateColumnWidthCb(css, cellRef, colspan);
|
|
54
54
|
maxColWidth = Math.max(colWidth, maxColWidth);
|
|
@@ -59,22 +59,18 @@ export var calculateColumnWidth = function calculateColumnWidth(cells, calculate
|
|
|
59
59
|
export var addContainerLeftRightPadding = function addContainerLeftRightPadding(amount, css) {
|
|
60
60
|
return amount + unitToNumber(css.paddingLeft) + unitToNumber(css.paddingRight);
|
|
61
61
|
};
|
|
62
|
-
|
|
63
62
|
function calculateColumnWidthCallback(css) {
|
|
64
63
|
return unitToNumber(css.width);
|
|
65
64
|
}
|
|
66
|
-
|
|
67
65
|
function calculateColumnMinWidthCallback(minColumnWidth) {
|
|
68
66
|
return function (css, cellRef, colSpan) {
|
|
69
67
|
if (colSpan && colSpan > 1) {
|
|
70
68
|
return unitToNumber(css.width);
|
|
71
69
|
}
|
|
72
|
-
|
|
73
70
|
var _contentWidth = contentWidth(cellRef, cellRef),
|
|
74
|
-
|
|
71
|
+
minContentWidth = _contentWidth.minWidth;
|
|
72
|
+
// Override the min width, if there is content that can't collapse
|
|
75
73
|
// Past a certain width.
|
|
76
|
-
|
|
77
|
-
|
|
78
74
|
return Math.max(addContainerLeftRightPadding(minContentWidth, css), minContentWidth, minColumnWidth);
|
|
79
75
|
};
|
|
80
76
|
}
|