@atlaskit/editor-plugin-table 0.0.0 → 0.0.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 +23 -0
- package/dist/cjs/plugins/table/commands/clear.js +64 -0
- package/dist/cjs/plugins/table/commands/collapse.js +24 -0
- package/dist/cjs/plugins/table/commands/go-to-next-cell.js +66 -0
- package/dist/cjs/plugins/table/commands/hover.js +183 -0
- package/dist/cjs/plugins/table/commands/index.js +235 -0
- package/dist/cjs/plugins/table/commands/insert.js +186 -0
- package/dist/cjs/plugins/table/commands/misc.js +509 -0
- package/dist/cjs/plugins/table/commands/selection.js +419 -0
- package/dist/cjs/plugins/table/commands/sort.js +94 -0
- package/dist/cjs/plugins/table/commands/split-cell.js +38 -0
- package/dist/cjs/plugins/table/commands/toggle.js +124 -0
- package/dist/cjs/plugins/table/commands-with-analytics.js +543 -0
- package/dist/cjs/plugins/table/create-plugin-config.js +31 -0
- package/dist/cjs/plugins/table/event-handlers.js +441 -0
- package/dist/cjs/plugins/table/handlers.js +155 -0
- package/dist/cjs/plugins/table/index.js +374 -0
- package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +182 -0
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +610 -0
- package/dist/cjs/plugins/table/nodeviews/table.js +261 -0
- package/dist/cjs/plugins/table/nodeviews/tableCell.js +123 -0
- package/dist/cjs/plugins/table/nodeviews/types.js +5 -0
- package/dist/cjs/plugins/table/nodeviews/update-overflow-shadows.js +67 -0
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +81 -0
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +88 -0
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-resizing.js +55 -0
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +21 -0
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/index.js +35 -0
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/types.js +5 -0
- package/dist/cjs/plugins/table/pm-plugins/default-table-selection.js +12 -0
- package/dist/cjs/plugins/table/pm-plugins/keymap.js +59 -0
- package/dist/cjs/plugins/table/pm-plugins/main.js +308 -0
- package/dist/cjs/plugins/table/pm-plugins/plugin-factory.js +65 -0
- package/dist/cjs/plugins/table/pm-plugins/plugin-key.js +11 -0
- package/dist/cjs/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +79 -0
- package/dist/cjs/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +118 -0
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/commands.js +30 -0
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/index.js +51 -0
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +46 -0
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +590 -0
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-key.js +11 -0
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-state.js +68 -0
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +34 -0
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/types.js +5 -0
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/util.js +25 -0
- package/dist/cjs/plugins/table/pm-plugins/table-local-id.js +205 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/commands.js +158 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +182 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/index.js +29 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-factory.js +40 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-key.js +11 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin.js +70 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/reducer.js +46 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +71 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/column-state.js +107 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/content-width.js +112 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +158 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/index.js +209 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +115 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-column.js +19 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +279 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +364 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +132 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/types.js +5 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.js +12 -0
- package/dist/cjs/plugins/table/pm-plugins/table-selection-keymap.js +23 -0
- package/dist/cjs/plugins/table/reducer.js +107 -0
- package/dist/cjs/plugins/table/todo-stubs.js +10 -0
- package/dist/cjs/plugins/table/toolbar.js +325 -0
- package/dist/cjs/plugins/table/transforms/column-width.js +196 -0
- package/dist/cjs/plugins/table/transforms/delete-columns.js +293 -0
- package/dist/cjs/plugins/table/transforms/delete-rows.js +176 -0
- package/dist/cjs/plugins/table/transforms/fix-tables.js +250 -0
- package/dist/cjs/plugins/table/transforms/index.js +85 -0
- package/dist/cjs/plugins/table/transforms/merge.js +349 -0
- package/dist/cjs/plugins/table/transforms/metadata.js +23 -0
- package/dist/cjs/plugins/table/transforms/replace-table.js +48 -0
- package/dist/cjs/plugins/table/transforms/split.js +92 -0
- package/dist/cjs/plugins/table/types.js +106 -0
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +194 -0
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/styles.js +26 -0
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +529 -0
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +116 -0
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/styles.js +34 -0
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +49 -0
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +71 -0
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +365 -0
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/types.js +5 -0
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +118 -0
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +108 -0
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +244 -0
- package/dist/cjs/plugins/table/ui/LayoutButton/index.js +255 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +140 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +146 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +135 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +229 -0
- package/dist/cjs/plugins/table/ui/common-styles.js +48 -0
- package/dist/cjs/plugins/table/ui/consts.js +109 -0
- package/dist/cjs/plugins/table/ui/messages.js +48 -0
- package/dist/cjs/plugins/table/ui/ui-styles.js +116 -0
- package/dist/cjs/plugins/table/utils/analytics.js +86 -0
- package/dist/cjs/plugins/table/utils/collapse.js +98 -0
- package/dist/cjs/plugins/table/utils/column-controls.js +234 -0
- package/dist/cjs/plugins/table/utils/decoration.js +405 -0
- package/dist/cjs/plugins/table/utils/dom.js +224 -0
- package/dist/cjs/plugins/table/utils/get-allow-add-column-custom-step.js +13 -0
- package/dist/cjs/plugins/table/utils/index.js +355 -0
- package/dist/cjs/plugins/table/utils/nodes.js +159 -0
- package/dist/cjs/plugins/table/utils/paste.js +148 -0
- package/dist/cjs/plugins/table/utils/referentiality.js +29 -0
- package/dist/cjs/plugins/table/utils/row-controls.js +254 -0
- package/dist/cjs/plugins/table/utils/selection.js +116 -0
- package/dist/cjs/plugins/table/utils/table.js +48 -0
- package/dist/cjs/plugins/table/utils/update-plugin-state-decorations.js +16 -0
- package/dist/cjs/plugins/table-plugin.js +4 -45
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/commands/clear.js +48 -0
- package/dist/es2019/plugins/table/commands/collapse.js +14 -0
- package/dist/es2019/plugins/table/commands/go-to-next-cell.js +47 -0
- package/dist/es2019/plugins/table/commands/hover.js +117 -0
- package/dist/es2019/plugins/table/commands/index.js +7 -0
- package/dist/es2019/plugins/table/commands/insert.js +141 -0
- package/dist/es2019/plugins/table/commands/misc.js +405 -0
- package/dist/es2019/plugins/table/commands/selection.js +369 -0
- package/dist/es2019/plugins/table/commands/sort.js +74 -0
- package/dist/es2019/plugins/table/commands/split-cell.js +29 -0
- package/dist/es2019/plugins/table/commands/toggle.js +76 -0
- package/dist/es2019/plugins/table/commands-with-analytics.js +409 -0
- package/dist/es2019/plugins/table/create-plugin-config.js +14 -0
- package/dist/es2019/plugins/table/event-handlers.js +387 -0
- package/dist/es2019/plugins/table/handlers.js +123 -0
- package/dist/es2019/plugins/table/index.js +340 -0
- package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +159 -0
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +578 -0
- package/dist/es2019/plugins/table/nodeviews/table.js +200 -0
- package/dist/es2019/plugins/table/nodeviews/tableCell.js +77 -0
- package/dist/es2019/plugins/table/nodeviews/types.js +1 -0
- package/dist/es2019/plugins/table/nodeviews/update-overflow-shadows.js +52 -0
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +52 -0
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +67 -0
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-resizing.js +27 -0
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +7 -0
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/index.js +3 -0
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/types.js +1 -0
- package/dist/es2019/plugins/table/pm-plugins/default-table-selection.js +5 -0
- package/dist/es2019/plugins/table/pm-plugins/keymap.js +34 -0
- package/dist/es2019/plugins/table/pm-plugins/main.js +274 -0
- package/dist/es2019/plugins/table/pm-plugins/plugin-factory.js +46 -0
- package/dist/es2019/plugins/table/pm-plugins/plugin-key.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +66 -0
- package/dist/es2019/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +106 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/commands.js +9 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/index.js +5 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +34 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +546 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin-key.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin-state.js +47 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin.js +17 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/types.js +1 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/util.js +14 -0
- package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +203 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/commands.js +109 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +173 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/index.js +3 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin-factory.js +20 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin-key.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin.js +58 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/reducer.js +31 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +45 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/column-state.js +78 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/content-width.js +97 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/dom.js +124 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/index.js +9 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +90 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-column.js +8 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +221 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +276 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +105 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/types.js +1 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.js +1 -0
- package/dist/es2019/plugins/table/pm-plugins/table-selection-keymap.js +10 -0
- package/dist/es2019/plugins/table/reducer.js +103 -0
- package/dist/es2019/plugins/table/todo-stubs.js +1 -0
- package/dist/es2019/plugins/table/toolbar.js +287 -0
- package/dist/es2019/plugins/table/transforms/column-width.js +163 -0
- package/dist/es2019/plugins/table/transforms/delete-columns.js +247 -0
- package/dist/es2019/plugins/table/transforms/delete-rows.js +135 -0
- package/dist/es2019/plugins/table/transforms/fix-tables.js +218 -0
- package/dist/es2019/plugins/table/transforms/index.js +7 -0
- package/dist/es2019/plugins/table/transforms/merge.js +312 -0
- package/dist/es2019/plugins/table/transforms/metadata.js +11 -0
- package/dist/es2019/plugins/table/transforms/replace-table.js +33 -0
- package/dist/es2019/plugins/table/transforms/split.js +72 -0
- package/dist/es2019/plugins/table/types.js +84 -0
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +142 -0
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/styles.js +28 -0
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +482 -0
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +99 -0
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/styles.js +48 -0
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +36 -0
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +59 -0
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +302 -0
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/types.js +1 -0
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +96 -0
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +96 -0
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +199 -0
- package/dist/es2019/plugins/table/ui/LayoutButton/index.js +195 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +95 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +91 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +82 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +158 -0
- package/dist/es2019/plugins/table/ui/common-styles.js +647 -0
- package/dist/es2019/plugins/table/ui/consts.js +61 -0
- package/dist/es2019/plugins/table/ui/messages.js +38 -0
- package/dist/es2019/plugins/table/ui/ui-styles.js +398 -0
- package/dist/es2019/plugins/table/utils/analytics.js +65 -0
- package/dist/es2019/plugins/table/utils/collapse.js +84 -0
- package/dist/es2019/plugins/table/utils/column-controls.js +178 -0
- package/dist/es2019/plugins/table/utils/decoration.js +346 -0
- package/dist/es2019/plugins/table/utils/dom.js +160 -0
- package/dist/es2019/plugins/table/utils/get-allow-add-column-custom-step.js +5 -0
- package/dist/es2019/plugins/table/utils/index.js +10 -0
- package/dist/es2019/plugins/table/utils/nodes.js +104 -0
- package/dist/es2019/plugins/table/utils/paste.js +117 -0
- package/dist/es2019/plugins/table/utils/referentiality.js +18 -0
- package/dist/es2019/plugins/table/utils/row-controls.js +210 -0
- package/dist/es2019/plugins/table/utils/selection.js +95 -0
- package/dist/es2019/plugins/table/utils/table.js +27 -0
- package/dist/es2019/plugins/table/utils/update-plugin-state-decorations.js +3 -0
- package/dist/es2019/plugins/table-plugin.js +1 -44
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/commands/clear.js +48 -0
- package/dist/esm/plugins/table/commands/collapse.js +14 -0
- package/dist/esm/plugins/table/commands/go-to-next-cell.js +50 -0
- package/dist/esm/plugins/table/commands/hover.js +149 -0
- package/dist/esm/plugins/table/commands/index.js +7 -0
- package/dist/esm/plugins/table/commands/insert.js +153 -0
- package/dist/esm/plugins/table/commands/misc.js +427 -0
- package/dist/esm/plugins/table/commands/selection.js +401 -0
- package/dist/esm/plugins/table/commands/sort.js +79 -0
- package/dist/esm/plugins/table/commands/split-cell.js +28 -0
- package/dist/esm/plugins/table/commands/toggle.js +97 -0
- package/dist/esm/plugins/table/commands-with-analytics.js +464 -0
- package/dist/esm/plugins/table/create-plugin-config.js +20 -0
- package/dist/esm/plugins/table/event-handlers.js +387 -0
- package/dist/esm/plugins/table/handlers.js +140 -0
- package/dist/esm/plugins/table/index.js +338 -0
- package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +177 -0
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +596 -0
- package/dist/esm/plugins/table/nodeviews/table.js +235 -0
- package/dist/esm/plugins/table/nodeviews/tableCell.js +111 -0
- package/dist/esm/plugins/table/nodeviews/types.js +1 -0
- package/dist/esm/plugins/table/nodeviews/update-overflow-shadows.js +54 -0
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +58 -0
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +71 -0
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-resizing.js +40 -0
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +12 -0
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/index.js +3 -0
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/types.js +1 -0
- package/dist/esm/plugins/table/pm-plugins/default-table-selection.js +5 -0
- package/dist/esm/plugins/table/pm-plugins/keymap.js +36 -0
- package/dist/esm/plugins/table/pm-plugins/main.js +278 -0
- package/dist/esm/plugins/table/pm-plugins/plugin-factory.js +51 -0
- package/dist/esm/plugins/table/pm-plugins/plugin-key.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +66 -0
- package/dist/esm/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +102 -0
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/commands.js +17 -0
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/index.js +5 -0
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +34 -0
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +588 -0
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin-key.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin-state.js +57 -0
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin.js +21 -0
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/types.js +1 -0
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/util.js +16 -0
- package/dist/esm/plugins/table/pm-plugins/table-local-id.js +205 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/commands.js +127 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +159 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/index.js +3 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin-factory.js +26 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin-key.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin.js +52 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/reducer.js +35 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +50 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/column-state.js +80 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/content-width.js +104 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/dom.js +125 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/index.js +9 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +88 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-column.js +8 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +257 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +320 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +109 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/types.js +1 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.js +3 -0
- package/dist/esm/plugins/table/pm-plugins/table-selection-keymap.js +10 -0
- package/dist/esm/plugins/table/reducer.js +95 -0
- package/dist/esm/plugins/table/todo-stubs.js +1 -0
- package/dist/esm/plugins/table/toolbar.js +290 -0
- package/dist/esm/plugins/table/transforms/column-width.js +175 -0
- package/dist/esm/plugins/table/transforms/delete-columns.js +271 -0
- package/dist/esm/plugins/table/transforms/delete-rows.js +156 -0
- package/dist/esm/plugins/table/transforms/fix-tables.js +229 -0
- package/dist/esm/plugins/table/transforms/index.js +7 -0
- package/dist/esm/plugins/table/transforms/merge.js +324 -0
- package/dist/esm/plugins/table/transforms/metadata.js +13 -0
- package/dist/esm/plugins/table/transforms/replace-table.js +34 -0
- package/dist/esm/plugins/table/transforms/split.js +82 -0
- package/dist/esm/plugins/table/types.js +90 -0
- package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +167 -0
- package/dist/esm/plugins/table/ui/FloatingContextualButton/styles.js +11 -0
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +501 -0
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +96 -0
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/styles.js +15 -0
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +37 -0
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +61 -0
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +333 -0
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/types.js +1 -0
- package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +90 -0
- package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +96 -0
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +214 -0
- package/dist/esm/plugins/table/ui/LayoutButton/index.js +227 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +120 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +126 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +113 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +207 -0
- package/dist/esm/plugins/table/ui/common-styles.js +25 -0
- package/dist/esm/plugins/table/ui/consts.js +61 -0
- package/dist/esm/plugins/table/ui/messages.js +38 -0
- package/dist/esm/plugins/table/ui/ui-styles.js +73 -0
- package/dist/esm/plugins/table/utils/analytics.js +71 -0
- package/dist/esm/plugins/table/utils/collapse.js +84 -0
- package/dist/esm/plugins/table/utils/column-controls.js +202 -0
- package/dist/esm/plugins/table/utils/decoration.js +366 -0
- package/dist/esm/plugins/table/utils/dom.js +175 -0
- package/dist/esm/plugins/table/utils/get-allow-add-column-custom-step.js +5 -0
- package/dist/esm/plugins/table/utils/index.js +10 -0
- package/dist/esm/plugins/table/utils/nodes.js +112 -0
- package/dist/esm/plugins/table/utils/paste.js +115 -0
- package/dist/esm/plugins/table/utils/referentiality.js +20 -0
- package/dist/esm/plugins/table/utils/row-controls.js +221 -0
- package/dist/esm/plugins/table/utils/selection.js +96 -0
- package/dist/esm/plugins/table/utils/table.js +30 -0
- package/dist/esm/plugins/table/utils/update-plugin-state-decorations.js +5 -0
- package/dist/esm/plugins/table-plugin.js +1 -42
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/commands/clear.d.ts +3 -0
- package/dist/types/plugins/table/commands/collapse.d.ts +2 -0
- package/dist/types/plugins/table/commands/go-to-next-cell.d.ts +4 -0
- package/dist/types/plugins/table/commands/hover.d.ts +8 -0
- package/dist/types/plugins/table/commands/index.d.ts +7 -0
- package/dist/types/plugins/table/commands/insert.d.ts +10 -0
- package/dist/types/plugins/table/commands/misc.d.ts +27 -0
- package/dist/types/plugins/table/commands/selection.d.ts +8 -0
- package/dist/types/plugins/table/commands/sort.d.ts +3 -0
- package/dist/types/plugins/table/commands/split-cell.d.ts +6 -0
- package/dist/types/plugins/table/commands/toggle.d.ts +12 -0
- package/dist/types/plugins/table/commands-with-analytics.d.ts +26 -0
- package/dist/types/plugins/table/create-plugin-config.d.ts +2 -0
- package/dist/types/plugins/table/event-handlers.d.ts +16 -0
- package/dist/types/plugins/table/handlers.d.ts +3 -0
- package/dist/types/plugins/table/index.d.ts +17 -0
- package/dist/types/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +26 -0
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +72 -0
- package/dist/types/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.d.ts +9 -0
- package/dist/types/plugins/table/nodeviews/__mocks__/OverridableMock.d.ts +9 -0
- package/dist/types/plugins/table/nodeviews/table.d.ts +31 -0
- package/dist/types/plugins/table/nodeviews/tableCell.d.ts +19 -0
- package/dist/types/plugins/table/nodeviews/types.d.ts +23 -0
- package/dist/types/plugins/table/nodeviews/update-overflow-shadows.d.ts +8 -0
- package/dist/types/plugins/table/pm-plugins/decorations/plugin.d.ts +7 -0
- package/dist/types/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/decorations/utils/index.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/decorations/utils/types.d.ts +6 -0
- package/dist/types/plugins/table/pm-plugins/default-table-selection.d.ts +5 -0
- package/dist/types/plugins/table/pm-plugins/keymap.d.ts +5 -0
- package/dist/types/plugins/table/pm-plugins/main.d.ts +8 -0
- package/dist/types/plugins/table/pm-plugins/plugin-factory.d.ts +1 -0
- package/dist/types/plugins/table/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.d.ts +4 -0
- package/dist/types/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +15 -0
- package/dist/types/plugins/table/pm-plugins/sticky-headers/commands.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/sticky-headers/index.d.ts +6 -0
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +6 -0
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +65 -0
- package/dist/types/plugins/table/pm-plugins/sticky-headers/plugin-key.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +4 -0
- package/dist/types/plugins/table/pm-plugins/sticky-headers/types.d.ts +16 -0
- package/dist/types/plugins/table/pm-plugins/sticky-headers/util.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/table-local-id.d.ts +22 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/commands.d.ts +25 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +4 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/index.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +4 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/plugin-key.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/plugin.d.ts +6 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/reducer.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +8 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/column-state.d.ts +14 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/content-width.d.ts +4 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +13 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +12 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +22 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +29 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +17 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/types.d.ts +22 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.d.ts +1 -0
- package/dist/types/plugins/table/pm-plugins/table-selection-keymap.d.ts +4 -0
- package/dist/types/plugins/table/reducer.d.ts +3 -0
- package/dist/types/plugins/table/todo-stubs.d.ts +1 -0
- package/dist/types/plugins/table/toolbar.d.ts +36 -0
- package/dist/types/plugins/table/transforms/column-width.d.ts +18 -0
- package/dist/types/plugins/table/transforms/delete-columns.d.ts +3 -0
- package/dist/types/plugins/table/transforms/delete-rows.d.ts +3 -0
- package/dist/types/plugins/table/transforms/fix-tables.d.ts +10 -0
- package/dist/types/plugins/table/transforms/index.d.ts +7 -0
- package/dist/types/plugins/table/transforms/merge.d.ts +5 -0
- package/dist/types/plugins/table/transforms/metadata.d.ts +21 -0
- package/dist/types/plugins/table/transforms/replace-table.d.ts +5 -0
- package/dist/types/plugins/table/transforms/split.d.ts +9 -0
- package/dist/types/plugins/table/types.d.ts +328 -0
- package/dist/types/plugins/table/ui/FloatingContextualButton/index.d.ts +29 -0
- package/dist/types/plugins/table/ui/FloatingContextualButton/styles.d.ts +1 -0
- package/dist/types/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +87 -0
- package/dist/types/plugins/table/ui/FloatingContextualMenu/index.d.ts +22 -0
- package/dist/types/plugins/table/ui/FloatingContextualMenu/styles.d.ts +2 -0
- package/dist/types/plugins/table/ui/FloatingDeleteButton/DeleteButton.d.ts +14 -0
- package/dist/types/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.d.ts +10 -0
- package/dist/types/plugins/table/ui/FloatingDeleteButton/index.d.ts +54 -0
- package/dist/types/plugins/table/ui/FloatingDeleteButton/types.d.ts +1 -0
- package/dist/types/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +12 -0
- package/dist/types/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +3 -0
- package/dist/types/plugins/table/ui/FloatingInsertButton/index.d.ts +35 -0
- package/dist/types/plugins/table/ui/LayoutButton/index.d.ts +21 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +19 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +21 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +17 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +40 -0
- package/dist/types/plugins/table/ui/common-styles.d.ts +4 -0
- package/dist/types/plugins/table/ui/consts.d.ts +39 -0
- package/dist/types/plugins/table/ui/messages.d.ts +38 -0
- package/dist/types/plugins/table/ui/ui-styles.d.ts +15 -0
- package/dist/types/plugins/table/utils/analytics.d.ts +18 -0
- package/dist/types/plugins/table/utils/collapse.d.ts +29 -0
- package/dist/types/plugins/table/utils/column-controls.d.ts +10 -0
- package/dist/types/plugins/table/utils/decoration.d.ts +13 -0
- package/dist/types/plugins/table/utils/dom.d.ts +17 -0
- package/dist/types/plugins/table/utils/get-allow-add-column-custom-step.d.ts +2 -0
- package/dist/types/plugins/table/utils/index.d.ts +11 -0
- package/dist/types/plugins/table/utils/nodes.d.ts +12 -0
- package/dist/types/plugins/table/utils/paste.d.ts +14 -0
- package/dist/types/plugins/table/utils/referentiality.d.ts +2 -0
- package/dist/types/plugins/table/utils/row-controls.d.ts +16 -0
- package/dist/types/plugins/table/utils/selection.d.ts +6 -0
- package/dist/types/plugins/table/utils/table.d.ts +4 -0
- package/dist/types/plugins/table/utils/update-plugin-state-decorations.d.ts +4 -0
- package/dist/types/plugins/table-plugin.d.ts +1 -1
- package/package.json +27 -5
- package/report.api.md +90 -4
- package/src/plugins/table/__tests__/integration/block-node-selection.ts +164 -0
- package/src/plugins/table/__tests__/unit/commands/go-to-next-cell.ts +155 -0
- package/src/plugins/table/__tests__/unit/commands/insert.ts +115 -0
- package/src/plugins/table/__tests__/unit/commands/misc.ts +165 -0
- package/src/plugins/table/__tests__/unit/commands.ts +982 -0
- package/src/plugins/table/__tests__/unit/event-handlers.ts +130 -0
- package/src/plugins/table/__tests__/unit/get-toolbar-config.ts +140 -0
- package/src/plugins/table/__tests__/unit/nodeviews/OverflowShadowsObserver.ts +153 -0
- package/src/plugins/table/__tests__/unit/nodeviews/TableComponent.tsx +388 -0
- package/src/plugins/table/__tests__/unit/nodeviews/table.ts +121 -0
- package/src/plugins/table/__tests__/unit/pm-plugins/decorations/column-controls.ts +34 -0
- package/src/plugins/table/__tests__/unit/pm-plugins/decorations/column-resizing.ts +152 -0
- package/src/plugins/table/__tests__/unit/pm-plugins/decorations/plugin.ts +140 -0
- package/src/plugins/table/__tests__/unit/pm-plugins/main-with-allow-collapse.ts +100 -0
- package/src/plugins/table/__tests__/unit/pm-plugins/main.ts +187 -0
- package/src/plugins/table/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +83 -0
- package/src/plugins/table/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +603 -0
- package/src/plugins/table/__tests__/unit/pm-plugins/table-local-id.ts +515 -0
- package/src/plugins/table/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +86 -0
- package/src/plugins/table/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +134 -0
- package/src/plugins/table/__tests__/unit/pm-plugins/table-selection-keymap.ts +564 -0
- package/src/plugins/table/__tests__/unit/toolbar.ts +240 -0
- package/src/plugins/table/__tests__/unit/utils/collapse.ts +74 -0
- package/src/plugins/table/__tests__/unit/utils/column-controls.ts +61 -0
- package/src/plugins/table/__tests__/visual-regression/__fixtures__/table-with-100-numbered-list-items.json +20272 -0
- package/src/plugins/table/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-should-remove-the-table-column-on-click-1-snap.png +3 -0
- package/src/plugins/table/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +3 -0
- package/src/plugins/table/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +3 -0
- package/src/plugins/table/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +3 -0
- package/src/plugins/table/__tests__/visual-regression/__image_snapshots__/copy-button-ts-floating-toolbar-copy-button-table-target-node-displays-blue-border-when-copy-button-is-hovered-1-snap.png +3 -0
- package/src/plugins/table/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-1-snap.png +3 -0
- package/src/plugins/table/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-2-snap.png +3 -0
- package/src/plugins/table/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-3-snap.png +3 -0
- package/src/plugins/table/__tests__/visual-regression/cell-options-menu.ts +97 -0
- package/src/plugins/table/__tests__/visual-regression/index.ts +42 -0
- package/src/plugins/table/commands/clear.ts +58 -0
- package/src/plugins/table/commands/collapse.ts +16 -0
- package/src/plugins/table/commands/go-to-next-cell.ts +56 -0
- package/src/plugins/table/commands/hover.ts +192 -0
- package/src/plugins/table/commands/index.ts +40 -0
- package/src/plugins/table/commands/insert.ts +174 -0
- package/src/plugins/table/commands/misc.ts +506 -0
- package/src/plugins/table/commands/selection.ts +406 -0
- package/src/plugins/table/commands/sort.ts +109 -0
- package/src/plugins/table/commands/split-cell.ts +28 -0
- package/src/plugins/table/commands/toggle.ts +93 -0
- package/src/plugins/table/commands-with-analytics.ts +523 -0
- package/src/plugins/table/create-plugin-config.ts +18 -0
- package/src/plugins/table/event-handlers.ts +514 -0
- package/src/plugins/table/handlers.ts +169 -0
- package/src/plugins/table/index.tsx +440 -0
- package/src/plugins/table/nodeviews/OverflowShadowsObserver.ts +189 -0
- package/src/plugins/table/nodeviews/TableComponent.tsx +693 -0
- package/src/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.ts +13 -0
- package/src/plugins/table/nodeviews/__mocks__/OverridableMock.ts +21 -0
- package/src/plugins/table/nodeviews/table.tsx +241 -0
- package/src/plugins/table/nodeviews/tableCell.tsx +110 -0
- package/src/plugins/table/nodeviews/types.ts +29 -0
- package/src/plugins/table/nodeviews/update-overflow-shadows.ts +72 -0
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +74 -0
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +89 -0
- package/src/plugins/table/pm-plugins/decorations/utils/column-resizing.ts +46 -0
- package/src/plugins/table/pm-plugins/decorations/utils/compose-decorations.ts +11 -0
- package/src/plugins/table/pm-plugins/decorations/utils/index.ts +6 -0
- package/src/plugins/table/pm-plugins/decorations/utils/types.ts +10 -0
- package/src/plugins/table/pm-plugins/default-table-selection.ts +5 -0
- package/src/plugins/table/pm-plugins/keymap.ts +108 -0
- package/src/plugins/table/pm-plugins/main.ts +399 -0
- package/src/plugins/table/pm-plugins/plugin-factory.ts +43 -0
- package/src/plugins/table/pm-plugins/plugin-key.ts +4 -0
- package/src/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.ts +78 -0
- package/src/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.ts +118 -0
- package/src/plugins/table/pm-plugins/sticky-headers/commands.ts +12 -0
- package/src/plugins/table/pm-plugins/sticky-headers/index.ts +7 -0
- package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.ts +37 -0
- package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +658 -0
- package/src/plugins/table/pm-plugins/sticky-headers/plugin-key.ts +6 -0
- package/src/plugins/table/pm-plugins/sticky-headers/plugin-state.ts +55 -0
- package/src/plugins/table/pm-plugins/sticky-headers/plugin.ts +36 -0
- package/src/plugins/table/pm-plugins/sticky-headers/types.ts +20 -0
- package/src/plugins/table/pm-plugins/sticky-headers/util.ts +18 -0
- package/src/plugins/table/pm-plugins/table-local-id.ts +203 -0
- package/src/plugins/table/pm-plugins/table-resizing/commands.ts +168 -0
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +218 -0
- package/src/plugins/table/pm-plugins/table-resizing/index.ts +3 -0
- package/src/plugins/table/pm-plugins/table-resizing/plugin-factory.ts +28 -0
- package/src/plugins/table/pm-plugins/table-resizing/plugin-key.ts +6 -0
- package/src/plugins/table/pm-plugins/table-resizing/plugin.ts +79 -0
- package/src/plugins/table/pm-plugins/table-resizing/reducer.ts +40 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/colgroup.ts +58 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/column-state.ts +122 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/content-width.ts +130 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +176 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/index.ts +37 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +136 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/resize-column.ts +23 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/resize-logic.ts +275 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/resize-state.ts +348 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/scale-table.ts +142 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/types.ts +23 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.ts +2 -0
- package/src/plugins/table/pm-plugins/table-selection-keymap.ts +32 -0
- package/src/plugins/table/reducer.ts +106 -0
- package/src/plugins/table/todo-stubs.ts +1 -0
- package/src/plugins/table/toolbar.ts +401 -0
- package/src/plugins/table/transforms/column-width.ts +187 -0
- package/src/plugins/table/transforms/delete-columns.ts +251 -0
- package/src/plugins/table/transforms/delete-rows.ts +150 -0
- package/src/plugins/table/transforms/fix-tables.ts +296 -0
- package/src/plugins/table/transforms/index.ts +7 -0
- package/src/plugins/table/transforms/merge.ts +312 -0
- package/src/plugins/table/transforms/metadata.ts +35 -0
- package/src/plugins/table/transforms/replace-table.ts +48 -0
- package/src/plugins/table/transforms/split.ts +99 -0
- package/src/plugins/table/types.ts +345 -0
- package/src/plugins/table/ui/FloatingContextualButton/index.tsx +196 -0
- package/src/plugins/table/ui/FloatingContextualButton/styles.ts +29 -0
- package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +524 -0
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/ContextualMenu.tsx +55 -0
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/FloatingContextualMenu.tsx +49 -0
- package/src/plugins/table/ui/FloatingContextualMenu/index.tsx +131 -0
- package/src/plugins/table/ui/FloatingContextualMenu/styles.ts +53 -0
- package/src/plugins/table/ui/FloatingDeleteButton/DeleteButton.tsx +49 -0
- package/src/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.ts +75 -0
- package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +384 -0
- package/src/plugins/table/ui/FloatingDeleteButton/types.ts +1 -0
- package/src/plugins/table/ui/FloatingInsertButton/InsertButton.tsx +132 -0
- package/src/plugins/table/ui/FloatingInsertButton/getPopupOptions.ts +122 -0
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +268 -0
- package/src/plugins/table/ui/LayoutButton/index.tsx +220 -0
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +105 -0
- package/src/plugins/table/ui/TableFloatingControls/NumberColumn/index.tsx +108 -0
- package/src/plugins/table/ui/TableFloatingControls/RowControls/index.tsx +119 -0
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +202 -0
- package/src/plugins/table/ui/common-styles.ts +726 -0
- package/src/plugins/table/ui/consts.ts +100 -0
- package/src/plugins/table/ui/messages.ts +43 -0
- package/src/plugins/table/ui/ui-styles.ts +459 -0
- package/src/plugins/table/utils/analytics.ts +81 -0
- package/src/plugins/table/utils/collapse.ts +99 -0
- package/src/plugins/table/utils/column-controls.ts +225 -0
- package/src/plugins/table/utils/decoration.ts +456 -0
- package/src/plugins/table/utils/dom.ts +211 -0
- package/src/plugins/table/utils/get-allow-add-column-custom-step.ts +11 -0
- package/src/plugins/table/utils/index.ts +69 -0
- package/src/plugins/table/utils/nodes.ts +140 -0
- package/src/plugins/table/utils/paste.ts +164 -0
- package/src/plugins/table/utils/referentiality.ts +24 -0
- package/src/plugins/table/utils/row-controls.ts +238 -0
- package/src/plugins/table/utils/selection.ts +107 -0
- package/src/plugins/table/utils/table.ts +31 -0
- package/src/plugins/table/utils/update-plugin-state-decorations.ts +14 -0
- package/src/plugins/table-plugin.ts +1 -38
|
@@ -0,0 +1,982 @@
|
|
|
1
|
+
import { Fragment, Slice } from 'prosemirror-model';
|
|
2
|
+
import { TextSelection } from 'prosemirror-state';
|
|
3
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
|
+
import { findParentNodeOfType } from 'prosemirror-utils';
|
|
5
|
+
import { isRowSelected } from '@atlaskit/editor-tables/utils';
|
|
6
|
+
import { EditorView } from 'prosemirror-view';
|
|
7
|
+
|
|
8
|
+
import { uuid } from '@atlaskit/adf-schema';
|
|
9
|
+
import { defaultSchema } from '@atlaskit/adf-schema/schema-default';
|
|
10
|
+
import {
|
|
11
|
+
createProsemirrorEditorFactory,
|
|
12
|
+
LightEditorPlugin,
|
|
13
|
+
Preset,
|
|
14
|
+
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
15
|
+
import {
|
|
16
|
+
doc,
|
|
17
|
+
p,
|
|
18
|
+
panelNote,
|
|
19
|
+
table,
|
|
20
|
+
td,
|
|
21
|
+
tdCursor,
|
|
22
|
+
tdEmpty,
|
|
23
|
+
thCursor,
|
|
24
|
+
thEmpty,
|
|
25
|
+
th,
|
|
26
|
+
tr,
|
|
27
|
+
expand,
|
|
28
|
+
bodiedExtension,
|
|
29
|
+
DocBuilder,
|
|
30
|
+
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
31
|
+
|
|
32
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
33
|
+
import {
|
|
34
|
+
getFreshMediaProvider,
|
|
35
|
+
temporaryMediaGroup,
|
|
36
|
+
} from '@atlaskit/editor-test-helpers/media-provider';
|
|
37
|
+
|
|
38
|
+
import type { EditorProps } from '@atlaskit/editor-core';
|
|
39
|
+
import {
|
|
40
|
+
addBoldInEmptyHeaderCells,
|
|
41
|
+
clearMultipleCells,
|
|
42
|
+
selectColumn,
|
|
43
|
+
selectRow,
|
|
44
|
+
setEditorFocus,
|
|
45
|
+
setMultipleCellAttrs,
|
|
46
|
+
setTableRef,
|
|
47
|
+
toggleContextualMenu,
|
|
48
|
+
toggleHeaderColumn,
|
|
49
|
+
toggleHeaderRow,
|
|
50
|
+
transformSliceToAddTableHeaders,
|
|
51
|
+
} from '../../commands';
|
|
52
|
+
import { splitCell } from '../../commands/split-cell';
|
|
53
|
+
import { wrapTableInExpand } from '../../commands/collapse';
|
|
54
|
+
import { handleCut } from '../../event-handlers';
|
|
55
|
+
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
56
|
+
import { pluginKey } from '../../pm-plugins/plugin-key';
|
|
57
|
+
import tablePlugin from '../../../table';
|
|
58
|
+
import panelPlugin from '@atlaskit/editor-core/src/plugins/panel';
|
|
59
|
+
import expandPlugin from '@atlaskit/editor-core/src/plugins/expand';
|
|
60
|
+
import extensionPlugin from '@atlaskit/editor-core/src/plugins/extension';
|
|
61
|
+
import mediaPlugin from '@atlaskit/editor-core/src/plugins/media';
|
|
62
|
+
import textFormattingPlugin from '@atlaskit/editor-core/src/plugins/text-formatting';
|
|
63
|
+
|
|
64
|
+
const TABLE_LOCAL_ID = 'test-table-local-id';
|
|
65
|
+
|
|
66
|
+
describe('table plugin: actions', () => {
|
|
67
|
+
beforeAll(() => {
|
|
68
|
+
uuid.setStatic(TABLE_LOCAL_ID);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
afterAll(() => {
|
|
72
|
+
uuid.setStatic(false);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
76
|
+
const editor = (doc: DocBuilder, props: Partial<EditorProps> = {}) =>
|
|
77
|
+
createEditor({
|
|
78
|
+
doc,
|
|
79
|
+
attachTo: document.body,
|
|
80
|
+
preset: new Preset<LightEditorPlugin>()
|
|
81
|
+
.add(tablePlugin)
|
|
82
|
+
.add(panelPlugin)
|
|
83
|
+
.add(textFormattingPlugin)
|
|
84
|
+
.add(extensionPlugin)
|
|
85
|
+
.add([mediaPlugin, { allowMediaSingle: true }])
|
|
86
|
+
.add(expandPlugin),
|
|
87
|
+
pluginKey,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('transformSliceToAddTableHeaders', () => {
|
|
91
|
+
const textNode = defaultSchema.text('hello', undefined);
|
|
92
|
+
const paragraphNode = defaultSchema.nodes.paragraph.createChecked(
|
|
93
|
+
undefined,
|
|
94
|
+
defaultSchema.text('within paragraph', [
|
|
95
|
+
defaultSchema.marks.strong.create(),
|
|
96
|
+
]),
|
|
97
|
+
undefined,
|
|
98
|
+
);
|
|
99
|
+
const ruleNode = defaultSchema.nodes.rule.createChecked();
|
|
100
|
+
|
|
101
|
+
const tableBody = tr(
|
|
102
|
+
td({ colwidth: [300] })(p('r4')),
|
|
103
|
+
td()(p('r5')),
|
|
104
|
+
td()(panelNote(p('r6'))),
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
it('handles an empty fragment', () => {
|
|
108
|
+
const slice = new Slice(Fragment.from(undefined), 0, 0);
|
|
109
|
+
expect(
|
|
110
|
+
transformSliceToAddTableHeaders(slice, defaultSchema).eq(slice),
|
|
111
|
+
).toBe(true);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('does nothing to a text fragment', () => {
|
|
115
|
+
const slice = new Slice(Fragment.from(textNode), 0, 0);
|
|
116
|
+
expect(
|
|
117
|
+
transformSliceToAddTableHeaders(slice, defaultSchema).eq(slice),
|
|
118
|
+
).toBe(true);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('does nothing to fragment with multiple non-table nodes', () => {
|
|
122
|
+
const slice = new Slice(
|
|
123
|
+
Fragment.from([textNode, ruleNode, paragraphNode]),
|
|
124
|
+
1,
|
|
125
|
+
0,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
expect(
|
|
129
|
+
transformSliceToAddTableHeaders(slice, defaultSchema).eq(slice),
|
|
130
|
+
).toBe(true);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('transforms only the table within the slice', () => {
|
|
134
|
+
const preTable = table({
|
|
135
|
+
isNumberColumnEnabled: true,
|
|
136
|
+
localId: TABLE_LOCAL_ID,
|
|
137
|
+
})(
|
|
138
|
+
tr(
|
|
139
|
+
td()(p('r1')),
|
|
140
|
+
th({ colspan: 2 })(p('r2')),
|
|
141
|
+
td()(panelNote(p('r3'))),
|
|
142
|
+
),
|
|
143
|
+
|
|
144
|
+
tableBody,
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const postTable = table({
|
|
148
|
+
isNumberColumnEnabled: true,
|
|
149
|
+
localId: TABLE_LOCAL_ID,
|
|
150
|
+
})(
|
|
151
|
+
tr(
|
|
152
|
+
th()(p('r1')),
|
|
153
|
+
th({ colspan: 2 })(p('r2')),
|
|
154
|
+
th()(panelNote(p('r3'))),
|
|
155
|
+
),
|
|
156
|
+
|
|
157
|
+
tableBody,
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
const preSlice = new Slice(
|
|
161
|
+
Fragment.from([textNode, preTable(defaultSchema), paragraphNode]),
|
|
162
|
+
1,
|
|
163
|
+
0,
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const postSlice = new Slice(
|
|
167
|
+
Fragment.from([textNode, postTable(defaultSchema), paragraphNode]),
|
|
168
|
+
1,
|
|
169
|
+
0,
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
expect(
|
|
173
|
+
transformSliceToAddTableHeaders(preSlice, defaultSchema).eq(postSlice),
|
|
174
|
+
).toBe(true);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('transforms any table within the slice', () => {
|
|
178
|
+
const preTableA = table({
|
|
179
|
+
isNumberColumnEnabled: true,
|
|
180
|
+
localId: TABLE_LOCAL_ID,
|
|
181
|
+
})(
|
|
182
|
+
tr(
|
|
183
|
+
td()(p('r1')),
|
|
184
|
+
th({ colspan: 2 })(p('r2')),
|
|
185
|
+
td()(panelNote(p('r3'))),
|
|
186
|
+
),
|
|
187
|
+
|
|
188
|
+
tableBody,
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
const postTableA = table({
|
|
192
|
+
isNumberColumnEnabled: true,
|
|
193
|
+
localId: TABLE_LOCAL_ID,
|
|
194
|
+
})(
|
|
195
|
+
tr(
|
|
196
|
+
th()(p('r1')),
|
|
197
|
+
th({ colspan: 2 })(p('r2')),
|
|
198
|
+
th()(panelNote(p('r3'))),
|
|
199
|
+
),
|
|
200
|
+
|
|
201
|
+
tableBody,
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
const preTableB = table({
|
|
205
|
+
isNumberColumnEnabled: true,
|
|
206
|
+
localId: TABLE_LOCAL_ID,
|
|
207
|
+
})(
|
|
208
|
+
tr(td()(p('b1')), th()(p('b2')), th()(p('b3'))),
|
|
209
|
+
|
|
210
|
+
tableBody,
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
const postTableB = table({
|
|
214
|
+
isNumberColumnEnabled: true,
|
|
215
|
+
localId: TABLE_LOCAL_ID,
|
|
216
|
+
})(
|
|
217
|
+
tr(th()(p('b1')), th()(p('b2')), th()(p('b3'))),
|
|
218
|
+
|
|
219
|
+
tableBody,
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
const preSlice = new Slice(
|
|
223
|
+
Fragment.from([
|
|
224
|
+
textNode,
|
|
225
|
+
preTableA(defaultSchema),
|
|
226
|
+
paragraphNode,
|
|
227
|
+
preTableB(defaultSchema),
|
|
228
|
+
]),
|
|
229
|
+
1,
|
|
230
|
+
0,
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
const postSlice = new Slice(
|
|
234
|
+
Fragment.from([
|
|
235
|
+
textNode,
|
|
236
|
+
postTableA(defaultSchema),
|
|
237
|
+
paragraphNode,
|
|
238
|
+
postTableB(defaultSchema),
|
|
239
|
+
]),
|
|
240
|
+
1,
|
|
241
|
+
0,
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
expect(
|
|
245
|
+
transformSliceToAddTableHeaders(preSlice, defaultSchema).eq(postSlice),
|
|
246
|
+
).toBe(true);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
describe('#clearMultipleCells', () => {
|
|
251
|
+
it('should empty selected cells', () => {
|
|
252
|
+
const { editorView } = editor(
|
|
253
|
+
doc(
|
|
254
|
+
p('text'),
|
|
255
|
+
table()(
|
|
256
|
+
tr(td()(p('c1')), tdEmpty),
|
|
257
|
+
tr(td()(panelNote(p('text'))), tdEmpty),
|
|
258
|
+
),
|
|
259
|
+
),
|
|
260
|
+
);
|
|
261
|
+
const { state, dispatch } = editorView;
|
|
262
|
+
selectColumn(0)(state, dispatch);
|
|
263
|
+
clearMultipleCells()(editorView.state, dispatch);
|
|
264
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
265
|
+
doc(
|
|
266
|
+
p('text'),
|
|
267
|
+
table({ localId: TABLE_LOCAL_ID })(
|
|
268
|
+
tr(tdEmpty, tdEmpty),
|
|
269
|
+
tr(tdEmpty, tdEmpty),
|
|
270
|
+
),
|
|
271
|
+
),
|
|
272
|
+
);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it('should empty cell with the cursor', () => {
|
|
276
|
+
const { editorView } = editor(
|
|
277
|
+
doc(
|
|
278
|
+
p('text'),
|
|
279
|
+
table()(
|
|
280
|
+
tr(td()(p('c1')), tdEmpty),
|
|
281
|
+
tr(td()(panelNote(p('te{<>}xt'))), tdEmpty),
|
|
282
|
+
),
|
|
283
|
+
),
|
|
284
|
+
);
|
|
285
|
+
const { state, dispatch } = editorView;
|
|
286
|
+
clearMultipleCells(state.selection.$from.pos)(editorView.state, dispatch);
|
|
287
|
+
|
|
288
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
289
|
+
doc(
|
|
290
|
+
p('text'),
|
|
291
|
+
table({ localId: TABLE_LOCAL_ID })(
|
|
292
|
+
tr(td()(p('c1')), tdEmpty),
|
|
293
|
+
tr(tdEmpty, tdEmpty),
|
|
294
|
+
),
|
|
295
|
+
),
|
|
296
|
+
);
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
describe('#setMultipleCellAttrs', () => {
|
|
301
|
+
it('should set selected cell attributes', () => {
|
|
302
|
+
const { editorView } = editor(
|
|
303
|
+
doc(
|
|
304
|
+
p('text'),
|
|
305
|
+
table()(
|
|
306
|
+
tr(td()(p('c1')), td()(p('c2'))),
|
|
307
|
+
tr(td()(p('c3')), td()(p('c4'))),
|
|
308
|
+
),
|
|
309
|
+
),
|
|
310
|
+
);
|
|
311
|
+
const { state, dispatch } = editorView;
|
|
312
|
+
selectColumn(0)(state, dispatch);
|
|
313
|
+
setMultipleCellAttrs({ background: 'purple' }, 0)(
|
|
314
|
+
editorView.state,
|
|
315
|
+
dispatch,
|
|
316
|
+
);
|
|
317
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
318
|
+
doc(
|
|
319
|
+
p('text'),
|
|
320
|
+
table({ localId: TABLE_LOCAL_ID })(
|
|
321
|
+
tr(td({ background: 'purple' })(p('c1')), td()(p('c2'))),
|
|
322
|
+
tr(td({ background: 'purple' })(p('c3')), td()(p('c4'))),
|
|
323
|
+
),
|
|
324
|
+
),
|
|
325
|
+
);
|
|
326
|
+
});
|
|
327
|
+
it('should set cell attributes if the cell has cursor', () => {
|
|
328
|
+
const { editorView } = editor(
|
|
329
|
+
doc(
|
|
330
|
+
p('text'),
|
|
331
|
+
table()(
|
|
332
|
+
tr(tdEmpty, tdEmpty),
|
|
333
|
+
tr(td()(panelNote(p('te{<>}xt'))), tdEmpty),
|
|
334
|
+
),
|
|
335
|
+
),
|
|
336
|
+
);
|
|
337
|
+
const { state, dispatch } = editorView;
|
|
338
|
+
setMultipleCellAttrs({ colspan: 2 }, state.selection.$from.pos)(
|
|
339
|
+
editorView.state,
|
|
340
|
+
dispatch,
|
|
341
|
+
);
|
|
342
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
343
|
+
doc(
|
|
344
|
+
p('text'),
|
|
345
|
+
table({ localId: TABLE_LOCAL_ID })(
|
|
346
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
347
|
+
tr(td({ colspan: 2 })(panelNote(p('text'))), tdEmpty),
|
|
348
|
+
),
|
|
349
|
+
),
|
|
350
|
+
);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
describe('#toggleContextualMenu', () => {
|
|
355
|
+
it('should update isContextualMenuOpen in plugin state', () => {
|
|
356
|
+
const { editorView } = editor(
|
|
357
|
+
doc(p('text'), table()(tr(tdEmpty, tdEmpty))),
|
|
358
|
+
);
|
|
359
|
+
const { state, dispatch } = editorView;
|
|
360
|
+
toggleContextualMenu()(state, dispatch);
|
|
361
|
+
const { isContextualMenuOpen } = getPluginState(editorView.state);
|
|
362
|
+
expect(isContextualMenuOpen).toBe(true);
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
describe('#setEditorFocus', () => {
|
|
367
|
+
it('should update editorHasFocus in plugin state', () => {
|
|
368
|
+
const { editorView } = editor(
|
|
369
|
+
doc(p('text'), table()(tr(tdEmpty, tdEmpty))),
|
|
370
|
+
);
|
|
371
|
+
const { state, dispatch } = editorView;
|
|
372
|
+
setEditorFocus(true)(state, dispatch);
|
|
373
|
+
const { editorHasFocus } = getPluginState(editorView.state);
|
|
374
|
+
expect(editorHasFocus).toBe(true);
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
describe('#setTableRef', () => {
|
|
379
|
+
it('should update tableRef and tableNode in plugin state', () => {
|
|
380
|
+
const { editorView } = editor(doc(table()(tr(tdCursor, tdEmpty))));
|
|
381
|
+
const { state, dispatch } = editorView;
|
|
382
|
+
const tableRef = document.querySelector(
|
|
383
|
+
'.ProseMirror table',
|
|
384
|
+
) as HTMLTableElement;
|
|
385
|
+
setEditorFocus(true)(state, dispatch);
|
|
386
|
+
setTableRef(tableRef)(editorView.state, dispatch);
|
|
387
|
+
const pluginState = getPluginState(editorView.state);
|
|
388
|
+
expect(pluginState.tableRef).toEqual(tableRef);
|
|
389
|
+
expect(pluginState.tableNode).toEqual(editorView.state.doc.firstChild!);
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
describe('#selectRow', () => {
|
|
394
|
+
it('should select a row and set targetCellPosition to point to the first cell', () => {
|
|
395
|
+
const { editorView } = editor(doc(table()(tr(tdEmpty), tr(tdEmpty))));
|
|
396
|
+
const { state, dispatch } = editorView;
|
|
397
|
+
selectRow(1)(state, dispatch);
|
|
398
|
+
const pluginState = getPluginState(editorView.state);
|
|
399
|
+
expect(pluginState.targetCellPosition).toEqual(8);
|
|
400
|
+
expect(isRowSelected(1)(editorView.state.selection));
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
describe('#handleCut', () => {
|
|
405
|
+
const editorAnalyticsAPIFake: EditorAnalyticsAPI = {
|
|
406
|
+
attachAnalyticsEvent: jest.fn().mockReturnValue(() => jest.fn()),
|
|
407
|
+
};
|
|
408
|
+
describe('when the entire table is selected', () => {
|
|
409
|
+
it('should remove the table', () => {
|
|
410
|
+
const { editorView, refs } = editor(
|
|
411
|
+
doc(
|
|
412
|
+
table()(
|
|
413
|
+
tr(
|
|
414
|
+
td()(p('{from}a1')),
|
|
415
|
+
td()(p('a2')),
|
|
416
|
+
td()(p('a3')),
|
|
417
|
+
td()(p('{cursorPos}a4')),
|
|
418
|
+
),
|
|
419
|
+
tr(
|
|
420
|
+
td()(p('b1')),
|
|
421
|
+
td()(p('b2')),
|
|
422
|
+
td()(p('b3')),
|
|
423
|
+
td()(p('{to}b4')),
|
|
424
|
+
),
|
|
425
|
+
),
|
|
426
|
+
),
|
|
427
|
+
);
|
|
428
|
+
const { state, dispatch } = editorView;
|
|
429
|
+
const sel = new CellSelection(
|
|
430
|
+
state.doc.resolve(refs.from - 2),
|
|
431
|
+
state.doc.resolve(refs.to - 2),
|
|
432
|
+
);
|
|
433
|
+
dispatch(state.tr.setSelection(sel as any));
|
|
434
|
+
const oldState = editorView.state;
|
|
435
|
+
dispatch(
|
|
436
|
+
oldState.tr.setSelection(
|
|
437
|
+
new TextSelection(oldState.doc.resolve(refs.cursorPos)),
|
|
438
|
+
),
|
|
439
|
+
);
|
|
440
|
+
const newTr = handleCut(
|
|
441
|
+
oldState.tr,
|
|
442
|
+
oldState,
|
|
443
|
+
editorView.state,
|
|
444
|
+
editorAnalyticsAPIFake,
|
|
445
|
+
);
|
|
446
|
+
expect(
|
|
447
|
+
editorAnalyticsAPIFake.attachAnalyticsEvent,
|
|
448
|
+
).toHaveBeenCalledWith({
|
|
449
|
+
action: 'cut',
|
|
450
|
+
actionSubject: 'table',
|
|
451
|
+
actionSubjectId: null,
|
|
452
|
+
attributes: {
|
|
453
|
+
horizontalCells: 4,
|
|
454
|
+
totalCells: 8,
|
|
455
|
+
totalColumnCount: 4,
|
|
456
|
+
totalRowCount: 2,
|
|
457
|
+
verticalCells: 2,
|
|
458
|
+
},
|
|
459
|
+
eventType: 'track',
|
|
460
|
+
});
|
|
461
|
+
expect(newTr.doc).toEqualDocument(doc(p('')));
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
describe('when selected columns are cut', () => {
|
|
466
|
+
it('should remove those columns', () => {
|
|
467
|
+
const { editorView, refs } = editor(
|
|
468
|
+
doc(
|
|
469
|
+
table()(
|
|
470
|
+
tr(
|
|
471
|
+
td()(p('a1')),
|
|
472
|
+
td()(p('{from}a2')),
|
|
473
|
+
td()(p('a3')),
|
|
474
|
+
td()(p('{cursorPos}a4')),
|
|
475
|
+
),
|
|
476
|
+
tr(
|
|
477
|
+
td()(p('b1')),
|
|
478
|
+
td()(p('b2')),
|
|
479
|
+
td()(p('{to}b3')),
|
|
480
|
+
td()(p('b4')),
|
|
481
|
+
),
|
|
482
|
+
),
|
|
483
|
+
),
|
|
484
|
+
);
|
|
485
|
+
const { state, dispatch } = editorView;
|
|
486
|
+
// selecting 2 and 3 columns
|
|
487
|
+
const sel = new CellSelection(
|
|
488
|
+
state.doc.resolve(refs.from - 2),
|
|
489
|
+
state.doc.resolve(refs.to - 2),
|
|
490
|
+
);
|
|
491
|
+
dispatch(state.tr.setSelection(sel as any));
|
|
492
|
+
const oldState = editorView.state;
|
|
493
|
+
// re-setting selection to a text selection
|
|
494
|
+
// this is what happens when we let PM handle cut so that it saves content to a clipboard
|
|
495
|
+
dispatch(
|
|
496
|
+
oldState.tr.setSelection(
|
|
497
|
+
new TextSelection(oldState.doc.resolve(refs.cursorPos)),
|
|
498
|
+
),
|
|
499
|
+
);
|
|
500
|
+
const newTr = handleCut(
|
|
501
|
+
oldState.tr,
|
|
502
|
+
oldState,
|
|
503
|
+
editorView.state,
|
|
504
|
+
editorAnalyticsAPIFake,
|
|
505
|
+
);
|
|
506
|
+
expect(
|
|
507
|
+
editorAnalyticsAPIFake.attachAnalyticsEvent,
|
|
508
|
+
).toHaveBeenCalledWith({
|
|
509
|
+
action: 'cut',
|
|
510
|
+
actionSubject: 'table',
|
|
511
|
+
actionSubjectId: null,
|
|
512
|
+
attributes: {
|
|
513
|
+
horizontalCells: 4,
|
|
514
|
+
totalCells: 8,
|
|
515
|
+
totalColumnCount: 4,
|
|
516
|
+
totalRowCount: 2,
|
|
517
|
+
verticalCells: 2,
|
|
518
|
+
},
|
|
519
|
+
eventType: 'track',
|
|
520
|
+
});
|
|
521
|
+
expect(newTr.doc).toEqualDocument(
|
|
522
|
+
doc(
|
|
523
|
+
table({ localId: TABLE_LOCAL_ID })(
|
|
524
|
+
tr(td()(p('a1')), td()(p('a4'))),
|
|
525
|
+
tr(td()(p('b1')), td()(p('b4'))),
|
|
526
|
+
),
|
|
527
|
+
),
|
|
528
|
+
);
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
describe('when selected rows are cut', () => {
|
|
533
|
+
it('should remove those rows', () => {
|
|
534
|
+
const { editorView, refs } = editor(
|
|
535
|
+
doc(
|
|
536
|
+
table()(
|
|
537
|
+
tr(td()(p('a1')), td()(p('a2')), td()(p('a3'))),
|
|
538
|
+
tr(td()(p('{from}b1')), td()(p('b2')), td()(p('b3'))),
|
|
539
|
+
tr(td()(p('c1')), td()(p('c2')), td()(p('{to}c3'))),
|
|
540
|
+
tr(td()(p('{cursorPos}d1')), td()(p('d2')), td()(p('d3'))),
|
|
541
|
+
),
|
|
542
|
+
),
|
|
543
|
+
);
|
|
544
|
+
const { state, dispatch } = editorView;
|
|
545
|
+
// selecting 2 and 3 rows
|
|
546
|
+
const sel = new CellSelection(
|
|
547
|
+
state.doc.resolve(refs.from - 2),
|
|
548
|
+
state.doc.resolve(refs.to - 2),
|
|
549
|
+
);
|
|
550
|
+
dispatch(state.tr.setSelection(sel as any));
|
|
551
|
+
const oldState = editorView.state;
|
|
552
|
+
// re-setting selection to a text selection
|
|
553
|
+
// this is what happens when we let PM handle cut so that it saves content to a clipboard
|
|
554
|
+
dispatch(
|
|
555
|
+
oldState.tr.setSelection(
|
|
556
|
+
new TextSelection(oldState.doc.resolve(refs.cursorPos)),
|
|
557
|
+
),
|
|
558
|
+
);
|
|
559
|
+
const newTr = handleCut(
|
|
560
|
+
oldState.tr,
|
|
561
|
+
oldState,
|
|
562
|
+
editorView.state,
|
|
563
|
+
editorAnalyticsAPIFake,
|
|
564
|
+
);
|
|
565
|
+
expect(
|
|
566
|
+
editorAnalyticsAPIFake.attachAnalyticsEvent,
|
|
567
|
+
).toHaveBeenCalledWith({
|
|
568
|
+
action: 'cut',
|
|
569
|
+
actionSubject: 'table',
|
|
570
|
+
actionSubjectId: null,
|
|
571
|
+
attributes: {
|
|
572
|
+
horizontalCells: 4,
|
|
573
|
+
totalCells: 8,
|
|
574
|
+
totalColumnCount: 4,
|
|
575
|
+
totalRowCount: 2,
|
|
576
|
+
verticalCells: 2,
|
|
577
|
+
},
|
|
578
|
+
eventType: 'track',
|
|
579
|
+
});
|
|
580
|
+
expect(newTr.doc).toEqualDocument(
|
|
581
|
+
doc(
|
|
582
|
+
table({ localId: TABLE_LOCAL_ID })(
|
|
583
|
+
tr(td()(p('a1')), td()(p('a2')), td()(p('a3'))),
|
|
584
|
+
tr(td()(p('d1')), td()(p('d2')), td()(p('d3'))),
|
|
585
|
+
),
|
|
586
|
+
),
|
|
587
|
+
);
|
|
588
|
+
});
|
|
589
|
+
});
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
describe('#toggleHeaderColumn', () => {
|
|
593
|
+
let editorView: EditorView;
|
|
594
|
+
const tableDoc = doc(
|
|
595
|
+
table({ localId: TABLE_LOCAL_ID })(
|
|
596
|
+
tr(td()(p('c1')), td()(p('c2'))),
|
|
597
|
+
tr(td({ rowspan: 2 })(p('c3')), td()(p('c4'))),
|
|
598
|
+
tr(td()(p('c6'))),
|
|
599
|
+
tr(td()(p('c7')), td()(p('c8'))),
|
|
600
|
+
),
|
|
601
|
+
);
|
|
602
|
+
beforeEach(() => {
|
|
603
|
+
({ editorView } = editor(tableDoc));
|
|
604
|
+
const { state, dispatch } = editorView;
|
|
605
|
+
toggleHeaderColumn(state, dispatch);
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
it('should convert all cells including rowspans to table headers', () => {
|
|
609
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
610
|
+
doc(
|
|
611
|
+
table({ localId: TABLE_LOCAL_ID })(
|
|
612
|
+
tr(th()(p('c1')), td()(p('c2'))),
|
|
613
|
+
tr(th({ rowspan: 2 })(p('c3')), td()(p('c4'))),
|
|
614
|
+
tr(td()(p('c6'))),
|
|
615
|
+
tr(th()(p('c7')), td()(p('c8'))),
|
|
616
|
+
),
|
|
617
|
+
),
|
|
618
|
+
);
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
it('should isHeaderColumnEnabled be true', () => {
|
|
622
|
+
const tableState = getPluginState(editorView.state);
|
|
623
|
+
|
|
624
|
+
expect(tableState.isHeaderColumnEnabled).toBe(true);
|
|
625
|
+
});
|
|
626
|
+
describe('Toggle header columns again', () => {
|
|
627
|
+
beforeEach(() => {
|
|
628
|
+
const { state, dispatch } = editorView;
|
|
629
|
+
toggleHeaderColumn(state, dispatch);
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
it('should convert all cells including rowspan back to the original document', () => {
|
|
633
|
+
expect(editorView.state.doc).toEqualDocument(tableDoc);
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
it('should isHeaderColumnEnabled be false', () => {
|
|
637
|
+
const tableState = getPluginState(editorView.state);
|
|
638
|
+
expect(tableState.isHeaderColumnEnabled).toBe(false);
|
|
639
|
+
});
|
|
640
|
+
});
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
describe('#toggleHeaderRow', () => {
|
|
644
|
+
let editorView: EditorView;
|
|
645
|
+
const tableDoc = doc(
|
|
646
|
+
table({ localId: TABLE_LOCAL_ID })(
|
|
647
|
+
tr(th()(p('c1')), th()(p('c2'))),
|
|
648
|
+
tr(td({ rowspan: 2 })(p('c3')), td()(p('c4'))),
|
|
649
|
+
tr(td()(p('c6'))),
|
|
650
|
+
tr(td()(p('c7')), td()(p('c8'))),
|
|
651
|
+
),
|
|
652
|
+
);
|
|
653
|
+
beforeEach(() => {
|
|
654
|
+
({ editorView } = editor(tableDoc));
|
|
655
|
+
const { state, dispatch } = editorView;
|
|
656
|
+
toggleHeaderRow(state, dispatch);
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
it('should convert all rows including to table normal', () => {
|
|
660
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
661
|
+
doc(
|
|
662
|
+
table({ localId: TABLE_LOCAL_ID })(
|
|
663
|
+
tr(td()(p('c1')), td()(p('c2'))),
|
|
664
|
+
tr(td({ rowspan: 2 })(p('c3')), td()(p('c4'))),
|
|
665
|
+
tr(td()(p('c6'))),
|
|
666
|
+
tr(td()(p('c7')), td()(p('c8'))),
|
|
667
|
+
),
|
|
668
|
+
),
|
|
669
|
+
);
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
it('should isHeaderRowEnabled be false', () => {
|
|
673
|
+
const tableState = getPluginState(editorView.state);
|
|
674
|
+
expect(tableState.isHeaderRowEnabled).toBe(false);
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
describe('Toggle header rows again', () => {
|
|
678
|
+
beforeEach(() => {
|
|
679
|
+
const { state, dispatch } = editorView;
|
|
680
|
+
toggleHeaderRow(state, dispatch);
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
it('should convert all rows back to the original document', () => {
|
|
684
|
+
expect(editorView.state.doc).toEqualDocument(tableDoc);
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
it('should isHeaderRowEnabled be false', () => {
|
|
688
|
+
const tableState = getPluginState(editorView.state);
|
|
689
|
+
expect(tableState.isHeaderRowEnabled).toBe(true);
|
|
690
|
+
});
|
|
691
|
+
});
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
describe('#toggleBoldOnHeaderCells', () => {
|
|
695
|
+
describe('when there is no cursor', () => {
|
|
696
|
+
it('should not add a strong mark on storedMarks', function () {
|
|
697
|
+
const { editorView } = editor(
|
|
698
|
+
doc(table()(tr(th()(p('{<}foo bar{>}'))), tr(td()(p(''))))),
|
|
699
|
+
);
|
|
700
|
+
|
|
701
|
+
const { state, dispatch } = editorView;
|
|
702
|
+
|
|
703
|
+
const tableCellHeader = findParentNodeOfType(
|
|
704
|
+
state.schema.nodes.tableHeader,
|
|
705
|
+
)(state.selection);
|
|
706
|
+
|
|
707
|
+
addBoldInEmptyHeaderCells(tableCellHeader!)(state, dispatch);
|
|
708
|
+
|
|
709
|
+
const result = editorView.state.storedMarks || [];
|
|
710
|
+
expect(result).toEqual([]);
|
|
711
|
+
});
|
|
712
|
+
});
|
|
713
|
+
describe('when the cursor is on table header cell', () => {
|
|
714
|
+
describe('and the cell is empty', () => {
|
|
715
|
+
it('should add strong mark on storedMarks', () => {
|
|
716
|
+
const { editorView } = editor(
|
|
717
|
+
doc(table()(tr(thCursor), tr(td()(p(''))))),
|
|
718
|
+
);
|
|
719
|
+
const { state, dispatch } = editorView;
|
|
720
|
+
|
|
721
|
+
const tableCellHeader = findParentNodeOfType(
|
|
722
|
+
state.schema.nodes.tableHeader,
|
|
723
|
+
)(state.selection);
|
|
724
|
+
|
|
725
|
+
addBoldInEmptyHeaderCells(tableCellHeader!)(state, dispatch);
|
|
726
|
+
const result = editorView.state.storedMarks || [];
|
|
727
|
+
expect(result.length).toBeGreaterThan(0);
|
|
728
|
+
expect(result[0].type).toEqual(state.schema.marks.strong);
|
|
729
|
+
});
|
|
730
|
+
|
|
731
|
+
describe('and the user removed the strong mark', () => {
|
|
732
|
+
it('should not add strong mark on storedMarks', () => {
|
|
733
|
+
const { editorView } = editor(
|
|
734
|
+
doc(table()(tr(thCursor), tr(td()(p(''))))),
|
|
735
|
+
);
|
|
736
|
+
const { state, dispatch } = editorView;
|
|
737
|
+
|
|
738
|
+
const tableCellHeader = findParentNodeOfType(
|
|
739
|
+
state.schema.nodes.tableHeader,
|
|
740
|
+
)(state.selection);
|
|
741
|
+
|
|
742
|
+
editorView.state.storedMarks = [];
|
|
743
|
+
addBoldInEmptyHeaderCells(tableCellHeader!)(state, dispatch);
|
|
744
|
+
|
|
745
|
+
const result = editorView.state.storedMarks || [];
|
|
746
|
+
expect(result).toEqual([]);
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
describe('and the cell is not empty', () => {
|
|
752
|
+
it('should not add strong mark on storedMarks', () => {
|
|
753
|
+
const { editorView } = editor(
|
|
754
|
+
doc(table()(tr(th()(p('Rato{<>}'))), tr(td()(p('Rato'))))),
|
|
755
|
+
);
|
|
756
|
+
const { state, dispatch } = editorView;
|
|
757
|
+
expect(editorView.state.storedMarks).toBeNull();
|
|
758
|
+
|
|
759
|
+
const tableCellHeader = findParentNodeOfType(
|
|
760
|
+
state.schema.nodes.tableHeader,
|
|
761
|
+
)(state.selection);
|
|
762
|
+
|
|
763
|
+
addBoldInEmptyHeaderCells(tableCellHeader!)(state, dispatch);
|
|
764
|
+
expect(editorView.state.storedMarks).toBeNull();
|
|
765
|
+
});
|
|
766
|
+
});
|
|
767
|
+
});
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
describe('#splitCell', () => {
|
|
771
|
+
/**
|
|
772
|
+
* | th | th | th |
|
|
773
|
+
* ---- ----
|
|
774
|
+
* | td | | td |
|
|
775
|
+
*
|
|
776
|
+
* If header row is enabled should split into:
|
|
777
|
+
*
|
|
778
|
+
* | th | th | th |
|
|
779
|
+
* ---- ---- ----
|
|
780
|
+
* | th | td | td |
|
|
781
|
+
*/
|
|
782
|
+
it('should keep right column header and cells after split', () => {
|
|
783
|
+
const { editorView } = editor(
|
|
784
|
+
doc(
|
|
785
|
+
table()(
|
|
786
|
+
tr(th()(p('')), th({ rowspan: 2 })(p('foo{<>}')), th()(p(''))),
|
|
787
|
+
tr(td()(p('')), td()(p(''))),
|
|
788
|
+
),
|
|
789
|
+
),
|
|
790
|
+
);
|
|
791
|
+
|
|
792
|
+
splitCell(editorView.state, editorView.dispatch);
|
|
793
|
+
|
|
794
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
795
|
+
doc(
|
|
796
|
+
table({ localId: TABLE_LOCAL_ID })(
|
|
797
|
+
tr(th()(p('')), th()(p('foo')), th()(p(''))),
|
|
798
|
+
tr(td()(p('')), td()(p('')), td()(p(''))),
|
|
799
|
+
),
|
|
800
|
+
),
|
|
801
|
+
);
|
|
802
|
+
});
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* | th | th | th |
|
|
806
|
+
* | th | td |
|
|
807
|
+
*
|
|
808
|
+
* If header column is enabled should split into:
|
|
809
|
+
*
|
|
810
|
+
* | th | th | th |
|
|
811
|
+
* | th | td | td |
|
|
812
|
+
*/
|
|
813
|
+
test('should keep right row header and cells after split', () => {
|
|
814
|
+
const { editorView } = editor(
|
|
815
|
+
doc(
|
|
816
|
+
table()(
|
|
817
|
+
tr(th()(p('')), th()(p('')), th()(p(''))),
|
|
818
|
+
tr(td({ colspan: 2 })(p('foo{<>}')), td()(p(''))),
|
|
819
|
+
),
|
|
820
|
+
),
|
|
821
|
+
);
|
|
822
|
+
toggleHeaderColumn(editorView.state, editorView.dispatch); // Activate header columns first
|
|
823
|
+
|
|
824
|
+
splitCell(editorView.state, editorView.dispatch);
|
|
825
|
+
|
|
826
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
827
|
+
doc(
|
|
828
|
+
table({ localId: TABLE_LOCAL_ID })(
|
|
829
|
+
tr(th()(p('')), th()(p('')), th()(p(''))),
|
|
830
|
+
tr(th()(p('foo')), td()(p('')), td()(p(''))),
|
|
831
|
+
),
|
|
832
|
+
),
|
|
833
|
+
);
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
test('should split cell with media selected', () => {
|
|
837
|
+
const { editorView } = editor(
|
|
838
|
+
doc(
|
|
839
|
+
table()(
|
|
840
|
+
tr(th()(p('')), th()(p('')), th()(p(''))),
|
|
841
|
+
tr(
|
|
842
|
+
td({ colspan: 2 })('{<node>}', temporaryMediaGroup),
|
|
843
|
+
td()(p('')),
|
|
844
|
+
),
|
|
845
|
+
),
|
|
846
|
+
),
|
|
847
|
+
{
|
|
848
|
+
media: {
|
|
849
|
+
allowMediaSingle: true,
|
|
850
|
+
provider: getFreshMediaProvider(),
|
|
851
|
+
},
|
|
852
|
+
},
|
|
853
|
+
);
|
|
854
|
+
|
|
855
|
+
splitCell(editorView.state, editorView.dispatch);
|
|
856
|
+
|
|
857
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
858
|
+
doc(
|
|
859
|
+
table({ localId: TABLE_LOCAL_ID })(
|
|
860
|
+
tr(th()(p('')), th()(p('')), th()(p(''))),
|
|
861
|
+
tr(td()(temporaryMediaGroup), td()(p('')), td()(p(''))),
|
|
862
|
+
),
|
|
863
|
+
),
|
|
864
|
+
);
|
|
865
|
+
});
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
describe('#wrapTableInExpand', () => {
|
|
869
|
+
it('should not wrap if selection is not on a table', () => {
|
|
870
|
+
const { editorView } = editor(
|
|
871
|
+
doc(
|
|
872
|
+
p('Cursor here{<>}'),
|
|
873
|
+
table()(tr(thEmpty, thEmpty, thEmpty), tr(tdEmpty, tdEmpty, tdEmpty)),
|
|
874
|
+
),
|
|
875
|
+
{ allowExpand: true, allowTables: { allowCollapse: true } },
|
|
876
|
+
);
|
|
877
|
+
|
|
878
|
+
const result = wrapTableInExpand(editorView.state, editorView.dispatch);
|
|
879
|
+
|
|
880
|
+
expect(result).toBeFalsy();
|
|
881
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
882
|
+
doc(
|
|
883
|
+
p('Cursor {<>}here'),
|
|
884
|
+
table({ localId: 'test-table-local-id' })(
|
|
885
|
+
tr(thEmpty, thEmpty, thEmpty),
|
|
886
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
887
|
+
),
|
|
888
|
+
),
|
|
889
|
+
);
|
|
890
|
+
});
|
|
891
|
+
|
|
892
|
+
it('should be able to wrap a root level table', () => {
|
|
893
|
+
const { editorView } = editor(
|
|
894
|
+
doc(
|
|
895
|
+
table()(
|
|
896
|
+
tr(thCursor, thEmpty, thEmpty),
|
|
897
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
898
|
+
),
|
|
899
|
+
),
|
|
900
|
+
{ allowExpand: true },
|
|
901
|
+
);
|
|
902
|
+
|
|
903
|
+
const result = wrapTableInExpand(editorView.state, editorView.dispatch);
|
|
904
|
+
|
|
905
|
+
expect(result).toBeTruthy();
|
|
906
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
907
|
+
doc(
|
|
908
|
+
expand()(
|
|
909
|
+
table({ localId: 'test-table-local-id' })(
|
|
910
|
+
tr(thEmpty, thEmpty, thEmpty),
|
|
911
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
912
|
+
),
|
|
913
|
+
),
|
|
914
|
+
),
|
|
915
|
+
);
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
it('should not wrap a table under an expand', () => {
|
|
919
|
+
const { editorView } = editor(
|
|
920
|
+
doc(
|
|
921
|
+
expand()(
|
|
922
|
+
table()(
|
|
923
|
+
tr(thCursor, thEmpty, thEmpty),
|
|
924
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
925
|
+
),
|
|
926
|
+
),
|
|
927
|
+
),
|
|
928
|
+
{ allowExpand: true },
|
|
929
|
+
);
|
|
930
|
+
|
|
931
|
+
const result = wrapTableInExpand(editorView.state, editorView.dispatch);
|
|
932
|
+
|
|
933
|
+
expect(result).toBeFalsy();
|
|
934
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
935
|
+
doc(
|
|
936
|
+
expand()(
|
|
937
|
+
table({ localId: 'test-table-local-id' })(
|
|
938
|
+
tr(thEmpty, thEmpty, thEmpty),
|
|
939
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
940
|
+
),
|
|
941
|
+
),
|
|
942
|
+
),
|
|
943
|
+
);
|
|
944
|
+
});
|
|
945
|
+
|
|
946
|
+
it('should not wrap a table inside a bodiedExtension', () => {
|
|
947
|
+
const { editorView } = editor(
|
|
948
|
+
doc(
|
|
949
|
+
bodiedExtension({
|
|
950
|
+
extensionKey: 'key',
|
|
951
|
+
extensionType: 'type',
|
|
952
|
+
localId: 'localId',
|
|
953
|
+
})(
|
|
954
|
+
table()(
|
|
955
|
+
tr(thCursor, thEmpty, thEmpty),
|
|
956
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
957
|
+
),
|
|
958
|
+
),
|
|
959
|
+
),
|
|
960
|
+
{ allowExpand: true, allowExtension: true },
|
|
961
|
+
);
|
|
962
|
+
|
|
963
|
+
const result = wrapTableInExpand(editorView.state, editorView.dispatch);
|
|
964
|
+
|
|
965
|
+
expect(result).toBeFalsy();
|
|
966
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
967
|
+
doc(
|
|
968
|
+
bodiedExtension({
|
|
969
|
+
extensionKey: 'key',
|
|
970
|
+
extensionType: 'type',
|
|
971
|
+
localId: 'localId',
|
|
972
|
+
})(
|
|
973
|
+
table({ localId: 'test-table-local-id' })(
|
|
974
|
+
tr(thEmpty, thEmpty, thEmpty),
|
|
975
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
976
|
+
),
|
|
977
|
+
),
|
|
978
|
+
),
|
|
979
|
+
);
|
|
980
|
+
});
|
|
981
|
+
});
|
|
982
|
+
});
|