@atlaskit/editor-plugin-table 1.1.1 → 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 +6 -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
|
@@ -5,24 +5,20 @@ import { convertArrayOfRowsToTableNode, convertTableNodeToArrayOfRows, findTable
|
|
|
5
5
|
import { createCompareNodes } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
|
|
7
7
|
import { TableSortStep, TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
|
|
8
|
-
|
|
9
8
|
function createGetInlineCardTextFromStore(state) {
|
|
10
9
|
return attrs => {
|
|
11
10
|
const {
|
|
12
11
|
data
|
|
13
12
|
} = attrs;
|
|
14
|
-
|
|
15
13
|
if (data && (data.name || data.title)) {
|
|
16
14
|
return data.name || data.title;
|
|
17
15
|
}
|
|
18
|
-
|
|
19
16
|
const {
|
|
20
17
|
url: cardUrl
|
|
21
18
|
} = attrs;
|
|
22
19
|
return cardUrl;
|
|
23
20
|
};
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
export const sortByColumn = (columnIndex, order = SortOrder.DESC) => createCommand(state => ({
|
|
27
23
|
type: 'SORT_TABLE',
|
|
28
24
|
data: {
|
|
@@ -33,34 +29,26 @@ export const sortByColumn = (columnIndex, order = SortOrder.DESC) => createComma
|
|
|
33
29
|
}
|
|
34
30
|
}), (tr, state) => {
|
|
35
31
|
const table = findTable(tr.selection);
|
|
36
|
-
|
|
37
32
|
if (!table || !table.node) {
|
|
38
33
|
return tr;
|
|
39
34
|
}
|
|
40
|
-
|
|
41
35
|
const selectionRect = isSelectionType(tr.selection, 'cell') ? getSelectionRect(tr.selection) : findCellRectClosestToPos(tr.selection.$from);
|
|
42
|
-
|
|
43
36
|
if (!selectionRect) {
|
|
44
37
|
return tr;
|
|
45
38
|
}
|
|
46
|
-
|
|
47
39
|
const tablePluginState = getPluginState(state);
|
|
48
40
|
const tableArray = convertTableNodeToArrayOfRows(table.node);
|
|
49
41
|
let headerRow;
|
|
50
|
-
|
|
51
42
|
if (tablePluginState.isHeaderRowEnabled) {
|
|
52
43
|
headerRow = tableArray.shift();
|
|
53
44
|
}
|
|
54
|
-
|
|
55
45
|
const compareNodesInOrder = createCompareNodes({
|
|
56
46
|
getInlineCardTextFromStore: createGetInlineCardTextFromStore(state)
|
|
57
47
|
}, order);
|
|
58
48
|
const sortedTable = tableArray.sort((rowA, rowB) => compareNodesInOrder(rowA[columnIndex], rowB[columnIndex]));
|
|
59
|
-
|
|
60
49
|
if (headerRow) {
|
|
61
50
|
sortedTable.unshift(headerRow);
|
|
62
51
|
}
|
|
63
|
-
|
|
64
52
|
const newTableNode = convertArrayOfRowsToTableNode(table.node, sortedTable);
|
|
65
53
|
tr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTableNode);
|
|
66
54
|
const pos = TableMap.get(table.node).positionAt(selectionRect.top, columnIndex, table.node);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { splitCellWithType } from '@atlaskit/editor-tables/utils';
|
|
2
2
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* We need to split cell keeping the right type of cell given current table configuration.
|
|
6
5
|
* We are using editor-tables splitCellWithType that allows you to choose what cell type should be.
|
|
@@ -11,7 +10,6 @@ export const splitCell = (state, dispatch) => {
|
|
|
11
10
|
tableHeader,
|
|
12
11
|
tableCell
|
|
13
12
|
} = state.schema.nodes;
|
|
14
|
-
|
|
15
13
|
if (dispatch) {
|
|
16
14
|
return splitCellWithType(({
|
|
17
15
|
row,
|
|
@@ -20,10 +18,8 @@ export const splitCell = (state, dispatch) => {
|
|
|
20
18
|
if (row === 0 && tableState.isHeaderRowEnabled || col === 0 && tableState.isHeaderColumnEnabled) {
|
|
21
19
|
return tableHeader;
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
return tableCell;
|
|
25
22
|
})(state, dispatch);
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
return true;
|
|
29
25
|
};
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
//#region Imports
|
|
2
|
+
|
|
2
3
|
import { toggleHeader } from '@atlaskit/editor-tables/utils';
|
|
3
4
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
4
|
-
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
5
|
-
|
|
5
|
+
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
6
|
+
//#endregion
|
|
6
7
|
|
|
8
|
+
// #region Utils
|
|
7
9
|
/**
|
|
8
10
|
* Table layout toggle logic
|
|
9
11
|
* default -> wide -> full-width -> default
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
13
|
export const getNextLayout = currentLayout => {
|
|
13
14
|
switch (currentLayout) {
|
|
14
15
|
case 'default':
|
|
15
16
|
return 'wide';
|
|
16
|
-
|
|
17
17
|
case 'wide':
|
|
18
18
|
return 'full-width';
|
|
19
|
-
|
|
20
19
|
case 'full-width':
|
|
21
20
|
return 'default';
|
|
22
|
-
|
|
23
21
|
default:
|
|
24
22
|
return 'default';
|
|
25
23
|
}
|
|
26
|
-
};
|
|
27
|
-
// #
|
|
24
|
+
};
|
|
25
|
+
// #endregion
|
|
28
26
|
|
|
27
|
+
// #region Actions
|
|
29
28
|
export const toggleHeaderRow = (state, dispatch) => toggleHeader('row')(state, tr => createCommand({
|
|
30
29
|
type: 'TOGGLE_HEADER_ROW'
|
|
31
30
|
}, () => tr.setMeta('scrollIntoView', false))(state, dispatch));
|
|
@@ -40,24 +39,21 @@ export const toggleNumberColumn = (state, dispatch) => {
|
|
|
40
39
|
node,
|
|
41
40
|
pos
|
|
42
41
|
} = findTable(state.selection);
|
|
43
|
-
tr.setNodeMarkup(pos, state.schema.nodes.table, {
|
|
42
|
+
tr.setNodeMarkup(pos, state.schema.nodes.table, {
|
|
43
|
+
...node.attrs,
|
|
44
44
|
isNumberColumnEnabled: !node.attrs.isNumberColumnEnabled
|
|
45
45
|
});
|
|
46
46
|
tr.setMeta('scrollIntoView', false);
|
|
47
|
-
|
|
48
47
|
if (dispatch) {
|
|
49
48
|
dispatch(tr);
|
|
50
49
|
}
|
|
51
|
-
|
|
52
50
|
return true;
|
|
53
51
|
};
|
|
54
52
|
export const toggleTableLayout = (state, dispatch) => {
|
|
55
53
|
const table = findTable(state.selection);
|
|
56
|
-
|
|
57
54
|
if (!table) {
|
|
58
55
|
return false;
|
|
59
56
|
}
|
|
60
|
-
|
|
61
57
|
const layout = getNextLayout(table.node.attrs.layout);
|
|
62
58
|
return createCommand({
|
|
63
59
|
type: 'SET_TABLE_LAYOUT',
|
|
@@ -65,7 +61,8 @@ export const toggleTableLayout = (state, dispatch) => {
|
|
|
65
61
|
layout
|
|
66
62
|
}
|
|
67
63
|
}, tr => {
|
|
68
|
-
tr.setNodeMarkup(table.pos, state.schema.nodes.table, {
|
|
64
|
+
tr.setNodeMarkup(table.pos, state.schema.nodes.table, {
|
|
65
|
+
...table.node.attrs,
|
|
69
66
|
layout
|
|
70
67
|
});
|
|
71
68
|
return tr.setMeta('scrollIntoView', false);
|
|
@@ -73,4 +70,5 @@ export const toggleTableLayout = (state, dispatch) => {
|
|
|
73
70
|
};
|
|
74
71
|
export const toggleContextualMenu = () => createCommand({
|
|
75
72
|
type: 'TOGGLE_CONTEXTUAL_MENU'
|
|
76
|
-
}, tr => tr.setMeta('addToHistory', false));
|
|
73
|
+
}, tr => tr.setMeta('addToHistory', false));
|
|
74
|
+
// #endregion
|
|
@@ -19,8 +19,9 @@ const TABLE_BREAKOUT_NAME_MAPPING = {
|
|
|
19
19
|
default: TABLE_BREAKOUT.NORMAL,
|
|
20
20
|
wide: TABLE_BREAKOUT.WIDE,
|
|
21
21
|
'full-width': TABLE_BREAKOUT.FULL_WIDTH
|
|
22
|
-
};
|
|
22
|
+
};
|
|
23
23
|
|
|
24
|
+
// #region Analytics wrappers
|
|
24
25
|
export const emptyMultipleCellsWithAnalytics = editorAnalyticsAPI => (inputMethod, targetCellPosition) => withEditorAnalyticsAPI(({
|
|
25
26
|
selection
|
|
26
27
|
}) => {
|
|
@@ -72,7 +73,6 @@ export const mergeCellsWithAnalytics = editorAnalyticsAPI => inputMethod => with
|
|
|
72
73
|
if (dispatch) {
|
|
73
74
|
dispatch(mergeCells(state.tr));
|
|
74
75
|
}
|
|
75
|
-
|
|
76
76
|
return true;
|
|
77
77
|
});
|
|
78
78
|
export const splitCellWithAnalytics = editorAnalyticsAPI => inputMethod => withEditorAnalyticsAPI(({
|
|
@@ -83,7 +83,6 @@ export const splitCellWithAnalytics = editorAnalyticsAPI => inputMethod => withE
|
|
|
83
83
|
totalColumnCount
|
|
84
84
|
} = getSelectedCellInfo(selection);
|
|
85
85
|
const cell = findCellClosestToPos(selection.$anchor);
|
|
86
|
-
|
|
87
86
|
if (cell) {
|
|
88
87
|
const {
|
|
89
88
|
rowspan: verticalCells,
|
|
@@ -104,7 +103,6 @@ export const splitCellWithAnalytics = editorAnalyticsAPI => inputMethod => withE
|
|
|
104
103
|
eventType: EVENT_TYPE.TRACK
|
|
105
104
|
};
|
|
106
105
|
}
|
|
107
|
-
|
|
108
106
|
return;
|
|
109
107
|
})(editorAnalyticsAPI)(splitCell);
|
|
110
108
|
export const setColorWithAnalytics = editorAnalyticsAPI => (inputMethod, cellColor, targetCellPosition) => withEditorAnalyticsAPI(({
|
|
@@ -141,11 +139,9 @@ export const addRowAroundSelection = editorAnalyticsAPI => side => (state, dispa
|
|
|
141
139
|
} = state;
|
|
142
140
|
const isCellSelection = selection instanceof CellSelection;
|
|
143
141
|
const rect = isCellSelection ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
144
|
-
|
|
145
142
|
if (!rect) {
|
|
146
143
|
return false;
|
|
147
144
|
}
|
|
148
|
-
|
|
149
145
|
const position = isCellSelection && side === 'TOP' ? rect.top : rect.bottom - 1;
|
|
150
146
|
const offset = side === 'BOTTOM' ? 1 : 0;
|
|
151
147
|
return insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, {
|
|
@@ -213,7 +209,6 @@ export const deleteRowsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect,
|
|
|
213
209
|
if (dispatch) {
|
|
214
210
|
dispatch(deleteRows(rect, isHeaderRowRequired)(state.tr));
|
|
215
211
|
}
|
|
216
|
-
|
|
217
212
|
return true;
|
|
218
213
|
});
|
|
219
214
|
export const deleteColumnsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect) => withEditorAnalyticsAPI(({
|
|
@@ -240,10 +235,8 @@ export const deleteColumnsWithAnalytics = editorAnalyticsAPI => (inputMethod, re
|
|
|
240
235
|
if (dispatch) {
|
|
241
236
|
dispatch(deleteColumns(rect, getAllowAddColumnCustomStep(state))(state.tr));
|
|
242
237
|
}
|
|
243
|
-
|
|
244
238
|
return true;
|
|
245
239
|
});
|
|
246
|
-
|
|
247
240
|
const getTableDeletedAnalytics = (selection, inputMethod) => {
|
|
248
241
|
const {
|
|
249
242
|
totalRowCount,
|
|
@@ -260,7 +253,6 @@ const getTableDeletedAnalytics = (selection, inputMethod) => {
|
|
|
260
253
|
eventType: EVENT_TYPE.TRACK
|
|
261
254
|
};
|
|
262
255
|
};
|
|
263
|
-
|
|
264
256
|
export const deleteTableWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsAPI(({
|
|
265
257
|
selection
|
|
266
258
|
}) => getTableDeletedAnalytics(selection, INPUT_METHOD.FLOATING_TB))(editorAnalyticsAPI)(deleteTable);
|
|
@@ -330,7 +322,6 @@ export const toggleTableLayoutWithAnalytics = editorAnalyticsAPI => withEditorAn
|
|
|
330
322
|
totalRowCount,
|
|
331
323
|
totalColumnCount
|
|
332
324
|
} = getSelectedTableInfo(state.selection);
|
|
333
|
-
|
|
334
325
|
if (table) {
|
|
335
326
|
const {
|
|
336
327
|
layout
|
|
@@ -348,7 +339,6 @@ export const toggleTableLayoutWithAnalytics = editorAnalyticsAPI => withEditorAn
|
|
|
348
339
|
eventType: EVENT_TYPE.TRACK
|
|
349
340
|
};
|
|
350
341
|
}
|
|
351
|
-
|
|
352
342
|
return;
|
|
353
343
|
})(editorAnalyticsAPI)(toggleTableLayout);
|
|
354
344
|
export const sortColumnWithAnalytics = editorAnalyticsAPI => (inputMethod, columnIndex, sortOrder) => withEditorAnalyticsAPI(state => {
|
|
@@ -390,7 +380,6 @@ export const distributeColumnsWidthsWithAnalytics = editorAnalyticsAPI => (input
|
|
|
390
380
|
if (dispatch) {
|
|
391
381
|
distributeColumnsWidths(resizeState, table)(state, dispatch);
|
|
392
382
|
}
|
|
393
|
-
|
|
394
383
|
return true;
|
|
395
384
|
});
|
|
396
385
|
};
|
|
@@ -409,4 +398,5 @@ export const wrapTableInExpandWithAnalytics = editorAnalyticsAPI => withEditorAn
|
|
|
409
398
|
},
|
|
410
399
|
eventType: EVENT_TYPE.TRACK
|
|
411
400
|
};
|
|
412
|
-
})(editorAnalyticsAPI)(wrapTableInExpand);
|
|
401
|
+
})(editorAnalyticsAPI)(wrapTableInExpand);
|
|
402
|
+
// #endregion
|
|
@@ -13,24 +13,19 @@ import { deleteColumns, deleteRows } from './transforms';
|
|
|
13
13
|
import { RESIZE_HANDLE_AREA_DECORATION_GAP } from './types';
|
|
14
14
|
import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, isCell, isColumnControlsDecorations, isCornerButton, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableControlsButton, isTableContainerOrWrapper, hasResizeHandler } from './utils';
|
|
15
15
|
import { getAllowAddColumnCustomStep } from './utils/get-allow-add-column-custom-step';
|
|
16
|
-
|
|
17
16
|
const isFocusingCalendar = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
|
|
18
|
-
|
|
19
17
|
const isFocusingModal = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="dialog"]');
|
|
20
|
-
|
|
21
18
|
const isFocusingFloatingToolbar = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="toolbar"]');
|
|
22
|
-
|
|
23
19
|
export const handleBlur = (view, event) => {
|
|
24
20
|
const {
|
|
25
21
|
state,
|
|
26
22
|
dispatch
|
|
27
|
-
} = view;
|
|
23
|
+
} = view;
|
|
24
|
+
// IE version check for ED-4665
|
|
28
25
|
// Calendar focus check for ED-10466
|
|
29
|
-
|
|
30
26
|
if (browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event)) {
|
|
31
27
|
setEditorFocus(false)(state, dispatch);
|
|
32
28
|
}
|
|
33
|
-
|
|
34
29
|
event.preventDefault();
|
|
35
30
|
return false;
|
|
36
31
|
};
|
|
@@ -47,10 +42,8 @@ export const handleClick = (view, event) => {
|
|
|
47
42
|
if (!(event.target instanceof HTMLElement)) {
|
|
48
43
|
return false;
|
|
49
44
|
}
|
|
50
|
-
|
|
51
45
|
const element = event.target;
|
|
52
46
|
const table = findTable(view.state.selection);
|
|
53
|
-
|
|
54
47
|
if (event instanceof MouseEvent && isColumnControlsDecorations(element)) {
|
|
55
48
|
const [startIndex] = getColumnOrRowIndex(element);
|
|
56
49
|
const {
|
|
@@ -59,16 +52,15 @@ export const handleClick = (view, event) => {
|
|
|
59
52
|
} = view;
|
|
60
53
|
return selectColumn(startIndex, event.shiftKey)(state, dispatch);
|
|
61
54
|
}
|
|
55
|
+
const matchfn = element.matches ? element.matches : element.msMatchesSelector;
|
|
62
56
|
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
// check if the table cell with an image is clicked and its not the image itself
|
|
65
58
|
if (!table || !isElementInTableCell(element) || !matchfn || matchfn.call(element, 'table .image, table p, table .image div')) {
|
|
66
59
|
return false;
|
|
67
60
|
}
|
|
68
|
-
|
|
69
61
|
const map = TableMap.get(table.node);
|
|
70
|
-
/** Getting the offset of current item clicked */
|
|
71
62
|
|
|
63
|
+
/** Getting the offset of current item clicked */
|
|
72
64
|
const colElement = closestElement(element, 'td') || closestElement(element, 'th');
|
|
73
65
|
const colIndex = colElement && colElement.cellIndex;
|
|
74
66
|
const rowElement = closestElement(element, 'tr');
|
|
@@ -86,28 +78,23 @@ export const handleClick = (view, event) => {
|
|
|
86
78
|
}
|
|
87
79
|
} = view;
|
|
88
80
|
const cellPos = map.map[cellIndex];
|
|
89
|
-
|
|
90
81
|
if (isNaN(cellPos) || cellPos === undefined || typeof cellPos !== 'number') {
|
|
91
82
|
return false;
|
|
92
83
|
}
|
|
93
|
-
|
|
94
84
|
const editorElement = table.node.nodeAt(cellPos);
|
|
95
85
|
/** Only if the last item is media group, insert a paragraph */
|
|
96
|
-
|
|
97
86
|
if (isLastItemMediaGroup(editorElement)) {
|
|
98
87
|
const posInTable = map.map[cellIndex] + editorElement.nodeSize;
|
|
99
88
|
tr.insert(posInTable + table.pos, paragraph.create());
|
|
100
89
|
dispatch(tr);
|
|
101
90
|
setNodeSelection(view, posInTable + table.pos);
|
|
102
91
|
}
|
|
103
|
-
|
|
104
92
|
return true;
|
|
105
93
|
};
|
|
106
94
|
export const handleMouseOver = (view, mouseEvent) => {
|
|
107
95
|
if (!(mouseEvent.target instanceof HTMLElement)) {
|
|
108
96
|
return false;
|
|
109
97
|
}
|
|
110
|
-
|
|
111
98
|
const {
|
|
112
99
|
state,
|
|
113
100
|
dispatch
|
|
@@ -117,13 +104,11 @@ export const handleMouseOver = (view, mouseEvent) => {
|
|
|
117
104
|
insertColumnButtonIndex,
|
|
118
105
|
insertRowButtonIndex
|
|
119
106
|
} = getPluginState(state);
|
|
120
|
-
|
|
121
107
|
if (isInsertRowButton(target)) {
|
|
122
108
|
const [startIndex, endIndex] = getColumnOrRowIndex(target);
|
|
123
109
|
const positionRow = getMousePositionVerticalRelativeByElement(mouseEvent) === 'bottom' ? endIndex : startIndex;
|
|
124
110
|
return showInsertRowButton(positionRow)(state, dispatch);
|
|
125
111
|
}
|
|
126
|
-
|
|
127
112
|
if (isColumnControlsDecorations(target)) {
|
|
128
113
|
const [startIndex] = getColumnOrRowIndex(target);
|
|
129
114
|
const {
|
|
@@ -132,11 +117,9 @@ export const handleMouseOver = (view, mouseEvent) => {
|
|
|
132
117
|
} = view;
|
|
133
118
|
return hoverColumns([startIndex], false)(state, dispatch);
|
|
134
119
|
}
|
|
135
|
-
|
|
136
120
|
if ((isCell(target) || isCornerButton(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
|
|
137
121
|
return hideInsertColumnOrRowButton()(state, dispatch);
|
|
138
122
|
}
|
|
139
|
-
|
|
140
123
|
if (isResizeHandleDecoration(target)) {
|
|
141
124
|
const [startIndex, endIndex] = getColumnOrRowIndex(target);
|
|
142
125
|
return showResizeHandleLine({
|
|
@@ -144,27 +127,23 @@ export const handleMouseOver = (view, mouseEvent) => {
|
|
|
144
127
|
right: endIndex
|
|
145
128
|
})(state, dispatch);
|
|
146
129
|
}
|
|
147
|
-
|
|
148
130
|
return false;
|
|
149
|
-
};
|
|
150
|
-
// PM end up changing selection during shift selection if not prevented
|
|
131
|
+
};
|
|
151
132
|
|
|
133
|
+
// Ignore any `mousedown` `event` from control and numbered column buttons
|
|
134
|
+
// PM end up changing selection during shift selection if not prevented
|
|
152
135
|
export const handleMouseDown = (_, event) => {
|
|
153
136
|
const isControl = !!(event.target && event.target instanceof HTMLElement && (isTableContainerOrWrapper(event.target) || isColumnControlsDecorations(event.target) || isRowControlsButton(event.target)));
|
|
154
|
-
|
|
155
137
|
if (isControl) {
|
|
156
138
|
event.preventDefault();
|
|
157
139
|
}
|
|
158
|
-
|
|
159
140
|
return isControl;
|
|
160
141
|
};
|
|
161
142
|
export const handleMouseOut = (view, mouseEvent) => {
|
|
162
143
|
if (!(mouseEvent instanceof MouseEvent) || !(mouseEvent.target instanceof HTMLElement)) {
|
|
163
144
|
return false;
|
|
164
145
|
}
|
|
165
|
-
|
|
166
146
|
const target = mouseEvent.target;
|
|
167
|
-
|
|
168
147
|
if (isColumnControlsDecorations(target)) {
|
|
169
148
|
const {
|
|
170
149
|
state,
|
|
@@ -172,10 +151,9 @@ export const handleMouseOut = (view, mouseEvent) => {
|
|
|
172
151
|
} = view;
|
|
173
152
|
return clearHoverSelection()(state, dispatch);
|
|
174
153
|
}
|
|
175
|
-
|
|
176
|
-
|
|
154
|
+
const relatedTarget = mouseEvent.relatedTarget;
|
|
155
|
+
// In case the user is moving between cell at the same column
|
|
177
156
|
// we don't need to hide the resize handle decoration
|
|
178
|
-
|
|
179
157
|
if (isResizeHandleDecoration(target) && !isResizeHandleDecoration(relatedTarget)) {
|
|
180
158
|
const {
|
|
181
159
|
state,
|
|
@@ -183,14 +161,12 @@ export const handleMouseOut = (view, mouseEvent) => {
|
|
|
183
161
|
} = view;
|
|
184
162
|
return hideResizeHandleLine()(state, dispatch);
|
|
185
163
|
}
|
|
186
|
-
|
|
187
164
|
return false;
|
|
188
165
|
};
|
|
189
166
|
export const handleMouseLeave = (view, event) => {
|
|
190
167
|
if (!(event.target instanceof HTMLElement)) {
|
|
191
168
|
return false;
|
|
192
169
|
}
|
|
193
|
-
|
|
194
170
|
const {
|
|
195
171
|
state,
|
|
196
172
|
dispatch
|
|
@@ -200,24 +176,19 @@ export const handleMouseLeave = (view, event) => {
|
|
|
200
176
|
insertRowButtonIndex
|
|
201
177
|
} = getPluginState(state);
|
|
202
178
|
const target = event.target;
|
|
203
|
-
|
|
204
179
|
if (isTableControlsButton(target)) {
|
|
205
180
|
return true;
|
|
206
181
|
}
|
|
207
|
-
|
|
208
182
|
if ((typeof insertColumnButtonIndex !== 'undefined' || typeof insertRowButtonIndex !== 'undefined') && hideInsertColumnOrRowButton()(state, dispatch)) {
|
|
209
183
|
return true;
|
|
210
184
|
}
|
|
211
|
-
|
|
212
185
|
return false;
|
|
213
186
|
};
|
|
214
187
|
export const handleMouseMove = getEditorFeatureFlags => (view, event, elementContentRects) => {
|
|
215
188
|
if (!(event.target instanceof HTMLElement)) {
|
|
216
189
|
return false;
|
|
217
190
|
}
|
|
218
|
-
|
|
219
191
|
const element = event.target;
|
|
220
|
-
|
|
221
192
|
if (isColumnControlsDecorations(element)) {
|
|
222
193
|
const {
|
|
223
194
|
state,
|
|
@@ -228,12 +199,10 @@ export const handleMouseMove = getEditorFeatureFlags => (view, event, elementCon
|
|
|
228
199
|
} = getPluginState(state);
|
|
229
200
|
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
230
201
|
const positionColumn = getMousePositionHorizontalRelativeByElement(event, false, elementContentRects) === 'right' ? endIndex : startIndex;
|
|
231
|
-
|
|
232
202
|
if (positionColumn !== insertColumnButtonIndex) {
|
|
233
203
|
return showInsertColumnButton(positionColumn)(state, dispatch);
|
|
234
204
|
}
|
|
235
205
|
}
|
|
236
|
-
|
|
237
206
|
if (isRowControlsButton(element)) {
|
|
238
207
|
const {
|
|
239
208
|
state,
|
|
@@ -244,19 +213,15 @@ export const handleMouseMove = getEditorFeatureFlags => (view, event, elementCon
|
|
|
244
213
|
} = getPluginState(state);
|
|
245
214
|
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
246
215
|
const positionRow = getMousePositionVerticalRelativeByElement(event) === 'bottom' ? endIndex : startIndex;
|
|
247
|
-
|
|
248
216
|
if (positionRow !== insertRowButtonIndex) {
|
|
249
217
|
return showInsertRowButton(positionRow)(state, dispatch);
|
|
250
218
|
}
|
|
251
219
|
}
|
|
252
|
-
|
|
253
220
|
const {
|
|
254
221
|
mouseMoveOptimization
|
|
255
222
|
} = getEditorFeatureFlags();
|
|
256
|
-
|
|
257
223
|
if (!isResizeHandleDecoration(element) && isCell(element)) {
|
|
258
224
|
const positionColumn = getMousePositionHorizontalRelativeByElement(event, mouseMoveOptimization, elementContentRects, RESIZE_HANDLE_AREA_DECORATION_GAP);
|
|
259
|
-
|
|
260
225
|
if (positionColumn !== null) {
|
|
261
226
|
const {
|
|
262
227
|
state,
|
|
@@ -269,11 +234,9 @@ export const handleMouseMove = getEditorFeatureFlags => (view, event, elementCon
|
|
|
269
234
|
const tableCell = closestElement(element, 'td, th');
|
|
270
235
|
const cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
271
236
|
const rect = findCellRectClosestToPos(state.doc.resolve(cellStartPosition));
|
|
272
|
-
|
|
273
237
|
if (rect) {
|
|
274
238
|
const columnEndIndexTarget = positionColumn === 'left' ? rect.left : rect.right;
|
|
275
239
|
const rowIndexTarget = rect.top;
|
|
276
|
-
|
|
277
240
|
if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !hasResizeHandler({
|
|
278
241
|
target: element,
|
|
279
242
|
columnEndIndexTarget
|
|
@@ -283,7 +246,6 @@ export const handleMouseMove = getEditorFeatureFlags => (view, event, elementCon
|
|
|
283
246
|
}
|
|
284
247
|
}
|
|
285
248
|
}
|
|
286
|
-
|
|
287
249
|
return false;
|
|
288
250
|
};
|
|
289
251
|
export function handleTripleClick(view, pos) {
|
|
@@ -292,23 +254,18 @@ export function handleTripleClick(view, pos) {
|
|
|
292
254
|
dispatch
|
|
293
255
|
} = view;
|
|
294
256
|
const $cellPos = cellAround(state.doc.resolve(pos));
|
|
295
|
-
|
|
296
257
|
if (!$cellPos) {
|
|
297
258
|
return false;
|
|
298
259
|
}
|
|
299
|
-
|
|
300
260
|
const cell = state.doc.nodeAt($cellPos.pos);
|
|
301
|
-
|
|
302
261
|
if (cell) {
|
|
303
262
|
const selFrom = Selection.findFrom($cellPos, 1, true);
|
|
304
263
|
const selTo = Selection.findFrom(state.doc.resolve($cellPos.pos + cell.nodeSize), -1, true);
|
|
305
|
-
|
|
306
264
|
if (selFrom && selTo) {
|
|
307
265
|
dispatch(state.tr.setSelection(new TextSelection(selFrom.$from, selTo.$to)));
|
|
308
266
|
return true;
|
|
309
267
|
}
|
|
310
268
|
}
|
|
311
|
-
|
|
312
269
|
return false;
|
|
313
270
|
}
|
|
314
271
|
export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
|
|
@@ -316,16 +273,13 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
|
|
|
316
273
|
let {
|
|
317
274
|
tr
|
|
318
275
|
} = newState;
|
|
319
|
-
|
|
320
276
|
if (oldSelection instanceof CellSelection) {
|
|
321
277
|
const $anchorCell = oldTr.doc.resolve(oldTr.mapping.map(oldSelection.$anchorCell.pos));
|
|
322
278
|
const $headCell = oldTr.doc.resolve(oldTr.mapping.map(oldSelection.$headCell.pos));
|
|
323
279
|
const cellSelection = new CellSelection($anchorCell, $headCell);
|
|
324
280
|
tr.setSelection(cellSelection);
|
|
325
|
-
|
|
326
281
|
if (tr.selection instanceof CellSelection) {
|
|
327
282
|
const rect = getSelectionRect(cellSelection);
|
|
328
|
-
|
|
329
283
|
if (rect) {
|
|
330
284
|
const {
|
|
331
285
|
verticalCells,
|
|
@@ -333,8 +287,9 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
|
|
|
333
287
|
totalCells,
|
|
334
288
|
totalRowCount,
|
|
335
289
|
totalColumnCount
|
|
336
|
-
} = getSelectedCellInfo(tr.selection);
|
|
290
|
+
} = getSelectedCellInfo(tr.selection);
|
|
337
291
|
|
|
292
|
+
// Reassigning to make it more obvious and consistent
|
|
338
293
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
339
294
|
action: TABLE_ACTION.CUT,
|
|
340
295
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -347,11 +302,11 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
|
|
|
347
302
|
totalColumnCount
|
|
348
303
|
},
|
|
349
304
|
eventType: EVENT_TYPE.TRACK
|
|
350
|
-
})(tr);
|
|
305
|
+
})(tr);
|
|
351
306
|
|
|
307
|
+
// Need this check again since we are overriding the tr in previous statement
|
|
352
308
|
if (tr.selection instanceof CellSelection) {
|
|
353
309
|
const isTableSelected = tr.selection.isRowSelection() && tr.selection.isColSelection();
|
|
354
|
-
|
|
355
310
|
if (isTableSelected) {
|
|
356
311
|
tr = removeTable(tr);
|
|
357
312
|
} else if (tr.selection.isRowSelection()) {
|
|
@@ -368,7 +323,6 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
|
|
|
368
323
|
}
|
|
369
324
|
}
|
|
370
325
|
}
|
|
371
|
-
|
|
372
326
|
return tr;
|
|
373
327
|
};
|
|
374
328
|
export const whenTableInFocus = (eventHandler, elementContentRects) => (view, mouseEvent) => {
|
|
@@ -376,10 +330,8 @@ export const whenTableInFocus = (eventHandler, elementContentRects) => (view, mo
|
|
|
376
330
|
const tablePluginState = getPluginState(view.state);
|
|
377
331
|
const isDragging = tableResizePluginState && !!tableResizePluginState.dragging;
|
|
378
332
|
const hasTableNode = tablePluginState && tablePluginState.tableNode;
|
|
379
|
-
|
|
380
333
|
if (!hasTableNode || isDragging) {
|
|
381
334
|
return false;
|
|
382
335
|
}
|
|
383
|
-
|
|
384
336
|
return eventHandler(view, mouseEvent, elementContentRects);
|
|
385
337
|
};
|