@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
|
@@ -6,15 +6,10 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
|
|
10
9
|
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; }
|
|
11
|
-
|
|
12
10
|
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; }
|
|
13
|
-
|
|
14
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
15
|
-
|
|
16
12
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
17
|
-
|
|
18
13
|
import React, { Component } from 'react';
|
|
19
14
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
20
15
|
import { getSelectionRect, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
@@ -37,102 +32,78 @@ export function getSelectionType(selection) {
|
|
|
37
32
|
if (selection.isRowSelection()) {
|
|
38
33
|
return 'row';
|
|
39
34
|
}
|
|
40
|
-
|
|
41
35
|
if (selection.isColSelection()) {
|
|
42
36
|
return 'column';
|
|
43
37
|
}
|
|
44
38
|
}
|
|
45
|
-
|
|
46
39
|
return;
|
|
47
40
|
}
|
|
48
|
-
|
|
49
41
|
var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
50
42
|
_inherits(FloatingDeleteButton, _Component);
|
|
51
|
-
|
|
52
43
|
var _super = _createSuper(FloatingDeleteButton);
|
|
53
|
-
|
|
54
44
|
function FloatingDeleteButton(props) {
|
|
55
45
|
var _this;
|
|
56
|
-
|
|
57
46
|
_classCallCheck(this, FloatingDeleteButton);
|
|
58
|
-
|
|
59
47
|
_this = _super.call(this, props);
|
|
60
|
-
|
|
61
48
|
_defineProperty(_assertThisInitialized(_this), "wrapper", null);
|
|
62
|
-
|
|
63
49
|
_defineProperty(_assertThisInitialized(_this), "updateWrapper", function () {
|
|
64
50
|
var tableWrapper = closestElement(_this.props.tableRef, ".".concat(ClassName.TABLE_NODE_WRAPPER));
|
|
65
|
-
|
|
66
51
|
if (tableWrapper) {
|
|
67
52
|
_this.wrapper = tableWrapper;
|
|
68
|
-
|
|
69
53
|
_this.wrapper.addEventListener('scroll', _this.onWrapperScrolled);
|
|
70
|
-
|
|
71
54
|
_this.setState({
|
|
72
55
|
scrollLeft: tableWrapper.scrollLeft
|
|
73
56
|
});
|
|
74
57
|
} else {
|
|
75
58
|
if (_this.wrapper) {
|
|
76
59
|
// unsubscribe if we previously had one and it just went away
|
|
77
|
-
_this.wrapper.removeEventListener('scroll', _this.onWrapperScrolled);
|
|
78
|
-
|
|
60
|
+
_this.wrapper.removeEventListener('scroll', _this.onWrapperScrolled);
|
|
79
61
|
|
|
62
|
+
// and reset scroll position
|
|
80
63
|
_this.setState({
|
|
81
64
|
scrollLeft: 0
|
|
82
65
|
});
|
|
83
66
|
}
|
|
84
|
-
|
|
85
67
|
_this.wrapper = null;
|
|
86
68
|
}
|
|
87
69
|
});
|
|
88
|
-
|
|
89
70
|
_defineProperty(_assertThisInitialized(_this), "onWrapperScrolled", function (e) {
|
|
90
71
|
var wrapper = e.target;
|
|
91
|
-
|
|
92
72
|
_this.setState({
|
|
93
73
|
scrollLeft: wrapper.scrollLeft
|
|
94
74
|
});
|
|
95
75
|
});
|
|
96
|
-
|
|
97
76
|
_defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function () {
|
|
98
77
|
var _this$props$editorVie = _this.props.editorView,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
78
|
+
state = _this$props$editorVie.state,
|
|
79
|
+
dispatch = _this$props$editorVie.dispatch;
|
|
102
80
|
switch (_this.state.selectionType) {
|
|
103
81
|
case 'row':
|
|
104
82
|
{
|
|
105
83
|
return hoverRows(_this.state.indexes, true)(state, dispatch, _this.props.editorView);
|
|
106
84
|
}
|
|
107
|
-
|
|
108
85
|
case 'column':
|
|
109
86
|
{
|
|
110
87
|
return hoverColumns(_this.state.indexes, true)(state, dispatch, _this.props.editorView);
|
|
111
88
|
}
|
|
112
89
|
}
|
|
113
|
-
|
|
114
90
|
return false;
|
|
115
91
|
});
|
|
116
|
-
|
|
117
92
|
_defineProperty(_assertThisInitialized(_this), "handleMouseLeave", function () {
|
|
118
93
|
var _this$props$editorVie2 = _this.props.editorView,
|
|
119
|
-
|
|
120
|
-
|
|
94
|
+
state = _this$props$editorVie2.state,
|
|
95
|
+
dispatch = _this$props$editorVie2.dispatch;
|
|
121
96
|
return clearHoverSelection()(state, dispatch);
|
|
122
97
|
});
|
|
123
|
-
|
|
124
98
|
_defineProperty(_assertThisInitialized(_this), "handleClick", function (event) {
|
|
125
99
|
event.preventDefault();
|
|
126
100
|
var editorAnalyticsAPI = _this.props.editorAnalyticsAPI;
|
|
127
101
|
var _this$props$editorVie3 = _this.props.editorView,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
102
|
+
state = _this$props$editorVie3.state,
|
|
103
|
+
dispatch = _this$props$editorVie3.dispatch;
|
|
131
104
|
var _getTablePluginState = getTablePluginState(state),
|
|
132
|
-
|
|
133
|
-
|
|
105
|
+
isHeaderRowRequired = _getTablePluginState.pluginConfig.isHeaderRowRequired;
|
|
134
106
|
var rect = getSelectionRect(state.selection);
|
|
135
|
-
|
|
136
107
|
if (rect) {
|
|
137
108
|
switch (_this.state.selectionType) {
|
|
138
109
|
case 'column':
|
|
@@ -140,7 +111,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
140
111
|
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, rect)(state, dispatch);
|
|
141
112
|
return;
|
|
142
113
|
}
|
|
143
|
-
|
|
144
114
|
case 'row':
|
|
145
115
|
{
|
|
146
116
|
deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, rect, !!isHeaderRowRequired)(state, dispatch);
|
|
@@ -148,13 +118,11 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
148
118
|
}
|
|
149
119
|
}
|
|
150
120
|
}
|
|
151
|
-
|
|
152
121
|
var _this$props$editorVie4 = _this.props.editorView;
|
|
153
122
|
state = _this$props$editorVie4.state;
|
|
154
123
|
dispatch = _this$props$editorVie4.dispatch;
|
|
155
124
|
clearHoverSelection()(state, dispatch);
|
|
156
125
|
});
|
|
157
|
-
|
|
158
126
|
_this.state = {
|
|
159
127
|
selectionType: undefined,
|
|
160
128
|
top: 0,
|
|
@@ -164,7 +132,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
164
132
|
};
|
|
165
133
|
return _this;
|
|
166
134
|
}
|
|
167
|
-
|
|
168
135
|
_createClass(FloatingDeleteButton, [{
|
|
169
136
|
key: "shouldComponentUpdate",
|
|
170
137
|
value: function shouldComponentUpdate(_, nextState) {
|
|
@@ -191,15 +158,13 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
191
158
|
key: "render",
|
|
192
159
|
value: function render() {
|
|
193
160
|
var _this$props = this.props,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
161
|
+
mountPoint = _this$props.mountPoint,
|
|
162
|
+
boundariesElement = _this$props.boundariesElement,
|
|
163
|
+
tableRef = _this$props.tableRef;
|
|
197
164
|
var selectionType = this.state.selectionType;
|
|
198
|
-
|
|
199
165
|
if (!selectionType || !tableRef) {
|
|
200
166
|
return null;
|
|
201
167
|
}
|
|
202
|
-
|
|
203
168
|
var tableContainerWrapper = closestElement(tableRef, ".".concat(ClassName.TABLE_CONTAINER));
|
|
204
169
|
var button = /*#__PURE__*/React.createElement(DeleteButton, {
|
|
205
170
|
removeLabel: selectionType === 'column' ? tableMessages.removeColumns : tableMessages.removeRows,
|
|
@@ -214,17 +179,13 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
214
179
|
tableWrapper: this.wrapper
|
|
215
180
|
});
|
|
216
181
|
var mountTo = tableContainerWrapper || mountPoint;
|
|
217
|
-
|
|
218
182
|
if (this.state.position === 'sticky' && mountTo) {
|
|
219
183
|
var headerRow = tableRef.querySelector('tr.sticky');
|
|
220
|
-
|
|
221
184
|
if (headerRow) {
|
|
222
185
|
var rect = headerRow.getBoundingClientRect();
|
|
223
|
-
|
|
224
186
|
var calculatePosition = popupOpts.onPositionCalculated || function (pos) {
|
|
225
187
|
return pos;
|
|
226
188
|
};
|
|
227
|
-
|
|
228
189
|
var pos = calculatePosition({
|
|
229
190
|
left: this.state.left,
|
|
230
191
|
top: this.state.top
|
|
@@ -239,7 +200,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
239
200
|
}, button), mountTo);
|
|
240
201
|
}
|
|
241
202
|
}
|
|
242
|
-
|
|
243
203
|
return /*#__PURE__*/React.createElement(Popup, _extends({
|
|
244
204
|
target: tableRef,
|
|
245
205
|
mountTo: mountTo,
|
|
@@ -260,14 +220,14 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
260
220
|
function getDerivedStateFromProps(nextProps, prevState) {
|
|
261
221
|
var selectionType = getSelectionType(nextProps.selection);
|
|
262
222
|
var inStickyMode = nextProps.stickyHeaders && nextProps.stickyHeaders.sticky;
|
|
263
|
-
var rect = getSelectionRect(nextProps.selection);
|
|
223
|
+
var rect = getSelectionRect(nextProps.selection);
|
|
224
|
+
|
|
225
|
+
// only tie row delete to sticky header if it's the only thing
|
|
264
226
|
// in the selection, otherwise the row delete will hover around
|
|
265
227
|
// the rest of the selection
|
|
266
|
-
|
|
267
228
|
var firstRowInSelection = rect && rect.top === 0 && rect.bottom === 1;
|
|
268
229
|
var shouldStickyButton = inStickyMode && firstRowInSelection;
|
|
269
230
|
var stickyTop = nextProps.stickyHeaders ? nextProps.stickyHeaders.top + nextProps.stickyHeaders.padding : 0;
|
|
270
|
-
|
|
271
231
|
if (selectionType) {
|
|
272
232
|
switch (selectionType) {
|
|
273
233
|
case 'column':
|
|
@@ -275,7 +235,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
275
235
|
// Calculate the button position and indexes for columns
|
|
276
236
|
var columnsWidths = getColumnsWidths(nextProps.editorView);
|
|
277
237
|
var deleteBtnParams = getColumnDeleteButtonParams(columnsWidths, nextProps.editorView.state.selection);
|
|
278
|
-
|
|
279
238
|
if (deleteBtnParams) {
|
|
280
239
|
return _objectSpread(_objectSpread({}, deleteBtnParams), {}, {
|
|
281
240
|
top: inStickyMode ? nextProps.stickyHeaders.top : 0,
|
|
@@ -283,19 +242,15 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
283
242
|
selectionType: selectionType
|
|
284
243
|
});
|
|
285
244
|
}
|
|
286
|
-
|
|
287
245
|
return null;
|
|
288
246
|
}
|
|
289
|
-
|
|
290
247
|
case 'row':
|
|
291
248
|
{
|
|
292
249
|
// Calculate the button position and indexes for rows
|
|
293
250
|
if (nextProps.tableRef) {
|
|
294
251
|
var rowHeights = getRowHeights(nextProps.tableRef);
|
|
295
252
|
var offsetTop = inStickyMode ? -rowHeights[0] : 0;
|
|
296
|
-
|
|
297
253
|
var _deleteBtnParams = getRowDeleteButtonParams(rowHeights, nextProps.editorView.state.selection, shouldStickyButton ? stickyTop : offsetTop);
|
|
298
|
-
|
|
299
254
|
if (_deleteBtnParams) {
|
|
300
255
|
return _objectSpread(_objectSpread({}, _deleteBtnParams), {}, {
|
|
301
256
|
position: shouldStickyButton ? 'sticky' : undefined,
|
|
@@ -304,13 +259,12 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
304
259
|
});
|
|
305
260
|
}
|
|
306
261
|
}
|
|
307
|
-
|
|
308
262
|
return null;
|
|
309
263
|
}
|
|
310
264
|
}
|
|
311
|
-
}
|
|
312
|
-
|
|
265
|
+
}
|
|
313
266
|
|
|
267
|
+
// Clean state if no type
|
|
314
268
|
if (prevState.selectionType !== selectionType) {
|
|
315
269
|
return {
|
|
316
270
|
selectionType: undefined,
|
|
@@ -318,16 +272,13 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
318
272
|
left: 0,
|
|
319
273
|
indexes: []
|
|
320
274
|
};
|
|
321
|
-
}
|
|
322
|
-
|
|
275
|
+
}
|
|
323
276
|
|
|
277
|
+
// Do nothing if doesn't change anything
|
|
324
278
|
return null;
|
|
325
279
|
}
|
|
326
280
|
}]);
|
|
327
|
-
|
|
328
281
|
return FloatingDeleteButton;
|
|
329
282
|
}(Component);
|
|
330
|
-
|
|
331
283
|
_defineProperty(FloatingDeleteButton, "displayName", 'FloatingDeleteButton');
|
|
332
|
-
|
|
333
284
|
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
|
var getInsertLineHeight = function 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,42 +16,36 @@ var getInsertLineHeight = function getInsertLineHeight(tableRef, hasStickyHeader
|
|
|
17
16
|
var 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
|
var getToolbarSize = function getToolbarSize(tableRef) {
|
|
22
20
|
var parent = closestElement(tableRef, ".".concat(ClassName.TABLE_CONTAINER));
|
|
23
|
-
|
|
24
21
|
if (parent) {
|
|
25
22
|
return parent.querySelector(".".concat(ClassName.NUMBERED_COLUMN)) ? tableToolbarSize + akEditorTableNumberColumnWidth - 1 : tableToolbarSize;
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
return tableToolbarSize;
|
|
29
25
|
};
|
|
30
|
-
|
|
31
26
|
var getInsertLineWidth = function getInsertLineWidth(tableRef) {
|
|
32
27
|
// The line gets width 100% from the table,
|
|
33
28
|
// but since we have an overflow on the left,
|
|
34
29
|
// we should add an offset to make up for it.
|
|
35
30
|
var LINE_OFFSET = 4;
|
|
36
31
|
var parentElement = tableRef.parentElement,
|
|
37
|
-
|
|
32
|
+
offsetWidth = tableRef.offsetWidth;
|
|
38
33
|
var parentOffsetWidth = parentElement.offsetWidth;
|
|
39
34
|
var _ref = parentElement,
|
|
40
|
-
|
|
35
|
+
scrollLeft = _ref.scrollLeft;
|
|
41
36
|
var diff = offsetWidth - parentOffsetWidth;
|
|
42
37
|
var toolbarSize = getToolbarSize(tableRef);
|
|
43
38
|
return Math.min(offsetWidth + toolbarSize, parentOffsetWidth + toolbarSize - Math.max(scrollLeft - diff, 0)) + LINE_OFFSET;
|
|
44
39
|
};
|
|
45
|
-
|
|
46
40
|
var tooltipMessageByType = function tooltipMessageByType(type) {
|
|
47
41
|
return type === 'row' ? tableMessages.insertRow : tableMessages.insertColumn;
|
|
48
42
|
};
|
|
49
|
-
|
|
50
43
|
var InsertButton = function InsertButton(_ref2) {
|
|
51
44
|
var onMouseDown = _ref2.onMouseDown,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
tableRef = _ref2.tableRef,
|
|
46
|
+
type = _ref2.type,
|
|
47
|
+
formatMessage = _ref2.intl.formatMessage,
|
|
48
|
+
hasStickyHeaders = _ref2.hasStickyHeaders;
|
|
56
49
|
var content = /*#__PURE__*/React.createElement(Tooltip, {
|
|
57
50
|
content: /*#__PURE__*/React.createElement(keymaps.ToolTipContent, {
|
|
58
51
|
description: formatMessage(tooltipMessageByType(type)),
|
|
@@ -86,5 +79,4 @@ var InsertButton = function InsertButton(_ref2) {
|
|
|
86
79
|
className: "".concat(ClassName.CONTROLS_INSERT_BUTTON_WRAP, " ").concat(ClassName.CONTROLS_INSERT_ROW)
|
|
87
80
|
}, content));
|
|
88
81
|
};
|
|
89
|
-
|
|
90
82
|
export default injectIntl(InsertButton);
|
|
@@ -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
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
8
5
|
import { tableInsertColumnButtonOffset, tableInsertColumnButtonSize, tableToolbarSize } from '../consts';
|
|
9
6
|
var HORIZONTAL_ALIGN_COLUMN_BUTTON = -(tableInsertColumnButtonSize / 2);
|
|
@@ -11,14 +8,12 @@ var HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON = HORIZONTAL_ALIGN_COLUMN_BUTTON + a
|
|
|
11
8
|
var VERTICAL_ALIGN_COLUMN_BUTTON = tableToolbarSize + tableInsertColumnButtonOffset;
|
|
12
9
|
var HORIZONTAL_ALIGN_ROW_BUTTON = -(tableToolbarSize + tableInsertColumnButtonOffset + tableInsertColumnButtonSize);
|
|
13
10
|
var VERTICAL_ALIGN_ROW_BUTTON = tableInsertColumnButtonSize / 2;
|
|
14
|
-
|
|
15
11
|
function getRowOptions(index) {
|
|
16
12
|
var defaultOptions = {
|
|
17
13
|
alignX: 'left',
|
|
18
14
|
alignY: 'bottom',
|
|
19
15
|
offset: [0, VERTICAL_ALIGN_ROW_BUTTON]
|
|
20
16
|
};
|
|
21
|
-
|
|
22
17
|
if (index === 0) {
|
|
23
18
|
defaultOptions = _objectSpread(_objectSpread({}, defaultOptions), {}, {
|
|
24
19
|
alignY: 'top',
|
|
@@ -26,7 +21,6 @@ function getRowOptions(index) {
|
|
|
26
21
|
offset: [0, -VERTICAL_ALIGN_ROW_BUTTON]
|
|
27
22
|
});
|
|
28
23
|
}
|
|
29
|
-
|
|
30
24
|
return _objectSpread(_objectSpread({}, defaultOptions), {}, {
|
|
31
25
|
onPositionCalculated: function onPositionCalculated(position) {
|
|
32
26
|
return _objectSpread(_objectSpread({}, position), {}, {
|
|
@@ -36,7 +30,6 @@ function getRowOptions(index) {
|
|
|
36
30
|
}
|
|
37
31
|
});
|
|
38
32
|
}
|
|
39
|
-
|
|
40
33
|
function getColumnOptions(index, tableContainer, hasNumberedColumns) {
|
|
41
34
|
var options = {
|
|
42
35
|
alignX: 'end',
|
|
@@ -49,48 +42,42 @@ function getColumnOptions(index, tableContainer, hasNumberedColumns) {
|
|
|
49
42
|
// considering the offset from the first column
|
|
50
43
|
onPositionCalculated: function onPositionCalculated(position) {
|
|
51
44
|
var left = position.left;
|
|
52
|
-
|
|
53
45
|
if (!left) {
|
|
54
46
|
// If not left, lest skip expensive next calculations.
|
|
55
47
|
return position;
|
|
56
48
|
}
|
|
57
|
-
|
|
58
49
|
if (index === 0) {
|
|
59
50
|
return _objectSpread(_objectSpread({}, position), {}, {
|
|
60
51
|
left: hasNumberedColumns ? HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON : HORIZONTAL_ALIGN_COLUMN_BUTTON
|
|
61
52
|
});
|
|
62
|
-
}
|
|
63
|
-
|
|
53
|
+
}
|
|
64
54
|
|
|
55
|
+
// Check if current position is greater than the available container width
|
|
65
56
|
var rect = tableContainer ? tableContainer.getBoundingClientRect() : null;
|
|
66
57
|
return _objectSpread(_objectSpread({}, position), {}, {
|
|
67
58
|
left: rect && left > rect.width ? rect.width : left
|
|
68
59
|
});
|
|
69
60
|
}
|
|
70
|
-
};
|
|
71
|
-
// the column index is zero
|
|
61
|
+
};
|
|
72
62
|
|
|
63
|
+
// We need to change the popup position when
|
|
64
|
+
// the column index is zero
|
|
73
65
|
if (index === 0) {
|
|
74
66
|
return _objectSpread(_objectSpread({}, options), {}, {
|
|
75
67
|
alignX: 'left',
|
|
76
68
|
alignY: 'top'
|
|
77
69
|
});
|
|
78
70
|
}
|
|
79
|
-
|
|
80
71
|
return options;
|
|
81
72
|
}
|
|
82
|
-
|
|
83
73
|
function getPopupOptions(type, index, hasNumberedColumns, tableContainer) {
|
|
84
74
|
switch (type) {
|
|
85
75
|
case 'column':
|
|
86
76
|
return getColumnOptions(index, tableContainer, hasNumberedColumns);
|
|
87
|
-
|
|
88
77
|
case 'row':
|
|
89
78
|
return getRowOptions(index);
|
|
90
|
-
|
|
91
79
|
default:
|
|
92
80
|
return {};
|
|
93
81
|
}
|
|
94
82
|
}
|
|
95
|
-
|
|
96
83
|
export default getPopupOptions;
|
|
@@ -6,11 +6,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
|
|
10
9
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
-
|
|
12
10
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
-
|
|
14
11
|
import React from 'react';
|
|
15
12
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
16
13
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
@@ -28,74 +25,59 @@ import InsertButton from './InsertButton';
|
|
|
28
25
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, CONTENT_COMPONENT } from '@atlaskit/editor-common/analytics';
|
|
29
26
|
export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
30
27
|
_inherits(FloatingInsertButton, _React$Component);
|
|
31
|
-
|
|
32
28
|
var _super = _createSuper(FloatingInsertButton);
|
|
33
|
-
|
|
34
29
|
function FloatingInsertButton(props) {
|
|
35
30
|
var _this;
|
|
36
|
-
|
|
37
31
|
_classCallCheck(this, FloatingInsertButton);
|
|
38
|
-
|
|
39
32
|
_this = _super.call(this, props);
|
|
40
33
|
_this.insertColumn = _this.insertColumn.bind(_assertThisInitialized(_this));
|
|
41
34
|
_this.insertRow = _this.insertRow.bind(_assertThisInitialized(_this));
|
|
42
35
|
return _this;
|
|
43
36
|
}
|
|
44
|
-
|
|
45
37
|
_createClass(FloatingInsertButton, [{
|
|
46
38
|
key: "render",
|
|
47
39
|
value: function render() {
|
|
48
40
|
var _this$props = this.props,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
tableNode = _this$props.tableNode,
|
|
42
|
+
editorView = _this$props.editorView,
|
|
43
|
+
insertColumnButtonIndex = _this$props.insertColumnButtonIndex,
|
|
44
|
+
insertRowButtonIndex = _this$props.insertRowButtonIndex,
|
|
45
|
+
tableRef = _this$props.tableRef,
|
|
46
|
+
mountPoint = _this$props.mountPoint,
|
|
47
|
+
boundariesElement = _this$props.boundariesElement,
|
|
48
|
+
isHeaderColumnEnabled = _this$props.isHeaderColumnEnabled,
|
|
49
|
+
isHeaderRowEnabled = _this$props.isHeaderRowEnabled,
|
|
50
|
+
dispatchAnalyticsEvent = _this$props.dispatchAnalyticsEvent;
|
|
59
51
|
var type = typeof insertColumnButtonIndex !== 'undefined' ? 'column' : typeof insertRowButtonIndex !== 'undefined' ? 'row' : null;
|
|
60
|
-
|
|
61
52
|
if (!tableNode || !tableRef || !type) {
|
|
62
53
|
return null;
|
|
63
|
-
}
|
|
64
|
-
// when the header row|colum is enabled, this feature will be change on the future
|
|
65
|
-
|
|
54
|
+
}
|
|
66
55
|
|
|
56
|
+
// We can’t display the insert button for row|colum index 0
|
|
57
|
+
// when the header row|colum is enabled, this feature will be change on the future
|
|
67
58
|
if (type === 'column' && isHeaderColumnEnabled && insertColumnButtonIndex === 0 || type === 'row' && isHeaderRowEnabled && insertRowButtonIndex === 0) {
|
|
68
59
|
return null;
|
|
69
60
|
}
|
|
70
|
-
|
|
71
61
|
var tr = editorView.state.tr;
|
|
72
|
-
|
|
73
62
|
if (tr.selection instanceof CellSelection && (tr.selection.isColSelection() || tr.selection.isRowSelection())) {
|
|
74
63
|
return null;
|
|
75
64
|
}
|
|
76
|
-
|
|
77
65
|
var cellPosition = this.getCellPosition(type);
|
|
78
|
-
|
|
79
66
|
if (!cellPosition) {
|
|
80
67
|
return null;
|
|
81
68
|
}
|
|
82
|
-
|
|
83
69
|
var tablePos = findTable(editorView.state.selection);
|
|
84
|
-
|
|
85
70
|
if (!tablePos) {
|
|
86
71
|
return null;
|
|
87
72
|
}
|
|
88
|
-
|
|
89
73
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
90
74
|
var pos = cellPosition + tablePos.start + 1;
|
|
91
75
|
var target;
|
|
92
|
-
|
|
93
76
|
try {
|
|
94
77
|
target = findDomRefAtPos(pos, domAtPos);
|
|
95
78
|
} catch (error) {
|
|
96
79
|
// eslint-disable-next-line no-console
|
|
97
80
|
console.warn(error);
|
|
98
|
-
|
|
99
81
|
if (dispatchAnalyticsEvent) {
|
|
100
82
|
var payload = {
|
|
101
83
|
action: ACTION.ERRORED,
|
|
@@ -115,17 +97,13 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
115
97
|
dispatchAnalyticsEvent(payload);
|
|
116
98
|
}
|
|
117
99
|
}
|
|
118
|
-
|
|
119
100
|
if (!target || !(target instanceof HTMLElement)) {
|
|
120
101
|
return null;
|
|
121
102
|
}
|
|
122
|
-
|
|
123
103
|
var targetCellRef = type === 'row' ? closestElement(target, 'tr') : closestElement(target, 'td, th');
|
|
124
|
-
|
|
125
104
|
if (!targetCellRef) {
|
|
126
105
|
return null;
|
|
127
106
|
}
|
|
128
|
-
|
|
129
107
|
var tableContainerWrapper = closestElement(targetCellRef, ".".concat(ClassName.TABLE_CONTAINER));
|
|
130
108
|
var tableWrapper = closestElement(targetCellRef, ".".concat(ClassName.TABLE_NODE_WRAPPER));
|
|
131
109
|
var index = type === 'column' ? insertColumnButtonIndex : insertRowButtonIndex;
|
|
@@ -148,26 +126,21 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
148
126
|
key: "getCellPosition",
|
|
149
127
|
value: function getCellPosition(type) {
|
|
150
128
|
var _this$props2 = this.props,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
129
|
+
tableNode = _this$props2.tableNode,
|
|
130
|
+
insertColumnButtonIndex = _this$props2.insertColumnButtonIndex,
|
|
131
|
+
insertRowButtonIndex = _this$props2.insertRowButtonIndex;
|
|
154
132
|
var tableMap = TableMap.get(tableNode);
|
|
155
|
-
|
|
156
133
|
if (type === 'column') {
|
|
157
134
|
var columnIndex = insertColumnButtonIndex === 0 ? 0 : insertColumnButtonIndex - 1;
|
|
158
|
-
|
|
159
135
|
if (columnIndex > tableMap.width - 1) {
|
|
160
136
|
return null;
|
|
161
137
|
}
|
|
162
|
-
|
|
163
138
|
return tableMap.positionAt(0, columnIndex, tableNode);
|
|
164
139
|
} else {
|
|
165
140
|
var rowIndex = insertRowButtonIndex === 0 ? 0 : insertRowButtonIndex - 1;
|
|
166
|
-
|
|
167
141
|
if (rowIndex > tableMap.height - 1) {
|
|
168
142
|
return null;
|
|
169
143
|
}
|
|
170
|
-
|
|
171
144
|
return tableMap.positionAt(rowIndex, 0, tableNode);
|
|
172
145
|
}
|
|
173
146
|
}
|
|
@@ -175,14 +148,13 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
175
148
|
key: "insertRow",
|
|
176
149
|
value: function insertRow(event) {
|
|
177
150
|
var _this$props3 = this.props,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
151
|
+
editorView = _this$props3.editorView,
|
|
152
|
+
insertRowButtonIndex = _this$props3.insertRowButtonIndex,
|
|
153
|
+
editorAnalyticsAPI = _this$props3.editorAnalyticsAPI;
|
|
182
154
|
if (typeof insertRowButtonIndex !== 'undefined') {
|
|
183
155
|
event.preventDefault();
|
|
184
156
|
var state = editorView.state,
|
|
185
|
-
|
|
157
|
+
dispatch = editorView.dispatch;
|
|
186
158
|
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, {
|
|
187
159
|
index: insertRowButtonIndex,
|
|
188
160
|
moveCursorToInsertedRow: true
|
|
@@ -193,23 +165,19 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
193
165
|
key: "insertColumn",
|
|
194
166
|
value: function insertColumn(event) {
|
|
195
167
|
var _this$props4 = this.props,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
168
|
+
editorView = _this$props4.editorView,
|
|
169
|
+
insertColumnButtonIndex = _this$props4.insertColumnButtonIndex,
|
|
170
|
+
editorAnalyticsAPI = _this$props4.editorAnalyticsAPI,
|
|
171
|
+
getEditorContainerWidth = _this$props4.getEditorContainerWidth;
|
|
201
172
|
if (typeof insertColumnButtonIndex !== 'undefined') {
|
|
202
173
|
event.preventDefault();
|
|
203
174
|
var state = editorView.state,
|
|
204
|
-
|
|
175
|
+
dispatch = editorView.dispatch;
|
|
205
176
|
insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
206
177
|
}
|
|
207
178
|
}
|
|
208
179
|
}]);
|
|
209
|
-
|
|
210
180
|
return FloatingInsertButton;
|
|
211
181
|
}(React.Component);
|
|
212
|
-
|
|
213
182
|
_defineProperty(FloatingInsertButton, "displayName", 'FloatingInsertButton');
|
|
214
|
-
|
|
215
183
|
export default injectIntl(FloatingInsertButton);
|