@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,68 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createPluginState = exports.createCommand = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
|
-
|
|
14
10
|
var _pluginKey = require("./plugin-key");
|
|
15
|
-
|
|
16
11
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
12
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
-
|
|
20
13
|
var reducer = function reducer(pluginState, action) {
|
|
21
14
|
if (action.name === 'UPDATE') {
|
|
22
15
|
var updated = false;
|
|
23
16
|
var updatedState = pluginState.map(function (oldTableState) {
|
|
24
17
|
var replace = oldTableState.pos === action.state.pos;
|
|
25
|
-
|
|
26
18
|
if (replace) {
|
|
27
19
|
updated = true;
|
|
28
20
|
}
|
|
29
|
-
|
|
30
21
|
return replace ? action.state : oldTableState;
|
|
31
22
|
});
|
|
32
|
-
|
|
33
23
|
if (!updated) {
|
|
34
24
|
// new, add it
|
|
35
25
|
updatedState.push(action.state);
|
|
36
26
|
}
|
|
37
|
-
|
|
38
27
|
return updatedState;
|
|
39
28
|
} else if (action.name === 'REMOVE') {
|
|
40
29
|
return pluginState.filter(function (rowState) {
|
|
41
30
|
return rowState.pos !== action.pos;
|
|
42
31
|
});
|
|
43
32
|
}
|
|
44
|
-
|
|
45
33
|
return pluginState;
|
|
46
34
|
};
|
|
47
|
-
|
|
48
35
|
var _pluginFactory = (0, _utils.pluginFactory)(_pluginKey.pluginKey, reducer, {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
36
|
+
mapping: function mapping(tr, pluginState) {
|
|
37
|
+
if (tr.docChanged) {
|
|
38
|
+
return pluginState.map(function (rowInfo) {
|
|
39
|
+
var remapped = tr.mapping.mapResult(rowInfo.pos);
|
|
40
|
+
return remapped ? _objectSpread(_objectSpread({}, rowInfo), {}, {
|
|
41
|
+
pos: remapped.pos
|
|
42
|
+
}) : undefined;
|
|
43
|
+
}).filter(function (f) {
|
|
44
|
+
return f !== undefined;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return pluginState;
|
|
59
48
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}),
|
|
64
|
-
createPluginState = _pluginFactory.createPluginState,
|
|
65
|
-
createCommand = _pluginFactory.createCommand;
|
|
66
|
-
|
|
49
|
+
}),
|
|
50
|
+
createPluginState = _pluginFactory.createPluginState,
|
|
51
|
+
createCommand = _pluginFactory.createCommand;
|
|
67
52
|
exports.createCommand = createCommand;
|
|
68
53
|
exports.createPluginState = createPluginState;
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createPlugin = void 0;
|
|
7
|
-
|
|
8
7
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
|
-
|
|
10
8
|
var _tableRow = require("./nodeviews/tableRow");
|
|
11
|
-
|
|
12
9
|
var _pluginKey = require("./plugin-key");
|
|
13
|
-
|
|
14
10
|
var _pluginState = require("./plugin-state");
|
|
15
|
-
|
|
16
11
|
var createPlugin = function createPlugin(dispatch, eventDispatcher) {
|
|
17
12
|
var initialState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
|
|
18
13
|
return [];
|
|
@@ -30,5 +25,4 @@ var createPlugin = function createPlugin(dispatch, eventDispatcher) {
|
|
|
30
25
|
}
|
|
31
26
|
});
|
|
32
27
|
};
|
|
33
|
-
|
|
34
28
|
exports.createPlugin = createPlugin;
|
|
@@ -4,22 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.findStickyHeaderForTable = void 0;
|
|
7
|
-
|
|
8
7
|
// only worry about the first row for now
|
|
9
8
|
var findStickyHeaderForTable = function findStickyHeaderForTable(state, tablePos) {
|
|
10
9
|
if (!state || tablePos === undefined) {
|
|
11
10
|
return undefined;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
var rowInfo = state.find(function (rowInfo) {
|
|
15
13
|
return rowInfo.pos === tablePos + 1;
|
|
16
14
|
});
|
|
17
|
-
|
|
18
15
|
if (!rowInfo) {
|
|
19
16
|
return undefined;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
return rowInfo.sticky ? rowInfo : undefined;
|
|
23
19
|
};
|
|
24
|
-
|
|
25
20
|
exports.findStickyHeaderForTable = findStickyHeaderForTable;
|
|
@@ -1,48 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
|
-
|
|
14
10
|
var _prosemirrorState = require("prosemirror-state");
|
|
15
|
-
|
|
16
11
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
17
|
-
|
|
18
12
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
19
|
-
|
|
20
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
21
|
-
|
|
22
14
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
-
|
|
24
15
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
-
|
|
26
16
|
var pluginKey = new _prosemirrorState.PluginKey('tableLocalIdPlugin');
|
|
27
|
-
|
|
28
17
|
var getPluginState = function getPluginState(state) {
|
|
29
18
|
return state && pluginKey.getState(state);
|
|
30
19
|
};
|
|
20
|
+
|
|
31
21
|
/**
|
|
32
22
|
* Traverses a transaction's steps to see if we're inserting any tables
|
|
33
23
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
24
|
var checkIsAddingTable = function checkIsAddingTable(transaction, nodeType) {
|
|
37
25
|
return transaction.steps.some(function (step) {
|
|
38
26
|
return (0, _utils.stepAddsOneOf)(step, new Set([nodeType]));
|
|
39
27
|
});
|
|
40
28
|
};
|
|
29
|
+
|
|
41
30
|
/**
|
|
42
31
|
* Ensures uniqueness of `localId`s on tables being created or edited
|
|
43
32
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
33
|
var createPlugin = function createPlugin(dispatch) {
|
|
47
34
|
return new _safePlugin.SafePlugin({
|
|
48
35
|
key: pluginKey,
|
|
@@ -54,21 +41,17 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
54
41
|
},
|
|
55
42
|
apply: function apply(tr, pluginState) {
|
|
56
43
|
var meta = tr.getMeta(pluginKey);
|
|
57
|
-
|
|
58
44
|
if (meta) {
|
|
59
45
|
var keys = Object.keys(meta);
|
|
60
46
|
var changed = keys.some(function (key) {
|
|
61
47
|
return pluginState[key] !== meta[key];
|
|
62
48
|
});
|
|
63
|
-
|
|
64
49
|
if (changed) {
|
|
65
50
|
var newState = _objectSpread(_objectSpread({}, pluginState), meta);
|
|
66
|
-
|
|
67
51
|
dispatch(pluginKey, newState);
|
|
68
52
|
return newState;
|
|
69
53
|
}
|
|
70
54
|
}
|
|
71
|
-
|
|
72
55
|
return pluginState;
|
|
73
56
|
}
|
|
74
57
|
},
|
|
@@ -94,17 +77,13 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
94
77
|
update: function update(editorView) {
|
|
95
78
|
var state = editorView.state;
|
|
96
79
|
var pluginState = getPluginState(state);
|
|
97
|
-
|
|
98
80
|
if (!pluginState) {
|
|
99
81
|
return;
|
|
100
82
|
}
|
|
101
|
-
|
|
102
83
|
var parsed = pluginState.parsedForLocalIds;
|
|
103
|
-
|
|
104
84
|
if (parsed) {
|
|
105
85
|
return;
|
|
106
86
|
}
|
|
107
|
-
|
|
108
87
|
var table = state.schema.nodes.table;
|
|
109
88
|
(0, _rafSchd.default)(function () {
|
|
110
89
|
var tr = state.tr;
|
|
@@ -112,7 +91,6 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
112
91
|
editorView.state.doc.descendants(function (node, pos) {
|
|
113
92
|
var isTable = node.type === table;
|
|
114
93
|
var localId = node.attrs.localId;
|
|
115
|
-
|
|
116
94
|
if (isTable && !localId) {
|
|
117
95
|
tableIdWasAdded = true;
|
|
118
96
|
tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
@@ -124,11 +102,8 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
124
102
|
* Otherwise continue traversing, we can encounter tables nested in
|
|
125
103
|
* expands/bodiedExtensions
|
|
126
104
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
105
|
return true;
|
|
130
106
|
});
|
|
131
|
-
|
|
132
107
|
if (tableIdWasAdded) {
|
|
133
108
|
tr.setMeta('addToHistory', false);
|
|
134
109
|
editorView.dispatch(tr);
|
|
@@ -148,58 +123,52 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
148
123
|
transactions.forEach(function (transaction) {
|
|
149
124
|
if (!transaction.docChanged) {
|
|
150
125
|
return;
|
|
151
|
-
}
|
|
152
|
-
// to handle any extra cut cases in this plugin
|
|
153
|
-
|
|
126
|
+
}
|
|
154
127
|
|
|
128
|
+
// Don't interfere with cut as it clashes with fixTables & we don't need
|
|
129
|
+
// to handle any extra cut cases in this plugin
|
|
155
130
|
var uiEvent = transaction.getMeta('uiEvent');
|
|
156
|
-
|
|
157
131
|
if (uiEvent === 'cut') {
|
|
158
132
|
return;
|
|
159
133
|
}
|
|
160
|
-
/** Check if we're actually inserting a table, otherwise we can ignore this tr */
|
|
161
|
-
|
|
162
134
|
|
|
135
|
+
/** Check if we're actually inserting a table, otherwise we can ignore this tr */
|
|
163
136
|
var isAddingTable = checkIsAddingTable(transaction, table);
|
|
164
|
-
|
|
165
137
|
if (!isAddingTable) {
|
|
166
138
|
return;
|
|
167
|
-
}
|
|
168
|
-
|
|
139
|
+
}
|
|
169
140
|
|
|
141
|
+
// Can't simply look at changed nodes, as we could be adding a table
|
|
170
142
|
newState.doc.descendants(function (node, pos) {
|
|
171
143
|
var isTable = node.type === table;
|
|
172
|
-
var localId = node.attrs.localId;
|
|
144
|
+
var localId = node.attrs.localId;
|
|
173
145
|
|
|
146
|
+
// Dealing with a table - make sure it's a unique ID
|
|
174
147
|
if (isTable) {
|
|
175
148
|
if (localId && !idsObserved.has(localId)) {
|
|
176
|
-
idsObserved.add(localId);
|
|
149
|
+
idsObserved.add(localId);
|
|
150
|
+
// Also add a localId if it happens to not have one,
|
|
177
151
|
} else if (!localId || idsObserved.has(localId)) {
|
|
178
152
|
modified = true;
|
|
179
153
|
tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
180
154
|
localId: _adfSchema.uuid.generate()
|
|
181
155
|
}));
|
|
182
156
|
}
|
|
183
|
-
|
|
184
157
|
return false;
|
|
185
158
|
}
|
|
159
|
+
|
|
186
160
|
/**
|
|
187
161
|
* Otherwise continue traversing, we can encounter tables nested in
|
|
188
162
|
* expands/bodiedExtensions
|
|
189
163
|
*/
|
|
190
|
-
|
|
191
|
-
|
|
192
164
|
return true;
|
|
193
165
|
});
|
|
194
166
|
});
|
|
195
|
-
|
|
196
167
|
if (modified) {
|
|
197
168
|
return tr;
|
|
198
169
|
}
|
|
199
|
-
|
|
200
170
|
return;
|
|
201
171
|
}
|
|
202
172
|
});
|
|
203
173
|
};
|
|
204
|
-
|
|
205
174
|
exports.createPlugin = createPlugin;
|
|
@@ -4,81 +4,65 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.stopResizing = exports.setResizeHandlePos = exports.setLastClick = exports.setDragging = exports.scaleTable = exports.evenColumns = exports.distributeColumnsWidths = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
9
|
-
|
|
10
8
|
var _transforms = require("../../transforms");
|
|
11
|
-
|
|
12
9
|
var _pluginFactory = require("./plugin-factory");
|
|
13
|
-
|
|
14
10
|
var _utils2 = require("./utils");
|
|
15
|
-
|
|
16
11
|
// Scale the table to meet new requirements (col, layout change etc)
|
|
17
12
|
var scaleTable = function scaleTable(tableRef, options, domAtPos) {
|
|
18
13
|
return function (state, dispatch) {
|
|
19
14
|
if (!tableRef) {
|
|
20
15
|
return false;
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
var node = options.node,
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
start = options.start,
|
|
19
|
+
parentWidth = options.parentWidth;
|
|
26
20
|
|
|
21
|
+
// If a table has not been resized yet, columns should be auto.
|
|
27
22
|
if ((0, _utils2.hasTableBeenResized)(node) === false) {
|
|
28
23
|
// If its not a re-sized table, we still want to re-create cols
|
|
29
24
|
// To force reflow of columns upon delete.
|
|
30
25
|
(0, _utils2.insertColgroupFromNode)(tableRef, node);
|
|
31
26
|
return false;
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
var resizeState;
|
|
35
|
-
|
|
36
29
|
if (parentWidth) {
|
|
37
30
|
resizeState = (0, _utils2.scaleWithParent)(tableRef, parentWidth, node, start, domAtPos);
|
|
38
31
|
} else {
|
|
39
32
|
resizeState = (0, _utils2.scale)(tableRef, options, domAtPos);
|
|
40
33
|
}
|
|
41
|
-
|
|
42
34
|
if (resizeState) {
|
|
43
35
|
var _tr = state.tr;
|
|
44
36
|
_tr = (0, _transforms.updateColumnWidths)(resizeState, node, start)(_tr);
|
|
45
|
-
|
|
46
37
|
if (_tr.docChanged && dispatch) {
|
|
47
|
-
_tr.setMeta('scrollIntoView', false);
|
|
38
|
+
_tr.setMeta('scrollIntoView', false);
|
|
39
|
+
// TODO: ED-8995
|
|
48
40
|
// We need to do this check to reduce the number of race conditions when working with tables.
|
|
49
41
|
// This metadata is been used in the sendTransaction function in the Collab plugin
|
|
50
|
-
|
|
51
|
-
|
|
52
42
|
_tr.setMeta('scaleTable', true);
|
|
53
|
-
|
|
54
43
|
dispatch(_tr);
|
|
55
44
|
return true;
|
|
56
45
|
}
|
|
57
46
|
}
|
|
58
|
-
|
|
59
47
|
return false;
|
|
60
48
|
};
|
|
61
49
|
};
|
|
62
|
-
|
|
63
50
|
exports.scaleTable = scaleTable;
|
|
64
|
-
|
|
65
51
|
var evenColumns = function evenColumns(_ref) {
|
|
66
52
|
var resizeState = _ref.resizeState,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
53
|
+
table = _ref.table,
|
|
54
|
+
start = _ref.start,
|
|
55
|
+
event = _ref.event;
|
|
70
56
|
return function (state, dispatch) {
|
|
71
57
|
if (!(0, _utils.isTableSelected)(state.selection)) {
|
|
72
58
|
return false;
|
|
73
|
-
}
|
|
74
|
-
// Note: ProseMirror's handleDoubleClick doesn't quite work with DOM mousedown event handler
|
|
75
|
-
|
|
59
|
+
}
|
|
76
60
|
|
|
61
|
+
// double click detection logic
|
|
62
|
+
// Note: ProseMirror's handleDoubleClick doesn't quite work with DOM mousedown event handler
|
|
77
63
|
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
lastClick = _getPluginState.lastClick;
|
|
80
65
|
var now = Date.now();
|
|
81
|
-
|
|
82
66
|
if (lastClick && now - lastClick.time < 500 && (0, _utils2.isClickNear)(event, lastClick)) {
|
|
83
67
|
var newState = (0, _utils2.evenAllColumnsWidths)(resizeState);
|
|
84
68
|
setLastClick(null, function (tr) {
|
|
@@ -86,7 +70,6 @@ var evenColumns = function evenColumns(_ref) {
|
|
|
86
70
|
})(state, dispatch);
|
|
87
71
|
return true;
|
|
88
72
|
}
|
|
89
|
-
|
|
90
73
|
setLastClick({
|
|
91
74
|
x: event.clientX,
|
|
92
75
|
y: event.clientY,
|
|
@@ -95,23 +78,17 @@ var evenColumns = function evenColumns(_ref) {
|
|
|
95
78
|
return false;
|
|
96
79
|
};
|
|
97
80
|
};
|
|
98
|
-
|
|
99
81
|
exports.evenColumns = evenColumns;
|
|
100
|
-
|
|
101
82
|
var distributeColumnsWidths = function distributeColumnsWidths(newResizeState, table) {
|
|
102
83
|
return function (state, dispatch) {
|
|
103
84
|
if (dispatch) {
|
|
104
85
|
var _tr2 = (0, _transforms.updateColumnWidths)(newResizeState, table.node, table.start)(state.tr);
|
|
105
|
-
|
|
106
86
|
stopResizing(_tr2)(state, dispatch);
|
|
107
87
|
}
|
|
108
|
-
|
|
109
88
|
return true;
|
|
110
89
|
};
|
|
111
90
|
};
|
|
112
|
-
|
|
113
91
|
exports.distributeColumnsWidths = distributeColumnsWidths;
|
|
114
|
-
|
|
115
92
|
var setResizeHandlePos = function setResizeHandlePos(resizeHandlePos) {
|
|
116
93
|
return (0, _pluginFactory.createCommand)({
|
|
117
94
|
type: 'SET_RESIZE_HANDLE_POSITION',
|
|
@@ -120,9 +97,7 @@ var setResizeHandlePos = function setResizeHandlePos(resizeHandlePos) {
|
|
|
120
97
|
}
|
|
121
98
|
});
|
|
122
99
|
};
|
|
123
|
-
|
|
124
100
|
exports.setResizeHandlePos = setResizeHandlePos;
|
|
125
|
-
|
|
126
101
|
var stopResizing = function stopResizing(tr) {
|
|
127
102
|
return (0, _pluginFactory.createCommand)({
|
|
128
103
|
type: 'STOP_RESIZING'
|
|
@@ -130,9 +105,7 @@ var stopResizing = function stopResizing(tr) {
|
|
|
130
105
|
return (tr || originalTr).setMeta('scrollIntoView', false);
|
|
131
106
|
});
|
|
132
107
|
};
|
|
133
|
-
|
|
134
108
|
exports.stopResizing = stopResizing;
|
|
135
|
-
|
|
136
109
|
var setDragging = function setDragging(dragging, tr) {
|
|
137
110
|
return (0, _pluginFactory.createCommand)({
|
|
138
111
|
type: 'SET_DRAGGING',
|
|
@@ -143,9 +116,7 @@ var setDragging = function setDragging(dragging, tr) {
|
|
|
143
116
|
return tr || originalTr;
|
|
144
117
|
});
|
|
145
118
|
};
|
|
146
|
-
|
|
147
119
|
exports.setDragging = setDragging;
|
|
148
|
-
|
|
149
120
|
var setLastClick = function setLastClick(lastClick, transform) {
|
|
150
121
|
return (0, _pluginFactory.createCommand)({
|
|
151
122
|
type: 'SET_LAST_CLICK',
|
|
@@ -154,5 +125,4 @@ var setLastClick = function setLastClick(lastClick, transform) {
|
|
|
154
125
|
}
|
|
155
126
|
}, transform);
|
|
156
127
|
};
|
|
157
|
-
|
|
158
128
|
exports.setLastClick = setLastClick;
|
|
@@ -4,39 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.handleMouseDown = void 0;
|
|
7
|
-
|
|
8
7
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
9
|
-
|
|
10
8
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
11
|
-
|
|
12
9
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
13
|
-
|
|
14
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
|
-
|
|
16
11
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
17
|
-
|
|
18
12
|
var _transforms = require("../../transforms");
|
|
19
|
-
|
|
20
13
|
var _utils2 = require("../../utils");
|
|
21
|
-
|
|
22
14
|
var _commands = require("./commands");
|
|
23
|
-
|
|
24
15
|
var _pluginFactory = require("./plugin-factory");
|
|
25
|
-
|
|
26
16
|
var _utils3 = require("./utils");
|
|
27
|
-
|
|
28
17
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
29
|
-
|
|
30
18
|
var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) {
|
|
31
19
|
var state = view.state,
|
|
32
|
-
|
|
20
|
+
dispatch = view.dispatch;
|
|
33
21
|
var editorDisabled = !view.editable;
|
|
34
22
|
var domAtPos = view.domAtPos.bind(view);
|
|
35
|
-
|
|
36
23
|
if (editorDisabled || localResizeHandlePos === null || !(0, _utils3.pointsAtCell)(state.doc.resolve(localResizeHandlePos))) {
|
|
37
24
|
return false;
|
|
38
25
|
}
|
|
39
|
-
|
|
40
26
|
event.preventDefault();
|
|
41
27
|
var mouseDownTime = event.timeStamp;
|
|
42
28
|
var cell = state.doc.nodeAt(localResizeHandlePos);
|
|
@@ -44,19 +30,15 @@ var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos
|
|
|
44
30
|
var originalTable = $cell.node(-1);
|
|
45
31
|
var start = $cell.start(-1);
|
|
46
32
|
var dom = domAtPos(start).node;
|
|
47
|
-
|
|
48
33
|
if (dom && dom.nodeName !== 'TABLE') {
|
|
49
34
|
dom = dom.closest('table');
|
|
50
35
|
}
|
|
51
|
-
|
|
52
36
|
var containerWidth = getEditorContainerWidth();
|
|
53
37
|
var parentWidth = (0, _nodeWidth.getParentNodeWidth)(start, state, containerWidth);
|
|
54
38
|
var maxSize = parentWidth || (0, _utils3.getLayoutSize)(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
55
|
-
|
|
56
39
|
if (originalTable.attrs.isNumberColumnEnabled) {
|
|
57
40
|
maxSize -= _editorSharedStyles.akEditorTableNumberColumnWidth;
|
|
58
41
|
}
|
|
59
|
-
|
|
60
42
|
var resizeState = (0, _utils3.getResizeState)({
|
|
61
43
|
minWidth: _styles.tableCellMinWidth,
|
|
62
44
|
maxSize: maxSize,
|
|
@@ -65,7 +47,6 @@ var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos
|
|
|
65
47
|
start: start,
|
|
66
48
|
domAtPos: domAtPos
|
|
67
49
|
});
|
|
68
|
-
|
|
69
50
|
if ((0, _commands.evenColumns)({
|
|
70
51
|
resizeState: resizeState,
|
|
71
52
|
table: originalTable,
|
|
@@ -75,60 +56,52 @@ var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos
|
|
|
75
56
|
finish(event);
|
|
76
57
|
return true;
|
|
77
58
|
}
|
|
78
|
-
|
|
79
59
|
var width = (0, _utils3.currentColWidth)(view, localResizeHandlePos, cell.attrs);
|
|
80
60
|
(0, _commands.setDragging)({
|
|
81
61
|
startX: event.clientX,
|
|
82
62
|
startWidth: width
|
|
83
63
|
})(state, dispatch);
|
|
84
|
-
|
|
85
64
|
function finish(event) {
|
|
86
65
|
window.removeEventListener('mouseup', finish);
|
|
87
66
|
window.removeEventListener('mousemove', move);
|
|
88
67
|
var clientX = event.clientX;
|
|
89
68
|
var state = view.state,
|
|
90
|
-
|
|
91
|
-
|
|
69
|
+
dispatch = view.dispatch;
|
|
92
70
|
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
71
|
+
dragging = _getPluginState.dragging,
|
|
72
|
+
resizeHandlePos = _getPluginState.resizeHandlePos;
|
|
96
73
|
if (resizeHandlePos === null) {
|
|
97
74
|
return (0, _commands.stopResizing)()(state, dispatch);
|
|
98
75
|
}
|
|
99
|
-
|
|
100
76
|
if (!(0, _utils3.pointsAtCell)(state.doc.resolve(resizeHandlePos))) {
|
|
101
77
|
return;
|
|
102
|
-
}
|
|
78
|
+
}
|
|
79
|
+
// resizeHandlePos could be remapped via a collab change.
|
|
103
80
|
// Fetch a fresh reference of the table.
|
|
104
|
-
|
|
105
|
-
|
|
106
81
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
107
82
|
var start = $cell.start(-1);
|
|
108
|
-
var table = $cell.node(-1);
|
|
83
|
+
var table = $cell.node(-1);
|
|
109
84
|
|
|
85
|
+
// If we let go in the same place we started, dont need to do anything.
|
|
110
86
|
if (dragging && clientX === dragging.startX) {
|
|
111
87
|
return (0, _commands.stopResizing)()(state, dispatch);
|
|
112
88
|
}
|
|
113
|
-
|
|
114
89
|
var tr = state.tr;
|
|
115
|
-
|
|
116
90
|
if (dragging) {
|
|
117
|
-
var startX = dragging.startX;
|
|
91
|
+
var startX = dragging.startX;
|
|
92
|
+
|
|
93
|
+
// If the table has changed (via collab for example) don't apply column widths
|
|
118
94
|
// For example, if a table col is deleted we won't be able to reliably remap the new widths
|
|
119
95
|
// There may be a more elegant solution to this, to avoid a jarring experience.
|
|
120
|
-
|
|
121
96
|
if (table.eq(originalTable)) {
|
|
122
97
|
var map = _tableMap.TableMap.get(table);
|
|
123
|
-
|
|
124
98
|
var colIndex = map.colCount($cell.pos - start) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
|
|
125
99
|
var selectionRect = (0, _utils.getSelectionRect)(state.selection);
|
|
126
|
-
var selectedColumns = selectionRect ? (0, _utils2.getSelectedColumnIndexes)(selectionRect) : [];
|
|
127
|
-
|
|
100
|
+
var selectedColumns = selectionRect ? (0, _utils2.getSelectedColumnIndexes)(selectionRect) : [];
|
|
101
|
+
// only selected (or selected - 1) columns should be distributed
|
|
128
102
|
var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
129
103
|
var newResizeState = (0, _utils3.resizeColumn)(resizeState, colIndex, clientX - startX, dom, resizingSelectedColumns ? selectedColumns : undefined);
|
|
130
104
|
tr = (0, _transforms.updateColumnWidths)(newResizeState, table, start)(tr);
|
|
131
|
-
|
|
132
105
|
if (colIndex === map.width - 1) {
|
|
133
106
|
var mouseUpTime = event.timeStamp;
|
|
134
107
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
@@ -145,38 +118,29 @@ var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos
|
|
|
145
118
|
})(tr);
|
|
146
119
|
}
|
|
147
120
|
}
|
|
148
|
-
|
|
149
121
|
return (0, _commands.stopResizing)(tr)(state, dispatch);
|
|
150
122
|
}
|
|
151
123
|
}
|
|
152
|
-
|
|
153
124
|
function move(event) {
|
|
154
125
|
var clientX = event.clientX,
|
|
155
|
-
|
|
126
|
+
which = event.which;
|
|
156
127
|
var state = view.state;
|
|
157
|
-
|
|
158
128
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
129
|
+
dragging = _getPluginState2.dragging,
|
|
130
|
+
resizeHandlePos = _getPluginState2.resizeHandlePos;
|
|
162
131
|
if (!which || !dragging || resizeHandlePos === null || !(0, _utils3.pointsAtCell)(state.doc.resolve(resizeHandlePos))) {
|
|
163
132
|
return finish(event);
|
|
164
133
|
}
|
|
165
|
-
|
|
166
134
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
167
135
|
var table = $cell.node(-1);
|
|
168
|
-
|
|
169
136
|
var map = _tableMap.TableMap.get(table);
|
|
170
|
-
|
|
171
137
|
var colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
|
|
172
138
|
(0, _utils3.resizeColumn)(resizeState, colIndex, clientX - dragging.startX, dom);
|
|
173
139
|
(0, _utils3.updateControls)(getEditorFeatureFlags)(state);
|
|
174
140
|
(0, _utils2.updateResizeHandles)(dom);
|
|
175
141
|
}
|
|
176
|
-
|
|
177
142
|
window.addEventListener('mouseup', finish);
|
|
178
143
|
window.addEventListener('mousemove', move);
|
|
179
144
|
return true;
|
|
180
145
|
};
|
|
181
|
-
|
|
182
146
|
exports.handleMouseDown = handleMouseDown;
|
|
@@ -27,11 +27,7 @@ Object.defineProperty(exports, "scaleTable", {
|
|
|
27
27
|
return _commands.scaleTable;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
|
|
31
30
|
var _plugin = require("./plugin");
|
|
32
|
-
|
|
33
31
|
var _commands = require("./commands");
|
|
34
|
-
|
|
35
32
|
var _pluginKey = require("./plugin-key");
|
|
36
|
-
|
|
37
33
|
var _pluginFactory = require("./plugin-factory");
|