@atlaskit/editor-plugin-table 0.0.0 → 0.0.1
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 +17 -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 +347 -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 +308 -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 +312 -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 +18 -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 +50 -1
- 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 +116 -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 +132 -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 +413 -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,10 @@
|
|
|
1
|
+
export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, isSelectionUpdated } from './selection';
|
|
2
|
+
export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnLineResize } from './decoration';
|
|
3
|
+
export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns } from './nodes';
|
|
4
|
+
export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell } from './paste';
|
|
5
|
+
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler } from './dom';
|
|
6
|
+
export { getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames } from './column-controls';
|
|
7
|
+
export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow } from './row-controls';
|
|
8
|
+
export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';
|
|
9
|
+
export { getMergedCellsPositions } from './table';
|
|
10
|
+
export { updatePluginStateDecorations } from './update-plugin-state-decorations';
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
2
|
+
import { hasParentNodeOfType } from 'prosemirror-utils';
|
|
3
|
+
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
4
|
+
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
5
|
+
export const isIsolating = node => {
|
|
6
|
+
return !!node.type.spec.isolating;
|
|
7
|
+
};
|
|
8
|
+
export const containsHeaderColumn = table => {
|
|
9
|
+
const map = TableMap.get(table); // Get cell positions for first column.
|
|
10
|
+
|
|
11
|
+
const cellPositions = map.cellsInRect({
|
|
12
|
+
left: 0,
|
|
13
|
+
top: 0,
|
|
14
|
+
right: 1,
|
|
15
|
+
bottom: map.height
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
for (let i = 0; i < cellPositions.length; i++) {
|
|
19
|
+
try {
|
|
20
|
+
const cell = table.nodeAt(cellPositions[i]);
|
|
21
|
+
|
|
22
|
+
if (cell && cell.type !== table.type.schema.nodes.tableHeader) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
} catch (e) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return true;
|
|
31
|
+
};
|
|
32
|
+
export const containsHeaderRow = table => {
|
|
33
|
+
const map = TableMap.get(table);
|
|
34
|
+
|
|
35
|
+
for (let i = 0; i < map.width; i++) {
|
|
36
|
+
const cell = table.nodeAt(map.map[i]);
|
|
37
|
+
|
|
38
|
+
if (cell && cell.type !== table.type.schema.nodes.tableHeader) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return true;
|
|
44
|
+
};
|
|
45
|
+
export const checkIfHeaderColumnEnabled = selection => filterNearSelection(selection, findTable, containsHeaderColumn, false);
|
|
46
|
+
export const checkIfHeaderRowEnabled = selection => filterNearSelection(selection, findTable, containsHeaderRow, false);
|
|
47
|
+
export const checkIfNumberColumnEnabled = selection => filterNearSelection(selection, findTable, table => !!table.attrs.isNumberColumnEnabled, false);
|
|
48
|
+
export const isLayoutSupported = state => {
|
|
49
|
+
const {
|
|
50
|
+
permittedLayouts
|
|
51
|
+
} = pluginKey.getState(state).pluginConfig;
|
|
52
|
+
const {
|
|
53
|
+
bodiedExtension,
|
|
54
|
+
layoutSection,
|
|
55
|
+
expand
|
|
56
|
+
} = state.schema.nodes;
|
|
57
|
+
return !hasParentNodeOfType([expand, layoutSection, bodiedExtension])(state.selection) && permittedLayouts && (permittedLayouts === 'all' || permittedLayouts.indexOf('default') > -1 && permittedLayouts.indexOf('wide') > -1 && permittedLayouts.indexOf('full-page') > -1);
|
|
58
|
+
};
|
|
59
|
+
export const getTableWidth = node => {
|
|
60
|
+
return getTableWidths(node).reduce((acc, current) => acc + current, 0);
|
|
61
|
+
};
|
|
62
|
+
export const tablesHaveDifferentColumnWidths = (currentTable, previousTable) => {
|
|
63
|
+
let currentTableWidths = getTableWidths(currentTable);
|
|
64
|
+
let previousTableWidths = getTableWidths(previousTable);
|
|
65
|
+
|
|
66
|
+
if (currentTableWidths.length !== previousTableWidths.length) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const sameWidths = currentTableWidths.every((value, index) => {
|
|
71
|
+
return value === previousTableWidths[index];
|
|
72
|
+
});
|
|
73
|
+
return sameWidths === false;
|
|
74
|
+
};
|
|
75
|
+
export const tablesHaveDifferentNoOfColumns = (currentTable, previousTable) => {
|
|
76
|
+
const prevMap = TableMap.get(previousTable);
|
|
77
|
+
const currentMap = TableMap.get(currentTable);
|
|
78
|
+
return prevMap.width !== currentMap.width;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
function filterNearSelection(selection, findNode, predicate, defaultValue) {
|
|
82
|
+
const found = findNode(selection);
|
|
83
|
+
|
|
84
|
+
if (!found) {
|
|
85
|
+
return defaultValue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return predicate(found.node, found.pos);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getTableWidths(node) {
|
|
92
|
+
if (!node.content.firstChild) {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let tableWidths = [];
|
|
97
|
+
node.content.firstChild.content.forEach(cell => {
|
|
98
|
+
if (Array.isArray(cell.attrs.colwidth)) {
|
|
99
|
+
const colspan = cell.attrs.colspan || 1;
|
|
100
|
+
tableWidths.push(...cell.attrs.colwidth.slice(0, colspan));
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return tableWidths;
|
|
104
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Fragment, Slice } from 'prosemirror-model';
|
|
2
|
+
import { flatten } from 'prosemirror-utils'; // import { flatmap, mapSlice } from '@atlaskit/editor-core/src/utils/slice';
|
|
3
|
+
|
|
4
|
+
import { flatmap, mapSlice } from '@atlaskit/editor-common/utils';
|
|
5
|
+
import { getPluginState } from '../pm-plugins/plugin-factory'; // lifts up the content of each cell, returning an array of nodes
|
|
6
|
+
|
|
7
|
+
export const unwrapContentFromTable = maybeTable => {
|
|
8
|
+
const {
|
|
9
|
+
schema
|
|
10
|
+
} = maybeTable.type;
|
|
11
|
+
|
|
12
|
+
if (maybeTable.type === schema.nodes.table) {
|
|
13
|
+
const content = [];
|
|
14
|
+
const {
|
|
15
|
+
tableCell,
|
|
16
|
+
tableHeader
|
|
17
|
+
} = schema.nodes;
|
|
18
|
+
maybeTable.descendants(maybeCell => {
|
|
19
|
+
if (maybeCell.type === tableCell || maybeCell.type === tableHeader) {
|
|
20
|
+
content.push(...flatten(maybeCell, false).map(child => child.node));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return true;
|
|
24
|
+
});
|
|
25
|
+
return content;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return maybeTable;
|
|
29
|
+
};
|
|
30
|
+
export const removeTableFromFirstChild = (node, i) => {
|
|
31
|
+
return i === 0 ? unwrapContentFromTable(node) : node;
|
|
32
|
+
};
|
|
33
|
+
export const removeTableFromLastChild = (node, i, fragment) => {
|
|
34
|
+
return i === fragment.childCount - 1 ? unwrapContentFromTable(node) : node;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* When we copy from a table cell with a hardBreak at the end,
|
|
38
|
+
* the slice generated will come with a hardBreak outside of the table.
|
|
39
|
+
* This code will look for that pattern and fix it.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
export const transformSliceToFixHardBreakProblemOnCopyFromCell = (slice, schema) => {
|
|
43
|
+
const {
|
|
44
|
+
paragraph,
|
|
45
|
+
table,
|
|
46
|
+
hardBreak
|
|
47
|
+
} = schema.nodes;
|
|
48
|
+
const emptyParagraphNode = paragraph.createAndFill();
|
|
49
|
+
const hardBreakNode = hardBreak === null || hardBreak === void 0 ? void 0 : hardBreak.createAndFill();
|
|
50
|
+
const paragraphNodeSize = emptyParagraphNode ? emptyParagraphNode.nodeSize : 0;
|
|
51
|
+
const hardBreakNodeSize = hardBreakNode ? hardBreakNode.nodeSize : 0;
|
|
52
|
+
const paragraphWithHardBreakSize = paragraphNodeSize + hardBreakNodeSize;
|
|
53
|
+
|
|
54
|
+
if (slice.content.childCount === 2 && slice.content.firstChild && slice.content.lastChild && slice.content.firstChild.type === table && slice.content.lastChild.type === paragraph && slice.content.lastChild.nodeSize === paragraphWithHardBreakSize) {
|
|
55
|
+
const nodes = unwrapContentFromTable(slice.content.firstChild);
|
|
56
|
+
|
|
57
|
+
if (nodes instanceof Array) {
|
|
58
|
+
return new Slice(Fragment.from( // keep only the content and discard the hardBreak
|
|
59
|
+
nodes[0]), slice.openStart, slice.openEnd);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return slice;
|
|
64
|
+
};
|
|
65
|
+
export const transformSliceToRemoveOpenTable = (slice, schema) => {
|
|
66
|
+
var _slice$content$firstC6;
|
|
67
|
+
|
|
68
|
+
// we're removing the table, tableRow and tableCell reducing the open depth by 3
|
|
69
|
+
const depthDecrement = 3; // Case 1: A slice entirely within a single CELL
|
|
70
|
+
|
|
71
|
+
if ( // starts and ends inside of a cell
|
|
72
|
+
slice.openStart >= 4 && slice.openEnd >= 4 && // slice is a table node
|
|
73
|
+
slice.content.childCount === 1 && slice.content.firstChild.type === schema.nodes.table) {
|
|
74
|
+
var _slice$content$firstC, _slice$content$firstC2, _slice$content$firstC3, _slice$content$firstC4, _slice$content$firstC5;
|
|
75
|
+
|
|
76
|
+
// prosemirror-view has a bug that it duplicates table entry when selecting multiple paragraphs in a table cell.
|
|
77
|
+
// https://github.com/ProseMirror/prosemirror/issues/1270
|
|
78
|
+
// The structure becomes
|
|
79
|
+
// table(genuine) > tableRow(genuine) > table(duplicated) > tableRow(duplicated) > tableCell/tableHeader(genuine) > contents(genuine)
|
|
80
|
+
// As we are removing wrapping table anyway, we keep duplicated table and tableRow for simplicity
|
|
81
|
+
let cleaned = slice;
|
|
82
|
+
|
|
83
|
+
if (((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : (_slice$content$firstC2 = _slice$content$firstC.content) === null || _slice$content$firstC2 === void 0 ? void 0 : (_slice$content$firstC3 = _slice$content$firstC2.firstChild) === null || _slice$content$firstC3 === void 0 ? void 0 : (_slice$content$firstC4 = _slice$content$firstC3.content) === null || _slice$content$firstC4 === void 0 ? void 0 : (_slice$content$firstC5 = _slice$content$firstC4.firstChild) === null || _slice$content$firstC5 === void 0 ? void 0 : _slice$content$firstC5.type) === schema.nodes.table) {
|
|
84
|
+
cleaned = new Slice(slice.content.firstChild.content.firstChild.content, slice.openStart - 2, slice.openEnd - 2);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return new Slice(flatmap(cleaned.content, unwrapContentFromTable), cleaned.openStart - depthDecrement, cleaned.openEnd - depthDecrement);
|
|
88
|
+
} // Case 2: A slice starting within a CELL and ending outside the table
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
if ( // starts inside of a cell but ends outside of the starting table
|
|
92
|
+
slice.openStart >= 4 && // slice starts from a table node (and spans across more than one node)
|
|
93
|
+
slice.content.childCount > 1 && ((_slice$content$firstC6 = slice.content.firstChild) === null || _slice$content$firstC6 === void 0 ? void 0 : _slice$content$firstC6.type) === schema.nodes.table) {
|
|
94
|
+
// repoint the slice's cutting depth so that cell content where the slice starts
|
|
95
|
+
// does not get lifted out of the cell on paste
|
|
96
|
+
return new Slice(slice.content, 1, slice.openEnd);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return slice;
|
|
100
|
+
};
|
|
101
|
+
export const transformSliceToCorrectEmptyTableCells = (slice, schema) => {
|
|
102
|
+
const {
|
|
103
|
+
tableCell,
|
|
104
|
+
tableHeader
|
|
105
|
+
} = schema.nodes;
|
|
106
|
+
return mapSlice(slice, node => {
|
|
107
|
+
if (node && (node.type === tableCell || node.type === tableHeader) && !node.content.childCount) {
|
|
108
|
+
return node.type.createAndFill(node.attrs) || node;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return node;
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
export function isHeaderRowRequired(state) {
|
|
115
|
+
const tableState = getPluginState(state);
|
|
116
|
+
return tableState && tableState.pluginConfig.isHeaderRowRequired;
|
|
117
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const isReferencedSource = (state, localId) => {
|
|
2
|
+
let found = false;
|
|
3
|
+
state.doc.descendants(node => {
|
|
4
|
+
if (found) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const dataConsumer = node.marks.find(mark => mark.type === state.schema.marks.dataConsumer);
|
|
9
|
+
|
|
10
|
+
if (!dataConsumer) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
found = (dataConsumer.attrs.sources || []).includes(localId);
|
|
15
|
+
return !found;
|
|
16
|
+
});
|
|
17
|
+
return found;
|
|
18
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
2
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
3
|
+
import { safeInsert } from 'prosemirror-utils';
|
|
4
|
+
import { findTable, getSelectionRect, isRowSelected, isTableSelected } from '@atlaskit/editor-tables/utils'; // import { parsePx } from '@atlaskit/editor-core/src/utils/dom';
|
|
5
|
+
|
|
6
|
+
import { parsePx } from '@atlaskit/editor-common/utils';
|
|
7
|
+
import { TableCssClassName as ClassName } from '../types';
|
|
8
|
+
import { tableDeleteButtonSize } from '../ui/consts';
|
|
9
|
+
export const getRowHeights = tableRef => {
|
|
10
|
+
const heights = [];
|
|
11
|
+
|
|
12
|
+
if (tableRef.lastChild) {
|
|
13
|
+
const rows = tableRef.lastChild.childNodes;
|
|
14
|
+
|
|
15
|
+
for (let i = 0, count = rows.length; i < count; i++) {
|
|
16
|
+
const row = rows[i];
|
|
17
|
+
heights[i] = row.getBoundingClientRect().height + 1; // padding only gets applied when the container has sticky
|
|
18
|
+
|
|
19
|
+
if (row.classList.contains('sticky') && i === 0) {
|
|
20
|
+
const styles = window.getComputedStyle(row);
|
|
21
|
+
const paddingTop = parsePx(styles.paddingTop || '');
|
|
22
|
+
heights[i] -= paddingTop ? paddingTop + 1 : +1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return heights;
|
|
28
|
+
};
|
|
29
|
+
export const isRowDeleteButtonVisible = selection => {
|
|
30
|
+
if (!isTableSelected(selection) && selection instanceof CellSelection && selection.isRowSelection()) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return false;
|
|
35
|
+
};
|
|
36
|
+
export const getRowDeleteButtonParams = (rowsHeights, selection, offsetTop = 0) => {
|
|
37
|
+
const rect = getSelectionRect(selection);
|
|
38
|
+
|
|
39
|
+
if (!rect) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let height = 0;
|
|
44
|
+
let offset = offsetTop; // find the rows before the selection
|
|
45
|
+
|
|
46
|
+
for (let i = 0; i < rect.top; i++) {
|
|
47
|
+
const rowHeight = rowsHeights[i];
|
|
48
|
+
|
|
49
|
+
if (rowHeight) {
|
|
50
|
+
offset += rowHeight - 1;
|
|
51
|
+
}
|
|
52
|
+
} // these are the selected rows widths
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
const indexes = [];
|
|
56
|
+
|
|
57
|
+
for (let i = rect.top; i < rect.bottom; i++) {
|
|
58
|
+
const rowHeight = rowsHeights[i];
|
|
59
|
+
|
|
60
|
+
if (rowHeight) {
|
|
61
|
+
height += rowHeight - 1;
|
|
62
|
+
indexes.push(i);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const top = offset + height / 2 - tableDeleteButtonSize / 2;
|
|
67
|
+
return {
|
|
68
|
+
top,
|
|
69
|
+
indexes
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export const getRowsParams = rowsHeights => {
|
|
73
|
+
const rows = [];
|
|
74
|
+
|
|
75
|
+
for (let i = 0, count = rowsHeights.length; i < count; i++) {
|
|
76
|
+
const height = rowsHeights[i];
|
|
77
|
+
|
|
78
|
+
if (!height) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let endIndex = rowsHeights.length;
|
|
83
|
+
|
|
84
|
+
for (let k = i + 1, count = rowsHeights.length; k < count; k++) {
|
|
85
|
+
if (rowsHeights[k]) {
|
|
86
|
+
endIndex = k;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
rows.push({
|
|
92
|
+
startIndex: i,
|
|
93
|
+
endIndex,
|
|
94
|
+
height
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return rows;
|
|
99
|
+
};
|
|
100
|
+
export const getRowClassNames = (index, selection, hoveredRows = [], isInDanger, isResizing) => {
|
|
101
|
+
const classNames = [];
|
|
102
|
+
|
|
103
|
+
if (isRowSelected(index)(selection) || hoveredRows.indexOf(index) > -1 && !isResizing) {
|
|
104
|
+
classNames.push(ClassName.HOVERED_CELL_ACTIVE);
|
|
105
|
+
|
|
106
|
+
if (isInDanger) {
|
|
107
|
+
classNames.push(ClassName.HOVERED_CELL_IN_DANGER);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return classNames.join(' ');
|
|
112
|
+
};
|
|
113
|
+
export const copyPreviousRow = schema => insertNewRowIndex => tr => {
|
|
114
|
+
const table = findTable(tr.selection);
|
|
115
|
+
|
|
116
|
+
if (!table) {
|
|
117
|
+
return tr;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const map = TableMap.get(table.node);
|
|
121
|
+
const copyPreviousRowIndex = insertNewRowIndex - 1;
|
|
122
|
+
|
|
123
|
+
if (insertNewRowIndex <= 0) {
|
|
124
|
+
throw Error(`Row Index less or equal 0 isn't not allowed since there is not a previous to copy`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (insertNewRowIndex > map.height) {
|
|
128
|
+
return tr;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const tableNode = table.node;
|
|
132
|
+
const {
|
|
133
|
+
nodes: {
|
|
134
|
+
tableRow
|
|
135
|
+
}
|
|
136
|
+
} = schema;
|
|
137
|
+
const cellsInRow = map.cellsInRect({
|
|
138
|
+
left: 0,
|
|
139
|
+
right: map.width,
|
|
140
|
+
top: copyPreviousRowIndex,
|
|
141
|
+
bottom: copyPreviousRowIndex + 1
|
|
142
|
+
});
|
|
143
|
+
const offsetIndexPosition = copyPreviousRowIndex * map.width;
|
|
144
|
+
const offsetNextLineIndexPosition = insertNewRowIndex * map.width;
|
|
145
|
+
const cellsPositionsInOriginalRow = map.map.slice(offsetIndexPosition, offsetIndexPosition + map.width);
|
|
146
|
+
const cellsPositionsInNextRow = map.map.slice(offsetNextLineIndexPosition, offsetNextLineIndexPosition + map.width);
|
|
147
|
+
let cells = [];
|
|
148
|
+
let fixRowspans = [];
|
|
149
|
+
|
|
150
|
+
for (let i = 0; i < cellsPositionsInOriginalRow.length;) {
|
|
151
|
+
const pos = cellsPositionsInOriginalRow[i];
|
|
152
|
+
const documentCellPos = pos + table.start;
|
|
153
|
+
const node = tr.doc.nodeAt(documentCellPos);
|
|
154
|
+
|
|
155
|
+
if (!node) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const attributes = { ...node.attrs,
|
|
160
|
+
colspan: 1,
|
|
161
|
+
rowspan: 1
|
|
162
|
+
};
|
|
163
|
+
const newCell = node.type.createAndFill(attributes);
|
|
164
|
+
|
|
165
|
+
if (!newCell) {
|
|
166
|
+
return tr;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (cellsPositionsInNextRow.indexOf(pos) > -1) {
|
|
170
|
+
fixRowspans.push({
|
|
171
|
+
pos: documentCellPos,
|
|
172
|
+
node
|
|
173
|
+
});
|
|
174
|
+
} else if (cellsInRow.indexOf(pos) > -1) {
|
|
175
|
+
if (node.attrs.colspan > 1) {
|
|
176
|
+
const newCellWithColspanFixed = node.type.createAndFill({ ...attributes,
|
|
177
|
+
colspan: node.attrs.colspan
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
if (!newCellWithColspanFixed) {
|
|
181
|
+
return tr;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
cells.push(newCellWithColspanFixed);
|
|
185
|
+
i = i + node.attrs.colspan;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
cells.push(newCell);
|
|
190
|
+
} else {
|
|
191
|
+
cells.push(newCell);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
i++;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
fixRowspans.forEach(cell => {
|
|
198
|
+
tr.setNodeMarkup(cell.pos, undefined, { ...cell.node.attrs,
|
|
199
|
+
rowspan: cell.node.attrs.rowspan + 1
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
const cloneRow = tableNode.child(copyPreviousRowIndex);
|
|
203
|
+
let rowPos = table.start;
|
|
204
|
+
|
|
205
|
+
for (let i = 0; i < insertNewRowIndex; i++) {
|
|
206
|
+
rowPos += tableNode.child(i).nodeSize;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return safeInsert(tableRow.createChecked(cloneRow.attrs, cells, cloneRow.marks), rowPos)(tr);
|
|
210
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
2
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
3
|
+
import { findTable, getSelectionRangeInColumn, getSelectionRangeInRow, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
4
|
+
export const isSelectionUpdated = (oldSelection, newSelection) => !!(!newSelection && oldSelection) || isSelectionType(oldSelection, 'cell') !== isSelectionType(newSelection, 'cell') || isSelectionType(oldSelection, 'cell') && isSelectionType(newSelection, 'cell') && oldSelection.ranges !== newSelection.ranges;
|
|
5
|
+
|
|
6
|
+
const isRectangularCellSelection = (selection, rect) => {
|
|
7
|
+
const table = findTable(selection);
|
|
8
|
+
|
|
9
|
+
if (!table) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
width,
|
|
15
|
+
height,
|
|
16
|
+
map
|
|
17
|
+
} = TableMap.get(table.node);
|
|
18
|
+
let indexTop = rect.top * width + rect.left;
|
|
19
|
+
let indexLeft = indexTop;
|
|
20
|
+
let indexBottom = (rect.bottom - 1) * width + rect.left;
|
|
21
|
+
let indexRight = indexTop + (rect.right - rect.left - 1);
|
|
22
|
+
|
|
23
|
+
for (let i = rect.top; i < rect.bottom; i++) {
|
|
24
|
+
if (rect.left > 0 && map[indexLeft] === map[indexLeft - 1] || rect.right < width && map[indexRight] === map[indexRight + 1]) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
indexLeft += width;
|
|
29
|
+
indexRight += width;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
for (let i = rect.left; i < rect.right; i++) {
|
|
33
|
+
if (rect.top > 0 && map[indexTop] === map[indexTop - width] || rect.bottom < height && map[indexBottom] === map[indexBottom + width]) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
indexTop++;
|
|
38
|
+
indexBottom++;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return true;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const normalizeSelection = tr => {
|
|
45
|
+
const {
|
|
46
|
+
selection
|
|
47
|
+
} = tr;
|
|
48
|
+
const rect = getSelectionRect(selection);
|
|
49
|
+
|
|
50
|
+
if (!rect || !(selection instanceof CellSelection) || isRectangularCellSelection(selection, rect)) {
|
|
51
|
+
return tr;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (selection.isColSelection()) {
|
|
55
|
+
var _getSelectionRangeInC, _getSelectionRangeInC2;
|
|
56
|
+
|
|
57
|
+
const $anchor = (_getSelectionRangeInC = getSelectionRangeInColumn(rect.left)(tr)) === null || _getSelectionRangeInC === void 0 ? void 0 : _getSelectionRangeInC.$anchor;
|
|
58
|
+
const $head = (_getSelectionRangeInC2 = getSelectionRangeInColumn(rect.right - 1)(tr)) === null || _getSelectionRangeInC2 === void 0 ? void 0 : _getSelectionRangeInC2.$head;
|
|
59
|
+
|
|
60
|
+
if ($anchor && $head) {
|
|
61
|
+
return tr.setSelection(new CellSelection($anchor, $head));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (selection.isRowSelection()) {
|
|
66
|
+
var _getSelectionRangeInR, _getSelectionRangeInR2;
|
|
67
|
+
|
|
68
|
+
const $anchor = (_getSelectionRangeInR = getSelectionRangeInRow(rect.top)(tr)) === null || _getSelectionRangeInR === void 0 ? void 0 : _getSelectionRangeInR.$anchor;
|
|
69
|
+
const $head = (_getSelectionRangeInR2 = getSelectionRangeInRow(rect.bottom - 1)(tr)) === null || _getSelectionRangeInR2 === void 0 ? void 0 : _getSelectionRangeInR2.$head;
|
|
70
|
+
|
|
71
|
+
if ($anchor && $head) {
|
|
72
|
+
return tr.setSelection(new CellSelection($anchor, $head));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return tr;
|
|
77
|
+
};
|
|
78
|
+
export const getSelectedColumnIndexes = selectionRect => {
|
|
79
|
+
const columnIndexes = [];
|
|
80
|
+
|
|
81
|
+
for (let i = selectionRect.left; i < selectionRect.right; i++) {
|
|
82
|
+
columnIndexes.push(i);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return columnIndexes;
|
|
86
|
+
};
|
|
87
|
+
export const getSelectedRowIndexes = selectionRect => {
|
|
88
|
+
const rowIndexes = [];
|
|
89
|
+
|
|
90
|
+
for (let i = selectionRect.top; i < selectionRect.bottom; i++) {
|
|
91
|
+
rowIndexes.push(i);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return rowIndexes;
|
|
95
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
2
|
+
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
3
|
+
export const getMergedCellsPositions = tr => {
|
|
4
|
+
const table = findTable(tr.selection);
|
|
5
|
+
|
|
6
|
+
if (!table) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const map = TableMap.get(table.node);
|
|
11
|
+
const cellPositions = new Set();
|
|
12
|
+
const mergedCells = [];
|
|
13
|
+
map.map.forEach(value => {
|
|
14
|
+
if (cellPositions.has(value)) {
|
|
15
|
+
mergedCells.push(value);
|
|
16
|
+
} else {
|
|
17
|
+
cellPositions.add(value);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return mergedCells;
|
|
21
|
+
};
|
|
22
|
+
export const colsToRect = (cols, noOfRows) => ({
|
|
23
|
+
left: Math.min(...cols),
|
|
24
|
+
right: Math.max(...cols) + 1,
|
|
25
|
+
top: 0,
|
|
26
|
+
bottom: noOfRows
|
|
27
|
+
});
|
|
@@ -1,45 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { pluginKey } from './plugin-key';
|
|
3
|
-
import { Mark } from 'prosemirror-model';
|
|
4
|
-
import { EditorView } from 'prosemirror-view';
|
|
5
|
-
|
|
6
|
-
function createPlugin() {
|
|
7
|
-
return new SafePlugin({
|
|
8
|
-
key: pluginKey,
|
|
9
|
-
state: {
|
|
10
|
-
init() {
|
|
11
|
-
const z = {
|
|
12
|
-
Mark,
|
|
13
|
-
EditorView
|
|
14
|
-
}; // eslint-disable-next-line no-console
|
|
15
|
-
|
|
16
|
-
console.log('delete to use prosemirror-model/view', z); // eslint-disable-next-line no-console
|
|
17
|
-
|
|
18
|
-
console.log('next table plugin loaded');
|
|
19
|
-
return {
|
|
20
|
-
scaffold: true
|
|
21
|
-
};
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
apply() {}
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
} // const tablesPlugin = (options?: TablePluginOptions): any => ({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const tablesPlugin = () => ({
|
|
32
|
-
name: 'nextTable',
|
|
33
|
-
|
|
34
|
-
pmPlugins() {
|
|
35
|
-
return [{
|
|
36
|
-
name: 'next-table-scaffold',
|
|
37
|
-
plugin: () => {
|
|
38
|
-
return createPlugin();
|
|
39
|
-
}
|
|
40
|
-
}];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
|
|
1
|
+
import { default as tablesPlugin } from './table';
|
|
45
2
|
export default tablesPlugin;
|
package/dist/es2019/version.json
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// #region Imports
|
|
2
|
+
import { Selection } from 'prosemirror-state';
|
|
3
|
+
import { findCellClosestToPos, emptyCell, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
4
|
+
// #endregion
|
|
5
|
+
// #region Commands
|
|
6
|
+
export var clearMultipleCells = function clearMultipleCells(targetCellPosition) {
|
|
7
|
+
return function (state, dispatch) {
|
|
8
|
+
var cursorPos;
|
|
9
|
+
var tr = state.tr;
|
|
10
|
+
|
|
11
|
+
if (isSelectionType(tr.selection, 'cell')) {
|
|
12
|
+
var selection = tr.selection;
|
|
13
|
+
selection.forEachCell(function (_node, pos) {
|
|
14
|
+
var $pos = tr.doc.resolve(tr.mapping.map(pos + 1));
|
|
15
|
+
tr = emptyCell(findCellClosestToPos($pos), state.schema)(tr);
|
|
16
|
+
});
|
|
17
|
+
cursorPos = selection.$headCell.pos;
|
|
18
|
+
} else if (targetCellPosition) {
|
|
19
|
+
var cell = findCellClosestToPos(tr.doc.resolve(targetCellPosition + 1));
|
|
20
|
+
tr = emptyCell(cell, state.schema)(tr);
|
|
21
|
+
cursorPos = cell.pos;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (tr.docChanged && cursorPos) {
|
|
25
|
+
var $pos = tr.doc.resolve(tr.mapping.map(cursorPos));
|
|
26
|
+
var textSelection = Selection.findFrom($pos, 1, true);
|
|
27
|
+
|
|
28
|
+
if (textSelection) {
|
|
29
|
+
tr.setSelection(textSelection);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (dispatch) {
|
|
33
|
+
dispatch(tr);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return false;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export var clearSelection = function clearSelection(state, dispatch) {
|
|
43
|
+
if (dispatch) {
|
|
44
|
+
dispatch(state.tr.setSelection(Selection.near(state.selection.$from)).setMeta('addToHistory', false));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return true;
|
|
48
|
+
}; // #endregion
|