@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
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Helper to split all the cells in a range of columns
|
|
5
4
|
* @param tr
|
|
@@ -10,63 +9,61 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
10
9
|
export function splitCellsInColumns(tr, tablePos, columnStart, columnEnd) {
|
|
11
10
|
let mapStart = tr.mapping.maps.length;
|
|
12
11
|
const table = tr.doc.nodeAt(tablePos);
|
|
13
|
-
|
|
14
12
|
if (!table) {
|
|
15
13
|
return tr;
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
const tableStart = tr.doc.resolve(tablePos).start(1);
|
|
19
16
|
const map = TableMap.get(table);
|
|
20
|
-
|
|
21
17
|
for (let column = columnStart; column < columnEnd; column++) {
|
|
22
18
|
for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
23
19
|
const cellIndex = rowIndex * map.width + column;
|
|
24
|
-
const cellPos = map.map[cellIndex];
|
|
25
|
-
|
|
26
|
-
const hasMergedCellsBefore = column > 0 && map.map[cellIndex - 1] === cellPos || rowIndex > 0 && map.map[(rowIndex - 1) * map.width + column] === cellPos; // Check if the cell contains another row/column
|
|
20
|
+
const cellPos = map.map[cellIndex];
|
|
27
21
|
|
|
22
|
+
// Check if the cell is contained by another by another row/column
|
|
23
|
+
const hasMergedCellsBefore = column > 0 && map.map[cellIndex - 1] === cellPos || rowIndex > 0 && map.map[(rowIndex - 1) * map.width + column] === cellPos;
|
|
24
|
+
// Check if the cell contains another row/column
|
|
28
25
|
const hasMergedCellsAfter = column < map.width - 1 && map.map[cellIndex + 1] === cellPos || rowIndex < map.height - 1 && map.map[(rowIndex + 1) * map.width + column] === cellPos;
|
|
29
|
-
|
|
30
26
|
if (!hasMergedCellsBefore && hasMergedCellsAfter) {
|
|
31
27
|
// Is a merged cell that start in this row/column
|
|
32
28
|
const cellNode = table.nodeAt(cellPos);
|
|
33
|
-
|
|
34
29
|
if (!cellNode) {
|
|
35
30
|
continue;
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
const {
|
|
39
33
|
colwidth,
|
|
40
34
|
colspan = 1,
|
|
41
35
|
rowspan = 1
|
|
42
36
|
} = cellNode.attrs;
|
|
43
|
-
let mapping = tr.mapping.slice(mapStart);
|
|
37
|
+
let mapping = tr.mapping.slice(mapStart);
|
|
44
38
|
|
|
45
|
-
|
|
39
|
+
// Update current node with the simple colspan
|
|
40
|
+
const baseAttrs = {
|
|
41
|
+
...cellNode.attrs,
|
|
46
42
|
colspan: 1,
|
|
47
43
|
rowspan: 1
|
|
48
|
-
};
|
|
49
|
-
|
|
44
|
+
};
|
|
45
|
+
// Add the new cells
|
|
50
46
|
for (let cellRowIndex = rowIndex; cellRowIndex < rowIndex + rowspan; cellRowIndex++) {
|
|
51
47
|
for (let i = 0; i < colspan; i++) {
|
|
52
48
|
let mapping = tr.mapping.slice(mapStart);
|
|
53
49
|
const cellPos = map.positionAt(cellRowIndex, column + i, table);
|
|
54
|
-
tr.insert(mapping.map(cellPos + tableStart), cellNode.type.createAndFill({
|
|
50
|
+
tr.insert(mapping.map(cellPos + tableStart), cellNode.type.createAndFill({
|
|
51
|
+
...baseAttrs,
|
|
55
52
|
colwidth: colwidth ? [colwidth[i]] : undefined
|
|
56
53
|
}));
|
|
57
54
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
55
|
+
}
|
|
60
56
|
|
|
57
|
+
// Delete the original cell
|
|
61
58
|
mapping = tr.mapping.slice(mapStart);
|
|
62
|
-
tr.delete(mapping.map(cellPos + tableStart), mapping.map(cellPos + tableStart + cellNode.nodeSize));
|
|
59
|
+
tr.delete(mapping.map(cellPos + tableStart), mapping.map(cellPos + tableStart + cellNode.nodeSize));
|
|
63
60
|
|
|
61
|
+
// Skip rows based on rowspan
|
|
64
62
|
if (rowspan && rowspan > 1) {
|
|
65
63
|
rowIndex += rowspan - 1;
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
67
|
}
|
|
70
|
-
|
|
71
68
|
return tr;
|
|
72
69
|
}
|
|
@@ -2,7 +2,6 @@ import { tableCellSelector, tableHeaderSelector, tablePrefixSelector } from '@at
|
|
|
2
2
|
import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
3
3
|
export const RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
|
|
4
4
|
export let TableDecorations;
|
|
5
|
-
|
|
6
5
|
(function (TableDecorations) {
|
|
7
6
|
TableDecorations["ALL_CONTROLS_HOVER"] = "CONTROLS_HOVER";
|
|
8
7
|
TableDecorations["ROW_CONTROLS_HOVER"] = "ROW_CONTROLS_HOVER";
|
|
@@ -15,8 +14,8 @@ export let TableDecorations;
|
|
|
15
14
|
TableDecorations["COLUMN_RESIZING_HANDLE_LINE"] = "COLUMN_RESIZING_HANDLE_LINE";
|
|
16
15
|
TableDecorations["LAST_CELL_ELEMENT"] = "LAST_CELL_ELEMENT";
|
|
17
16
|
})(TableDecorations || (TableDecorations = {}));
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
export const TableCssClassName = {
|
|
18
|
+
...TableSharedCssClassName,
|
|
20
19
|
COLUMN_CONTROLS: `${tablePrefixSelector}-column-controls`,
|
|
21
20
|
COLUMN_CONTROLS_DECORATIONS: `${tablePrefixSelector}-column-controls-decoration`,
|
|
22
21
|
COLUMN_SELECTED: `${tablePrefixSelector}-column__selected`,
|
|
@@ -78,7 +77,6 @@ export const TableCssClassName = { ...TableSharedCssClassName,
|
|
|
78
77
|
WITH_RESIZE_LINE_LAST_COLUMN: `${tablePrefixSelector}-column-resize-line-last-column`
|
|
79
78
|
};
|
|
80
79
|
export let ShadowEvent;
|
|
81
|
-
|
|
82
80
|
(function (ShadowEvent) {
|
|
83
81
|
ShadowEvent["SHOW_BEFORE_SHADOW"] = "showBeforeShadow";
|
|
84
82
|
ShadowEvent["SHOW_AFTER_SHADOW"] = "showAfterShadow";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import React from 'react';
|
|
5
4
|
import { jsx } from '@emotion/react';
|
|
@@ -20,23 +19,21 @@ import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
|
20
19
|
export class FloatingContextualButtonInner extends React.Component {
|
|
21
20
|
constructor(...args) {
|
|
22
21
|
super(...args);
|
|
23
|
-
|
|
24
22
|
_defineProperty(this, "handleClick", () => {
|
|
25
23
|
const {
|
|
26
24
|
state,
|
|
27
25
|
dispatch
|
|
28
|
-
} = this.props.editorView;
|
|
26
|
+
} = this.props.editorView;
|
|
27
|
+
// Clicking outside the dropdown handles toggling the menu closed
|
|
29
28
|
// (otherwise these two toggles combat each other).
|
|
30
29
|
// In the event a user clicks the chevron button again
|
|
31
30
|
// That will count as clicking outside the dropdown and
|
|
32
31
|
// will be toggled appropriately
|
|
33
|
-
|
|
34
32
|
if (!this.props.isContextualMenuOpen) {
|
|
35
33
|
toggleContextualMenu()(state, dispatch);
|
|
36
34
|
}
|
|
37
35
|
});
|
|
38
36
|
}
|
|
39
|
-
|
|
40
37
|
render() {
|
|
41
38
|
const {
|
|
42
39
|
mountPoint,
|
|
@@ -49,16 +46,13 @@ export class FloatingContextualButtonInner extends React.Component {
|
|
|
49
46
|
},
|
|
50
47
|
dispatchAnalyticsEvent
|
|
51
48
|
} = this.props; // : Props & WrappedComponentProps
|
|
52
|
-
|
|
53
49
|
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
54
50
|
let targetCellRef;
|
|
55
|
-
|
|
56
51
|
try {
|
|
57
52
|
targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
58
53
|
} catch (error) {
|
|
59
54
|
// eslint-disable-next-line no-console
|
|
60
55
|
console.warn(error);
|
|
61
|
-
|
|
62
56
|
if (dispatchAnalyticsEvent) {
|
|
63
57
|
const payload = {
|
|
64
58
|
action: ACTION.ERRORED,
|
|
@@ -78,11 +72,9 @@ export class FloatingContextualButtonInner extends React.Component {
|
|
|
78
72
|
dispatchAnalyticsEvent(payload);
|
|
79
73
|
}
|
|
80
74
|
}
|
|
81
|
-
|
|
82
75
|
if (!targetCellRef || !(targetCellRef instanceof HTMLElement)) {
|
|
83
76
|
return null;
|
|
84
77
|
}
|
|
85
|
-
|
|
86
78
|
const tableWrapper = closestElement(targetCellRef, `.${ClassName.TABLE_NODE_WRAPPER}`);
|
|
87
79
|
const labelCellOptions = formatMessage(messages.cellOptions);
|
|
88
80
|
const button = jsx("div", {
|
|
@@ -102,7 +94,6 @@ export class FloatingContextualButtonInner extends React.Component {
|
|
|
102
94
|
"aria-label": labelCellOptions
|
|
103
95
|
}));
|
|
104
96
|
const parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
105
|
-
|
|
106
97
|
if (this.props.stickyHeader && parentSticky) {
|
|
107
98
|
const pos = targetCellRef.getBoundingClientRect();
|
|
108
99
|
return jsx("div", {
|
|
@@ -114,7 +105,6 @@ export class FloatingContextualButtonInner extends React.Component {
|
|
|
114
105
|
}
|
|
115
106
|
}, button);
|
|
116
107
|
}
|
|
117
|
-
|
|
118
108
|
return jsx(Popup, {
|
|
119
109
|
alignX: "right",
|
|
120
110
|
alignY: "start",
|
|
@@ -128,15 +118,11 @@ export class FloatingContextualButtonInner extends React.Component {
|
|
|
128
118
|
zIndex: akEditorSmallZIndex
|
|
129
119
|
}, button);
|
|
130
120
|
}
|
|
131
|
-
|
|
132
121
|
shouldComponentUpdate(nextProps) {
|
|
133
122
|
return this.props.tableNode !== nextProps.tableNode || this.props.targetCellPosition !== nextProps.targetCellPosition || this.props.layout !== nextProps.layout || this.props.isContextualMenuOpen !== nextProps.isContextualMenuOpen || this.props.isNumberColumnEnabled !== nextProps.isNumberColumnEnabled || this.props.stickyHeader !== nextProps.stickyHeader;
|
|
134
123
|
}
|
|
135
|
-
|
|
136
124
|
}
|
|
137
|
-
|
|
138
125
|
_defineProperty(FloatingContextualButtonInner, "displayName", 'FloatingContextualButton');
|
|
139
|
-
|
|
140
126
|
const FloatingContextualButton = injectIntl(FloatingContextualButtonInner);
|
|
141
127
|
export default function (props) {
|
|
142
128
|
return jsx(ErrorBoundary, {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { Component } from 'react';
|
|
5
4
|
import { jsx } from '@emotion/react';
|
|
@@ -67,26 +66,20 @@ export const messages = defineMessages({
|
|
|
67
66
|
export class ContextualMenu extends Component {
|
|
68
67
|
constructor(...args) {
|
|
69
68
|
super(...args);
|
|
70
|
-
|
|
71
69
|
_defineProperty(this, "state", {
|
|
72
70
|
isSubmenuOpen: false
|
|
73
71
|
});
|
|
74
|
-
|
|
75
72
|
_defineProperty(this, "handleSubMenuRef", ref => {
|
|
76
73
|
const parent = closestElement(this.props.editorView.dom, '.fabric-editor-popup-scroll-parent');
|
|
77
|
-
|
|
78
74
|
if (!(parent && ref)) {
|
|
79
75
|
return;
|
|
80
76
|
}
|
|
81
|
-
|
|
82
77
|
const boundariesRect = parent.getBoundingClientRect();
|
|
83
78
|
const rect = ref.getBoundingClientRect();
|
|
84
|
-
|
|
85
79
|
if (rect.left + rect.width > boundariesRect.width) {
|
|
86
80
|
ref.style.left = `-${rect.width}px`;
|
|
87
81
|
}
|
|
88
82
|
});
|
|
89
|
-
|
|
90
83
|
_defineProperty(this, "createItems", () => {
|
|
91
84
|
const {
|
|
92
85
|
allowMergeCells,
|
|
@@ -105,18 +98,16 @@ export class ContextualMenu extends Component {
|
|
|
105
98
|
const items = [];
|
|
106
99
|
const {
|
|
107
100
|
isSubmenuOpen
|
|
108
|
-
} = this.state;
|
|
109
|
-
|
|
101
|
+
} = this.state;
|
|
102
|
+
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
110
103
|
const {
|
|
111
104
|
targetCellPosition,
|
|
112
105
|
pluginConfig: {
|
|
113
106
|
allowDistributeColumns
|
|
114
107
|
}
|
|
115
108
|
} = getPluginState(editorView.state);
|
|
116
|
-
|
|
117
109
|
if (allowBackgroundColor) {
|
|
118
110
|
var _node$attrs;
|
|
119
|
-
|
|
120
111
|
const node = isOpen && targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
121
112
|
const background = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff';
|
|
122
113
|
items.push({
|
|
@@ -138,7 +129,6 @@ export class ContextualMenu extends Component {
|
|
|
138
129
|
})))
|
|
139
130
|
});
|
|
140
131
|
}
|
|
141
|
-
|
|
142
132
|
items.push({
|
|
143
133
|
content: formatMessage(tableMessages.insertColumn),
|
|
144
134
|
value: {
|
|
@@ -181,7 +171,6 @@ export class ContextualMenu extends Component {
|
|
|
181
171
|
name: 'delete_row'
|
|
182
172
|
}
|
|
183
173
|
});
|
|
184
|
-
|
|
185
174
|
if (allowMergeCells) {
|
|
186
175
|
items.push({
|
|
187
176
|
content: formatMessage(messages.mergeCells),
|
|
@@ -198,10 +187,8 @@ export class ContextualMenu extends Component {
|
|
|
198
187
|
isDisabled: !splitCell(state)
|
|
199
188
|
});
|
|
200
189
|
}
|
|
201
|
-
|
|
202
190
|
if (allowDistributeColumns) {
|
|
203
191
|
var _newResizeState$chang;
|
|
204
|
-
|
|
205
192
|
const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), this.props.getEditorContainerWidth);
|
|
206
193
|
const wouldChange = (_newResizeState$chang = newResizeState === null || newResizeState === void 0 ? void 0 : newResizeState.changed) !== null && _newResizeState$chang !== void 0 ? _newResizeState$chang : false;
|
|
207
194
|
items.push({
|
|
@@ -212,7 +199,6 @@ export class ContextualMenu extends Component {
|
|
|
212
199
|
isDisabled: !wouldChange
|
|
213
200
|
});
|
|
214
201
|
}
|
|
215
|
-
|
|
216
202
|
if (allowColumnSorting) {
|
|
217
203
|
const hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
218
204
|
const warning = hasMergedCellsInTable ? {
|
|
@@ -234,7 +220,6 @@ export class ContextualMenu extends Component {
|
|
|
234
220
|
...warning
|
|
235
221
|
});
|
|
236
222
|
}
|
|
237
|
-
|
|
238
223
|
items.push({
|
|
239
224
|
content: formatMessage(messages.clearCells, {
|
|
240
225
|
0: Math.max(noOfColumns, noOfRows)
|
|
@@ -250,7 +235,6 @@ export class ContextualMenu extends Component {
|
|
|
250
235
|
items
|
|
251
236
|
}] : null;
|
|
252
237
|
});
|
|
253
|
-
|
|
254
238
|
_defineProperty(this, "onMenuItemActivated", ({
|
|
255
239
|
item
|
|
256
240
|
}) => {
|
|
@@ -259,8 +243,8 @@ export class ContextualMenu extends Component {
|
|
|
259
243
|
selectionRect,
|
|
260
244
|
editorAnalyticsAPI,
|
|
261
245
|
getEditorContainerWidth
|
|
262
|
-
} = this.props;
|
|
263
|
-
|
|
246
|
+
} = this.props;
|
|
247
|
+
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
264
248
|
const {
|
|
265
249
|
state,
|
|
266
250
|
dispatch
|
|
@@ -268,48 +252,38 @@ export class ContextualMenu extends Component {
|
|
|
268
252
|
const {
|
|
269
253
|
targetCellPosition
|
|
270
254
|
} = getPluginState(state);
|
|
271
|
-
|
|
272
255
|
switch (item.value.name) {
|
|
273
256
|
case 'sort_column_desc':
|
|
274
257
|
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect.left, SortOrder.DESC)(state, dispatch);
|
|
275
258
|
this.toggleOpen();
|
|
276
259
|
break;
|
|
277
|
-
|
|
278
260
|
case 'sort_column_asc':
|
|
279
261
|
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect.left, SortOrder.ASC)(state, dispatch);
|
|
280
262
|
this.toggleOpen();
|
|
281
263
|
break;
|
|
282
|
-
|
|
283
264
|
case 'merge':
|
|
284
265
|
mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU)(state, dispatch);
|
|
285
266
|
this.toggleOpen();
|
|
286
267
|
break;
|
|
287
|
-
|
|
288
268
|
case 'split':
|
|
289
269
|
splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU)(state, dispatch);
|
|
290
270
|
this.toggleOpen();
|
|
291
271
|
break;
|
|
292
|
-
|
|
293
272
|
case 'distribute_columns':
|
|
294
273
|
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
|
|
295
|
-
|
|
296
274
|
if (newResizeStateWithAnalytics) {
|
|
297
275
|
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, newResizeStateWithAnalytics)(state, dispatch);
|
|
298
276
|
this.toggleOpen();
|
|
299
277
|
}
|
|
300
|
-
|
|
301
278
|
break;
|
|
302
|
-
|
|
303
279
|
case 'clear':
|
|
304
280
|
emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, targetCellPosition)(state, dispatch);
|
|
305
281
|
this.toggleOpen();
|
|
306
282
|
break;
|
|
307
|
-
|
|
308
283
|
case 'insert_column':
|
|
309
284
|
insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
310
285
|
this.toggleOpen();
|
|
311
286
|
break;
|
|
312
|
-
|
|
313
287
|
case 'insert_row':
|
|
314
288
|
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, {
|
|
315
289
|
index: selectionRect.bottom,
|
|
@@ -317,12 +291,10 @@ export class ContextualMenu extends Component {
|
|
|
317
291
|
})(state, dispatch);
|
|
318
292
|
this.toggleOpen();
|
|
319
293
|
break;
|
|
320
|
-
|
|
321
294
|
case 'delete_column':
|
|
322
295
|
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch);
|
|
323
296
|
this.toggleOpen();
|
|
324
297
|
break;
|
|
325
|
-
|
|
326
298
|
case 'delete_row':
|
|
327
299
|
const {
|
|
328
300
|
pluginConfig: {
|
|
@@ -334,7 +306,6 @@ export class ContextualMenu extends Component {
|
|
|
334
306
|
break;
|
|
335
307
|
}
|
|
336
308
|
});
|
|
337
|
-
|
|
338
309
|
_defineProperty(this, "toggleOpen", () => {
|
|
339
310
|
const {
|
|
340
311
|
isOpen,
|
|
@@ -344,14 +315,12 @@ export class ContextualMenu extends Component {
|
|
|
344
315
|
}
|
|
345
316
|
} = this.props;
|
|
346
317
|
toggleContextualMenu()(state, dispatch);
|
|
347
|
-
|
|
348
318
|
if (!isOpen) {
|
|
349
319
|
this.setState({
|
|
350
320
|
isSubmenuOpen: false
|
|
351
321
|
});
|
|
352
322
|
}
|
|
353
323
|
});
|
|
354
|
-
|
|
355
324
|
_defineProperty(this, "handleOpenChange", () => {
|
|
356
325
|
const {
|
|
357
326
|
editorView: {
|
|
@@ -364,7 +333,6 @@ export class ContextualMenu extends Component {
|
|
|
364
333
|
isSubmenuOpen: false
|
|
365
334
|
});
|
|
366
335
|
});
|
|
367
|
-
|
|
368
336
|
_defineProperty(this, "handleItemMouseEnter", ({
|
|
369
337
|
item
|
|
370
338
|
}) => {
|
|
@@ -375,7 +343,6 @@ export class ContextualMenu extends Component {
|
|
|
375
343
|
},
|
|
376
344
|
selectionRect
|
|
377
345
|
} = this.props;
|
|
378
|
-
|
|
379
346
|
if (item.value.name === 'background') {
|
|
380
347
|
if (!this.state.isSubmenuOpen) {
|
|
381
348
|
this.setState({
|
|
@@ -383,20 +350,16 @@ export class ContextualMenu extends Component {
|
|
|
383
350
|
});
|
|
384
351
|
}
|
|
385
352
|
}
|
|
386
|
-
|
|
387
353
|
if (item.value.name === 'delete_column') {
|
|
388
354
|
hoverColumns(getSelectedColumnIndexes(selectionRect), true)(state, dispatch);
|
|
389
355
|
}
|
|
390
|
-
|
|
391
356
|
if (item.value.name === 'delete_row') {
|
|
392
357
|
hoverRows(getSelectedRowIndexes(selectionRect), true)(state, dispatch);
|
|
393
358
|
}
|
|
394
|
-
|
|
395
359
|
if (['sort_column_asc', 'sort_column_desc'].indexOf(item.value.name) > -1 && getMergedCellsPositions(state.tr).length !== 0) {
|
|
396
360
|
hoverMergedCells()(state, dispatch);
|
|
397
361
|
}
|
|
398
362
|
});
|
|
399
|
-
|
|
400
363
|
_defineProperty(this, "handleItemMouseLeave", ({
|
|
401
364
|
item
|
|
402
365
|
}) => {
|
|
@@ -404,16 +367,13 @@ export class ContextualMenu extends Component {
|
|
|
404
367
|
state,
|
|
405
368
|
dispatch
|
|
406
369
|
} = this.props.editorView;
|
|
407
|
-
|
|
408
370
|
if (item.value.name === 'background') {
|
|
409
371
|
this.closeSubmenu();
|
|
410
372
|
}
|
|
411
|
-
|
|
412
373
|
if (['sort_column_asc', 'sort_column_desc', 'delete_column', 'delete_row'].indexOf(item.value.name) > -1) {
|
|
413
374
|
clearHoverSelection()(state, dispatch);
|
|
414
375
|
}
|
|
415
376
|
});
|
|
416
|
-
|
|
417
377
|
_defineProperty(this, "closeSubmenu", () => {
|
|
418
378
|
if (this.state.isSubmenuOpen) {
|
|
419
379
|
this.setState({
|
|
@@ -421,13 +381,12 @@ export class ContextualMenu extends Component {
|
|
|
421
381
|
});
|
|
422
382
|
}
|
|
423
383
|
});
|
|
424
|
-
|
|
425
384
|
_defineProperty(this, "setColor", color => {
|
|
426
385
|
const {
|
|
427
386
|
editorView,
|
|
428
387
|
editorAnalyticsAPI
|
|
429
|
-
} = this.props;
|
|
430
|
-
|
|
388
|
+
} = this.props;
|
|
389
|
+
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
431
390
|
const {
|
|
432
391
|
targetCellPosition
|
|
433
392
|
} = getPluginState(editorView.state);
|
|
@@ -439,7 +398,6 @@ export class ContextualMenu extends Component {
|
|
|
439
398
|
this.toggleOpen();
|
|
440
399
|
});
|
|
441
400
|
}
|
|
442
|
-
|
|
443
401
|
render() {
|
|
444
402
|
const {
|
|
445
403
|
isOpen,
|
|
@@ -448,16 +406,15 @@ export class ContextualMenu extends Component {
|
|
|
448
406
|
boundariesElement
|
|
449
407
|
} = this.props;
|
|
450
408
|
const items = this.createItems();
|
|
451
|
-
|
|
452
409
|
if (!items) {
|
|
453
410
|
return null;
|
|
454
411
|
}
|
|
455
|
-
|
|
456
412
|
return jsx("div", {
|
|
457
413
|
"data-testid": "table-cell-contextual-menu",
|
|
458
414
|
onMouseLeave: this.closeSubmenu
|
|
459
415
|
}, jsx(DropdownMenu, {
|
|
460
|
-
mountTo: mountPoint
|
|
416
|
+
mountTo: mountPoint
|
|
417
|
+
//This needs be removed when the a11y is completely handled
|
|
461
418
|
//Disabling key navigation now as it works only partially
|
|
462
419
|
,
|
|
463
420
|
disableArrowKeyNavigation: true,
|
|
@@ -473,11 +430,8 @@ export class ContextualMenu extends Component {
|
|
|
473
430
|
offset: offset
|
|
474
431
|
}));
|
|
475
432
|
}
|
|
476
|
-
|
|
477
433
|
}
|
|
478
|
-
|
|
479
434
|
_defineProperty(ContextualMenu, "defaultProps", {
|
|
480
435
|
boundariesElement: document.body
|
|
481
436
|
});
|
|
482
|
-
|
|
483
437
|
export default injectIntl(ContextualMenu);
|
|
@@ -8,27 +8,24 @@ import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
|
8
8
|
import { pluginKey } from '../../pm-plugins/plugin-key';
|
|
9
9
|
import { contextualMenuDropdownWidth, contextualMenuTriggerSize } from '../consts';
|
|
10
10
|
import { tablePopupStyles } from './styles';
|
|
11
|
-
import ContextualMenu from './ContextualMenu';
|
|
11
|
+
import ContextualMenu from './ContextualMenu';
|
|
12
12
|
|
|
13
|
+
// offset of the contextual menu dropdown
|
|
13
14
|
const calculateOffset = (targetCellRef, state) => {
|
|
14
15
|
const {
|
|
15
16
|
tableRef
|
|
16
17
|
} = pluginKey.getState(state);
|
|
17
18
|
let top = -contextualMenuTriggerSize;
|
|
18
|
-
|
|
19
19
|
if (tableRef && targetCellRef) {
|
|
20
20
|
const targetOffset = targetCellRef.getBoundingClientRect();
|
|
21
21
|
const tableOffset = tableRef.getBoundingClientRect();
|
|
22
22
|
let topDiff = targetOffset.top - tableOffset.top;
|
|
23
|
-
|
|
24
23
|
if (topDiff < 200) {
|
|
25
24
|
top -= topDiff + 2;
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
return [contextualMenuTriggerSize / 2, top];
|
|
30
28
|
};
|
|
31
|
-
|
|
32
29
|
const FloatingContextualMenu = ({
|
|
33
30
|
mountPoint,
|
|
34
31
|
boundariesElement,
|
|
@@ -43,27 +40,21 @@ const FloatingContextualMenu = ({
|
|
|
43
40
|
const {
|
|
44
41
|
targetCellPosition
|
|
45
42
|
} = getPluginState(editorView.state);
|
|
46
|
-
|
|
47
43
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
48
44
|
return null;
|
|
49
45
|
}
|
|
50
|
-
|
|
51
46
|
const {
|
|
52
47
|
selection
|
|
53
48
|
} = editorView.state;
|
|
54
49
|
const selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
55
|
-
|
|
56
50
|
if (!selectionRect) {
|
|
57
51
|
return null;
|
|
58
52
|
}
|
|
59
|
-
|
|
60
53
|
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
61
54
|
const targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
62
|
-
|
|
63
55
|
if (!targetCellRef) {
|
|
64
56
|
return null;
|
|
65
57
|
}
|
|
66
|
-
|
|
67
58
|
return jsx(Popup, {
|
|
68
59
|
alignX: "right",
|
|
69
60
|
alignY: "top",
|
|
@@ -72,7 +63,8 @@ const FloatingContextualMenu = ({
|
|
|
72
63
|
boundariesElement: boundariesElement,
|
|
73
64
|
scrollableElement: scrollableElement,
|
|
74
65
|
fitHeight: 188,
|
|
75
|
-
fitWidth: contextualMenuDropdownWidth
|
|
66
|
+
fitWidth: contextualMenuDropdownWidth
|
|
67
|
+
// z-index value below is to ensure that this menu is above other floating menu
|
|
76
68
|
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
77
69
|
,
|
|
78
70
|
zIndex: akEditorFloatingOverlapPanelZIndex,
|
|
@@ -94,6 +86,5 @@ const FloatingContextualMenu = ({
|
|
|
94
86
|
getEditorContainerWidth: getEditorContainerWidth
|
|
95
87
|
})));
|
|
96
88
|
};
|
|
97
|
-
|
|
98
89
|
FloatingContextualMenu.displayName = 'FloatingContextualMenu';
|
|
99
90
|
export default FloatingContextualMenu;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { injectIntl } from 'react-intl-next';
|
|
3
3
|
import { TableCssClassName as ClassName } from '../../types';
|
|
4
|
-
|
|
5
4
|
const DeleteButton = ({
|
|
6
5
|
style,
|
|
7
6
|
onClick,
|
|
@@ -31,5 +30,4 @@ const DeleteButton = ({
|
|
|
31
30
|
fill: "currentColor",
|
|
32
31
|
fillRule: "evenodd"
|
|
33
32
|
}))));
|
|
34
|
-
|
|
35
33
|
export default injectIntl(DeleteButton);
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { tableDeleteButtonOffset, tableDeleteButtonSize, tableToolbarSize } from '../consts';
|
|
2
2
|
const DELETE_BUTTON_CONTROLS_OFFSET = tableToolbarSize + tableDeleteButtonSize + tableDeleteButtonOffset;
|
|
3
|
-
|
|
4
3
|
function getColumnOptions(left, tableWrapper) {
|
|
5
4
|
return {
|
|
6
5
|
alignX: 'left',
|
|
7
6
|
alignY: 'start',
|
|
8
7
|
offset: [left, DELETE_BUTTON_CONTROLS_OFFSET],
|
|
9
|
-
|
|
10
8
|
shouldRenderPopup() {
|
|
11
9
|
if (tableWrapper) {
|
|
12
10
|
const rect = tableWrapper.getBoundingClientRect();
|
|
@@ -14,30 +12,25 @@ function getColumnOptions(left, tableWrapper) {
|
|
|
14
12
|
const minVisibleLeftPosition = tableWrapper.scrollLeft;
|
|
15
13
|
return maxVisibleLeftPosition - left > 0 && left > minVisibleLeftPosition;
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
return true;
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
};
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
function getRowOptions(top) {
|
|
25
20
|
return {
|
|
26
21
|
alignX: 'left',
|
|
27
22
|
alignY: 'start',
|
|
28
23
|
forcePlacement: true,
|
|
29
24
|
offset: [0, -top],
|
|
30
|
-
|
|
31
25
|
onPositionCalculated(position) {
|
|
32
|
-
return {
|
|
26
|
+
return {
|
|
27
|
+
...position,
|
|
33
28
|
// We need to force left to always be the offset to not be affected by overflow
|
|
34
29
|
left: -DELETE_BUTTON_CONTROLS_OFFSET
|
|
35
30
|
};
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
};
|
|
39
33
|
}
|
|
40
|
-
|
|
41
34
|
export default function getPopupOptions({
|
|
42
35
|
left,
|
|
43
36
|
top,
|
|
@@ -47,10 +40,8 @@ export default function getPopupOptions({
|
|
|
47
40
|
switch (selectionType) {
|
|
48
41
|
case 'column':
|
|
49
42
|
return getColumnOptions(left, tableWrapper);
|
|
50
|
-
|
|
51
43
|
case 'row':
|
|
52
44
|
return getRowOptions(top);
|
|
53
|
-
|
|
54
45
|
default:
|
|
55
46
|
{
|
|
56
47
|
return {};
|