@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
|
@@ -10,19 +10,17 @@ export var getColumnsWidths = function getColumnsWidths(view) {
|
|
|
10
10
|
var selection = view.state.selection;
|
|
11
11
|
var widths = [];
|
|
12
12
|
var table = findTable(selection);
|
|
13
|
-
|
|
14
13
|
if (table) {
|
|
15
14
|
var map = TableMap.get(table.node);
|
|
16
|
-
var domAtPos = view.domAtPos.bind(view);
|
|
15
|
+
var domAtPos = view.domAtPos.bind(view);
|
|
17
16
|
|
|
17
|
+
// When there is no cell we need to fill it with undefined
|
|
18
18
|
widths = Array.from({
|
|
19
19
|
length: map.width
|
|
20
20
|
});
|
|
21
|
-
|
|
22
21
|
for (var i = 0; i < map.width; i++) {
|
|
23
22
|
var cells = getCellsInColumn(i)(selection);
|
|
24
23
|
var cell = cells[0];
|
|
25
|
-
|
|
26
24
|
if (cell) {
|
|
27
25
|
var cellRef = findDomRefAtPos(cell.pos, domAtPos);
|
|
28
26
|
var rect = cellRef.getBoundingClientRect();
|
|
@@ -31,46 +29,37 @@ export var getColumnsWidths = function getColumnsWidths(view) {
|
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
|
-
|
|
35
32
|
return widths;
|
|
36
33
|
};
|
|
37
34
|
export var isColumnDeleteButtonVisible = function isColumnDeleteButtonVisible(selection) {
|
|
38
35
|
if (!isTableSelected(selection) && selection instanceof CellSelection && selection.isColSelection()) {
|
|
39
36
|
return true;
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
return false;
|
|
43
39
|
};
|
|
44
40
|
export var getColumnDeleteButtonParams = function getColumnDeleteButtonParams(columnsWidths, selection) {
|
|
45
41
|
var rect = getSelectionRect(selection);
|
|
46
|
-
|
|
47
42
|
if (!rect) {
|
|
48
43
|
return null;
|
|
49
44
|
}
|
|
50
|
-
|
|
51
45
|
var width = 0;
|
|
52
|
-
var offset = 0;
|
|
53
|
-
|
|
46
|
+
var offset = 0;
|
|
47
|
+
// find the columns before the selection
|
|
54
48
|
for (var i = 0; i < rect.left; i++) {
|
|
55
49
|
var colWidth = columnsWidths[i];
|
|
56
|
-
|
|
57
50
|
if (colWidth) {
|
|
58
51
|
offset += colWidth - 1;
|
|
59
52
|
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
}
|
|
54
|
+
// these are the selected columns widths
|
|
63
55
|
var indexes = [];
|
|
64
|
-
|
|
65
56
|
for (var _i = rect.left; _i < rect.right; _i++) {
|
|
66
57
|
var _colWidth = columnsWidths[_i];
|
|
67
|
-
|
|
68
58
|
if (_colWidth) {
|
|
69
59
|
width += _colWidth;
|
|
70
60
|
indexes.push(_i);
|
|
71
61
|
}
|
|
72
62
|
}
|
|
73
|
-
|
|
74
63
|
var left = offset + width / 2 - tableDeleteButtonSize / 2;
|
|
75
64
|
return {
|
|
76
65
|
left: left,
|
|
@@ -82,19 +71,17 @@ export var getColumnClassNames = function getColumnClassNames(index, selection)
|
|
|
82
71
|
var isInDanger = arguments.length > 3 ? arguments[3] : undefined;
|
|
83
72
|
var isResizing = arguments.length > 4 ? arguments[4] : undefined;
|
|
84
73
|
var classNames = [];
|
|
85
|
-
|
|
86
74
|
if (isColumnSelected(index)(selection) || hoveredColumns.indexOf(index) > -1 && !isResizing) {
|
|
87
75
|
classNames.push(ClassName.HOVERED_CELL_ACTIVE);
|
|
88
|
-
|
|
89
76
|
if (isInDanger) {
|
|
90
77
|
classNames.push(ClassName.HOVERED_CELL_IN_DANGER);
|
|
91
78
|
}
|
|
92
79
|
}
|
|
93
|
-
|
|
94
80
|
return classNames.join(' ');
|
|
95
|
-
};
|
|
96
|
-
// and map to a row's colwidths
|
|
81
|
+
};
|
|
97
82
|
|
|
83
|
+
// give a row colspan and a colwidths
|
|
84
|
+
// and map to a row's colwidths
|
|
98
85
|
var mapTableColwidthsToRow = function mapTableColwidthsToRow(rowColSpans, tableColWidths) {
|
|
99
86
|
var curColIdx = 0;
|
|
100
87
|
var colWidths = [];
|
|
@@ -107,12 +94,10 @@ var mapTableColwidthsToRow = function mapTableColwidthsToRow(rowColSpans, tableC
|
|
|
107
94
|
});
|
|
108
95
|
return colWidths;
|
|
109
96
|
};
|
|
110
|
-
|
|
111
97
|
var getRelativeDomCellWidths = function getRelativeDomCellWidths(_ref) {
|
|
112
98
|
var width = _ref.width,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
99
|
+
colspan = _ref.colspan,
|
|
100
|
+
colwidth = _ref.colwidth;
|
|
116
101
|
// For cells with colSpan 1
|
|
117
102
|
// or
|
|
118
103
|
// for cells in a table with unchanged column widths,
|
|
@@ -120,20 +105,22 @@ var getRelativeDomCellWidths = function getRelativeDomCellWidths(_ref) {
|
|
|
120
105
|
// return equally partitioned total cell width in DOM for each cell.
|
|
121
106
|
if (colspan === 1 || !colwidth) {
|
|
122
107
|
return new Array(colspan).fill(width / colspan);
|
|
123
|
-
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// For cells that have colSpan > 1 and
|
|
124
111
|
// are part of a table with resized columns
|
|
125
112
|
// return the current total DOM width of the cell multiplied
|
|
126
113
|
// by the percentage of the each individual cell's size.
|
|
127
114
|
// The cell size percentage is calculated using individual colwidth of the cell,
|
|
128
115
|
// from data-colwidth attribute on the cell,
|
|
129
116
|
// divided by the total width of the cells from colwidths for merged cells.
|
|
117
|
+
|
|
130
118
|
// Ex:
|
|
131
119
|
// colwidth = ‘201,102’
|
|
132
120
|
// Total colWidth = 303
|
|
133
121
|
// returned cellWidths = [303 * (201/303), 303 * (102/303)]
|
|
134
|
-
// For merged cells we get back colwidth as `201,102`
|
|
135
|
-
|
|
136
122
|
|
|
123
|
+
// For merged cells we get back colwidth as `201,102`
|
|
137
124
|
var cellColWidths = colwidth.split(',').map(function (colwidth) {
|
|
138
125
|
return Number(colwidth);
|
|
139
126
|
});
|
|
@@ -144,14 +131,13 @@ var getRelativeDomCellWidths = function getRelativeDomCellWidths(_ref) {
|
|
|
144
131
|
return width * (cellColWidth / totalCalculatedCellWidth);
|
|
145
132
|
});
|
|
146
133
|
};
|
|
147
|
-
|
|
148
134
|
export var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
|
|
149
135
|
// get the colspans
|
|
150
136
|
var rowColSpans = maphElem(tr, function (cell) {
|
|
151
|
-
return Number(cell.getAttribute('colspan') || 1
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
137
|
+
return Number(cell.getAttribute('colspan') || 1 /* default to span of 1 */);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// Chrome has trouble aligning borders with auto tables
|
|
155
141
|
// and the rest of the page grid. tables with defined
|
|
156
142
|
// column widths align fine.
|
|
157
143
|
//
|
|
@@ -159,9 +145,7 @@ export var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
|
|
|
159
145
|
//
|
|
160
146
|
// prefer copying the widths via the DOM
|
|
161
147
|
// or inferring from the next row if one exists
|
|
162
|
-
|
|
163
148
|
var copyTarget = tr.nextElementSibling || tr;
|
|
164
|
-
|
|
165
149
|
if (copyTarget) {
|
|
166
150
|
// either from the first row while it's still in the table
|
|
167
151
|
var cellInfos = maphElem(copyTarget, function (cell) {
|
|
@@ -170,13 +154,13 @@ export var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
|
|
|
170
154
|
colspan: Number(cell.getAttribute('colspan') || 1),
|
|
171
155
|
colwidth: cell.dataset.colwidth
|
|
172
156
|
};
|
|
173
|
-
});
|
|
157
|
+
});
|
|
174
158
|
|
|
159
|
+
// reverse engineer cell widths from table widths
|
|
175
160
|
var domBasedCellWidths = [];
|
|
176
161
|
cellInfos.map(function (cell, idx) {
|
|
177
162
|
domBasedCellWidths.push.apply(domBasedCellWidths, _toConsumableArray(getRelativeDomCellWidths(cell)));
|
|
178
163
|
});
|
|
179
|
-
|
|
180
164
|
if (cellInfos.reduce(function (acc, cell) {
|
|
181
165
|
return acc + cell.width;
|
|
182
166
|
}, 0) !== 0) {
|
|
@@ -185,10 +169,10 @@ export var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
|
|
|
185
169
|
return "".concat(px, "px");
|
|
186
170
|
}).join(' ');
|
|
187
171
|
}
|
|
188
|
-
}
|
|
189
|
-
// it aligns perfectly in the user's browser
|
|
190
|
-
|
|
172
|
+
}
|
|
191
173
|
|
|
174
|
+
// as a fallback, just calculate a %, and hope that
|
|
175
|
+
// it aligns perfectly in the user's browser
|
|
192
176
|
var visualColCount = rowColSpans.reduce(function (acc, val) {
|
|
193
177
|
return acc + val;
|
|
194
178
|
}, 0);
|
|
@@ -4,13 +4,11 @@ import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tab
|
|
|
4
4
|
import { Decoration } from 'prosemirror-view';
|
|
5
5
|
import { nonNullable } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
7
|
-
|
|
8
7
|
var filterDecorationByKey = function filterDecorationByKey(key, decorationSet) {
|
|
9
8
|
return decorationSet.find(undefined, undefined, function (spec) {
|
|
10
9
|
return spec.key.indexOf(key) > -1;
|
|
11
10
|
});
|
|
12
11
|
};
|
|
13
|
-
|
|
14
12
|
export var findColumnControlSelectedDecoration = function findColumnControlSelectedDecoration(decorationSet) {
|
|
15
13
|
return filterDecorationByKey(TableDecorations.COLUMN_SELECTED, decorationSet);
|
|
16
14
|
};
|
|
@@ -28,39 +26,33 @@ export var createCellHoverDecoration = function createCellHoverDecoration(cells,
|
|
|
28
26
|
};
|
|
29
27
|
export var createControlsHoverDecoration = function createControlsHoverDecoration(cells, type, tr, danger, selected) {
|
|
30
28
|
var table = findTable(tr.selection);
|
|
31
|
-
|
|
32
29
|
if (!table) {
|
|
33
30
|
return [];
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
var map = TableMap.get(table.node);
|
|
37
|
-
|
|
38
33
|
var _cells$reduce = cells.reduce(function (_ref, cell) {
|
|
39
|
-
|
|
34
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
40
35
|
min = _ref2[0],
|
|
41
36
|
max = _ref2[1];
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
_cells$reduce2 = _slicedToArray(_cells$reduce, 2),
|
|
54
|
-
min = _cells$reduce2[0],
|
|
55
|
-
max = _cells$reduce2[1];
|
|
56
|
-
|
|
37
|
+
if (min === null || cell.pos < min) {
|
|
38
|
+
min = cell.pos;
|
|
39
|
+
}
|
|
40
|
+
if (max === null || cell.pos > max) {
|
|
41
|
+
max = cell.pos;
|
|
42
|
+
}
|
|
43
|
+
return [min, max];
|
|
44
|
+
}, [null, null]),
|
|
45
|
+
_cells$reduce2 = _slicedToArray(_cells$reduce, 2),
|
|
46
|
+
min = _cells$reduce2[0],
|
|
47
|
+
max = _cells$reduce2[1];
|
|
57
48
|
if (min === null || max === null) {
|
|
58
49
|
return [];
|
|
59
50
|
}
|
|
60
|
-
|
|
61
51
|
var updatedCells = cells.map(function (x) {
|
|
62
52
|
return x.pos;
|
|
63
|
-
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// ED-15246 fixed trello card table overflow issue
|
|
64
56
|
// If columns / rows have been merged the hovered selection is different to the actual selection
|
|
65
57
|
// So If the table cells are in danger we want to create a "rectangle" selection
|
|
66
58
|
// to match the "clicked" selection
|
|
@@ -69,68 +61,59 @@ export var createControlsHoverDecoration = function createControlsHoverDecoratio
|
|
|
69
61
|
// Find the bounding rectangle of all the given cells, also considering
|
|
70
62
|
// merged cells.
|
|
71
63
|
var _cells$reduce3 = cells.reduce(function (acc, cell) {
|
|
72
|
-
|
|
64
|
+
var _map$findCell = map.findCell(cell.pos - table.start),
|
|
73
65
|
left = _map$findCell.left,
|
|
74
66
|
right = _map$findCell.right,
|
|
75
67
|
bottom = _map$findCell.bottom,
|
|
76
|
-
top = _map$findCell.top;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
68
|
+
top = _map$findCell.top;
|
|
69
|
+
// Finding the bounding rect requires finding the min left and top positions,
|
|
70
|
+
// and the max right and bottom positions of the cells
|
|
71
|
+
return {
|
|
72
|
+
recLeft: Math.min(acc.recLeft, left),
|
|
73
|
+
recTop: Math.min(acc.recTop, top),
|
|
74
|
+
recRight: Math.max(acc.recRight, right),
|
|
75
|
+
recBottom: Math.max(acc.recBottom, bottom)
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
// +-Infinity as initialisation vars which will always be overwritten
|
|
79
|
+
// by smaller/larger values respectively
|
|
80
|
+
{
|
|
81
|
+
recLeft: Infinity,
|
|
82
|
+
recTop: Infinity,
|
|
83
|
+
recRight: -Infinity,
|
|
84
|
+
recBottom: -Infinity
|
|
85
|
+
}),
|
|
86
|
+
recLeft = _cells$reduce3.recLeft,
|
|
87
|
+
recTop = _cells$reduce3.recTop,
|
|
88
|
+
recRight = _cells$reduce3.recRight,
|
|
89
|
+
recBottom = _cells$reduce3.recBottom;
|
|
99
90
|
var rect = new Rect(recLeft, recTop, recRight, recBottom);
|
|
100
91
|
updatedCells = map.cellsInRect(rect).map(function (x) {
|
|
101
92
|
return x + table.start;
|
|
102
93
|
});
|
|
103
94
|
}
|
|
104
|
-
|
|
105
95
|
return updatedCells.map(function (pos) {
|
|
106
96
|
var cell = tr.doc.nodeAt(pos);
|
|
107
97
|
var classes = [ClassName.HOVERED_CELL];
|
|
108
|
-
|
|
109
98
|
if (danger) {
|
|
110
99
|
classes.push(ClassName.HOVERED_CELL_IN_DANGER);
|
|
111
100
|
}
|
|
112
|
-
|
|
113
101
|
if (selected) {
|
|
114
102
|
classes.push(ClassName.SELECTED_CELL);
|
|
115
103
|
}
|
|
116
|
-
|
|
117
104
|
classes.push(type === 'column' ? ClassName.HOVERED_COLUMN : type === 'row' ? ClassName.HOVERED_ROW : ClassName.HOVERED_TABLE);
|
|
118
105
|
var key;
|
|
119
|
-
|
|
120
106
|
switch (type) {
|
|
121
107
|
case 'row':
|
|
122
108
|
key = TableDecorations.ROW_CONTROLS_HOVER;
|
|
123
109
|
break;
|
|
124
|
-
|
|
125
110
|
case 'column':
|
|
126
111
|
key = TableDecorations.COLUMN_CONTROLS_HOVER;
|
|
127
112
|
break;
|
|
128
|
-
|
|
129
113
|
default:
|
|
130
114
|
key = TableDecorations.TABLE_CONTROLS_HOVER;
|
|
131
115
|
break;
|
|
132
116
|
}
|
|
133
|
-
|
|
134
117
|
return Decoration.node(pos, pos + cell.nodeSize, {
|
|
135
118
|
class: classes.join(' ')
|
|
136
119
|
}, {
|
|
@@ -140,14 +123,12 @@ export var createControlsHoverDecoration = function createControlsHoverDecoratio
|
|
|
140
123
|
};
|
|
141
124
|
export var createColumnSelectedDecoration = function createColumnSelectedDecoration(tr) {
|
|
142
125
|
var selection = tr.selection,
|
|
143
|
-
|
|
126
|
+
doc = tr.doc;
|
|
144
127
|
var table = findTable(selection);
|
|
145
128
|
var rect = getSelectionRect(selection);
|
|
146
|
-
|
|
147
129
|
if (!table || !rect) {
|
|
148
130
|
return [];
|
|
149
131
|
}
|
|
150
|
-
|
|
151
132
|
var map = TableMap.get(table.node);
|
|
152
133
|
var cellPositions = map.cellsInRect(rect);
|
|
153
134
|
return cellPositions.map(function (pos, index) {
|
|
@@ -163,12 +144,13 @@ export var createColumnControlsDecoration = function createColumnControlsDecorat
|
|
|
163
144
|
var cells = getCellsInRow(0)(selection) || [];
|
|
164
145
|
var index = 0;
|
|
165
146
|
return cells.map(function (cell) {
|
|
166
|
-
var colspan = cell.node.attrs.colspan || 1;
|
|
147
|
+
var colspan = cell.node.attrs.colspan || 1;
|
|
148
|
+
// It's important these values are scoped locally as the widget callback could be executed anytime in the future
|
|
167
149
|
// and we want to avoid value leak
|
|
168
|
-
|
|
169
150
|
var startIndex = index;
|
|
170
|
-
var endIndex = startIndex + colspan;
|
|
151
|
+
var endIndex = startIndex + colspan;
|
|
171
152
|
|
|
153
|
+
// The next cell start index will commence from the current cell end index.
|
|
172
154
|
index = endIndex;
|
|
173
155
|
return Decoration.widget(cell.pos + 1, function () {
|
|
174
156
|
var element = document.createElement('div');
|
|
@@ -188,10 +170,10 @@ export var updateDecorations = function updateDecorations(node, decorationSet, d
|
|
|
188
170
|
var decorationSetFiltered = decorationSet.remove(filteredDecorations);
|
|
189
171
|
return decorationSetFiltered.add(node, decorations);
|
|
190
172
|
};
|
|
191
|
-
|
|
192
173
|
var makeArray = function makeArray(n) {
|
|
193
174
|
return Array.from(Array(n).keys());
|
|
194
175
|
};
|
|
176
|
+
|
|
195
177
|
/*
|
|
196
178
|
* This function will create two specific decorations for each cell in a column index target,
|
|
197
179
|
* for example given that table:
|
|
@@ -271,22 +253,16 @@ var makeArray = function makeArray(n) {
|
|
|
271
253
|
* we will add a new class on the last item for each cell,
|
|
272
254
|
* hence the second media will receive this class `ClassName.LAST_ITEM_IN_CELL`
|
|
273
255
|
*/
|
|
274
|
-
|
|
275
|
-
|
|
276
256
|
export var createResizeHandleDecoration = function createResizeHandleDecoration(tr, rowIndexTarget, columnEndIndexTarget) {
|
|
277
257
|
var emptyResult = [[], []];
|
|
278
258
|
var table = findTable(tr.selection);
|
|
279
|
-
|
|
280
259
|
if (!table || !table.node) {
|
|
281
260
|
return emptyResult;
|
|
282
261
|
}
|
|
283
|
-
|
|
284
262
|
var map = TableMap.get(table.node);
|
|
285
|
-
|
|
286
263
|
if (!map.width) {
|
|
287
264
|
return emptyResult;
|
|
288
265
|
}
|
|
289
|
-
|
|
290
266
|
var createResizerHandleDecoration = function createResizerHandleDecoration(cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode) {
|
|
291
267
|
var position = cellPos + cellNode.nodeSize - 1;
|
|
292
268
|
return Decoration.widget(position, function () {
|
|
@@ -299,7 +275,6 @@ export var createResizeHandleDecoration = function createResizeHandleDecoration(
|
|
|
299
275
|
key: "".concat(TableDecorations.COLUMN_RESIZING_HANDLE, "_").concat(rowIndex, "_").concat(columnIndex)
|
|
300
276
|
});
|
|
301
277
|
};
|
|
302
|
-
|
|
303
278
|
var createLastCellElementDecoration = function createLastCellElementDecoration(cellColumnPositioning, cellPos, cellNode) {
|
|
304
279
|
var lastItemPositions;
|
|
305
280
|
cellNode.forEach(function (childNode, offset, index) {
|
|
@@ -311,51 +286,39 @@ export var createResizeHandleDecoration = function createResizeHandleDecoration(
|
|
|
311
286
|
};
|
|
312
287
|
}
|
|
313
288
|
});
|
|
314
|
-
|
|
315
289
|
if (!lastItemPositions) {
|
|
316
290
|
return null;
|
|
317
291
|
}
|
|
318
|
-
|
|
319
292
|
return Decoration.node(lastItemPositions.from, lastItemPositions.to, {
|
|
320
293
|
class: ClassName.LAST_ITEM_IN_CELL
|
|
321
294
|
}, {
|
|
322
295
|
key: "".concat(TableDecorations.LAST_CELL_ELEMENT, "_").concat(cellColumnPositioning.left, "_").concat(cellColumnPositioning.right)
|
|
323
296
|
});
|
|
324
297
|
};
|
|
325
|
-
|
|
326
298
|
var resizeHandleCellDecorations = [];
|
|
327
299
|
var lastCellElementsDecorations = [];
|
|
328
|
-
|
|
329
300
|
for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
330
301
|
var seen = {};
|
|
331
|
-
|
|
332
302
|
if (rowIndex !== rowIndexTarget) {
|
|
333
303
|
continue;
|
|
334
304
|
}
|
|
335
|
-
|
|
336
305
|
for (var columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
337
306
|
var cellPosition = map.map[map.width * rowIndex + columnIndex];
|
|
338
|
-
|
|
339
307
|
if (seen[cellPosition]) {
|
|
340
308
|
continue;
|
|
341
309
|
}
|
|
342
|
-
|
|
343
310
|
seen[cellPosition] = true;
|
|
344
311
|
var cellPos = table.start + cellPosition;
|
|
345
312
|
var cell = tr.doc.nodeAt(cellPos);
|
|
346
|
-
|
|
347
313
|
if (!cell) {
|
|
348
314
|
continue;
|
|
349
315
|
}
|
|
350
|
-
|
|
351
316
|
var colspan = cell.attrs.colspan || 1;
|
|
352
317
|
var startIndex = columnIndex;
|
|
353
318
|
var endIndex = colspan + startIndex;
|
|
354
|
-
|
|
355
319
|
if (endIndex !== columnEndIndexTarget.right) {
|
|
356
320
|
continue;
|
|
357
321
|
}
|
|
358
|
-
|
|
359
322
|
var resizerHandleDec = createResizerHandleDecoration({
|
|
360
323
|
left: startIndex,
|
|
361
324
|
right: endIndex
|
|
@@ -368,9 +331,9 @@ export var createResizeHandleDecoration = function createResizeHandleDecoration(
|
|
|
368
331
|
lastCellElementsDecorations.push(lastCellDec);
|
|
369
332
|
}
|
|
370
333
|
}
|
|
371
|
-
|
|
372
334
|
return [resizeHandleCellDecorations, lastCellElementsDecorations.filter(nonNullable)];
|
|
373
335
|
};
|
|
336
|
+
|
|
374
337
|
/*
|
|
375
338
|
* This function will create a decoration for each cell using the right position on the CellColumnPositioning
|
|
376
339
|
* for example given that table:
|
|
@@ -413,22 +376,17 @@ export var createResizeHandleDecoration = function createResizeHandleDecoration(
|
|
|
413
376
|
* this function will return two decorations applying a new class `ClassName.WITH_RESIZE_LINE`
|
|
414
377
|
* only on the cells: `C1` and `D1`.
|
|
415
378
|
*/
|
|
416
|
-
|
|
417
379
|
export var createColumnLineResize = function createColumnLineResize(selection, cellColumnPositioning) {
|
|
418
380
|
var table = findTable(selection);
|
|
419
|
-
|
|
420
381
|
if (!table || cellColumnPositioning.right === null) {
|
|
421
382
|
return [];
|
|
422
383
|
}
|
|
423
|
-
|
|
424
384
|
var columnIndex = cellColumnPositioning.right;
|
|
425
385
|
var map = TableMap.get(table.node);
|
|
426
386
|
var isLastColumn = columnIndex === map.width;
|
|
427
|
-
|
|
428
387
|
if (isLastColumn) {
|
|
429
388
|
columnIndex -= 1;
|
|
430
389
|
}
|
|
431
|
-
|
|
432
390
|
var decorationClassName = isLastColumn ? ClassName.WITH_RESIZE_LINE_LAST_COLUMN : ClassName.WITH_RESIZE_LINE;
|
|
433
391
|
var cellPositions = makeArray(map.height).map(function (rowIndex) {
|
|
434
392
|
return map.map[map.width * rowIndex + columnIndex];
|
|
@@ -440,6 +398,7 @@ export var createColumnLineResize = function createColumnLineResize(selection, c
|
|
|
440
398
|
var nextPosition = map.map[map.width * rowIndex + columnIndex - 1];
|
|
441
399
|
return cellPosition !== nextPosition; // Removed it if next position is merged
|
|
442
400
|
});
|
|
401
|
+
|
|
443
402
|
var cells = cellPositions.map(function (pos) {
|
|
444
403
|
return {
|
|
445
404
|
pos: pos + table.start,
|
|
@@ -450,7 +409,6 @@ export var createColumnLineResize = function createColumnLineResize(selection, c
|
|
|
450
409
|
if (!cell || !cell.node) {
|
|
451
410
|
return;
|
|
452
411
|
}
|
|
453
|
-
|
|
454
412
|
return Decoration.node(cell.pos, cell.pos + cell.node.nodeSize, {
|
|
455
413
|
class: decorationClassName
|
|
456
414
|
}, {
|
|
@@ -29,6 +29,7 @@ export var isTableControlsButton = function isTableControlsButton(node) {
|
|
|
29
29
|
export var isTableContainerOrWrapper = function isTableContainerOrWrapper(node) {
|
|
30
30
|
return containsClassName(node, ClassName.TABLE_CONTAINER) || containsClassName(node, ClassName.TABLE_NODE_WRAPPER);
|
|
31
31
|
};
|
|
32
|
+
|
|
32
33
|
/*
|
|
33
34
|
* This function returns which side of a given element the mouse cursor is,
|
|
34
35
|
* using as a base the half of the width by default, for example:
|
|
@@ -85,14 +86,11 @@ export var isTableContainerOrWrapper = function isTableContainerOrWrapper(node)
|
|
|
85
86
|
|
|
86
87
|
export var getMousePositionHorizontalRelativeByElement = function getMousePositionHorizontalRelativeByElement(mouseEvent, mouseMoveOptimization, elementContentRects, gapInPixels) {
|
|
87
88
|
var element = mouseEvent.target;
|
|
88
|
-
|
|
89
89
|
if (element instanceof HTMLElement) {
|
|
90
90
|
var width, x;
|
|
91
91
|
var closestCell = element.closest(SELECTOR_TABLE_LEAFS);
|
|
92
|
-
|
|
93
92
|
if (mouseMoveOptimization) {
|
|
94
93
|
var _closestCell$id, _elementContentRects$, _elementContentRects$2;
|
|
95
|
-
|
|
96
94
|
var id = (_closestCell$id = closestCell === null || closestCell === void 0 ? void 0 : closestCell.id) !== null && _closestCell$id !== void 0 ? _closestCell$id : '';
|
|
97
95
|
width = (_elementContentRects$ = elementContentRects === null || elementContentRects === void 0 ? void 0 : (_elementContentRects$2 = elementContentRects[id]) === null || _elementContentRects$2 === void 0 ? void 0 : _elementContentRects$2.width) !== null && _elementContentRects$ !== void 0 ? _elementContentRects$ : 0;
|
|
98
96
|
x = mouseEvent.offsetX;
|
|
@@ -102,11 +100,9 @@ export var getMousePositionHorizontalRelativeByElement = function getMousePositi
|
|
|
102
100
|
var left = elementRect.left;
|
|
103
101
|
x = mouseEvent.clientX - left;
|
|
104
102
|
}
|
|
105
|
-
|
|
106
103
|
if (width <= 0) {
|
|
107
104
|
return null;
|
|
108
105
|
}
|
|
109
|
-
|
|
110
106
|
if (!gapInPixels) {
|
|
111
107
|
return x / width > 0.5 ? 'right' : 'left';
|
|
112
108
|
} else {
|
|
@@ -117,57 +113,45 @@ export var getMousePositionHorizontalRelativeByElement = function getMousePositi
|
|
|
117
113
|
}
|
|
118
114
|
}
|
|
119
115
|
}
|
|
120
|
-
|
|
121
116
|
return null;
|
|
122
117
|
};
|
|
123
118
|
export var getMousePositionVerticalRelativeByElement = function getMousePositionVerticalRelativeByElement(mouseEvent) {
|
|
124
119
|
var element = mouseEvent.target;
|
|
125
|
-
|
|
126
120
|
if (element instanceof HTMLElement) {
|
|
127
121
|
var elementRect = element.getBoundingClientRect();
|
|
128
|
-
|
|
129
122
|
if (elementRect.height <= 0) {
|
|
130
123
|
return null;
|
|
131
124
|
}
|
|
132
|
-
|
|
133
125
|
var y = mouseEvent.clientY - elementRect.top;
|
|
134
126
|
return y / elementRect.height > 0.5 ? 'bottom' : 'top';
|
|
135
127
|
}
|
|
136
|
-
|
|
137
128
|
return null;
|
|
138
129
|
};
|
|
139
130
|
export var updateResizeHandles = function updateResizeHandles(tableRef) {
|
|
140
131
|
if (!tableRef) {
|
|
141
132
|
return;
|
|
142
133
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
134
|
+
var height = tableRef.offsetHeight + tableToolbarSize;
|
|
135
|
+
// see ED-7600
|
|
146
136
|
var nodes = Array.from(tableRef.querySelectorAll(".".concat(ClassName.RESIZE_HANDLE)));
|
|
147
|
-
|
|
148
137
|
if (!nodes || !nodes.length) {
|
|
149
138
|
return;
|
|
150
139
|
}
|
|
151
|
-
|
|
152
140
|
nodes.forEach(function (node) {
|
|
153
141
|
node.style.height = "".concat(height, "px");
|
|
154
142
|
});
|
|
155
143
|
};
|
|
156
144
|
export var hasResizeHandler = function hasResizeHandler(_ref) {
|
|
157
145
|
var columnEndIndexTarget = _ref.columnEndIndexTarget,
|
|
158
|
-
|
|
146
|
+
target = _ref.target;
|
|
159
147
|
var tableElement = closestElement(target, 'table');
|
|
160
|
-
|
|
161
148
|
if (!tableElement) {
|
|
162
149
|
return false;
|
|
163
150
|
}
|
|
164
|
-
|
|
165
151
|
var query = [".".concat(ClassName.RESIZE_HANDLE_DECORATION), "[data-end-index=\"".concat(columnEndIndexTarget, "\"]")];
|
|
166
152
|
var decorationElement = tableElement.querySelectorAll(query.join(''));
|
|
167
|
-
|
|
168
153
|
if (!decorationElement || decorationElement.length === 0) {
|
|
169
154
|
return false;
|
|
170
155
|
}
|
|
171
|
-
|
|
172
156
|
return true;
|
|
173
157
|
};
|