@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,46 +1,33 @@
|
|
|
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.isColumnDeleteButtonVisible = exports.getColumnsWidths = exports.getColumnDeleteButtonParams = exports.getColumnClassNames = exports.colWidthsForRow = void 0;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
13
|
-
|
|
14
10
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
15
|
-
|
|
16
11
|
var _prosemirrorUtils = require("prosemirror-utils");
|
|
17
|
-
|
|
18
12
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
19
|
-
|
|
20
13
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
21
|
-
|
|
22
14
|
var _types = require("../types");
|
|
23
|
-
|
|
24
15
|
var _consts = require("../ui/consts");
|
|
25
|
-
|
|
26
16
|
var getColumnsWidths = function getColumnsWidths(view) {
|
|
27
17
|
var selection = view.state.selection;
|
|
28
18
|
var widths = [];
|
|
29
19
|
var table = (0, _utils.findTable)(selection);
|
|
30
|
-
|
|
31
20
|
if (table) {
|
|
32
21
|
var map = _tableMap.TableMap.get(table.node);
|
|
22
|
+
var domAtPos = view.domAtPos.bind(view);
|
|
33
23
|
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
// When there is no cell we need to fill it with undefined
|
|
36
25
|
widths = Array.from({
|
|
37
26
|
length: map.width
|
|
38
27
|
});
|
|
39
|
-
|
|
40
28
|
for (var i = 0; i < map.width; i++) {
|
|
41
29
|
var cells = (0, _utils.getCellsInColumn)(i)(selection);
|
|
42
30
|
var cell = cells[0];
|
|
43
|
-
|
|
44
31
|
if (cell) {
|
|
45
32
|
var cellRef = (0, _prosemirrorUtils.findDomRefAtPos)(cell.pos, domAtPos);
|
|
46
33
|
var rect = cellRef.getBoundingClientRect();
|
|
@@ -49,82 +36,63 @@ var getColumnsWidths = function getColumnsWidths(view) {
|
|
|
49
36
|
}
|
|
50
37
|
}
|
|
51
38
|
}
|
|
52
|
-
|
|
53
39
|
return widths;
|
|
54
40
|
};
|
|
55
|
-
|
|
56
41
|
exports.getColumnsWidths = getColumnsWidths;
|
|
57
|
-
|
|
58
42
|
var isColumnDeleteButtonVisible = function isColumnDeleteButtonVisible(selection) {
|
|
59
43
|
if (!(0, _utils.isTableSelected)(selection) && selection instanceof _cellSelection.CellSelection && selection.isColSelection()) {
|
|
60
44
|
return true;
|
|
61
45
|
}
|
|
62
|
-
|
|
63
46
|
return false;
|
|
64
47
|
};
|
|
65
|
-
|
|
66
48
|
exports.isColumnDeleteButtonVisible = isColumnDeleteButtonVisible;
|
|
67
|
-
|
|
68
49
|
var getColumnDeleteButtonParams = function getColumnDeleteButtonParams(columnsWidths, selection) {
|
|
69
50
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
70
|
-
|
|
71
51
|
if (!rect) {
|
|
72
52
|
return null;
|
|
73
53
|
}
|
|
74
|
-
|
|
75
54
|
var width = 0;
|
|
76
|
-
var offset = 0;
|
|
77
|
-
|
|
55
|
+
var offset = 0;
|
|
56
|
+
// find the columns before the selection
|
|
78
57
|
for (var i = 0; i < rect.left; i++) {
|
|
79
58
|
var colWidth = columnsWidths[i];
|
|
80
|
-
|
|
81
59
|
if (colWidth) {
|
|
82
60
|
offset += colWidth - 1;
|
|
83
61
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
62
|
+
}
|
|
63
|
+
// these are the selected columns widths
|
|
87
64
|
var indexes = [];
|
|
88
|
-
|
|
89
65
|
for (var _i = rect.left; _i < rect.right; _i++) {
|
|
90
66
|
var _colWidth = columnsWidths[_i];
|
|
91
|
-
|
|
92
67
|
if (_colWidth) {
|
|
93
68
|
width += _colWidth;
|
|
94
69
|
indexes.push(_i);
|
|
95
70
|
}
|
|
96
71
|
}
|
|
97
|
-
|
|
98
72
|
var left = offset + width / 2 - _consts.tableDeleteButtonSize / 2;
|
|
99
73
|
return {
|
|
100
74
|
left: left,
|
|
101
75
|
indexes: indexes
|
|
102
76
|
};
|
|
103
77
|
};
|
|
104
|
-
|
|
105
78
|
exports.getColumnDeleteButtonParams = getColumnDeleteButtonParams;
|
|
106
|
-
|
|
107
79
|
var getColumnClassNames = function getColumnClassNames(index, selection) {
|
|
108
80
|
var hoveredColumns = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
109
81
|
var isInDanger = arguments.length > 3 ? arguments[3] : undefined;
|
|
110
82
|
var isResizing = arguments.length > 4 ? arguments[4] : undefined;
|
|
111
83
|
var classNames = [];
|
|
112
|
-
|
|
113
84
|
if ((0, _utils.isColumnSelected)(index)(selection) || hoveredColumns.indexOf(index) > -1 && !isResizing) {
|
|
114
85
|
classNames.push(_types.TableCssClassName.HOVERED_CELL_ACTIVE);
|
|
115
|
-
|
|
116
86
|
if (isInDanger) {
|
|
117
87
|
classNames.push(_types.TableCssClassName.HOVERED_CELL_IN_DANGER);
|
|
118
88
|
}
|
|
119
89
|
}
|
|
120
|
-
|
|
121
90
|
return classNames.join(' ');
|
|
122
|
-
};
|
|
123
|
-
// and map to a row's colwidths
|
|
124
|
-
|
|
91
|
+
};
|
|
125
92
|
|
|
93
|
+
// give a row colspan and a colwidths
|
|
94
|
+
// and map to a row's colwidths
|
|
126
95
|
exports.getColumnClassNames = getColumnClassNames;
|
|
127
|
-
|
|
128
96
|
var mapTableColwidthsToRow = function mapTableColwidthsToRow(rowColSpans, tableColWidths) {
|
|
129
97
|
var curColIdx = 0;
|
|
130
98
|
var colWidths = [];
|
|
@@ -137,12 +105,10 @@ var mapTableColwidthsToRow = function mapTableColwidthsToRow(rowColSpans, tableC
|
|
|
137
105
|
});
|
|
138
106
|
return colWidths;
|
|
139
107
|
};
|
|
140
|
-
|
|
141
108
|
var getRelativeDomCellWidths = function getRelativeDomCellWidths(_ref) {
|
|
142
109
|
var width = _ref.width,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
110
|
+
colspan = _ref.colspan,
|
|
111
|
+
colwidth = _ref.colwidth;
|
|
146
112
|
// For cells with colSpan 1
|
|
147
113
|
// or
|
|
148
114
|
// for cells in a table with unchanged column widths,
|
|
@@ -150,20 +116,22 @@ var getRelativeDomCellWidths = function getRelativeDomCellWidths(_ref) {
|
|
|
150
116
|
// return equally partitioned total cell width in DOM for each cell.
|
|
151
117
|
if (colspan === 1 || !colwidth) {
|
|
152
118
|
return new Array(colspan).fill(width / colspan);
|
|
153
|
-
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// For cells that have colSpan > 1 and
|
|
154
122
|
// are part of a table with resized columns
|
|
155
123
|
// return the current total DOM width of the cell multiplied
|
|
156
124
|
// by the percentage of the each individual cell's size.
|
|
157
125
|
// The cell size percentage is calculated using individual colwidth of the cell,
|
|
158
126
|
// from data-colwidth attribute on the cell,
|
|
159
127
|
// divided by the total width of the cells from colwidths for merged cells.
|
|
128
|
+
|
|
160
129
|
// Ex:
|
|
161
130
|
// colwidth = ‘201,102’
|
|
162
131
|
// Total colWidth = 303
|
|
163
132
|
// returned cellWidths = [303 * (201/303), 303 * (102/303)]
|
|
164
|
-
// For merged cells we get back colwidth as `201,102`
|
|
165
|
-
|
|
166
133
|
|
|
134
|
+
// For merged cells we get back colwidth as `201,102`
|
|
167
135
|
var cellColWidths = colwidth.split(',').map(function (colwidth) {
|
|
168
136
|
return Number(colwidth);
|
|
169
137
|
});
|
|
@@ -174,14 +142,13 @@ var getRelativeDomCellWidths = function getRelativeDomCellWidths(_ref) {
|
|
|
174
142
|
return width * (cellColWidth / totalCalculatedCellWidth);
|
|
175
143
|
});
|
|
176
144
|
};
|
|
177
|
-
|
|
178
145
|
var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
|
|
179
146
|
// get the colspans
|
|
180
147
|
var rowColSpans = (0, _utils2.maphElem)(tr, function (cell) {
|
|
181
|
-
return Number(cell.getAttribute('colspan') || 1
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
148
|
+
return Number(cell.getAttribute('colspan') || 1 /* default to span of 1 */);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Chrome has trouble aligning borders with auto tables
|
|
185
152
|
// and the rest of the page grid. tables with defined
|
|
186
153
|
// column widths align fine.
|
|
187
154
|
//
|
|
@@ -189,9 +156,7 @@ var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
|
|
|
189
156
|
//
|
|
190
157
|
// prefer copying the widths via the DOM
|
|
191
158
|
// or inferring from the next row if one exists
|
|
192
|
-
|
|
193
159
|
var copyTarget = tr.nextElementSibling || tr;
|
|
194
|
-
|
|
195
160
|
if (copyTarget) {
|
|
196
161
|
// either from the first row while it's still in the table
|
|
197
162
|
var cellInfos = (0, _utils2.maphElem)(copyTarget, function (cell) {
|
|
@@ -200,13 +165,13 @@ var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
|
|
|
200
165
|
colspan: Number(cell.getAttribute('colspan') || 1),
|
|
201
166
|
colwidth: cell.dataset.colwidth
|
|
202
167
|
};
|
|
203
|
-
});
|
|
168
|
+
});
|
|
204
169
|
|
|
170
|
+
// reverse engineer cell widths from table widths
|
|
205
171
|
var domBasedCellWidths = [];
|
|
206
172
|
cellInfos.map(function (cell, idx) {
|
|
207
173
|
domBasedCellWidths.push.apply(domBasedCellWidths, (0, _toConsumableArray2.default)(getRelativeDomCellWidths(cell)));
|
|
208
174
|
});
|
|
209
|
-
|
|
210
175
|
if (cellInfos.reduce(function (acc, cell) {
|
|
211
176
|
return acc + cell.width;
|
|
212
177
|
}, 0) !== 0) {
|
|
@@ -215,10 +180,10 @@ var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
|
|
|
215
180
|
return "".concat(px, "px");
|
|
216
181
|
}).join(' ');
|
|
217
182
|
}
|
|
218
|
-
}
|
|
219
|
-
// it aligns perfectly in the user's browser
|
|
220
|
-
|
|
183
|
+
}
|
|
221
184
|
|
|
185
|
+
// as a fallback, just calculate a %, and hope that
|
|
186
|
+
// it aligns perfectly in the user's browser
|
|
222
187
|
var visualColCount = rowColSpans.reduce(function (acc, val) {
|
|
223
188
|
return acc + val;
|
|
224
189
|
}, 0);
|
|
@@ -229,5 +194,4 @@ var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
|
|
|
229
194
|
return "".concat(pct, "%");
|
|
230
195
|
}).join(' ');
|
|
231
196
|
};
|
|
232
|
-
|
|
233
197
|
exports.colWidthsForRow = colWidthsForRow;
|
|
@@ -1,42 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.updateDecorations = exports.findControlsHoverDecoration = exports.findColumnControlSelectedDecoration = exports.createResizeHandleDecoration = exports.createControlsHoverDecoration = exports.createColumnSelectedDecoration = exports.createColumnLineResize = exports.createColumnControlsDecoration = exports.createCellHoverDecoration = void 0;
|
|
9
|
-
|
|
10
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
|
|
12
9
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
13
|
-
|
|
14
10
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
15
|
-
|
|
16
11
|
var _prosemirrorView = require("prosemirror-view");
|
|
17
|
-
|
|
18
12
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
19
|
-
|
|
20
13
|
var _types = require("../types");
|
|
21
|
-
|
|
22
14
|
var filterDecorationByKey = function filterDecorationByKey(key, decorationSet) {
|
|
23
15
|
return decorationSet.find(undefined, undefined, function (spec) {
|
|
24
16
|
return spec.key.indexOf(key) > -1;
|
|
25
17
|
});
|
|
26
18
|
};
|
|
27
|
-
|
|
28
19
|
var findColumnControlSelectedDecoration = function findColumnControlSelectedDecoration(decorationSet) {
|
|
29
20
|
return filterDecorationByKey(_types.TableDecorations.COLUMN_SELECTED, decorationSet);
|
|
30
21
|
};
|
|
31
|
-
|
|
32
22
|
exports.findColumnControlSelectedDecoration = findColumnControlSelectedDecoration;
|
|
33
|
-
|
|
34
23
|
var findControlsHoverDecoration = function findControlsHoverDecoration(decorationSet) {
|
|
35
24
|
return filterDecorationByKey(_types.TableDecorations.ALL_CONTROLS_HOVER, decorationSet);
|
|
36
25
|
};
|
|
37
|
-
|
|
38
26
|
exports.findControlsHoverDecoration = findControlsHoverDecoration;
|
|
39
|
-
|
|
40
27
|
var createCellHoverDecoration = function createCellHoverDecoration(cells, type) {
|
|
41
28
|
return cells.map(function (cell) {
|
|
42
29
|
return _prosemirrorView.Decoration.node(cell.pos, cell.pos + cell.node.nodeSize, {
|
|
@@ -46,44 +33,36 @@ var createCellHoverDecoration = function createCellHoverDecoration(cells, type)
|
|
|
46
33
|
});
|
|
47
34
|
});
|
|
48
35
|
};
|
|
49
|
-
|
|
50
36
|
exports.createCellHoverDecoration = createCellHoverDecoration;
|
|
51
|
-
|
|
52
37
|
var createControlsHoverDecoration = function createControlsHoverDecoration(cells, type, tr, danger, selected) {
|
|
53
38
|
var table = (0, _utils.findTable)(tr.selection);
|
|
54
|
-
|
|
55
39
|
if (!table) {
|
|
56
40
|
return [];
|
|
57
41
|
}
|
|
58
|
-
|
|
59
42
|
var map = _tableMap.TableMap.get(table.node);
|
|
60
|
-
|
|
61
43
|
var _cells$reduce = cells.reduce(function (_ref, cell) {
|
|
62
|
-
|
|
44
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
63
45
|
min = _ref2[0],
|
|
64
46
|
max = _ref2[1];
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
_cells$reduce2 = (0, _slicedToArray2.default)(_cells$reduce, 2),
|
|
77
|
-
min = _cells$reduce2[0],
|
|
78
|
-
max = _cells$reduce2[1];
|
|
79
|
-
|
|
47
|
+
if (min === null || cell.pos < min) {
|
|
48
|
+
min = cell.pos;
|
|
49
|
+
}
|
|
50
|
+
if (max === null || cell.pos > max) {
|
|
51
|
+
max = cell.pos;
|
|
52
|
+
}
|
|
53
|
+
return [min, max];
|
|
54
|
+
}, [null, null]),
|
|
55
|
+
_cells$reduce2 = (0, _slicedToArray2.default)(_cells$reduce, 2),
|
|
56
|
+
min = _cells$reduce2[0],
|
|
57
|
+
max = _cells$reduce2[1];
|
|
80
58
|
if (min === null || max === null) {
|
|
81
59
|
return [];
|
|
82
60
|
}
|
|
83
|
-
|
|
84
61
|
var updatedCells = cells.map(function (x) {
|
|
85
62
|
return x.pos;
|
|
86
|
-
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// ED-15246 fixed trello card table overflow issue
|
|
87
66
|
// If columns / rows have been merged the hovered selection is different to the actual selection
|
|
88
67
|
// So If the table cells are in danger we want to create a "rectangle" selection
|
|
89
68
|
// to match the "clicked" selection
|
|
@@ -92,68 +71,59 @@ var createControlsHoverDecoration = function createControlsHoverDecoration(cells
|
|
|
92
71
|
// Find the bounding rectangle of all the given cells, also considering
|
|
93
72
|
// merged cells.
|
|
94
73
|
var _cells$reduce3 = cells.reduce(function (acc, cell) {
|
|
95
|
-
|
|
74
|
+
var _map$findCell = map.findCell(cell.pos - table.start),
|
|
96
75
|
left = _map$findCell.left,
|
|
97
76
|
right = _map$findCell.right,
|
|
98
77
|
bottom = _map$findCell.bottom,
|
|
99
|
-
top = _map$findCell.top;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
78
|
+
top = _map$findCell.top;
|
|
79
|
+
// Finding the bounding rect requires finding the min left and top positions,
|
|
80
|
+
// and the max right and bottom positions of the cells
|
|
81
|
+
return {
|
|
82
|
+
recLeft: Math.min(acc.recLeft, left),
|
|
83
|
+
recTop: Math.min(acc.recTop, top),
|
|
84
|
+
recRight: Math.max(acc.recRight, right),
|
|
85
|
+
recBottom: Math.max(acc.recBottom, bottom)
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
// +-Infinity as initialisation vars which will always be overwritten
|
|
89
|
+
// by smaller/larger values respectively
|
|
90
|
+
{
|
|
91
|
+
recLeft: Infinity,
|
|
92
|
+
recTop: Infinity,
|
|
93
|
+
recRight: -Infinity,
|
|
94
|
+
recBottom: -Infinity
|
|
95
|
+
}),
|
|
96
|
+
recLeft = _cells$reduce3.recLeft,
|
|
97
|
+
recTop = _cells$reduce3.recTop,
|
|
98
|
+
recRight = _cells$reduce3.recRight,
|
|
99
|
+
recBottom = _cells$reduce3.recBottom;
|
|
122
100
|
var rect = new _tableMap.Rect(recLeft, recTop, recRight, recBottom);
|
|
123
101
|
updatedCells = map.cellsInRect(rect).map(function (x) {
|
|
124
102
|
return x + table.start;
|
|
125
103
|
});
|
|
126
104
|
}
|
|
127
|
-
|
|
128
105
|
return updatedCells.map(function (pos) {
|
|
129
106
|
var cell = tr.doc.nodeAt(pos);
|
|
130
107
|
var classes = [_types.TableCssClassName.HOVERED_CELL];
|
|
131
|
-
|
|
132
108
|
if (danger) {
|
|
133
109
|
classes.push(_types.TableCssClassName.HOVERED_CELL_IN_DANGER);
|
|
134
110
|
}
|
|
135
|
-
|
|
136
111
|
if (selected) {
|
|
137
112
|
classes.push(_types.TableCssClassName.SELECTED_CELL);
|
|
138
113
|
}
|
|
139
|
-
|
|
140
114
|
classes.push(type === 'column' ? _types.TableCssClassName.HOVERED_COLUMN : type === 'row' ? _types.TableCssClassName.HOVERED_ROW : _types.TableCssClassName.HOVERED_TABLE);
|
|
141
115
|
var key;
|
|
142
|
-
|
|
143
116
|
switch (type) {
|
|
144
117
|
case 'row':
|
|
145
118
|
key = _types.TableDecorations.ROW_CONTROLS_HOVER;
|
|
146
119
|
break;
|
|
147
|
-
|
|
148
120
|
case 'column':
|
|
149
121
|
key = _types.TableDecorations.COLUMN_CONTROLS_HOVER;
|
|
150
122
|
break;
|
|
151
|
-
|
|
152
123
|
default:
|
|
153
124
|
key = _types.TableDecorations.TABLE_CONTROLS_HOVER;
|
|
154
125
|
break;
|
|
155
126
|
}
|
|
156
|
-
|
|
157
127
|
return _prosemirrorView.Decoration.node(pos, pos + cell.nodeSize, {
|
|
158
128
|
class: classes.join(' ')
|
|
159
129
|
}, {
|
|
@@ -161,21 +131,16 @@ var createControlsHoverDecoration = function createControlsHoverDecoration(cells
|
|
|
161
131
|
});
|
|
162
132
|
});
|
|
163
133
|
};
|
|
164
|
-
|
|
165
134
|
exports.createControlsHoverDecoration = createControlsHoverDecoration;
|
|
166
|
-
|
|
167
135
|
var createColumnSelectedDecoration = function createColumnSelectedDecoration(tr) {
|
|
168
136
|
var selection = tr.selection,
|
|
169
|
-
|
|
137
|
+
doc = tr.doc;
|
|
170
138
|
var table = (0, _utils.findTable)(selection);
|
|
171
139
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
172
|
-
|
|
173
140
|
if (!table || !rect) {
|
|
174
141
|
return [];
|
|
175
142
|
}
|
|
176
|
-
|
|
177
143
|
var map = _tableMap.TableMap.get(table.node);
|
|
178
|
-
|
|
179
144
|
var cellPositions = map.cellsInRect(rect);
|
|
180
145
|
return cellPositions.map(function (pos, index) {
|
|
181
146
|
var cell = doc.nodeAt(pos + table.start);
|
|
@@ -186,19 +151,18 @@ var createColumnSelectedDecoration = function createColumnSelectedDecoration(tr)
|
|
|
186
151
|
});
|
|
187
152
|
});
|
|
188
153
|
};
|
|
189
|
-
|
|
190
154
|
exports.createColumnSelectedDecoration = createColumnSelectedDecoration;
|
|
191
|
-
|
|
192
155
|
var createColumnControlsDecoration = function createColumnControlsDecoration(selection) {
|
|
193
156
|
var cells = (0, _utils.getCellsInRow)(0)(selection) || [];
|
|
194
157
|
var index = 0;
|
|
195
158
|
return cells.map(function (cell) {
|
|
196
|
-
var colspan = cell.node.attrs.colspan || 1;
|
|
159
|
+
var colspan = cell.node.attrs.colspan || 1;
|
|
160
|
+
// It's important these values are scoped locally as the widget callback could be executed anytime in the future
|
|
197
161
|
// and we want to avoid value leak
|
|
198
|
-
|
|
199
162
|
var startIndex = index;
|
|
200
|
-
var endIndex = startIndex + colspan;
|
|
163
|
+
var endIndex = startIndex + colspan;
|
|
201
164
|
|
|
165
|
+
// The next cell start index will commence from the current cell end index.
|
|
202
166
|
index = endIndex;
|
|
203
167
|
return _prosemirrorView.Decoration.widget(cell.pos + 1, function () {
|
|
204
168
|
var element = document.createElement('div');
|
|
@@ -213,20 +177,17 @@ var createColumnControlsDecoration = function createColumnControlsDecoration(sel
|
|
|
213
177
|
});
|
|
214
178
|
});
|
|
215
179
|
};
|
|
216
|
-
|
|
217
180
|
exports.createColumnControlsDecoration = createColumnControlsDecoration;
|
|
218
|
-
|
|
219
181
|
var updateDecorations = function updateDecorations(node, decorationSet, decorations, key) {
|
|
220
182
|
var filteredDecorations = filterDecorationByKey(key, decorationSet);
|
|
221
183
|
var decorationSetFiltered = decorationSet.remove(filteredDecorations);
|
|
222
184
|
return decorationSetFiltered.add(node, decorations);
|
|
223
185
|
};
|
|
224
|
-
|
|
225
186
|
exports.updateDecorations = updateDecorations;
|
|
226
|
-
|
|
227
187
|
var makeArray = function makeArray(n) {
|
|
228
188
|
return Array.from(Array(n).keys());
|
|
229
189
|
};
|
|
190
|
+
|
|
230
191
|
/*
|
|
231
192
|
* This function will create two specific decorations for each cell in a column index target,
|
|
232
193
|
* for example given that table:
|
|
@@ -306,22 +267,16 @@ var makeArray = function makeArray(n) {
|
|
|
306
267
|
* we will add a new class on the last item for each cell,
|
|
307
268
|
* hence the second media will receive this class `ClassName.LAST_ITEM_IN_CELL`
|
|
308
269
|
*/
|
|
309
|
-
|
|
310
|
-
|
|
311
270
|
var createResizeHandleDecoration = function createResizeHandleDecoration(tr, rowIndexTarget, columnEndIndexTarget) {
|
|
312
271
|
var emptyResult = [[], []];
|
|
313
272
|
var table = (0, _utils.findTable)(tr.selection);
|
|
314
|
-
|
|
315
273
|
if (!table || !table.node) {
|
|
316
274
|
return emptyResult;
|
|
317
275
|
}
|
|
318
|
-
|
|
319
276
|
var map = _tableMap.TableMap.get(table.node);
|
|
320
|
-
|
|
321
277
|
if (!map.width) {
|
|
322
278
|
return emptyResult;
|
|
323
279
|
}
|
|
324
|
-
|
|
325
280
|
var createResizerHandleDecoration = function createResizerHandleDecoration(cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode) {
|
|
326
281
|
var position = cellPos + cellNode.nodeSize - 1;
|
|
327
282
|
return _prosemirrorView.Decoration.widget(position, function () {
|
|
@@ -334,7 +289,6 @@ var createResizeHandleDecoration = function createResizeHandleDecoration(tr, row
|
|
|
334
289
|
key: "".concat(_types.TableDecorations.COLUMN_RESIZING_HANDLE, "_").concat(rowIndex, "_").concat(columnIndex)
|
|
335
290
|
});
|
|
336
291
|
};
|
|
337
|
-
|
|
338
292
|
var createLastCellElementDecoration = function createLastCellElementDecoration(cellColumnPositioning, cellPos, cellNode) {
|
|
339
293
|
var lastItemPositions;
|
|
340
294
|
cellNode.forEach(function (childNode, offset, index) {
|
|
@@ -346,51 +300,39 @@ var createResizeHandleDecoration = function createResizeHandleDecoration(tr, row
|
|
|
346
300
|
};
|
|
347
301
|
}
|
|
348
302
|
});
|
|
349
|
-
|
|
350
303
|
if (!lastItemPositions) {
|
|
351
304
|
return null;
|
|
352
305
|
}
|
|
353
|
-
|
|
354
306
|
return _prosemirrorView.Decoration.node(lastItemPositions.from, lastItemPositions.to, {
|
|
355
307
|
class: _types.TableCssClassName.LAST_ITEM_IN_CELL
|
|
356
308
|
}, {
|
|
357
309
|
key: "".concat(_types.TableDecorations.LAST_CELL_ELEMENT, "_").concat(cellColumnPositioning.left, "_").concat(cellColumnPositioning.right)
|
|
358
310
|
});
|
|
359
311
|
};
|
|
360
|
-
|
|
361
312
|
var resizeHandleCellDecorations = [];
|
|
362
313
|
var lastCellElementsDecorations = [];
|
|
363
|
-
|
|
364
314
|
for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
365
315
|
var seen = {};
|
|
366
|
-
|
|
367
316
|
if (rowIndex !== rowIndexTarget) {
|
|
368
317
|
continue;
|
|
369
318
|
}
|
|
370
|
-
|
|
371
319
|
for (var columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
372
320
|
var cellPosition = map.map[map.width * rowIndex + columnIndex];
|
|
373
|
-
|
|
374
321
|
if (seen[cellPosition]) {
|
|
375
322
|
continue;
|
|
376
323
|
}
|
|
377
|
-
|
|
378
324
|
seen[cellPosition] = true;
|
|
379
325
|
var cellPos = table.start + cellPosition;
|
|
380
326
|
var cell = tr.doc.nodeAt(cellPos);
|
|
381
|
-
|
|
382
327
|
if (!cell) {
|
|
383
328
|
continue;
|
|
384
329
|
}
|
|
385
|
-
|
|
386
330
|
var colspan = cell.attrs.colspan || 1;
|
|
387
331
|
var startIndex = columnIndex;
|
|
388
332
|
var endIndex = colspan + startIndex;
|
|
389
|
-
|
|
390
333
|
if (endIndex !== columnEndIndexTarget.right) {
|
|
391
334
|
continue;
|
|
392
335
|
}
|
|
393
|
-
|
|
394
336
|
var resizerHandleDec = createResizerHandleDecoration({
|
|
395
337
|
left: startIndex,
|
|
396
338
|
right: endIndex
|
|
@@ -403,9 +345,9 @@ var createResizeHandleDecoration = function createResizeHandleDecoration(tr, row
|
|
|
403
345
|
lastCellElementsDecorations.push(lastCellDec);
|
|
404
346
|
}
|
|
405
347
|
}
|
|
406
|
-
|
|
407
348
|
return [resizeHandleCellDecorations, lastCellElementsDecorations.filter(_utils2.nonNullable)];
|
|
408
349
|
};
|
|
350
|
+
|
|
409
351
|
/*
|
|
410
352
|
* This function will create a decoration for each cell using the right position on the CellColumnPositioning
|
|
411
353
|
* for example given that table:
|
|
@@ -448,27 +390,18 @@ var createResizeHandleDecoration = function createResizeHandleDecoration(tr, row
|
|
|
448
390
|
* this function will return two decorations applying a new class `ClassName.WITH_RESIZE_LINE`
|
|
449
391
|
* only on the cells: `C1` and `D1`.
|
|
450
392
|
*/
|
|
451
|
-
|
|
452
|
-
|
|
453
393
|
exports.createResizeHandleDecoration = createResizeHandleDecoration;
|
|
454
|
-
|
|
455
394
|
var createColumnLineResize = function createColumnLineResize(selection, cellColumnPositioning) {
|
|
456
395
|
var table = (0, _utils.findTable)(selection);
|
|
457
|
-
|
|
458
396
|
if (!table || cellColumnPositioning.right === null) {
|
|
459
397
|
return [];
|
|
460
398
|
}
|
|
461
|
-
|
|
462
399
|
var columnIndex = cellColumnPositioning.right;
|
|
463
|
-
|
|
464
400
|
var map = _tableMap.TableMap.get(table.node);
|
|
465
|
-
|
|
466
401
|
var isLastColumn = columnIndex === map.width;
|
|
467
|
-
|
|
468
402
|
if (isLastColumn) {
|
|
469
403
|
columnIndex -= 1;
|
|
470
404
|
}
|
|
471
|
-
|
|
472
405
|
var decorationClassName = isLastColumn ? _types.TableCssClassName.WITH_RESIZE_LINE_LAST_COLUMN : _types.TableCssClassName.WITH_RESIZE_LINE;
|
|
473
406
|
var cellPositions = makeArray(map.height).map(function (rowIndex) {
|
|
474
407
|
return map.map[map.width * rowIndex + columnIndex];
|
|
@@ -480,6 +413,7 @@ var createColumnLineResize = function createColumnLineResize(selection, cellColu
|
|
|
480
413
|
var nextPosition = map.map[map.width * rowIndex + columnIndex - 1];
|
|
481
414
|
return cellPosition !== nextPosition; // Removed it if next position is merged
|
|
482
415
|
});
|
|
416
|
+
|
|
483
417
|
var cells = cellPositions.map(function (pos) {
|
|
484
418
|
return {
|
|
485
419
|
pos: pos + table.start,
|
|
@@ -490,7 +424,6 @@ var createColumnLineResize = function createColumnLineResize(selection, cellColu
|
|
|
490
424
|
if (!cell || !cell.node) {
|
|
491
425
|
return;
|
|
492
426
|
}
|
|
493
|
-
|
|
494
427
|
return _prosemirrorView.Decoration.node(cell.pos, cell.pos + cell.node.nodeSize, {
|
|
495
428
|
class: decorationClassName
|
|
496
429
|
}, {
|
|
@@ -498,5 +431,4 @@ var createColumnLineResize = function createColumnLineResize(selection, cellColu
|
|
|
498
431
|
});
|
|
499
432
|
}).filter(_utils2.nonNullable);
|
|
500
433
|
};
|
|
501
|
-
|
|
502
434
|
exports.createColumnLineResize = createColumnLineResize;
|