@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
|
@@ -7,98 +7,84 @@ import { AddColumnStep } from '@atlaskit/adf-schema/steps';
|
|
|
7
7
|
import { checkIfHeaderRowEnabled, copyPreviousRow } from '../utils';
|
|
8
8
|
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
9
9
|
import { rescaleColumns } from '../transforms/column-width';
|
|
10
|
-
|
|
11
10
|
// #endregion
|
|
11
|
+
|
|
12
12
|
function addColumnAtCustomStep(column) {
|
|
13
13
|
return function (tr) {
|
|
14
14
|
var table = findTable(tr.selection);
|
|
15
|
-
|
|
16
15
|
if (table) {
|
|
17
16
|
return tr.step(AddColumnStep.create(tr.doc, table.pos, column));
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
return tr;
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
export function addColumnAt(getEditorContainerWidth) {
|
|
25
22
|
return function (column) {
|
|
26
23
|
var allowAddColumnCustomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
27
24
|
var view = arguments.length > 2 ? arguments[2] : undefined;
|
|
28
25
|
return function (tr) {
|
|
29
26
|
var updatedTr = tr;
|
|
30
|
-
|
|
31
27
|
if (allowAddColumnCustomStep) {
|
|
32
28
|
updatedTr = addColumnAtCustomStep(column)(updatedTr);
|
|
33
29
|
} else {
|
|
34
30
|
updatedTr = addColumnAtPMUtils(column)(updatedTr);
|
|
35
31
|
}
|
|
36
|
-
|
|
37
32
|
var table = findTable(updatedTr.selection);
|
|
38
|
-
|
|
39
33
|
if (table) {
|
|
40
34
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
41
35
|
updatedTr = rescaleColumns(getEditorContainerWidth)(table, view)(updatedTr);
|
|
42
36
|
}
|
|
43
|
-
|
|
44
37
|
return updatedTr;
|
|
45
38
|
};
|
|
46
39
|
};
|
|
47
|
-
}
|
|
48
|
-
// Command to add a column before the column with the selection.
|
|
40
|
+
}
|
|
49
41
|
|
|
42
|
+
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
43
|
+
// Command to add a column before the column with the selection.
|
|
50
44
|
export var addColumnBefore = function addColumnBefore(getEditorContainerWidth) {
|
|
51
45
|
return function (state, dispatch, view) {
|
|
52
46
|
var table = findTable(state.selection);
|
|
53
|
-
|
|
54
47
|
if (!table) {
|
|
55
48
|
return false;
|
|
56
49
|
}
|
|
57
|
-
|
|
58
50
|
if (dispatch) {
|
|
59
51
|
var rect = selectedRect(state);
|
|
60
52
|
dispatch(addColumnAt(getEditorContainerWidth)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
61
53
|
}
|
|
62
|
-
|
|
63
54
|
return true;
|
|
64
55
|
};
|
|
65
|
-
};
|
|
66
|
-
// Command to add a column after the column with the selection.
|
|
56
|
+
};
|
|
67
57
|
|
|
58
|
+
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
59
|
+
// Command to add a column after the column with the selection.
|
|
68
60
|
export var addColumnAfter = function addColumnAfter(getEditorContainerWidth) {
|
|
69
61
|
return function (state, dispatch, view) {
|
|
70
62
|
var table = findTable(state.selection);
|
|
71
|
-
|
|
72
63
|
if (!table) {
|
|
73
64
|
return false;
|
|
74
65
|
}
|
|
75
|
-
|
|
76
66
|
if (dispatch) {
|
|
77
67
|
var rect = selectedRect(state);
|
|
78
68
|
dispatch(addColumnAt(getEditorContainerWidth)(rect.right, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
79
69
|
}
|
|
80
|
-
|
|
81
70
|
return true;
|
|
82
71
|
};
|
|
83
|
-
};
|
|
72
|
+
};
|
|
84
73
|
|
|
74
|
+
// #region Commands
|
|
85
75
|
export var insertColumn = function insertColumn(getEditorContainerWidth) {
|
|
86
76
|
return function (column) {
|
|
87
77
|
return function (state, dispatch, view) {
|
|
88
78
|
var tr = addColumnAt(getEditorContainerWidth)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
89
79
|
var table = findTable(tr.selection);
|
|
90
|
-
|
|
91
80
|
if (!table) {
|
|
92
81
|
return false;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
}
|
|
83
|
+
// move the cursor to the newly created column
|
|
96
84
|
var pos = TableMap.get(table.node).positionAt(0, column, table.node);
|
|
97
|
-
|
|
98
85
|
if (dispatch) {
|
|
99
86
|
dispatch(tr.setSelection(Selection.near(tr.doc.resolve(table.start + pos))));
|
|
100
87
|
}
|
|
101
|
-
|
|
102
88
|
return true;
|
|
103
89
|
};
|
|
104
90
|
};
|
|
@@ -107,23 +93,20 @@ export var insertRow = function insertRow(row, moveCursorToTheNewRow) {
|
|
|
107
93
|
return function (state, dispatch) {
|
|
108
94
|
// Don't clone the header row
|
|
109
95
|
var headerRowEnabled = checkIfHeaderRowEnabled(state.selection);
|
|
110
|
-
var clonePreviousRow = headerRowEnabled && row > 1 || !headerRowEnabled && row > 0;
|
|
111
|
-
// we should not add row on the position zero
|
|
96
|
+
var clonePreviousRow = headerRowEnabled && row > 1 || !headerRowEnabled && row > 0;
|
|
112
97
|
|
|
98
|
+
// When the table have header row
|
|
99
|
+
// we should not add row on the position zero
|
|
113
100
|
if (row === 0 && headerRowEnabled) {
|
|
114
101
|
return false;
|
|
115
102
|
}
|
|
116
|
-
|
|
117
103
|
var tr = clonePreviousRow ? copyPreviousRow(state.schema)(row)(state.tr) : addRowAt(row)(state.tr);
|
|
118
104
|
var table = findTable(tr.selection);
|
|
119
|
-
|
|
120
105
|
if (!table) {
|
|
121
106
|
return false;
|
|
122
107
|
}
|
|
123
|
-
|
|
124
108
|
if (dispatch) {
|
|
125
109
|
var selection = state.selection;
|
|
126
|
-
|
|
127
110
|
if (moveCursorToTheNewRow) {
|
|
128
111
|
// move the cursor to the newly created row
|
|
129
112
|
var pos = TableMap.get(table.node).positionAt(row, 0, table.node);
|
|
@@ -131,10 +114,8 @@ export var insertRow = function insertRow(row, moveCursorToTheNewRow) {
|
|
|
131
114
|
} else {
|
|
132
115
|
tr.setSelection(selection.map(tr.doc, tr.mapping));
|
|
133
116
|
}
|
|
134
|
-
|
|
135
117
|
dispatch(tr);
|
|
136
118
|
}
|
|
137
|
-
|
|
138
119
|
return true;
|
|
139
120
|
};
|
|
140
121
|
};
|
|
@@ -143,11 +124,10 @@ export var createTable = function createTable() {
|
|
|
143
124
|
var table = createTableNode({
|
|
144
125
|
schema: state.schema
|
|
145
126
|
});
|
|
146
|
-
|
|
147
127
|
if (dispatch) {
|
|
148
128
|
dispatch(safeInsert(table)(state.tr).scrollIntoView());
|
|
149
129
|
}
|
|
150
|
-
|
|
151
130
|
return true;
|
|
152
131
|
};
|
|
153
|
-
};
|
|
132
|
+
};
|
|
133
|
+
// #endregion
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
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; }
|
|
4
|
-
|
|
5
3
|
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) { _defineProperty(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; }
|
|
6
|
-
|
|
7
4
|
// #region Imports
|
|
5
|
+
|
|
8
6
|
import { Selection, TextSelection } from 'prosemirror-state';
|
|
9
7
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
10
8
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
@@ -17,10 +15,12 @@ import { fixAutoSizedTable } from '../transforms';
|
|
|
17
15
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
18
16
|
import { createColumnControlsDecoration, createColumnSelectedDecoration } from '../utils/decoration';
|
|
19
17
|
import { checkIfNumberColumnEnabled, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, isIsolating } from '../utils/nodes';
|
|
20
|
-
import { updatePluginStateDecorations } from '../utils/update-plugin-state-decorations';
|
|
18
|
+
import { updatePluginStateDecorations } from '../utils/update-plugin-state-decorations';
|
|
21
19
|
// #endregion
|
|
22
|
-
// #region Commands
|
|
23
20
|
|
|
21
|
+
// #endregion
|
|
22
|
+
|
|
23
|
+
// #region Commands
|
|
24
24
|
export var setEditorFocus = function setEditorFocus(editorHasFocus) {
|
|
25
25
|
return createCommand({
|
|
26
26
|
type: 'SET_EDITOR_FOCUS',
|
|
@@ -61,8 +61,7 @@ export var setTableRef = function setTableRef(ref) {
|
|
|
61
61
|
export var setCellAttr = function setCellAttr(name, value) {
|
|
62
62
|
return function (state, dispatch) {
|
|
63
63
|
var tr = state.tr,
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
selection = state.selection;
|
|
66
65
|
if (selection instanceof CellSelection) {
|
|
67
66
|
var updated = false;
|
|
68
67
|
selection.forEachCell(function (cell, pos) {
|
|
@@ -71,79 +70,65 @@ export var setCellAttr = function setCellAttr(name, value) {
|
|
|
71
70
|
updated = true;
|
|
72
71
|
}
|
|
73
72
|
});
|
|
74
|
-
|
|
75
73
|
if (updated) {
|
|
76
74
|
if (dispatch) {
|
|
77
75
|
dispatch(tr);
|
|
78
76
|
}
|
|
79
|
-
|
|
80
77
|
return true;
|
|
81
78
|
}
|
|
82
79
|
} else {
|
|
83
80
|
var cell = selectionCell(state.selection);
|
|
84
|
-
|
|
85
81
|
if (cell) {
|
|
86
82
|
if (dispatch) {
|
|
87
83
|
var _cell$nodeAfter, _cell$nodeAfter2;
|
|
88
|
-
|
|
89
84
|
dispatch(tr.setNodeMarkup(cell.pos, (_cell$nodeAfter = cell.nodeAfter) === null || _cell$nodeAfter === void 0 ? void 0 : _cell$nodeAfter.type, _objectSpread(_objectSpread({}, (_cell$nodeAfter2 = cell.nodeAfter) === null || _cell$nodeAfter2 === void 0 ? void 0 : _cell$nodeAfter2.attrs), {}, _defineProperty({}, name, value))));
|
|
90
85
|
}
|
|
91
|
-
|
|
92
86
|
return true;
|
|
93
87
|
}
|
|
94
88
|
}
|
|
95
|
-
|
|
96
89
|
return false;
|
|
97
90
|
};
|
|
98
91
|
};
|
|
99
92
|
export var triggerUnlessTableHeader = function triggerUnlessTableHeader(command) {
|
|
100
93
|
return function (state, dispatch, view) {
|
|
101
94
|
var selection = state.selection,
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
tableHeader = state.schema.nodes.tableHeader;
|
|
104
96
|
if (selection instanceof TextSelection) {
|
|
105
97
|
var cell = findCellClosestToPos(selection.$from);
|
|
106
|
-
|
|
107
98
|
if (cell && cell.node.type !== tableHeader) {
|
|
108
99
|
return command(state, dispatch, view);
|
|
109
100
|
}
|
|
110
101
|
}
|
|
111
|
-
|
|
112
102
|
if (selection instanceof CellSelection) {
|
|
113
103
|
var rect = getSelectionRect(selection);
|
|
114
|
-
|
|
115
104
|
if (!checkIfHeaderRowEnabled(selection) || rect && rect.top > 0) {
|
|
116
105
|
return command(state, dispatch, view);
|
|
117
106
|
}
|
|
118
107
|
}
|
|
119
|
-
|
|
120
108
|
return false;
|
|
121
109
|
};
|
|
122
110
|
};
|
|
123
111
|
export var transformSliceRemoveCellBackgroundColor = function transformSliceRemoveCellBackgroundColor(slice, schema) {
|
|
124
112
|
var _schema$nodes = schema.nodes,
|
|
125
|
-
|
|
126
|
-
|
|
113
|
+
tableCell = _schema$nodes.tableCell,
|
|
114
|
+
tableHeader = _schema$nodes.tableHeader;
|
|
127
115
|
return mapSlice(slice, function (maybeCell) {
|
|
128
116
|
if (maybeCell.type === tableCell || maybeCell.type === tableHeader) {
|
|
129
117
|
var cellAttrs = _objectSpread({}, maybeCell.attrs);
|
|
130
|
-
|
|
131
118
|
cellAttrs.background = undefined;
|
|
132
119
|
return maybeCell.type.createChecked(cellAttrs, maybeCell.content, maybeCell.marks);
|
|
133
120
|
}
|
|
134
|
-
|
|
135
121
|
return maybeCell;
|
|
136
122
|
});
|
|
137
123
|
};
|
|
138
124
|
export var transformSliceToAddTableHeaders = function transformSliceToAddTableHeaders(slice, schema) {
|
|
139
125
|
var _schema$nodes2 = schema.nodes,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
126
|
+
table = _schema$nodes2.table,
|
|
127
|
+
tableHeader = _schema$nodes2.tableHeader,
|
|
128
|
+
tableRow = _schema$nodes2.tableRow;
|
|
143
129
|
return mapSlice(slice, function (maybeTable) {
|
|
144
130
|
if (maybeTable.type === table) {
|
|
145
131
|
var firstRow = maybeTable.firstChild;
|
|
146
|
-
|
|
147
132
|
if (firstRow) {
|
|
148
133
|
var headerCols = [];
|
|
149
134
|
firstRow.forEach(function (oldCol) {
|
|
@@ -153,25 +138,22 @@ export var transformSliceToAddTableHeaders = function transformSliceToAddTableHe
|
|
|
153
138
|
return maybeTable.copy(maybeTable.content.replaceChild(0, headerRow));
|
|
154
139
|
}
|
|
155
140
|
}
|
|
156
|
-
|
|
157
141
|
return maybeTable;
|
|
158
142
|
});
|
|
159
143
|
};
|
|
160
144
|
export var transformSliceToRemoveColumnsWidths = function transformSliceToRemoveColumnsWidths(slice, schema) {
|
|
161
145
|
var _schema$nodes3 = schema.nodes,
|
|
162
|
-
|
|
163
|
-
|
|
146
|
+
tableHeader = _schema$nodes3.tableHeader,
|
|
147
|
+
tableCell = _schema$nodes3.tableCell;
|
|
164
148
|
return mapSlice(slice, function (maybeCell) {
|
|
165
149
|
if (maybeCell.type === tableCell || maybeCell.type === tableHeader) {
|
|
166
150
|
if (!maybeCell.attrs.colwidth) {
|
|
167
151
|
return maybeCell;
|
|
168
152
|
}
|
|
169
|
-
|
|
170
153
|
return maybeCell.type.createChecked(_objectSpread(_objectSpread({}, maybeCell.attrs), {}, {
|
|
171
154
|
colwidth: undefined
|
|
172
155
|
}), maybeCell.content, maybeCell.marks);
|
|
173
156
|
}
|
|
174
|
-
|
|
175
157
|
return maybeCell;
|
|
176
158
|
});
|
|
177
159
|
};
|
|
@@ -179,102 +161,91 @@ export var deleteTable = function deleteTable(state, dispatch) {
|
|
|
179
161
|
if (dispatch) {
|
|
180
162
|
dispatch(removeTable(state.tr));
|
|
181
163
|
}
|
|
182
|
-
|
|
183
164
|
return true;
|
|
184
165
|
};
|
|
185
166
|
export var deleteTableIfSelected = function deleteTableIfSelected(state, dispatch) {
|
|
186
167
|
if (isTableSelected(state.selection)) {
|
|
187
168
|
return deleteTable(state, dispatch);
|
|
188
169
|
}
|
|
189
|
-
|
|
190
170
|
return false;
|
|
191
171
|
};
|
|
192
172
|
export var convertFirstRowToHeader = function convertFirstRowToHeader(schema) {
|
|
193
173
|
return function (tr) {
|
|
194
174
|
var table = findTable(tr.selection);
|
|
195
175
|
var map = TableMap.get(table.node);
|
|
196
|
-
|
|
197
176
|
for (var i = 0; i < map.width; i++) {
|
|
198
177
|
var cell = table.node.child(0).child(i);
|
|
199
178
|
tr.setNodeMarkup(table.start + map.map[i], schema.nodes.tableHeader, cell.attrs);
|
|
200
179
|
}
|
|
201
|
-
|
|
202
180
|
return tr;
|
|
203
181
|
};
|
|
204
182
|
};
|
|
205
183
|
export var moveCursorBackward = function moveCursorBackward(state, dispatch) {
|
|
206
184
|
var _ref = state.selection,
|
|
207
|
-
|
|
208
|
-
|
|
185
|
+
$cursor = _ref.$cursor;
|
|
186
|
+
// if cursor is in the middle of a text node, do nothing
|
|
209
187
|
if (!$cursor || $cursor.parentOffset > 0) {
|
|
210
188
|
return false;
|
|
211
|
-
}
|
|
212
|
-
|
|
189
|
+
}
|
|
213
190
|
|
|
191
|
+
// find the node before the cursor
|
|
214
192
|
var before;
|
|
215
193
|
var cut;
|
|
216
|
-
|
|
217
194
|
if (!isIsolating($cursor.parent)) {
|
|
218
195
|
for (var i = $cursor.depth - 1; !before && i >= 0; i--) {
|
|
219
196
|
if ($cursor.index(i) > 0) {
|
|
220
197
|
cut = $cursor.before(i + 1);
|
|
221
198
|
before = $cursor.node(i).child($cursor.index(i) - 1);
|
|
222
199
|
}
|
|
223
|
-
|
|
224
200
|
if (isIsolating($cursor.node(i))) {
|
|
225
201
|
break;
|
|
226
202
|
}
|
|
227
203
|
}
|
|
228
|
-
}
|
|
229
|
-
|
|
204
|
+
}
|
|
230
205
|
|
|
206
|
+
// if the node before is not a table node - do nothing
|
|
231
207
|
if (!before || before.type !== state.schema.nodes.table) {
|
|
232
208
|
return false;
|
|
233
209
|
}
|
|
210
|
+
|
|
234
211
|
/*
|
|
235
212
|
ensure we're just at a top level paragraph
|
|
236
213
|
otherwise, perform regular backspace behaviour
|
|
237
214
|
*/
|
|
238
|
-
|
|
239
|
-
|
|
240
215
|
var grandparent = $cursor.node($cursor.depth - 1);
|
|
241
|
-
|
|
242
216
|
if ($cursor.parent.type !== state.schema.nodes.paragraph || grandparent && grandparent.type !== state.schema.nodes.doc) {
|
|
243
217
|
return false;
|
|
244
218
|
}
|
|
245
|
-
|
|
246
219
|
var tr = state.tr;
|
|
247
|
-
var lastCellPos = (cut || 0) - 4;
|
|
248
|
-
|
|
220
|
+
var lastCellPos = (cut || 0) - 4;
|
|
221
|
+
// need to move cursor inside the table to be able to calculate table's offset
|
|
249
222
|
tr.setSelection(new TextSelection(state.doc.resolve(lastCellPos)));
|
|
250
223
|
var $from = tr.selection.$from;
|
|
251
224
|
var start = $from.start(-1);
|
|
252
|
-
var pos = start + $from.parent.nodeSize - 1;
|
|
225
|
+
var pos = start + $from.parent.nodeSize - 1;
|
|
226
|
+
|
|
227
|
+
// move cursor to the last cell
|
|
253
228
|
// it doesn't join node before (last cell) with node after (content after the cursor)
|
|
254
229
|
// due to ridiculous amount of PM code that would have been required to overwrite
|
|
230
|
+
tr.setSelection(new TextSelection(state.doc.resolve(pos)));
|
|
255
231
|
|
|
256
|
-
|
|
257
|
-
|
|
232
|
+
// if we are inside an empty paragraph not at the end of the doc we delete it
|
|
258
233
|
var cursorNode = $cursor.node();
|
|
259
234
|
var docEnd = state.doc.content.size;
|
|
260
235
|
var paragraphWrapStart = $cursor.pos - 1;
|
|
261
236
|
var paragraphWrapEnd = $cursor.pos + 1;
|
|
262
|
-
|
|
263
237
|
if (cursorNode.content.size === 0 && $cursor.pos + 1 !== docEnd) {
|
|
264
238
|
tr.delete(paragraphWrapStart, paragraphWrapEnd);
|
|
265
239
|
}
|
|
266
|
-
|
|
267
240
|
if (dispatch) {
|
|
268
241
|
dispatch(tr);
|
|
269
242
|
}
|
|
270
|
-
|
|
271
243
|
return true;
|
|
272
244
|
};
|
|
273
245
|
export var setMultipleCellAttrs = function setMultipleCellAttrs(attrs, targetCellPosition) {
|
|
274
246
|
return function (state, dispatch) {
|
|
275
247
|
var cursorPos;
|
|
276
248
|
var tr = state.tr;
|
|
277
|
-
|
|
278
249
|
if (isSelectionType(tr.selection, 'cell')) {
|
|
279
250
|
var selection = tr.selection;
|
|
280
251
|
selection.forEachCell(function (_cell, pos) {
|
|
@@ -287,28 +258,22 @@ export var setMultipleCellAttrs = function setMultipleCellAttrs(attrs, targetCel
|
|
|
287
258
|
tr = setCellAttrs(cell, attrs)(tr);
|
|
288
259
|
cursorPos = cell.pos;
|
|
289
260
|
}
|
|
290
|
-
|
|
291
261
|
if (tr.docChanged && cursorPos !== undefined) {
|
|
292
262
|
var $pos = tr.doc.resolve(tr.mapping.map(cursorPos));
|
|
293
|
-
|
|
294
263
|
if (dispatch) {
|
|
295
264
|
dispatch(tr.setSelection(Selection.near($pos)));
|
|
296
265
|
}
|
|
297
|
-
|
|
298
266
|
return true;
|
|
299
267
|
}
|
|
300
|
-
|
|
301
268
|
return false;
|
|
302
269
|
};
|
|
303
270
|
};
|
|
304
271
|
export var selectColumn = function selectColumn(column, expand) {
|
|
305
272
|
return createCommand(function (state) {
|
|
306
273
|
var cells = getCellsInColumn(column)(state.tr.selection);
|
|
307
|
-
|
|
308
274
|
if (!cells || !cells.length || typeof cells[0].pos !== 'number') {
|
|
309
275
|
return false;
|
|
310
276
|
}
|
|
311
|
-
|
|
312
277
|
var decorations = createColumnSelectedDecoration(selectColumnTransform(column, expand)(state.tr));
|
|
313
278
|
var decorationSet = updatePluginStateDecorations(state, decorations, TableDecorations.COLUMN_SELECTED);
|
|
314
279
|
var targetCellPosition = cells[0].pos;
|
|
@@ -327,11 +292,9 @@ export var selectRow = function selectRow(row, expand) {
|
|
|
327
292
|
return createCommand(function (state) {
|
|
328
293
|
var targetCellPosition;
|
|
329
294
|
var cells = getCellsInRow(row)(state.tr.selection);
|
|
330
|
-
|
|
331
295
|
if (cells && cells.length) {
|
|
332
296
|
targetCellPosition = cells[0].pos;
|
|
333
297
|
}
|
|
334
|
-
|
|
335
298
|
return {
|
|
336
299
|
type: 'SET_TARGET_CELL_POSITION',
|
|
337
300
|
data: {
|
|
@@ -376,14 +339,11 @@ export var hideInsertColumnOrRowButton = function hideInsertColumnOrRowButton()
|
|
|
376
339
|
export var addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex) {
|
|
377
340
|
return createCommand(function (state) {
|
|
378
341
|
var tableNode = findTable(state.selection);
|
|
379
|
-
|
|
380
342
|
var _getPluginState = getPluginState(state),
|
|
381
|
-
|
|
382
|
-
|
|
343
|
+
allowColumnResizing = _getPluginState.pluginConfig.allowColumnResizing;
|
|
383
344
|
if (!tableNode || !allowColumnResizing) {
|
|
384
345
|
return false;
|
|
385
346
|
}
|
|
386
|
-
|
|
387
347
|
return {
|
|
388
348
|
type: 'ADD_RESIZE_HANDLE_DECORATIONS',
|
|
389
349
|
data: {
|
|
@@ -406,24 +366,25 @@ export var autoSizeTable = function autoSizeTable(view, node, table, basePos, op
|
|
|
406
366
|
export var addBoldInEmptyHeaderCells = function addBoldInEmptyHeaderCells(tableCellHeader) {
|
|
407
367
|
return function (state, dispatch) {
|
|
408
368
|
var tr = state.tr;
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
isTextSelection(tr.selection) && tr.selection.$cursor &&
|
|
369
|
+
if (
|
|
370
|
+
// Avoid infinite loop when the current selection is not a TextSelection
|
|
371
|
+
isTextSelection(tr.selection) && tr.selection.$cursor &&
|
|
372
|
+
// When storedMark is null that means this is the initial state
|
|
412
373
|
// if the user press to remove the mark storedMark will be an empty array
|
|
413
374
|
// and we shouldn't apply the strong mark
|
|
414
|
-
tr.storedMarks == null &&
|
|
415
|
-
|
|
375
|
+
tr.storedMarks == null &&
|
|
376
|
+
// Check if the current node is a direct child from paragraph
|
|
377
|
+
tr.selection.$from.depth === tableCellHeader.depth + 1 &&
|
|
378
|
+
// this logic is applied only for empty paragraph
|
|
416
379
|
tableCellHeader.node.nodeSize === 4 && isParagraph(tableCellHeader.node.firstChild, state.schema)) {
|
|
417
380
|
var strong = state.schema.marks.strong;
|
|
418
381
|
tr.setStoredMarks([strong.create()]).setMeta('addToHistory', false);
|
|
419
|
-
|
|
420
382
|
if (dispatch) {
|
|
421
383
|
dispatch(tr);
|
|
422
384
|
}
|
|
423
|
-
|
|
424
385
|
return true;
|
|
425
386
|
}
|
|
426
|
-
|
|
427
387
|
return false;
|
|
428
388
|
};
|
|
429
|
-
};
|
|
389
|
+
};
|
|
390
|
+
// #endregion
|