@atlaskit/editor-plugin-table 1.1.0 → 1.1.2
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 +12 -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 +82 -188
- 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 +12 -42
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -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 +0 -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 +15 -36
- 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 +15 -71
- 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 +12 -45
- 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 +6 -19
- 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 +27 -100
- 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 +7 -15
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -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 +0 -4
- 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 +10 -18
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +29 -59
- 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 +16 -28
- 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 +6 -5
- 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 +82 -181
- 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 +12 -24
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -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 +0 -4
- 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 +15 -23
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +15 -60
- 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 +12 -32
- 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 +6 -7
- 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/package.json +2 -2
- package/src/__tests__/visual-regression/cell-options-menu.ts +1 -12
|
@@ -22,24 +22,18 @@ export function getSelectionType(selection) {
|
|
|
22
22
|
if (selection.isRowSelection()) {
|
|
23
23
|
return 'row';
|
|
24
24
|
}
|
|
25
|
-
|
|
26
25
|
if (selection.isColSelection()) {
|
|
27
26
|
return 'column';
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
|
-
|
|
31
29
|
return;
|
|
32
30
|
}
|
|
33
|
-
|
|
34
31
|
class FloatingDeleteButton extends Component {
|
|
35
32
|
constructor(props) {
|
|
36
33
|
super(props);
|
|
37
|
-
|
|
38
34
|
_defineProperty(this, "wrapper", null);
|
|
39
|
-
|
|
40
35
|
_defineProperty(this, "updateWrapper", () => {
|
|
41
36
|
const tableWrapper = closestElement(this.props.tableRef, `.${ClassName.TABLE_NODE_WRAPPER}`);
|
|
42
|
-
|
|
43
37
|
if (tableWrapper) {
|
|
44
38
|
this.wrapper = tableWrapper;
|
|
45
39
|
this.wrapper.addEventListener('scroll', this.onWrapperScrolled);
|
|
@@ -49,45 +43,39 @@ class FloatingDeleteButton extends Component {
|
|
|
49
43
|
} else {
|
|
50
44
|
if (this.wrapper) {
|
|
51
45
|
// unsubscribe if we previously had one and it just went away
|
|
52
|
-
this.wrapper.removeEventListener('scroll', this.onWrapperScrolled);
|
|
46
|
+
this.wrapper.removeEventListener('scroll', this.onWrapperScrolled);
|
|
53
47
|
|
|
48
|
+
// and reset scroll position
|
|
54
49
|
this.setState({
|
|
55
50
|
scrollLeft: 0
|
|
56
51
|
});
|
|
57
52
|
}
|
|
58
|
-
|
|
59
53
|
this.wrapper = null;
|
|
60
54
|
}
|
|
61
55
|
});
|
|
62
|
-
|
|
63
56
|
_defineProperty(this, "onWrapperScrolled", e => {
|
|
64
57
|
const wrapper = e.target;
|
|
65
58
|
this.setState({
|
|
66
59
|
scrollLeft: wrapper.scrollLeft
|
|
67
60
|
});
|
|
68
61
|
});
|
|
69
|
-
|
|
70
62
|
_defineProperty(this, "handleMouseEnter", () => {
|
|
71
63
|
const {
|
|
72
64
|
state,
|
|
73
65
|
dispatch
|
|
74
66
|
} = this.props.editorView;
|
|
75
|
-
|
|
76
67
|
switch (this.state.selectionType) {
|
|
77
68
|
case 'row':
|
|
78
69
|
{
|
|
79
70
|
return hoverRows(this.state.indexes, true)(state, dispatch, this.props.editorView);
|
|
80
71
|
}
|
|
81
|
-
|
|
82
72
|
case 'column':
|
|
83
73
|
{
|
|
84
74
|
return hoverColumns(this.state.indexes, true)(state, dispatch, this.props.editorView);
|
|
85
75
|
}
|
|
86
76
|
}
|
|
87
|
-
|
|
88
77
|
return false;
|
|
89
78
|
});
|
|
90
|
-
|
|
91
79
|
_defineProperty(this, "handleMouseLeave", () => {
|
|
92
80
|
const {
|
|
93
81
|
state,
|
|
@@ -95,7 +83,6 @@ class FloatingDeleteButton extends Component {
|
|
|
95
83
|
} = this.props.editorView;
|
|
96
84
|
return clearHoverSelection()(state, dispatch);
|
|
97
85
|
});
|
|
98
|
-
|
|
99
86
|
_defineProperty(this, "handleClick", event => {
|
|
100
87
|
event.preventDefault();
|
|
101
88
|
const {
|
|
@@ -111,7 +98,6 @@ class FloatingDeleteButton extends Component {
|
|
|
111
98
|
}
|
|
112
99
|
} = getTablePluginState(state);
|
|
113
100
|
const rect = getSelectionRect(state.selection);
|
|
114
|
-
|
|
115
101
|
if (rect) {
|
|
116
102
|
switch (this.state.selectionType) {
|
|
117
103
|
case 'column':
|
|
@@ -119,7 +105,6 @@ class FloatingDeleteButton extends Component {
|
|
|
119
105
|
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, rect)(state, dispatch);
|
|
120
106
|
return;
|
|
121
107
|
}
|
|
122
|
-
|
|
123
108
|
case 'row':
|
|
124
109
|
{
|
|
125
110
|
deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, rect, !!isHeaderRowRequired)(state, dispatch);
|
|
@@ -127,14 +112,12 @@ class FloatingDeleteButton extends Component {
|
|
|
127
112
|
}
|
|
128
113
|
}
|
|
129
114
|
}
|
|
130
|
-
|
|
131
115
|
({
|
|
132
116
|
state,
|
|
133
117
|
dispatch
|
|
134
118
|
} = this.props.editorView);
|
|
135
119
|
clearHoverSelection()(state, dispatch);
|
|
136
120
|
});
|
|
137
|
-
|
|
138
121
|
this.state = {
|
|
139
122
|
selectionType: undefined,
|
|
140
123
|
top: 0,
|
|
@@ -143,25 +126,20 @@ class FloatingDeleteButton extends Component {
|
|
|
143
126
|
scrollLeft: 0
|
|
144
127
|
};
|
|
145
128
|
}
|
|
146
|
-
|
|
147
129
|
shouldComponentUpdate(_, nextState) {
|
|
148
130
|
return this.state.selectionType !== nextState.selectionType || this.state.left !== nextState.left || this.state.top !== nextState.top || this.state.scrollLeft !== nextState.scrollLeft;
|
|
149
131
|
}
|
|
150
|
-
|
|
151
132
|
componentDidMount() {
|
|
152
133
|
this.updateWrapper();
|
|
153
134
|
}
|
|
154
|
-
|
|
155
135
|
componentDidUpdate() {
|
|
156
136
|
this.updateWrapper();
|
|
157
137
|
}
|
|
158
|
-
|
|
159
138
|
componentWillUnmount() {
|
|
160
139
|
if (this.wrapper) {
|
|
161
140
|
this.wrapper.removeEventListener('scroll', this.onWrapperScrolled);
|
|
162
141
|
}
|
|
163
142
|
}
|
|
164
|
-
|
|
165
143
|
/**
|
|
166
144
|
* We derivate the button state from the properties passed.
|
|
167
145
|
* We do this in here because we need this information in different places
|
|
@@ -170,14 +148,14 @@ class FloatingDeleteButton extends Component {
|
|
|
170
148
|
static getDerivedStateFromProps(nextProps, prevState) {
|
|
171
149
|
const selectionType = getSelectionType(nextProps.selection);
|
|
172
150
|
const inStickyMode = nextProps.stickyHeaders && nextProps.stickyHeaders.sticky;
|
|
173
|
-
const rect = getSelectionRect(nextProps.selection);
|
|
151
|
+
const rect = getSelectionRect(nextProps.selection);
|
|
152
|
+
|
|
153
|
+
// only tie row delete to sticky header if it's the only thing
|
|
174
154
|
// in the selection, otherwise the row delete will hover around
|
|
175
155
|
// the rest of the selection
|
|
176
|
-
|
|
177
156
|
const firstRowInSelection = rect && rect.top === 0 && rect.bottom === 1;
|
|
178
157
|
const shouldStickyButton = inStickyMode && firstRowInSelection;
|
|
179
158
|
const stickyTop = nextProps.stickyHeaders ? nextProps.stickyHeaders.top + nextProps.stickyHeaders.padding : 0;
|
|
180
|
-
|
|
181
159
|
if (selectionType) {
|
|
182
160
|
switch (selectionType) {
|
|
183
161
|
case 'column':
|
|
@@ -185,18 +163,16 @@ class FloatingDeleteButton extends Component {
|
|
|
185
163
|
// Calculate the button position and indexes for columns
|
|
186
164
|
const columnsWidths = getColumnsWidths(nextProps.editorView);
|
|
187
165
|
const deleteBtnParams = getColumnDeleteButtonParams(columnsWidths, nextProps.editorView.state.selection);
|
|
188
|
-
|
|
189
166
|
if (deleteBtnParams) {
|
|
190
|
-
return {
|
|
167
|
+
return {
|
|
168
|
+
...deleteBtnParams,
|
|
191
169
|
top: inStickyMode ? nextProps.stickyHeaders.top : 0,
|
|
192
170
|
position: inStickyMode ? 'sticky' : undefined,
|
|
193
171
|
selectionType
|
|
194
172
|
};
|
|
195
173
|
}
|
|
196
|
-
|
|
197
174
|
return null;
|
|
198
175
|
}
|
|
199
|
-
|
|
200
176
|
case 'row':
|
|
201
177
|
{
|
|
202
178
|
// Calculate the button position and indexes for rows
|
|
@@ -204,22 +180,21 @@ class FloatingDeleteButton extends Component {
|
|
|
204
180
|
const rowHeights = getRowHeights(nextProps.tableRef);
|
|
205
181
|
const offsetTop = inStickyMode ? -rowHeights[0] : 0;
|
|
206
182
|
const deleteBtnParams = getRowDeleteButtonParams(rowHeights, nextProps.editorView.state.selection, shouldStickyButton ? stickyTop : offsetTop);
|
|
207
|
-
|
|
208
183
|
if (deleteBtnParams) {
|
|
209
|
-
return {
|
|
184
|
+
return {
|
|
185
|
+
...deleteBtnParams,
|
|
210
186
|
position: shouldStickyButton ? 'sticky' : undefined,
|
|
211
187
|
left: 0,
|
|
212
188
|
selectionType: selectionType
|
|
213
189
|
};
|
|
214
190
|
}
|
|
215
191
|
}
|
|
216
|
-
|
|
217
192
|
return null;
|
|
218
193
|
}
|
|
219
194
|
}
|
|
220
|
-
}
|
|
221
|
-
|
|
195
|
+
}
|
|
222
196
|
|
|
197
|
+
// Clean state if no type
|
|
223
198
|
if (prevState.selectionType !== selectionType) {
|
|
224
199
|
return {
|
|
225
200
|
selectionType: undefined,
|
|
@@ -227,12 +202,11 @@ class FloatingDeleteButton extends Component {
|
|
|
227
202
|
left: 0,
|
|
228
203
|
indexes: []
|
|
229
204
|
};
|
|
230
|
-
}
|
|
231
|
-
|
|
205
|
+
}
|
|
232
206
|
|
|
207
|
+
// Do nothing if doesn't change anything
|
|
233
208
|
return null;
|
|
234
209
|
}
|
|
235
|
-
|
|
236
210
|
render() {
|
|
237
211
|
const {
|
|
238
212
|
mountPoint,
|
|
@@ -242,11 +216,9 @@ class FloatingDeleteButton extends Component {
|
|
|
242
216
|
const {
|
|
243
217
|
selectionType
|
|
244
218
|
} = this.state;
|
|
245
|
-
|
|
246
219
|
if (!selectionType || !tableRef) {
|
|
247
220
|
return null;
|
|
248
221
|
}
|
|
249
|
-
|
|
250
222
|
const tableContainerWrapper = closestElement(tableRef, `.${ClassName.TABLE_CONTAINER}`);
|
|
251
223
|
const button = /*#__PURE__*/React.createElement(DeleteButton, {
|
|
252
224
|
removeLabel: selectionType === 'column' ? tableMessages.removeColumns : tableMessages.removeRows,
|
|
@@ -261,15 +233,11 @@ class FloatingDeleteButton extends Component {
|
|
|
261
233
|
tableWrapper: this.wrapper
|
|
262
234
|
});
|
|
263
235
|
const mountTo = tableContainerWrapper || mountPoint;
|
|
264
|
-
|
|
265
236
|
if (this.state.position === 'sticky' && mountTo) {
|
|
266
237
|
const headerRow = tableRef.querySelector('tr.sticky');
|
|
267
|
-
|
|
268
238
|
if (headerRow) {
|
|
269
239
|
const rect = headerRow.getBoundingClientRect();
|
|
270
|
-
|
|
271
240
|
const calculatePosition = popupOpts.onPositionCalculated || (pos => pos);
|
|
272
|
-
|
|
273
241
|
const pos = calculatePosition({
|
|
274
242
|
left: this.state.left,
|
|
275
243
|
top: this.state.top
|
|
@@ -284,7 +252,6 @@ class FloatingDeleteButton extends Component {
|
|
|
284
252
|
}, button), mountTo);
|
|
285
253
|
}
|
|
286
254
|
}
|
|
287
|
-
|
|
288
255
|
return /*#__PURE__*/React.createElement(Popup, _extends({
|
|
289
256
|
target: tableRef,
|
|
290
257
|
mountTo: mountTo,
|
|
@@ -294,9 +261,6 @@ class FloatingDeleteButton extends Component {
|
|
|
294
261
|
allowOutOfBounds: true
|
|
295
262
|
}, popupOpts), button);
|
|
296
263
|
}
|
|
297
|
-
|
|
298
264
|
}
|
|
299
|
-
|
|
300
265
|
_defineProperty(FloatingDeleteButton, "displayName", 'FloatingDeleteButton');
|
|
301
|
-
|
|
302
266
|
export default FloatingDeleteButton;
|
|
@@ -8,7 +8,6 @@ import { closestElement } from '@atlaskit/editor-common/utils';
|
|
|
8
8
|
import { TableCssClassName as ClassName } from '../../types';
|
|
9
9
|
import tableMessages from '../messages';
|
|
10
10
|
import { tableToolbarSize } from '../consts';
|
|
11
|
-
|
|
12
11
|
const getInsertLineHeight = (tableRef, hasStickyHeaders) => {
|
|
13
12
|
// The line gets height 100% from the table,
|
|
14
13
|
// but since we have an overflow on the left,
|
|
@@ -17,17 +16,13 @@ const getInsertLineHeight = (tableRef, hasStickyHeaders) => {
|
|
|
17
16
|
const ADDITIONAL_HEIGHT = hasStickyHeaders ? tableRef.getBoundingClientRect().top - tableMarginTop * 4 - LINE_OFFSET : tableToolbarSize + LINE_OFFSET;
|
|
18
17
|
return tableRef.offsetHeight + ADDITIONAL_HEIGHT;
|
|
19
18
|
};
|
|
20
|
-
|
|
21
19
|
const getToolbarSize = tableRef => {
|
|
22
20
|
const parent = closestElement(tableRef, `.${ClassName.TABLE_CONTAINER}`);
|
|
23
|
-
|
|
24
21
|
if (parent) {
|
|
25
22
|
return parent.querySelector(`.${ClassName.NUMBERED_COLUMN}`) ? tableToolbarSize + akEditorTableNumberColumnWidth - 1 : tableToolbarSize;
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
return tableToolbarSize;
|
|
29
25
|
};
|
|
30
|
-
|
|
31
26
|
const getInsertLineWidth = tableRef => {
|
|
32
27
|
// The line gets width 100% from the table,
|
|
33
28
|
// but since we have an overflow on the left,
|
|
@@ -45,11 +40,9 @@ const getInsertLineWidth = tableRef => {
|
|
|
45
40
|
const toolbarSize = getToolbarSize(tableRef);
|
|
46
41
|
return Math.min(offsetWidth + toolbarSize, parentOffsetWidth + toolbarSize - Math.max(scrollLeft - diff, 0)) + LINE_OFFSET;
|
|
47
42
|
};
|
|
48
|
-
|
|
49
43
|
const tooltipMessageByType = type => {
|
|
50
44
|
return type === 'row' ? tableMessages.insertRow : tableMessages.insertColumn;
|
|
51
45
|
};
|
|
52
|
-
|
|
53
46
|
const InsertButton = ({
|
|
54
47
|
onMouseDown,
|
|
55
48
|
tableRef,
|
|
@@ -92,5 +85,4 @@ const InsertButton = ({
|
|
|
92
85
|
className: `${ClassName.CONTROLS_INSERT_BUTTON_WRAP} ${ClassName.CONTROLS_INSERT_ROW}`
|
|
93
86
|
}, content));
|
|
94
87
|
};
|
|
95
|
-
|
|
96
88
|
export default injectIntl(InsertButton);
|
|
@@ -5,40 +5,36 @@ const HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON = HORIZONTAL_ALIGN_COLUMN_BUTTON +
|
|
|
5
5
|
const VERTICAL_ALIGN_COLUMN_BUTTON = tableToolbarSize + tableInsertColumnButtonOffset;
|
|
6
6
|
const HORIZONTAL_ALIGN_ROW_BUTTON = -(tableToolbarSize + tableInsertColumnButtonOffset + tableInsertColumnButtonSize);
|
|
7
7
|
const VERTICAL_ALIGN_ROW_BUTTON = tableInsertColumnButtonSize / 2;
|
|
8
|
-
|
|
9
8
|
function getRowOptions(index) {
|
|
10
9
|
let defaultOptions = {
|
|
11
10
|
alignX: 'left',
|
|
12
11
|
alignY: 'bottom',
|
|
13
12
|
offset: [0, VERTICAL_ALIGN_ROW_BUTTON]
|
|
14
13
|
};
|
|
15
|
-
|
|
16
14
|
if (index === 0) {
|
|
17
|
-
defaultOptions = {
|
|
15
|
+
defaultOptions = {
|
|
16
|
+
...defaultOptions,
|
|
18
17
|
alignY: 'top',
|
|
19
18
|
// The offset is the inverse the original, because is align top nop bottom.
|
|
20
19
|
offset: [0, -VERTICAL_ALIGN_ROW_BUTTON]
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
return {
|
|
23
|
+
...defaultOptions,
|
|
26
24
|
onPositionCalculated(position) {
|
|
27
|
-
return {
|
|
25
|
+
return {
|
|
26
|
+
...position,
|
|
28
27
|
// Left position should be always the offset (To place in the correct position even if the table has overflow).
|
|
29
28
|
left: HORIZONTAL_ALIGN_ROW_BUTTON
|
|
30
29
|
};
|
|
31
30
|
}
|
|
32
|
-
|
|
33
31
|
};
|
|
34
32
|
}
|
|
35
|
-
|
|
36
33
|
function getColumnOptions(index, tableContainer, hasNumberedColumns) {
|
|
37
34
|
const options = {
|
|
38
35
|
alignX: 'end',
|
|
39
36
|
alignY: 'top',
|
|
40
37
|
offset: [HORIZONTAL_ALIGN_COLUMN_BUTTON, VERTICAL_ALIGN_COLUMN_BUTTON],
|
|
41
|
-
|
|
42
38
|
// :: (position: PopupPosition) -> PopupPosition
|
|
43
39
|
// Limit the InsertButton position to the table container
|
|
44
40
|
// if the left position starts before it
|
|
@@ -48,49 +44,45 @@ function getColumnOptions(index, tableContainer, hasNumberedColumns) {
|
|
|
48
44
|
const {
|
|
49
45
|
left
|
|
50
46
|
} = position;
|
|
51
|
-
|
|
52
47
|
if (!left) {
|
|
53
48
|
// If not left, lest skip expensive next calculations.
|
|
54
49
|
return position;
|
|
55
50
|
}
|
|
56
|
-
|
|
57
51
|
if (index === 0) {
|
|
58
|
-
return {
|
|
52
|
+
return {
|
|
53
|
+
...position,
|
|
59
54
|
left: hasNumberedColumns ? HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON : HORIZONTAL_ALIGN_COLUMN_BUTTON
|
|
60
55
|
};
|
|
61
|
-
}
|
|
62
|
-
|
|
56
|
+
}
|
|
63
57
|
|
|
58
|
+
// Check if current position is greater than the available container width
|
|
64
59
|
const rect = tableContainer ? tableContainer.getBoundingClientRect() : null;
|
|
65
|
-
return {
|
|
60
|
+
return {
|
|
61
|
+
...position,
|
|
66
62
|
left: rect && left > rect.width ? rect.width : left
|
|
67
63
|
};
|
|
68
64
|
}
|
|
65
|
+
};
|
|
69
66
|
|
|
70
|
-
|
|
67
|
+
// We need to change the popup position when
|
|
71
68
|
// the column index is zero
|
|
72
|
-
|
|
73
69
|
if (index === 0) {
|
|
74
|
-
return {
|
|
70
|
+
return {
|
|
71
|
+
...options,
|
|
75
72
|
alignX: 'left',
|
|
76
73
|
alignY: 'top'
|
|
77
74
|
};
|
|
78
75
|
}
|
|
79
|
-
|
|
80
76
|
return options;
|
|
81
77
|
}
|
|
82
|
-
|
|
83
78
|
function getPopupOptions(type, index, hasNumberedColumns, tableContainer) {
|
|
84
79
|
switch (type) {
|
|
85
80
|
case 'column':
|
|
86
81
|
return getColumnOptions(index, tableContainer, hasNumberedColumns);
|
|
87
|
-
|
|
88
82
|
case 'row':
|
|
89
83
|
return getRowOptions(index);
|
|
90
|
-
|
|
91
84
|
default:
|
|
92
85
|
return {};
|
|
93
86
|
}
|
|
94
87
|
}
|
|
95
|
-
|
|
96
88
|
export default getPopupOptions;
|
|
@@ -21,7 +21,6 @@ export class FloatingInsertButton extends React.Component {
|
|
|
21
21
|
this.insertColumn = this.insertColumn.bind(this);
|
|
22
22
|
this.insertRow = this.insertRow.bind(this);
|
|
23
23
|
}
|
|
24
|
-
|
|
25
24
|
render() {
|
|
26
25
|
const {
|
|
27
26
|
tableNode,
|
|
@@ -36,49 +35,39 @@ export class FloatingInsertButton extends React.Component {
|
|
|
36
35
|
dispatchAnalyticsEvent
|
|
37
36
|
} = this.props;
|
|
38
37
|
const type = typeof insertColumnButtonIndex !== 'undefined' ? 'column' : typeof insertRowButtonIndex !== 'undefined' ? 'row' : null;
|
|
39
|
-
|
|
40
38
|
if (!tableNode || !tableRef || !type) {
|
|
41
39
|
return null;
|
|
42
|
-
}
|
|
43
|
-
// when the header row|colum is enabled, this feature will be change on the future
|
|
44
|
-
|
|
40
|
+
}
|
|
45
41
|
|
|
42
|
+
// We can’t display the insert button for row|colum index 0
|
|
43
|
+
// when the header row|colum is enabled, this feature will be change on the future
|
|
46
44
|
if (type === 'column' && isHeaderColumnEnabled && insertColumnButtonIndex === 0 || type === 'row' && isHeaderRowEnabled && insertRowButtonIndex === 0) {
|
|
47
45
|
return null;
|
|
48
46
|
}
|
|
49
|
-
|
|
50
47
|
const {
|
|
51
48
|
state: {
|
|
52
49
|
tr
|
|
53
50
|
}
|
|
54
51
|
} = editorView;
|
|
55
|
-
|
|
56
52
|
if (tr.selection instanceof CellSelection && (tr.selection.isColSelection() || tr.selection.isRowSelection())) {
|
|
57
53
|
return null;
|
|
58
54
|
}
|
|
59
|
-
|
|
60
55
|
const cellPosition = this.getCellPosition(type);
|
|
61
|
-
|
|
62
56
|
if (!cellPosition) {
|
|
63
57
|
return null;
|
|
64
58
|
}
|
|
65
|
-
|
|
66
59
|
const tablePos = findTable(editorView.state.selection);
|
|
67
|
-
|
|
68
60
|
if (!tablePos) {
|
|
69
61
|
return null;
|
|
70
62
|
}
|
|
71
|
-
|
|
72
63
|
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
73
64
|
const pos = cellPosition + tablePos.start + 1;
|
|
74
65
|
let target;
|
|
75
|
-
|
|
76
66
|
try {
|
|
77
67
|
target = findDomRefAtPos(pos, domAtPos);
|
|
78
68
|
} catch (error) {
|
|
79
69
|
// eslint-disable-next-line no-console
|
|
80
70
|
console.warn(error);
|
|
81
|
-
|
|
82
71
|
if (dispatchAnalyticsEvent) {
|
|
83
72
|
const payload = {
|
|
84
73
|
action: ACTION.ERRORED,
|
|
@@ -98,17 +87,13 @@ export class FloatingInsertButton extends React.Component {
|
|
|
98
87
|
dispatchAnalyticsEvent(payload);
|
|
99
88
|
}
|
|
100
89
|
}
|
|
101
|
-
|
|
102
90
|
if (!target || !(target instanceof HTMLElement)) {
|
|
103
91
|
return null;
|
|
104
92
|
}
|
|
105
|
-
|
|
106
93
|
const targetCellRef = type === 'row' ? closestElement(target, 'tr') : closestElement(target, 'td, th');
|
|
107
|
-
|
|
108
94
|
if (!targetCellRef) {
|
|
109
95
|
return null;
|
|
110
96
|
}
|
|
111
|
-
|
|
112
97
|
const tableContainerWrapper = closestElement(targetCellRef, `.${ClassName.TABLE_CONTAINER}`);
|
|
113
98
|
const tableWrapper = closestElement(targetCellRef, `.${ClassName.TABLE_NODE_WRAPPER}`);
|
|
114
99
|
const index = type === 'column' ? insertColumnButtonIndex : insertRowButtonIndex;
|
|
@@ -127,7 +112,6 @@ export class FloatingInsertButton extends React.Component {
|
|
|
127
112
|
hasStickyHeaders: this.props.hasStickyHeaders || false
|
|
128
113
|
}));
|
|
129
114
|
}
|
|
130
|
-
|
|
131
115
|
getCellPosition(type) {
|
|
132
116
|
const {
|
|
133
117
|
tableNode,
|
|
@@ -135,33 +119,26 @@ export class FloatingInsertButton extends React.Component {
|
|
|
135
119
|
insertRowButtonIndex
|
|
136
120
|
} = this.props;
|
|
137
121
|
const tableMap = TableMap.get(tableNode);
|
|
138
|
-
|
|
139
122
|
if (type === 'column') {
|
|
140
123
|
const columnIndex = insertColumnButtonIndex === 0 ? 0 : insertColumnButtonIndex - 1;
|
|
141
|
-
|
|
142
124
|
if (columnIndex > tableMap.width - 1) {
|
|
143
125
|
return null;
|
|
144
126
|
}
|
|
145
|
-
|
|
146
127
|
return tableMap.positionAt(0, columnIndex, tableNode);
|
|
147
128
|
} else {
|
|
148
129
|
const rowIndex = insertRowButtonIndex === 0 ? 0 : insertRowButtonIndex - 1;
|
|
149
|
-
|
|
150
130
|
if (rowIndex > tableMap.height - 1) {
|
|
151
131
|
return null;
|
|
152
132
|
}
|
|
153
|
-
|
|
154
133
|
return tableMap.positionAt(rowIndex, 0, tableNode);
|
|
155
134
|
}
|
|
156
135
|
}
|
|
157
|
-
|
|
158
136
|
insertRow(event) {
|
|
159
137
|
const {
|
|
160
138
|
editorView,
|
|
161
139
|
insertRowButtonIndex,
|
|
162
140
|
editorAnalyticsAPI
|
|
163
141
|
} = this.props;
|
|
164
|
-
|
|
165
142
|
if (typeof insertRowButtonIndex !== 'undefined') {
|
|
166
143
|
event.preventDefault();
|
|
167
144
|
const {
|
|
@@ -174,7 +151,6 @@ export class FloatingInsertButton extends React.Component {
|
|
|
174
151
|
})(state, dispatch);
|
|
175
152
|
}
|
|
176
153
|
}
|
|
177
|
-
|
|
178
154
|
insertColumn(event) {
|
|
179
155
|
const {
|
|
180
156
|
editorView,
|
|
@@ -182,7 +158,6 @@ export class FloatingInsertButton extends React.Component {
|
|
|
182
158
|
editorAnalyticsAPI,
|
|
183
159
|
getEditorContainerWidth
|
|
184
160
|
} = this.props;
|
|
185
|
-
|
|
186
161
|
if (typeof insertColumnButtonIndex !== 'undefined') {
|
|
187
162
|
event.preventDefault();
|
|
188
163
|
const {
|
|
@@ -192,9 +167,6 @@ export class FloatingInsertButton extends React.Component {
|
|
|
192
167
|
insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
193
168
|
}
|
|
194
169
|
}
|
|
195
|
-
|
|
196
170
|
}
|
|
197
|
-
|
|
198
171
|
_defineProperty(FloatingInsertButton, "displayName", 'FloatingInsertButton');
|
|
199
|
-
|
|
200
172
|
export default injectIntl(FloatingInsertButton);
|