@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,34 +1,24 @@
|
|
|
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.getPluginState = 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
|
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
17
|
-
|
|
18
12
|
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; }
|
|
19
|
-
|
|
20
13
|
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; }
|
|
21
|
-
|
|
22
14
|
function mapping(tr, pluginState) {
|
|
23
15
|
if (pluginState && pluginState.resizeHandlePos !== null) {
|
|
24
16
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
25
17
|
resizeHandlePos: tr.mapping.map(pluginState.resizeHandlePos)
|
|
26
18
|
});
|
|
27
19
|
}
|
|
28
|
-
|
|
29
20
|
return pluginState;
|
|
30
21
|
}
|
|
31
|
-
|
|
32
22
|
var factory = (0, _utils.pluginFactory)(_pluginKey.pluginKey, _reducer.default, {
|
|
33
23
|
mapping: mapping
|
|
34
24
|
});
|
|
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.pluginKey = void 0;
|
|
7
|
-
|
|
8
7
|
var _prosemirrorState = require("prosemirror-state");
|
|
9
|
-
|
|
10
8
|
var pluginKey = new _prosemirrorState.PluginKey('tableFlexiColumnResizing');
|
|
11
9
|
exports.pluginKey = pluginKey;
|
|
@@ -1,33 +1,22 @@
|
|
|
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 = createPlugin;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
15
|
-
|
|
16
11
|
var _types = require("../../types");
|
|
17
|
-
|
|
18
12
|
var _commands = require("./commands");
|
|
19
|
-
|
|
20
13
|
var _eventHandlers = require("./event-handlers");
|
|
21
|
-
|
|
22
14
|
var _pluginFactory = require("./plugin-factory");
|
|
23
|
-
|
|
24
15
|
var _pluginKey = require("./plugin-key");
|
|
25
|
-
|
|
26
16
|
var _utils = require("./utils");
|
|
27
|
-
|
|
28
17
|
function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) {
|
|
29
18
|
var _ref$lastColumnResiza = _ref.lastColumnResizable,
|
|
30
|
-
|
|
19
|
+
lastColumnResizable = _ref$lastColumnResiza === void 0 ? true : _ref$lastColumnResiza;
|
|
31
20
|
return new _safePlugin.SafePlugin({
|
|
32
21
|
key: _pluginKey.pluginKey,
|
|
33
22
|
state: (0, _pluginFactory.createPluginState)(dispatch, {
|
|
@@ -39,7 +28,6 @@ function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureF
|
|
|
39
28
|
props: {
|
|
40
29
|
attributes: function attributes(state) {
|
|
41
30
|
var _classnames;
|
|
42
|
-
|
|
43
31
|
var pluginState = (0, _pluginFactory.getPluginState)(state);
|
|
44
32
|
return {
|
|
45
33
|
class: (0, _classnames2.default)(_types.TableCssClassName.RESIZING_PLUGIN, (_classnames = {}, (0, _defineProperty2.default)(_classnames, _types.TableCssClassName.RESIZE_CURSOR, pluginState.resizeHandlePos !== null), (0, _defineProperty2.default)(_classnames, _types.TableCssClassName.IS_RESIZING, !!pluginState.dragging), _classnames))
|
|
@@ -48,20 +36,18 @@ function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureF
|
|
|
48
36
|
handleDOMEvents: {
|
|
49
37
|
mousedown: function mousedown(view, event) {
|
|
50
38
|
var state = view.state;
|
|
51
|
-
var resizeHandlePos =
|
|
39
|
+
var resizeHandlePos =
|
|
40
|
+
// we're setting `resizeHandlePos` via command in unit tests
|
|
52
41
|
(0, _pluginFactory.getPluginState)(state).resizeHandlePos || (0, _utils.getResizeCellPos)(view, event, lastColumnResizable);
|
|
53
|
-
|
|
54
42
|
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
dragging = _getPluginState.dragging;
|
|
57
44
|
if (resizeHandlePos !== null && !dragging) {
|
|
58
45
|
if ((0, _eventHandlers.handleMouseDown)(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI)) {
|
|
59
46
|
var _state = view.state,
|
|
60
|
-
|
|
47
|
+
_dispatch = view.dispatch;
|
|
61
48
|
return (0, _commands.setResizeHandlePos)(resizeHandlePos)(_state, _dispatch);
|
|
62
49
|
}
|
|
63
50
|
}
|
|
64
|
-
|
|
65
51
|
return false;
|
|
66
52
|
}
|
|
67
53
|
}
|
|
@@ -1,18 +1,13 @@
|
|
|
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.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
10
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (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; }
|
|
15
|
-
|
|
16
11
|
var _default = function _default(pluginState, action) {
|
|
17
12
|
switch (action.type) {
|
|
18
13
|
case 'STOP_RESIZING':
|
|
@@ -20,27 +15,22 @@ var _default = function _default(pluginState, action) {
|
|
|
20
15
|
resizeHandlePos: null,
|
|
21
16
|
dragging: null
|
|
22
17
|
});
|
|
23
|
-
|
|
24
18
|
case 'SET_RESIZE_HANDLE_POSITION':
|
|
25
19
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
26
20
|
resizeHandlePos: action.data.resizeHandlePos
|
|
27
21
|
});
|
|
28
|
-
|
|
29
22
|
case 'SET_DRAGGING':
|
|
30
23
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
31
24
|
dragging: action.data.dragging
|
|
32
25
|
});
|
|
33
|
-
|
|
34
26
|
case 'SET_LAST_CLICK':
|
|
35
27
|
var lastClick = action.data.lastClick;
|
|
36
28
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
37
29
|
lastClick: lastClick,
|
|
38
30
|
resizeHandlePos: lastClick ? pluginState.resizeHandlePos : null
|
|
39
31
|
});
|
|
40
|
-
|
|
41
32
|
default:
|
|
42
33
|
return pluginState;
|
|
43
34
|
}
|
|
44
35
|
};
|
|
45
|
-
|
|
46
36
|
exports.default = _default;
|
|
@@ -1,23 +1,17 @@
|
|
|
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.insertColgroupFromNode = exports.hasTableBeenResized = exports.generateColgroup = void 0;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
var _prosemirrorModel = require("prosemirror-model");
|
|
13
|
-
|
|
14
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
|
-
|
|
16
11
|
var generateColgroup = function generateColgroup(table) {
|
|
17
12
|
var cols = [];
|
|
18
13
|
table.content.firstChild.content.forEach(function (cell) {
|
|
19
14
|
var colspan = cell.attrs.colspan || 1;
|
|
20
|
-
|
|
21
15
|
if (Array.isArray(cell.attrs.colwidth)) {
|
|
22
16
|
// We slice here to guard against our colwidth array having more entries
|
|
23
17
|
// Than the we actually span. We'll patch the document at a later point.
|
|
@@ -39,33 +33,24 @@ var generateColgroup = function generateColgroup(table) {
|
|
|
39
33
|
});
|
|
40
34
|
return cols;
|
|
41
35
|
};
|
|
42
|
-
|
|
43
36
|
exports.generateColgroup = generateColgroup;
|
|
44
|
-
|
|
45
37
|
var insertColgroupFromNode = function insertColgroupFromNode(tableRef, table) {
|
|
46
38
|
var colgroup = tableRef.querySelector('colgroup');
|
|
47
|
-
|
|
48
39
|
if (colgroup) {
|
|
49
40
|
tableRef.removeChild(colgroup);
|
|
50
41
|
}
|
|
51
|
-
|
|
52
42
|
colgroup = renderColgroupFromNode(table);
|
|
53
43
|
tableRef.insertBefore(colgroup, tableRef.firstChild);
|
|
54
44
|
return colgroup.children;
|
|
55
45
|
};
|
|
56
|
-
|
|
57
46
|
exports.insertColgroupFromNode = insertColgroupFromNode;
|
|
58
|
-
|
|
59
47
|
var hasTableBeenResized = function hasTableBeenResized(table) {
|
|
60
48
|
return !!(0, _utils.getFragmentBackingArray)(table.content.firstChild.content).find(function (cell) {
|
|
61
49
|
return cell.attrs.colwidth;
|
|
62
50
|
});
|
|
63
51
|
};
|
|
64
|
-
|
|
65
52
|
exports.hasTableBeenResized = hasTableBeenResized;
|
|
66
|
-
|
|
67
53
|
function renderColgroupFromNode(table) {
|
|
68
54
|
var rendered = _prosemirrorModel.DOMSerializer.renderSpec(document, ['colgroup', {}].concat((0, _toConsumableArray2.default)(generateColgroup(table))));
|
|
69
|
-
|
|
70
55
|
return rendered.dom;
|
|
71
56
|
}
|
|
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getFreeSpace = exports.getColumnStateFromDOM = exports.getCellsRefsInColumn = exports.calculateColumnWidth = exports.addContainerLeftRightPadding = void 0;
|
|
7
|
-
|
|
8
7
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
9
|
-
|
|
10
8
|
var _prosemirrorUtils = require("prosemirror-utils");
|
|
11
|
-
|
|
12
9
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
13
|
-
|
|
14
10
|
var _contentWidth2 = require("./content-width");
|
|
15
|
-
|
|
16
11
|
var _unitToNumber = require("./unit-to-number");
|
|
17
|
-
|
|
18
12
|
// Reads `width` and `minWidth` of each column from DOM and returns `ColumnState` containing those values
|
|
19
13
|
var getColumnStateFromDOM = function getColumnStateFromDOM(cells, index, minWidth) {
|
|
20
14
|
var width = calculateColumnWidth(cells, calculateColumnWidthCallback);
|
|
21
|
-
var minColumnWidth = width < minWidth ?
|
|
15
|
+
var minColumnWidth = width < minWidth ?
|
|
16
|
+
// for newly created column (where width < minWidth) we set minWidth = tableNewColumnMinWidth (140px atm)
|
|
22
17
|
_styles.tableNewColumnMinWidth : calculateColumnWidth(cells, calculateColumnMinWidthCallback(minWidth));
|
|
23
18
|
return {
|
|
24
19
|
index: index,
|
|
@@ -26,19 +21,15 @@ var getColumnStateFromDOM = function getColumnStateFromDOM(cells, index, minWidt
|
|
|
26
21
|
minWidth: minColumnWidth
|
|
27
22
|
};
|
|
28
23
|
};
|
|
29
|
-
|
|
30
24
|
exports.getColumnStateFromDOM = getColumnStateFromDOM;
|
|
31
|
-
|
|
32
25
|
var getFreeSpace = function getFreeSpace(state) {
|
|
33
26
|
return Math.max(state.width - state.minWidth, 0);
|
|
34
|
-
};
|
|
35
|
-
|
|
27
|
+
};
|
|
36
28
|
|
|
29
|
+
// Returns DOM refs of all cells in a column by `columnIndex`
|
|
37
30
|
exports.getFreeSpace = getFreeSpace;
|
|
38
|
-
|
|
39
31
|
var getCellsRefsInColumn = function getCellsRefsInColumn(columnIndex, table, tableStart, domAtPos) {
|
|
40
32
|
var map = _tableMap.TableMap.get(table);
|
|
41
|
-
|
|
42
33
|
var cellsPositions = map.cellsInRect({
|
|
43
34
|
left: columnIndex,
|
|
44
35
|
right: columnIndex + 1,
|
|
@@ -48,29 +39,25 @@ var getCellsRefsInColumn = function getCellsRefsInColumn(columnIndex, table, tab
|
|
|
48
39
|
var cells = [];
|
|
49
40
|
cellsPositions.forEach(function (pos) {
|
|
50
41
|
var col = (0, _prosemirrorUtils.findDomRefAtPos)(pos + tableStart, domAtPos);
|
|
51
|
-
|
|
52
42
|
if (col) {
|
|
53
43
|
cells.push(col);
|
|
54
44
|
}
|
|
55
45
|
});
|
|
56
46
|
return cells;
|
|
57
|
-
};
|
|
58
|
-
|
|
47
|
+
};
|
|
59
48
|
|
|
49
|
+
// calculates column widths based on `cells` DOM refs
|
|
60
50
|
exports.getCellsRefsInColumn = getCellsRefsInColumn;
|
|
61
|
-
|
|
62
51
|
var calculateColumnWidth = function calculateColumnWidth(cells, calculateColumnWidthCb) {
|
|
63
52
|
var maxColWidth = 0;
|
|
64
53
|
var colSpanWidth = 0;
|
|
65
54
|
cells.forEach(function (cellRef) {
|
|
66
55
|
var css = getComputedStyle(cellRef);
|
|
67
56
|
var colspan = Number(cellRef.getAttribute('colspan') || 1);
|
|
68
|
-
|
|
69
57
|
if (colspan > 1) {
|
|
70
58
|
colSpanWidth = calculateColumnWidthCb(css, cellRef, colspan);
|
|
71
59
|
return;
|
|
72
60
|
}
|
|
73
|
-
|
|
74
61
|
if (css) {
|
|
75
62
|
var colWidth = calculateColumnWidthCb(css, cellRef, colspan);
|
|
76
63
|
maxColWidth = Math.max(colWidth, maxColWidth);
|
|
@@ -78,30 +65,23 @@ var calculateColumnWidth = function calculateColumnWidth(cells, calculateColumnW
|
|
|
78
65
|
});
|
|
79
66
|
return maxColWidth || colSpanWidth;
|
|
80
67
|
};
|
|
81
|
-
|
|
82
68
|
exports.calculateColumnWidth = calculateColumnWidth;
|
|
83
|
-
|
|
84
69
|
var addContainerLeftRightPadding = function addContainerLeftRightPadding(amount, css) {
|
|
85
70
|
return amount + (0, _unitToNumber.unitToNumber)(css.paddingLeft) + (0, _unitToNumber.unitToNumber)(css.paddingRight);
|
|
86
71
|
};
|
|
87
|
-
|
|
88
72
|
exports.addContainerLeftRightPadding = addContainerLeftRightPadding;
|
|
89
|
-
|
|
90
73
|
function calculateColumnWidthCallback(css) {
|
|
91
74
|
return (0, _unitToNumber.unitToNumber)(css.width);
|
|
92
75
|
}
|
|
93
|
-
|
|
94
76
|
function calculateColumnMinWidthCallback(minColumnWidth) {
|
|
95
77
|
return function (css, cellRef, colSpan) {
|
|
96
78
|
if (colSpan && colSpan > 1) {
|
|
97
79
|
return (0, _unitToNumber.unitToNumber)(css.width);
|
|
98
80
|
}
|
|
99
|
-
|
|
100
81
|
var _contentWidth = (0, _contentWidth2.contentWidth)(cellRef, cellRef),
|
|
101
|
-
|
|
82
|
+
minContentWidth = _contentWidth.minWidth;
|
|
83
|
+
// Override the min width, if there is content that can't collapse
|
|
102
84
|
// Past a certain width.
|
|
103
|
-
|
|
104
|
-
|
|
105
85
|
return Math.max(addContainerLeftRightPadding(minContentWidth, css), minContentWidth, minColumnWidth);
|
|
106
86
|
};
|
|
107
87
|
}
|
|
@@ -4,42 +4,35 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.contentWidth = contentWidth;
|
|
7
|
-
|
|
8
7
|
var _unitToNumber = require("./unit-to-number");
|
|
9
|
-
|
|
10
8
|
// calculates content width of a cell
|
|
11
9
|
function contentWidth(elem, container) {
|
|
12
10
|
var colWidths = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
13
11
|
var canvas = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : document.createElement('canvas');
|
|
14
12
|
return calcContentWidth(elem, container || elem, canvas, colWidths);
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
function calcContentWidth(elem, container, canvas, colWidths) {
|
|
18
15
|
var flowWidths = [];
|
|
19
16
|
var curWidth = 0;
|
|
20
|
-
|
|
21
17
|
for (var i = 0; i < elem.childNodes.length; i++) {
|
|
22
18
|
var child = elem.childNodes[i];
|
|
23
|
-
|
|
24
19
|
if (child.nodeType === Node.COMMENT_NODE) {
|
|
25
20
|
continue;
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
if (child.nodeType === Node.TEXT_NODE) {
|
|
29
23
|
var parent = child.parentNode;
|
|
30
24
|
var parentStyle = getComputedStyle(parent);
|
|
31
25
|
var contentLength = 0;
|
|
32
|
-
|
|
33
26
|
if (parent.nodeName === 'CODE' || parent.nodeName === 'PRE') {
|
|
34
27
|
contentLength = handlePreText(canvas, parent, child.textContent, parentStyle.font);
|
|
35
28
|
} else {
|
|
36
29
|
contentLength = measureText(canvas, child.textContent, parentStyle.font);
|
|
37
30
|
}
|
|
38
|
-
|
|
39
31
|
var left = parent.offsetLeft - container.offsetLeft;
|
|
40
32
|
flowWidths.push(curWidth);
|
|
41
|
-
curWidth += contentLength + left;
|
|
33
|
+
curWidth += contentLength + left;
|
|
42
34
|
|
|
35
|
+
// If the text isn't meant to wrap, we should set that as a hard limit.
|
|
43
36
|
if (parentStyle.whiteSpace === 'nowrap') {
|
|
44
37
|
// + 3 is for date offset plus cursor
|
|
45
38
|
// TODO There should be a programmatic way to get this.
|
|
@@ -48,14 +41,11 @@ function calcContentWidth(elem, container, canvas, colWidths) {
|
|
|
48
41
|
} else {
|
|
49
42
|
// FIXME: doesn't quite work right with spacing
|
|
50
43
|
var style = getComputedStyle(child);
|
|
51
|
-
|
|
52
44
|
if (style.minWidth && style.minWidth.endsWith('px') && style.minWidth !== '0px') {
|
|
53
45
|
colWidths.push((0, _unitToNumber.unitToNumber)(style.minWidth));
|
|
54
46
|
}
|
|
55
|
-
|
|
56
47
|
var _contentWidth = contentWidth(child, container, colWidths, canvas),
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
width = _contentWidth.width;
|
|
59
49
|
if (style.display && style.display.indexOf('inline') > -1) {
|
|
60
50
|
// is inline element, add to curWidth
|
|
61
51
|
curWidth += width;
|
|
@@ -66,7 +56,6 @@ function calcContentWidth(elem, container, canvas, colWidths) {
|
|
|
66
56
|
}
|
|
67
57
|
}
|
|
68
58
|
}
|
|
69
|
-
|
|
70
59
|
flowWidths.push(curWidth);
|
|
71
60
|
return {
|
|
72
61
|
minWidth: colWidths.reduce(function (oldMax, width) {
|
|
@@ -77,36 +66,27 @@ function calcContentWidth(elem, container, canvas, colWidths) {
|
|
|
77
66
|
}, 0)
|
|
78
67
|
};
|
|
79
68
|
}
|
|
80
|
-
|
|
81
69
|
function measureText(canvas, text, font) {
|
|
82
70
|
var ctx = canvas.getContext('2d');
|
|
83
|
-
|
|
84
71
|
if (!ctx) {
|
|
85
72
|
return 0;
|
|
86
73
|
}
|
|
87
|
-
|
|
88
74
|
if (font) {
|
|
89
75
|
ctx.font = font;
|
|
90
76
|
}
|
|
91
|
-
|
|
92
77
|
return Math.round(ctx.measureText(text || '').width);
|
|
93
78
|
}
|
|
94
|
-
|
|
95
79
|
function handlePreText(canvas, node, textContent, font) {
|
|
96
80
|
var parent = node;
|
|
97
|
-
|
|
98
81
|
if (node.nodeName === 'CODE') {
|
|
99
82
|
parent = node.parentNode;
|
|
100
83
|
}
|
|
101
|
-
|
|
102
84
|
var computedStyle = getComputedStyle(parent);
|
|
103
|
-
|
|
104
85
|
if (textContent && computedStyle.whiteSpace === 'pre') {
|
|
105
86
|
// If white space is pre grab the longest line in the block.
|
|
106
87
|
return textContent.split('\n').reduce(function (acc, current) {
|
|
107
88
|
return Math.max(measureText(canvas, current, font), acc);
|
|
108
89
|
}, 0);
|
|
109
90
|
}
|
|
110
|
-
|
|
111
91
|
return measureText(canvas, textContent, font);
|
|
112
92
|
}
|
|
@@ -4,143 +4,102 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.updateStickyMargins = exports.updateControls = exports.syncStickyRowToTable = exports.isClickNear = exports.getResizeCellPos = exports.applyTableWidthToStickyRow = exports.applyColWidthsToStickyRow = void 0;
|
|
7
|
-
|
|
8
7
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
9
|
-
|
|
10
8
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
|
-
|
|
12
9
|
var _updateOverflowShadows = require("../../../nodeviews/update-overflow-shadows");
|
|
13
|
-
|
|
14
10
|
var _types = require("../../../types");
|
|
15
|
-
|
|
16
11
|
var _rowControls = require("../../../utils/row-controls");
|
|
17
|
-
|
|
18
12
|
var _columnControls = require("../../../utils/column-controls");
|
|
19
|
-
|
|
20
13
|
var _pluginFactory = require("../../plugin-factory");
|
|
21
|
-
|
|
22
14
|
var updateControls = function updateControls(getEditorFeatureFlags) {
|
|
23
15
|
return function (state) {
|
|
24
16
|
var _getMainPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
tableRef = _getMainPluginState.tableRef;
|
|
27
18
|
if (!tableRef) {
|
|
28
19
|
return;
|
|
29
20
|
}
|
|
30
|
-
|
|
31
21
|
var tr = tableRef.querySelector('tr');
|
|
32
|
-
|
|
33
22
|
if (!tr) {
|
|
34
23
|
return;
|
|
35
24
|
}
|
|
36
|
-
|
|
37
25
|
var wrapper = tableRef.parentElement;
|
|
38
|
-
|
|
39
26
|
if (!(wrapper && wrapper.parentElement)) {
|
|
40
27
|
return;
|
|
41
28
|
}
|
|
42
|
-
|
|
43
29
|
var rowControls = wrapper.parentElement.querySelectorAll(".".concat(_types.TableCssClassName.ROW_CONTROLS_BUTTON_WRAP));
|
|
44
30
|
var numberedRows = wrapper.parentElement.querySelectorAll(_types.TableCssClassName.NUMBERED_COLUMN_BUTTON);
|
|
45
31
|
syncStickyRowToTable(tableRef);
|
|
46
|
-
var rowHeights = (0, _rowControls.getRowHeights)(tableRef);
|
|
32
|
+
var rowHeights = (0, _rowControls.getRowHeights)(tableRef);
|
|
47
33
|
|
|
34
|
+
// update rows controls height on resize
|
|
48
35
|
for (var i = 0, count = rowControls.length; i < count; i++) {
|
|
49
36
|
var height = rowHeights[i];
|
|
50
|
-
|
|
51
37
|
if (height) {
|
|
52
38
|
rowControls[i].style.height = "".concat(height, "px");
|
|
53
|
-
|
|
54
39
|
if (numberedRows.length) {
|
|
55
40
|
numberedRows[i].style.height = "".concat(height, "px");
|
|
56
41
|
}
|
|
57
42
|
}
|
|
58
43
|
}
|
|
59
|
-
|
|
60
44
|
var rightShadows = wrapper.parentElement.querySelectorAll(".".concat(_types.TableCssClassName.TABLE_RIGHT_SHADOW));
|
|
61
45
|
var leftShadows = wrapper.parentElement.querySelectorAll(".".concat(_types.TableCssClassName.TABLE_LEFT_SHADOW));
|
|
62
46
|
(0, _updateOverflowShadows.updateOverflowShadows)(getEditorFeatureFlags)(state, wrapper, tableRef, rightShadows, leftShadows);
|
|
63
47
|
};
|
|
64
48
|
};
|
|
65
|
-
|
|
66
49
|
exports.updateControls = updateControls;
|
|
67
|
-
|
|
68
50
|
var isClickNear = function isClickNear(event, click) {
|
|
69
51
|
var dx = click.x - event.clientX,
|
|
70
|
-
|
|
52
|
+
dy = click.y - event.clientY;
|
|
71
53
|
return dx * dx + dy * dy < 100;
|
|
72
54
|
};
|
|
73
|
-
|
|
74
55
|
exports.isClickNear = isClickNear;
|
|
75
|
-
|
|
76
56
|
var getResizeCellPos = function getResizeCellPos(view, event, lastColumnResizable) {
|
|
77
57
|
var target = event.target;
|
|
78
|
-
|
|
79
58
|
if (!(0, _utils.containsClassName)(target, _types.TableCssClassName.RESIZE_HANDLE_DECORATION)) {
|
|
80
59
|
return null;
|
|
81
60
|
}
|
|
82
|
-
|
|
83
61
|
var tableCell = (0, _utils.closestElement)(target, 'td, th');
|
|
84
|
-
|
|
85
62
|
if (!tableCell) {
|
|
86
63
|
return null;
|
|
87
64
|
}
|
|
88
|
-
|
|
89
65
|
var cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
90
66
|
return cellStartPosition - 1;
|
|
91
67
|
};
|
|
92
|
-
|
|
93
68
|
exports.getResizeCellPos = getResizeCellPos;
|
|
94
|
-
|
|
95
69
|
var updateStickyMargins = function updateStickyMargins(table) {
|
|
96
70
|
var row = table.querySelector('tr.sticky');
|
|
97
|
-
|
|
98
71
|
if (!row) {
|
|
99
72
|
table.style.marginTop = '';
|
|
100
73
|
return;
|
|
101
74
|
}
|
|
102
|
-
|
|
103
75
|
var paddingTop = (0, _utils.parsePx)(window.getComputedStyle(row).paddingTop || '') || 0;
|
|
104
|
-
|
|
105
76
|
var firstRowHeight = row.getBoundingClientRect().height - paddingTop - _styles.tableCellBorderWidth;
|
|
106
|
-
|
|
107
77
|
table.style.marginTop = "".concat(_styles.tableMarginTop + firstRowHeight, "px");
|
|
108
78
|
};
|
|
109
|
-
|
|
110
79
|
exports.updateStickyMargins = updateStickyMargins;
|
|
111
|
-
|
|
112
80
|
var applyColWidthsToStickyRow = function applyColWidthsToStickyRow(colGroup, headerRow) {
|
|
113
81
|
// sync column widths for the sticky row
|
|
114
82
|
var newCols = (0, _columnControls.colWidthsForRow)(colGroup, headerRow);
|
|
115
|
-
|
|
116
83
|
if (newCols) {
|
|
117
84
|
headerRow.style.gridTemplateColumns = newCols;
|
|
118
85
|
}
|
|
119
86
|
};
|
|
120
|
-
|
|
121
87
|
exports.applyColWidthsToStickyRow = applyColWidthsToStickyRow;
|
|
122
|
-
|
|
123
88
|
var syncStickyRowToTable = function syncStickyRowToTable(tableRef) {
|
|
124
89
|
if (!tableRef) {
|
|
125
90
|
return;
|
|
126
91
|
}
|
|
127
|
-
|
|
128
92
|
var headerRow = tableRef.querySelector('tr[data-header-row]');
|
|
129
|
-
|
|
130
93
|
if (!headerRow) {
|
|
131
94
|
return;
|
|
132
95
|
}
|
|
133
|
-
|
|
134
96
|
applyColWidthsToStickyRow(tableRef.querySelector('colgroup'), headerRow);
|
|
135
97
|
applyTableWidthToStickyRow(tableRef, headerRow);
|
|
136
98
|
};
|
|
137
|
-
|
|
138
99
|
exports.syncStickyRowToTable = syncStickyRowToTable;
|
|
139
|
-
|
|
140
100
|
var applyTableWidthToStickyRow = function applyTableWidthToStickyRow(tableRef, headerRow) {
|
|
141
101
|
var tbody = tableRef.querySelector('tbody');
|
|
142
102
|
var wrapper = tableRef.parentElement;
|
|
143
|
-
|
|
144
103
|
if (tbody && wrapper) {
|
|
145
104
|
// when resizing in Chrome, clientWidth will give us 759px
|
|
146
105
|
// but toggling the sticky class will reset it to 760px.
|
|
@@ -152,5 +111,4 @@ var applyTableWidthToStickyRow = function applyTableWidthToStickyRow(tableRef, h
|
|
|
152
111
|
headerRow.scrollLeft = wrapper.scrollLeft;
|
|
153
112
|
}
|
|
154
113
|
};
|
|
155
|
-
|
|
156
114
|
exports.applyTableWidthToStickyRow = applyTableWidthToStickyRow;
|
|
@@ -189,21 +189,12 @@ Object.defineProperty(exports, "updateControls", {
|
|
|
189
189
|
return _dom.updateControls;
|
|
190
190
|
}
|
|
191
191
|
});
|
|
192
|
-
|
|
193
192
|
var _colgroup = require("./colgroup");
|
|
194
|
-
|
|
195
193
|
var _contentWidth = require("./content-width");
|
|
196
|
-
|
|
197
194
|
var _columnState = require("./column-state");
|
|
198
|
-
|
|
199
195
|
var _resizeLogic = require("./resize-logic");
|
|
200
|
-
|
|
201
196
|
var _resizeState = require("./resize-state");
|
|
202
|
-
|
|
203
197
|
var _misc = require("./misc");
|
|
204
|
-
|
|
205
198
|
var _dom = require("./dom");
|
|
206
|
-
|
|
207
199
|
var _scaleTable = require("./scale-table");
|
|
208
|
-
|
|
209
200
|
var _resizeColumn = require("./resize-column");
|