@atlaskit/editor-plugin-table 5.0.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/plugins/table/index.js +47 -37
- package/dist/cjs/plugins/table/nodeviews/TableCell.js +111 -0
- package/dist/cjs/plugins/table/nodeviews/TableNodeViewBase.js +30 -0
- package/dist/cjs/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +313 -307
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/actions.js +12 -0
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +27 -0
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/consts.js +11 -0
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/index.js +32 -0
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin-factory.js +13 -0
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin-key.js +8 -0
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +28 -0
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/reducer.js +28 -0
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/types.js +5 -0
- package/dist/cjs/plugins/table/pm-plugins/main.js +16 -13
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/index.js +1 -8
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
- package/dist/cjs/plugins/table/utils/dom.js +31 -1
- package/dist/cjs/plugins/table/utils/index.js +12 -0
- package/dist/cjs/plugins/table/utils/nodes.js +31 -7
- package/dist/es2019/plugins/table/index.js +12 -3
- package/dist/es2019/plugins/table/nodeviews/{tableCell.js → TableCell.js} +28 -24
- package/dist/es2019/plugins/table/nodeviews/TableNodeViewBase.js +22 -0
- package/dist/es2019/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +273 -284
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/actions.js +6 -0
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +14 -0
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/consts.js +5 -0
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/index.js +3 -0
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin-factory.js +8 -0
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin-key.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +22 -0
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/reducer.js +20 -0
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/types.js +1 -0
- package/dist/es2019/plugins/table/pm-plugins/main.js +8 -8
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/index.js +1 -2
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
- package/dist/es2019/plugins/table/utils/dom.js +30 -0
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/es2019/plugins/table/utils/nodes.js +16 -0
- package/dist/esm/plugins/table/index.js +47 -37
- package/dist/esm/plugins/table/nodeviews/TableCell.js +105 -0
- package/dist/esm/plugins/table/nodeviews/TableNodeViewBase.js +24 -0
- package/dist/esm/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +314 -307
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/actions.js +6 -0
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +22 -0
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/consts.js +5 -0
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/index.js +3 -0
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin-factory.js +7 -0
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin-key.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +22 -0
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/reducer.js +21 -0
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/types.js +1 -0
- package/dist/esm/plugins/table/pm-plugins/main.js +16 -13
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/index.js +1 -2
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
- package/dist/esm/plugins/table/utils/dom.js +30 -0
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/utils/nodes.js +24 -0
- package/dist/types/plugins/table/nodeviews/TableCell.d.ts +13 -0
- package/dist/types/plugins/table/nodeviews/TableNodeViewBase.d.ts +18 -0
- package/dist/types/plugins/table/nodeviews/TableRow.d.ts +60 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +15 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +4 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/consts.d.ts +6 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/index.d.ts +4 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/plugin-factory.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/plugin-key.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/plugin.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/reducer.d.ts +4 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/types.d.ts +5 -0
- package/dist/types/plugins/table/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/sticky-headers/index.d.ts +0 -1
- package/dist/types/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +1 -1
- package/dist/types/plugins/table/types.d.ts +1 -0
- package/dist/types/plugins/table/utils/dom.d.ts +6 -0
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types/plugins/table/utils/nodes.d.ts +12 -2
- package/dist/types-ts4.5/i18n/cs.d.ts +37 -0
- package/dist/types-ts4.5/i18n/da.d.ts +35 -0
- package/dist/types-ts4.5/i18n/de.d.ts +35 -0
- package/dist/types-ts4.5/i18n/en.d.ts +37 -0
- package/dist/types-ts4.5/i18n/en_GB.d.ts +37 -0
- package/dist/types-ts4.5/i18n/en_ZZ.d.ts +37 -0
- package/dist/types-ts4.5/i18n/es.d.ts +35 -0
- package/dist/types-ts4.5/i18n/fi.d.ts +35 -0
- package/dist/types-ts4.5/i18n/fr.d.ts +37 -0
- package/dist/types-ts4.5/i18n/hu.d.ts +37 -0
- package/dist/types-ts4.5/i18n/it.d.ts +37 -0
- package/dist/types-ts4.5/i18n/ja.d.ts +37 -0
- package/dist/types-ts4.5/i18n/ko.d.ts +35 -0
- package/dist/types-ts4.5/i18n/nb.d.ts +35 -0
- package/dist/types-ts4.5/i18n/nl.d.ts +37 -0
- package/dist/types-ts4.5/i18n/pl.d.ts +37 -0
- package/dist/types-ts4.5/i18n/pt_BR.d.ts +37 -0
- package/dist/types-ts4.5/i18n/ru.d.ts +37 -0
- package/dist/types-ts4.5/i18n/sv.d.ts +35 -0
- package/dist/types-ts4.5/i18n/th.d.ts +35 -0
- package/dist/types-ts4.5/i18n/tr.d.ts +37 -0
- package/dist/types-ts4.5/i18n/uk.d.ts +37 -0
- package/dist/types-ts4.5/i18n/vi.d.ts +35 -0
- package/dist/types-ts4.5/i18n/zh.d.ts +37 -0
- package/dist/types-ts4.5/i18n/zh_TW.d.ts +37 -0
- package/dist/types-ts4.5/index.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/commands/clear.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/commands/collapse.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/commands/delete.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/commands/go-to-next-cell.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/commands/index.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/commands/insert.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +29 -0
- package/dist/types-ts4.5/plugins/table/commands/referentiality.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/commands/selection.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/commands/sort.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/commands/split-cell.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/commands/toggle.d.ts +12 -0
- package/dist/types-ts4.5/plugins/table/commands-with-analytics.d.ts +25 -0
- package/dist/types-ts4.5/plugins/table/create-plugin-config.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +15 -0
- package/dist/types-ts4.5/plugins/table/handlers.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/index.d.ts +38 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +24 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableCell.d.ts +13 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +73 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +44 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableNodeViewBase.d.ts +18 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +25 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableRow.d.ts +60 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableStickyScrollbar.d.ts +24 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/__mocks__/OverridableMock.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +33 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +26 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/update-overflow-shadows.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +7 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/index.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/types.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/default-table-selection.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +15 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/consts.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/index.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/plugin-factory.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/plugin.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/reducer.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/types.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/keymap.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/plugin-factory.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +15 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/commands.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/index.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/types.d.ts +16 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/util.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-analytics.d.ts +23 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-local-id.d.ts +10 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/commands.d.ts +23 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/index.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/reducer.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +23 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/column-state.d.ts +14 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/content-width.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +12 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +13 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +20 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +29 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +21 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/types.d.ts +22 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-selection-keymap.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-width.d.ts +17 -0
- package/dist/types-ts4.5/plugins/table/reducer.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/toolbar.d.ts +36 -0
- package/dist/types-ts4.5/plugins/table/transforms/column-width.d.ts +37 -0
- package/dist/types-ts4.5/plugins/table/transforms/delete-columns.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/transforms/delete-rows.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/transforms/fix-tables.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/transforms/index.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/transforms/merge.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/transforms/replace-table.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/transforms/split.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/types.d.ts +343 -0
- package/dist/types-ts4.5/plugins/table/ui/ColumnResizeWidget/index.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingContextualButton/FixedButton.d.ts +23 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingContextualButton/index.d.ts +21 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingContextualButton/styles.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +87 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/index.d.ts +23 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/styles.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/DeleteButton.d.ts +13 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.d.ts +10 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +54 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +13 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/index.d.ts +35 -0
- package/dist/types-ts4.5/plugins/table/ui/LayoutButton/index.d.ts +21 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +16 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +21 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +17 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +39 -0
- package/dist/types-ts4.5/plugins/table/ui/common-styles.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +50 -0
- package/dist/types-ts4.5/plugins/table/ui/messages.d.ts +63 -0
- package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +15 -0
- package/dist/types-ts4.5/plugins/table/utils/analytics.d.ts +45 -0
- package/dist/types-ts4.5/plugins/table/utils/collapse.d.ts +29 -0
- package/dist/types-ts4.5/plugins/table/utils/column-controls.d.ts +10 -0
- package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +19 -0
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +26 -0
- package/dist/types-ts4.5/plugins/table/utils/get-allow-add-column-custom-step.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/utils/guidelines.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +11 -0
- package/dist/types-ts4.5/plugins/table/utils/nodes.d.ts +23 -0
- package/dist/types-ts4.5/plugins/table/utils/paste.d.ts +14 -0
- package/dist/types-ts4.5/plugins/table/utils/row-controls.d.ts +16 -0
- package/dist/types-ts4.5/plugins/table/utils/selection.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/utils/snapping.d.ts +10 -0
- package/dist/types-ts4.5/plugins/table/utils/table.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/utils/update-plugin-state-decorations.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table-plugin.d.ts +2 -0
- package/dist/types-ts4.5/types/i18n.d.ts +5 -0
- package/package.json +3 -3
- package/report.api.md +2 -17
- package/src/__tests__/unit/nodeviews/cell.ts +2 -2
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +25 -148
- package/src/plugins/table/index.tsx +14 -0
- package/src/plugins/table/nodeviews/{tableCell.tsx → TableCell.ts} +41 -46
- package/src/plugins/table/nodeviews/TableNodeViewBase.ts +32 -0
- package/src/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.ts → nodeviews/TableRow.ts} +193 -246
- package/src/plugins/table/pm-plugins/drag-and-drop/actions.ts +29 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +32 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/consts.ts +8 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/index.ts +5 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin-factory.ts +8 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin-key.ts +7 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +32 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/reducer.ts +26 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/types.ts +6 -0
- package/src/plugins/table/pm-plugins/main.ts +10 -19
- package/src/plugins/table/pm-plugins/sticky-headers/index.ts +0 -1
- package/src/plugins/table/pm-plugins/sticky-headers/plugin.ts +1 -9
- package/src/plugins/table/types.ts +2 -0
- package/src/plugins/table/utils/dom.ts +38 -0
- package/src/plugins/table/utils/index.ts +2 -0
- package/src/plugins/table/utils/nodes.ts +30 -2
- package/tmp/api-report-tmp.d.ts +100 -0
- package/dist/cjs/plugins/table/nodeviews/tableCell.js +0 -99
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -35
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -29
- package/dist/esm/plugins/table/nodeviews/tableCell.js +0 -93
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -29
- package/dist/types/plugins/table/nodeviews/tableCell.d.ts +0 -17
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +0 -6
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +0 -73
- package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.ts +0 -37
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
3
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
4
10
|
import debounce from 'lodash/debounce';
|
|
5
11
|
import throttle from 'lodash/throttle';
|
|
6
12
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
7
|
-
import { browser
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
13
|
+
import { browser } from '@atlaskit/editor-common/utils';
|
|
14
|
+
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
15
|
+
import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
|
|
16
|
+
import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
|
|
17
|
+
import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
|
|
18
|
+
import { TableCssClassName as ClassName, TableCssClassName } from '../types';
|
|
19
|
+
import { STICKY_HEADER_TOGGLE_TOLERANCE_MS, stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableControlsSpacing, tableScrollbarOffset } from '../ui/consts';
|
|
20
|
+
import { getTop, getTree } from '../utils/dom';
|
|
21
|
+
import { supportedHeaderRow } from '../utils/nodes';
|
|
22
|
+
import TableNodeView from './TableNodeViewBase';
|
|
14
23
|
|
|
15
24
|
// limit scroll event calls
|
|
16
25
|
var HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
|
|
@@ -18,268 +27,127 @@ var HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
|
|
|
18
27
|
// timeout for resetting the scroll class - if it’s too long then users won’t be able to click on the header cells,
|
|
19
28
|
// if too short it would trigger too many dom updates.
|
|
20
29
|
var HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return child.type.name === 'tableHeader';
|
|
40
|
-
}).every(Boolean);
|
|
41
|
-
var someMerged = anyChildCellMergedAcrossRow(node);
|
|
42
|
-
return allHeaders && !someMerged;
|
|
43
|
-
};
|
|
44
|
-
export var TableRowNodeView = /*#__PURE__*/function () {
|
|
45
|
-
function TableRowNodeView(node, view, getPos, eventDispatcher) {
|
|
46
|
-
var _this = this;
|
|
47
|
-
_classCallCheck(this, TableRowNodeView);
|
|
48
|
-
// this is the sticky header table row
|
|
49
|
-
_defineProperty(this, "colControlsOffset", 0);
|
|
50
|
-
_defineProperty(this, "focused", false);
|
|
51
|
-
_defineProperty(this, "topPosEditorElement", 0);
|
|
52
|
-
_defineProperty(this, "sentinels", {});
|
|
53
|
-
/* external events */
|
|
54
|
-
_defineProperty(this, "listening", false);
|
|
55
|
-
_defineProperty(this, "headerRowMouseScrollEnd", debounce(function () {
|
|
30
|
+
var TableRow = /*#__PURE__*/function (_ref) {
|
|
31
|
+
_inherits(TableRow, _ref);
|
|
32
|
+
var _super = _createSuper(TableRow);
|
|
33
|
+
function TableRow(node, view, getPos, eventDispatcher) {
|
|
34
|
+
var _this;
|
|
35
|
+
_classCallCheck(this, TableRow);
|
|
36
|
+
_this = _super.call(this, node, view, getPos, eventDispatcher);
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "colControlsOffset", 0);
|
|
38
|
+
_defineProperty(_assertThisInitialized(_this), "focused", false);
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "topPosEditorElement", 0);
|
|
40
|
+
_defineProperty(_assertThisInitialized(_this), "sentinels", {});
|
|
41
|
+
_defineProperty(_assertThisInitialized(_this), "listening", false);
|
|
42
|
+
_defineProperty(_assertThisInitialized(_this), "padding", 0);
|
|
43
|
+
_defineProperty(_assertThisInitialized(_this), "top", 0);
|
|
44
|
+
/**
|
|
45
|
+
* Methods
|
|
46
|
+
*/
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "headerRowMouseScrollEnd", debounce(function () {
|
|
56
48
|
_this.dom.classList.remove('no-pointer-events');
|
|
57
49
|
}, HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT));
|
|
58
50
|
// When the header is sticky, the header row is set to position: fixed
|
|
59
51
|
// This prevents mouse wheel scrolling on the scroll-parent div when user's mouse is hovering the header row.
|
|
60
52
|
// This fix sets pointer-events: none on the header row briefly to avoid this behaviour
|
|
61
|
-
_defineProperty(
|
|
53
|
+
_defineProperty(_assertThisInitialized(_this), "headerRowMouseScroll", throttle(function () {
|
|
62
54
|
if (_this.isSticky) {
|
|
63
55
|
_this.dom.classList.add('no-pointer-events');
|
|
64
56
|
_this.headerRowMouseScrollEnd();
|
|
65
57
|
}
|
|
66
58
|
}, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
if (el) {
|
|
79
|
-
delete el.dataset.isObserved;
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
var isCurrentTableSelected = tableRef === tree.table;
|
|
84
|
-
|
|
85
|
-
// If current table selected and header row is toggled off, turn off sticky header
|
|
86
|
-
if (isCurrentTableSelected && !state.isHeaderRowEnabled && _this.tree) {
|
|
87
|
-
_this.makeRowHeaderNotSticky(_this.tree.table);
|
|
88
|
-
}
|
|
89
|
-
_this.focused = isCurrentTableSelected;
|
|
90
|
-
var wrapper = tree.wrapper;
|
|
91
|
-
var tableContainer = wrapper.parentElement;
|
|
92
|
-
var tableContentWrapper = tableContainer.parentElement;
|
|
93
|
-
var layoutContainer = tableContentWrapper && tableContentWrapper.parentElement;
|
|
94
|
-
if (isCurrentTableSelected) {
|
|
95
|
-
_this.colControlsOffset = tableControlsSpacing;
|
|
96
|
-
if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
|
|
97
|
-
// move table a little out of the way
|
|
98
|
-
// to provide spacing for table controls
|
|
99
|
-
tableContentWrapper.style.paddingLeft = '11px';
|
|
100
|
-
}
|
|
101
|
-
} else {
|
|
102
|
-
_this.colControlsOffset = 0;
|
|
103
|
-
if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
|
|
104
|
-
tableContentWrapper.style.removeProperty('padding-left');
|
|
105
|
-
}
|
|
59
|
+
_this.isHeaderRow = supportedHeaderRow(node);
|
|
60
|
+
_this.isSticky = false;
|
|
61
|
+
var _getPluginState = getPluginState(view.state),
|
|
62
|
+
pluginConfig = _getPluginState.pluginConfig,
|
|
63
|
+
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
64
|
+
_this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
|
|
65
|
+
_this.isDragAndDropEnabled = !!isDragAndDropEnabled;
|
|
66
|
+
if (_this.isHeaderRow) {
|
|
67
|
+
_this.dom.setAttribute('data-header-row', 'true');
|
|
68
|
+
if (_this.isStickyHeaderEnabled) {
|
|
69
|
+
_this.subscribe();
|
|
106
70
|
}
|
|
71
|
+
}
|
|
72
|
+
return _this;
|
|
73
|
+
}
|
|
107
74
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}, 0);
|
|
112
|
-
});
|
|
113
|
-
_defineProperty(this, "updateStickyHeaderWidth", function () {
|
|
114
|
-
// table width might have changed, sync that back to sticky row
|
|
115
|
-
var tree = _this.tree;
|
|
116
|
-
if (!tree) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
syncStickyRowToTable(tree.table);
|
|
120
|
-
});
|
|
121
|
-
_defineProperty(this, "shouldHeaderStick", function (tree) {
|
|
122
|
-
var wrapper = tree.wrapper;
|
|
123
|
-
var tableWrapperRect = wrapper.getBoundingClientRect();
|
|
124
|
-
var editorAreaRect = _this.editorScrollableElement.getBoundingClientRect();
|
|
125
|
-
var stickyHeaderRect = _this.contentDOM.getBoundingClientRect();
|
|
126
|
-
var firstHeaderRow = !_this.dom.previousElementSibling;
|
|
127
|
-
var subsequentRows = !!_this.dom.nextElementSibling;
|
|
128
|
-
var isHeaderValid = firstHeaderRow && subsequentRows;
|
|
75
|
+
/**
|
|
76
|
+
* Variables
|
|
77
|
+
*/
|
|
129
78
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
_createClass(TableRow, [{
|
|
81
|
+
key: "update",
|
|
82
|
+
value:
|
|
83
|
+
/**
|
|
84
|
+
* Methods: Nodeview Lifecycle
|
|
85
|
+
*/
|
|
86
|
+
function update(node) {
|
|
87
|
+
// do nothing if nodes were identical
|
|
88
|
+
if (node === this.node) {
|
|
134
89
|
return true;
|
|
135
90
|
}
|
|
136
91
|
|
|
137
|
-
// if
|
|
138
|
-
|
|
139
|
-
|
|
92
|
+
// see if we're changing into a header row or
|
|
93
|
+
// changing away from one
|
|
94
|
+
var newNodeIsHeaderRow = supportedHeaderRow(node);
|
|
95
|
+
if (this.isHeaderRow !== newNodeIsHeaderRow) {
|
|
96
|
+
return false; // re-create nodeview
|
|
140
97
|
}
|
|
141
98
|
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
});
|
|
145
|
-
/**
|
|
146
|
-
* Manually refire the intersection observers.
|
|
147
|
-
* Useful when the header may have detached from the table.
|
|
148
|
-
*/
|
|
149
|
-
_defineProperty(this, "refireIntersectionObservers", function () {
|
|
150
|
-
if (_this.isSticky) {
|
|
151
|
-
[_this.sentinels.top, _this.sentinels.bottom].forEach(function (el) {
|
|
152
|
-
if (el && _this.intersectionObserver) {
|
|
153
|
-
_this.intersectionObserver.unobserve(el);
|
|
154
|
-
_this.intersectionObserver.observe(el);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
_defineProperty(this, "makeHeaderRowSticky", function (tree, scrollTop) {
|
|
160
|
-
var _tbody$firstChild;
|
|
161
|
-
// If header row height is more than 50% of viewport height don't do this
|
|
162
|
-
if (_this.isSticky || _this.stickyRowHeight && _this.stickyRowHeight > window.innerHeight / 2) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
var table = tree.table,
|
|
166
|
-
wrapper = tree.wrapper;
|
|
99
|
+
// node is different but no need to re-create nodeview
|
|
100
|
+
this.node = node;
|
|
167
101
|
|
|
168
|
-
//
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (!isFirstHeader) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
var currentTableTop = _this.getCurrentTableTop(tree);
|
|
175
|
-
if (!scrollTop) {
|
|
176
|
-
scrollTop = getTop(_this.editorScrollableElement);
|
|
102
|
+
// don't do anything if we're just a regular tr
|
|
103
|
+
if (!this.isHeaderRow) {
|
|
104
|
+
return true;
|
|
177
105
|
}
|
|
178
|
-
var domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
|
|
179
|
-
if (!_this.isSticky) {
|
|
180
|
-
var _this$editorScrollabl;
|
|
181
|
-
syncStickyRowToTable(table);
|
|
182
|
-
_this.dom.classList.add('sticky');
|
|
183
|
-
table.classList.add(ClassName.TABLE_STICKY);
|
|
184
|
-
_this.isSticky = true;
|
|
185
106
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
(_this$editorScrollabl = _this.editorScrollableElement) === null || _this$editorScrollabl === void 0 || _this$editorScrollabl.addEventListener('scrollend', _this.refireIntersectionObservers, {
|
|
192
|
-
passive: true,
|
|
193
|
-
once: true
|
|
194
|
-
});
|
|
195
|
-
var fastScrollThresholdMs = 500;
|
|
196
|
-
setTimeout(function () {
|
|
197
|
-
_this.refireIntersectionObservers();
|
|
198
|
-
}, fastScrollThresholdMs);
|
|
199
|
-
}
|
|
200
|
-
_this.dom.style.top = "".concat(domTop, "px");
|
|
201
|
-
updateTableMargin(table);
|
|
202
|
-
_this.dom.scrollLeft = wrapper.scrollLeft;
|
|
203
|
-
_this.emitOn(domTop, _this.colControlsOffset);
|
|
204
|
-
});
|
|
205
|
-
_defineProperty(this, "makeRowHeaderNotSticky", function (table) {
|
|
206
|
-
var isEditorDestroyed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
207
|
-
if (!_this.isSticky || !table || !_this.dom) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
_this.dom.style.removeProperty('width');
|
|
211
|
-
_this.dom.classList.remove('sticky');
|
|
212
|
-
table.classList.remove(ClassName.TABLE_STICKY);
|
|
213
|
-
_this.isSticky = false;
|
|
214
|
-
_this.dom.style.top = '';
|
|
215
|
-
table.style.removeProperty('margin-top');
|
|
216
|
-
_this.emitOff(isEditorDestroyed);
|
|
217
|
-
});
|
|
218
|
-
_defineProperty(this, "getWrapperoffset", function () {
|
|
219
|
-
var inverse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
220
|
-
var focusValue = inverse ? !_this.focused : _this.focused;
|
|
221
|
-
return focusValue ? 0 : tableControlsSpacing;
|
|
222
|
-
});
|
|
223
|
-
_defineProperty(this, "getWrapperRefTop", function (wrapper) {
|
|
224
|
-
return Math.round(getTop(wrapper)) + _this.getWrapperoffset();
|
|
225
|
-
});
|
|
226
|
-
// TODO: rename!
|
|
227
|
-
_defineProperty(this, "getScrolledTableTop", function (wrapper) {
|
|
228
|
-
return _this.getWrapperRefTop(wrapper) - _this.topPosEditorElement;
|
|
229
|
-
});
|
|
230
|
-
_defineProperty(this, "getCurrentTableTop", function (tree) {
|
|
231
|
-
return _this.getScrolledTableTop(tree.wrapper) + tree.table.clientHeight;
|
|
232
|
-
});
|
|
233
|
-
/* emit external events */
|
|
234
|
-
_defineProperty(this, "padding", 0);
|
|
235
|
-
_defineProperty(this, "top", 0);
|
|
236
|
-
_defineProperty(this, "emitOn", function (top, padding) {
|
|
237
|
-
if (top === _this.top && padding === _this.padding) {
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
_this.top = top;
|
|
241
|
-
_this.padding = padding;
|
|
242
|
-
updateStickyState({
|
|
243
|
-
pos: _this.getPos(),
|
|
244
|
-
top: top,
|
|
245
|
-
sticky: true,
|
|
246
|
-
padding: padding
|
|
247
|
-
})(_this.view.state, _this.view.dispatch, _this.view);
|
|
248
|
-
});
|
|
249
|
-
_defineProperty(this, "emitOff", function (isEditorDestroyed) {
|
|
250
|
-
if (_this.top === 0 && _this.padding === 0) {
|
|
251
|
-
return;
|
|
107
|
+
// something changed, sync widths
|
|
108
|
+
if (this.isStickyHeaderEnabled) {
|
|
109
|
+
var tbody = this.dom.parentElement;
|
|
110
|
+
var table = tbody && tbody.parentElement;
|
|
111
|
+
syncStickyRowToTable(table);
|
|
252
112
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "destroy",
|
|
117
|
+
value: function destroy() {
|
|
118
|
+
if (this.isStickyHeaderEnabled) {
|
|
119
|
+
this.unsubscribe();
|
|
120
|
+
var tree = getTree(this.dom);
|
|
121
|
+
if (tree) {
|
|
122
|
+
this.makeRowHeaderNotSticky(tree.table, true);
|
|
123
|
+
}
|
|
124
|
+
this.emitOff(true);
|
|
262
125
|
}
|
|
263
|
-
});
|
|
264
|
-
this.view = view;
|
|
265
|
-
this.node = node;
|
|
266
|
-
this.getPos = getPos;
|
|
267
|
-
this.eventDispatcher = eventDispatcher;
|
|
268
|
-
this.dom = document.createElement('tr');
|
|
269
|
-
this.contentDOM = this.dom;
|
|
270
|
-
this.lastTimePainted = 0;
|
|
271
|
-
this.isHeaderRow = supportedHeaderRow(node);
|
|
272
|
-
this.isSticky = false;
|
|
273
|
-
this.lastStickyTimestamp = undefined;
|
|
274
|
-
if (this.isHeaderRow) {
|
|
275
|
-
this.dom.setAttribute('data-header-row', 'true');
|
|
276
|
-
this.subscribe();
|
|
277
126
|
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
127
|
+
}, {
|
|
128
|
+
key: "ignoreMutation",
|
|
129
|
+
value: function ignoreMutation(mutationRecord) {
|
|
130
|
+
/* tableRows are not directly editable by the user
|
|
131
|
+
* so it should be safe to ignore mutations that we cause
|
|
132
|
+
* by updating styles and classnames on this DOM element
|
|
133
|
+
*
|
|
134
|
+
* Update: should not ignore mutations for row selection to avoid known issue with table selection highlight in firefox
|
|
135
|
+
* Related bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1289673
|
|
136
|
+
* */
|
|
137
|
+
var isTableSelection = mutationRecord.type === 'selection' && mutationRecord.target.nodeName === 'TR';
|
|
138
|
+
/**
|
|
139
|
+
* Update: should not ignore mutations when an node is added, as this interferes with
|
|
140
|
+
* prosemirrors handling of some language inputs in Safari (ie. Pinyin, Hiragana).
|
|
141
|
+
*
|
|
142
|
+
* In paticular, when a composition occurs at the start of the first node inside a table cell, if the resulting mutation
|
|
143
|
+
* from the composition end is ignored than prosemirror will end up with; invalid table markup nesting and a misplaced
|
|
144
|
+
* selection and insertion.
|
|
145
|
+
*/
|
|
146
|
+
var isNodeInsertion = mutationRecord.type === 'childList' && mutationRecord.target.nodeName === 'TR' && mutationRecord.addedNodes.length;
|
|
147
|
+
if (isTableSelection || isNodeInsertion) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
283
151
|
}
|
|
284
152
|
}, {
|
|
285
153
|
key: "subscribe",
|
|
@@ -289,8 +157,8 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
289
157
|
this.initObservers();
|
|
290
158
|
this.topPosEditorElement = getTop(this.editorScrollableElement);
|
|
291
159
|
}
|
|
292
|
-
this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth);
|
|
293
|
-
this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState);
|
|
160
|
+
this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
|
|
161
|
+
this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState.bind(this));
|
|
294
162
|
this.listening = true;
|
|
295
163
|
this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this), {
|
|
296
164
|
passive: true
|
|
@@ -344,9 +212,9 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
344
212
|
this.resizeObserver.observe(this.editorScrollableElement);
|
|
345
213
|
}
|
|
346
214
|
window.requestAnimationFrame(function () {
|
|
347
|
-
var
|
|
215
|
+
var _getTree;
|
|
348
216
|
// we expect tree to be defined after animation frame
|
|
349
|
-
var tableContainer = (
|
|
217
|
+
var tableContainer = (_getTree = getTree(_this2.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(TableCssClassName.NODEVIEW_WRAPPER));
|
|
350
218
|
if (tableContainer) {
|
|
351
219
|
_this2.sentinels.top = tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_TOP).item(0);
|
|
352
220
|
_this2.sentinels.bottom = tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_BOTTOM).item(0);
|
|
@@ -368,10 +236,11 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
368
236
|
value: function createResizeObserver() {
|
|
369
237
|
var _this3 = this;
|
|
370
238
|
this.resizeObserver = new ResizeObserver(function (entries) {
|
|
371
|
-
|
|
239
|
+
var tree = getTree(_this3.dom);
|
|
240
|
+
if (!tree) {
|
|
372
241
|
return;
|
|
373
242
|
}
|
|
374
|
-
var table =
|
|
243
|
+
var table = tree.table;
|
|
375
244
|
entries.forEach(function (entry) {
|
|
376
245
|
var _this3$editorScrollab;
|
|
377
246
|
// On resize of the parent scroll element we need to adjust the width
|
|
@@ -397,10 +266,11 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
397
266
|
value: function createIntersectionObserver() {
|
|
398
267
|
var _this4 = this;
|
|
399
268
|
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
400
|
-
|
|
269
|
+
var tree = getTree(_this4.dom);
|
|
270
|
+
if (!tree) {
|
|
401
271
|
return;
|
|
402
272
|
}
|
|
403
|
-
var table =
|
|
273
|
+
var table = tree.table;
|
|
404
274
|
if (table.rows.length < 2) {
|
|
405
275
|
// ED-19307 - When there's only one row in a table the top & bottom sentinels become inverted. This creates some nasty visiblity
|
|
406
276
|
// toggling side-effects because the intersection observers gets confused.
|
|
@@ -419,7 +289,7 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
419
289
|
var sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
|
|
420
290
|
if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
|
|
421
291
|
var _entry$rootBounds3;
|
|
422
|
-
|
|
292
|
+
tree && _this4.makeHeaderRowSticky(tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
|
|
423
293
|
_this4.lastStickyTimestamp = Date.now();
|
|
424
294
|
} else {
|
|
425
295
|
table && _this4.makeRowHeaderNotSticky(table);
|
|
@@ -439,7 +309,7 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
439
309
|
}
|
|
440
310
|
} else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
441
311
|
var _entry$rootBounds5;
|
|
442
|
-
|
|
312
|
+
tree && _this4.makeHeaderRowSticky(tree, entry === null || entry === void 0 || (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
|
|
443
313
|
_this4.lastStickyTimestamp = Date.now();
|
|
444
314
|
}
|
|
445
315
|
}
|
|
@@ -449,72 +319,209 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
449
319
|
root: this.editorScrollableElement
|
|
450
320
|
});
|
|
451
321
|
}
|
|
452
|
-
|
|
453
|
-
/* paint/update loop */
|
|
322
|
+
/* receive external events */
|
|
454
323
|
}, {
|
|
455
|
-
key: "
|
|
456
|
-
value:
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
if (
|
|
460
|
-
return
|
|
324
|
+
key: "onTablePluginState",
|
|
325
|
+
value: function onTablePluginState(state) {
|
|
326
|
+
var tableRef = state.tableRef;
|
|
327
|
+
var tree = getTree(this.dom);
|
|
328
|
+
if (!tree) {
|
|
329
|
+
return;
|
|
461
330
|
}
|
|
462
331
|
|
|
463
|
-
//
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
332
|
+
// when header rows are toggled off - mark sentinels as unobserved
|
|
333
|
+
if (!state.isHeaderRowEnabled) {
|
|
334
|
+
[this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
|
|
335
|
+
if (el) {
|
|
336
|
+
delete el.dataset.isObserved;
|
|
337
|
+
}
|
|
338
|
+
});
|
|
468
339
|
}
|
|
340
|
+
var isCurrentTableSelected = tableRef === tree.table;
|
|
469
341
|
|
|
470
|
-
//
|
|
471
|
-
|
|
342
|
+
// If current table selected and header row is toggled off, turn off sticky header
|
|
343
|
+
if (isCurrentTableSelected && !state.isHeaderRowEnabled && tree) {
|
|
344
|
+
this.makeRowHeaderNotSticky(tree.table);
|
|
345
|
+
}
|
|
346
|
+
this.focused = isCurrentTableSelected;
|
|
347
|
+
var wrapper = tree.wrapper;
|
|
348
|
+
var tableContainer = wrapper.parentElement;
|
|
349
|
+
var tableContentWrapper = tableContainer.parentElement;
|
|
350
|
+
var layoutContainer = tableContentWrapper && tableContentWrapper.parentElement;
|
|
351
|
+
if (isCurrentTableSelected) {
|
|
352
|
+
this.colControlsOffset = tableControlsSpacing;
|
|
353
|
+
if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
|
|
354
|
+
// move table a little out of the way
|
|
355
|
+
// to provide spacing for table controls
|
|
356
|
+
tableContentWrapper.style.paddingLeft = '11px';
|
|
357
|
+
}
|
|
358
|
+
} else {
|
|
359
|
+
this.colControlsOffset = 0;
|
|
360
|
+
if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
|
|
361
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
362
|
+
}
|
|
363
|
+
}
|
|
472
364
|
|
|
473
|
-
//
|
|
474
|
-
|
|
475
|
-
|
|
365
|
+
// run after table style changes have been committed
|
|
366
|
+
setTimeout(function () {
|
|
367
|
+
syncStickyRowToTable(tree.table);
|
|
368
|
+
}, 0);
|
|
369
|
+
}
|
|
370
|
+
}, {
|
|
371
|
+
key: "updateStickyHeaderWidth",
|
|
372
|
+
value: function updateStickyHeaderWidth() {
|
|
373
|
+
// table width might have changed, sync that back to sticky row
|
|
374
|
+
var tree = getTree(this.dom);
|
|
375
|
+
if (!tree) {
|
|
376
|
+
return;
|
|
476
377
|
}
|
|
378
|
+
syncStickyRowToTable(tree.table);
|
|
379
|
+
}
|
|
477
380
|
|
|
478
|
-
|
|
381
|
+
/**
|
|
382
|
+
* Manually refire the intersection observers.
|
|
383
|
+
* Useful when the header may have detached from the table.
|
|
384
|
+
*/
|
|
385
|
+
}, {
|
|
386
|
+
key: "refireIntersectionObservers",
|
|
387
|
+
value: function refireIntersectionObservers() {
|
|
388
|
+
var _this5 = this;
|
|
389
|
+
if (this.isSticky) {
|
|
390
|
+
[this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
|
|
391
|
+
if (el && _this5.intersectionObserver) {
|
|
392
|
+
_this5.intersectionObserver.unobserve(el);
|
|
393
|
+
_this5.intersectionObserver.observe(el);
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}, {
|
|
399
|
+
key: "makeHeaderRowSticky",
|
|
400
|
+
value: function makeHeaderRowSticky(tree, scrollTop) {
|
|
401
|
+
var _tbody$firstChild,
|
|
402
|
+
_this6 = this;
|
|
403
|
+
// If header row height is more than 50% of viewport height don't do this
|
|
404
|
+
if (this.isSticky || this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
var table = tree.table,
|
|
408
|
+
wrapper = tree.wrapper;
|
|
409
|
+
|
|
410
|
+
// ED-16035 Make sure sticky header is only applied to first row
|
|
479
411
|
var tbody = this.dom.parentElement;
|
|
480
|
-
var
|
|
481
|
-
|
|
482
|
-
|
|
412
|
+
var isFirstHeader = tbody === null || tbody === void 0 || (_tbody$firstChild = tbody.firstChild) === null || _tbody$firstChild === void 0 ? void 0 : _tbody$firstChild.isEqualNode(this.dom);
|
|
413
|
+
if (!isFirstHeader) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
var currentTableTop = this.getCurrentTableTop(tree);
|
|
417
|
+
if (!scrollTop) {
|
|
418
|
+
scrollTop = getTop(this.editorScrollableElement);
|
|
419
|
+
}
|
|
420
|
+
var domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
|
|
421
|
+
if (!this.isSticky) {
|
|
422
|
+
var _this$editorScrollabl;
|
|
423
|
+
syncStickyRowToTable(table);
|
|
424
|
+
this.dom.classList.add('sticky');
|
|
425
|
+
table.classList.add(ClassName.TABLE_STICKY);
|
|
426
|
+
this.isSticky = true;
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* The logic below is not desirable, but acts as a fail safe for scenarios where the sticky header
|
|
430
|
+
* detaches from the table. This typically happens during a fast scroll by the user which causes
|
|
431
|
+
* the intersection observer logic to not fire as expected.
|
|
432
|
+
*/
|
|
433
|
+
(_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 || _this$editorScrollabl.addEventListener('scrollend', this.refireIntersectionObservers, {
|
|
434
|
+
passive: true,
|
|
435
|
+
once: true
|
|
436
|
+
});
|
|
437
|
+
var fastScrollThresholdMs = 500;
|
|
438
|
+
setTimeout(function () {
|
|
439
|
+
_this6.refireIntersectionObservers();
|
|
440
|
+
}, fastScrollThresholdMs);
|
|
441
|
+
}
|
|
442
|
+
this.dom.style.top = "".concat(domTop, "px");
|
|
443
|
+
updateTableMargin(table);
|
|
444
|
+
this.dom.scrollLeft = wrapper.scrollLeft;
|
|
445
|
+
this.emitOn(domTop, this.colControlsOffset);
|
|
483
446
|
}
|
|
484
447
|
}, {
|
|
485
|
-
key: "
|
|
486
|
-
value: function
|
|
487
|
-
|
|
488
|
-
if (this.
|
|
489
|
-
|
|
448
|
+
key: "makeRowHeaderNotSticky",
|
|
449
|
+
value: function makeRowHeaderNotSticky(table) {
|
|
450
|
+
var isEditorDestroyed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
451
|
+
if (!this.isSticky || !table || !this.dom) {
|
|
452
|
+
return;
|
|
490
453
|
}
|
|
491
|
-
this.
|
|
454
|
+
this.dom.style.removeProperty('width');
|
|
455
|
+
this.dom.classList.remove('sticky');
|
|
456
|
+
table.classList.remove(ClassName.TABLE_STICKY);
|
|
457
|
+
this.isSticky = false;
|
|
458
|
+
this.dom.style.top = '';
|
|
459
|
+
table.style.removeProperty('margin-top');
|
|
460
|
+
this.emitOff(isEditorDestroyed);
|
|
492
461
|
}
|
|
493
462
|
}, {
|
|
494
|
-
key: "
|
|
495
|
-
value: function
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
463
|
+
key: "getWrapperoffset",
|
|
464
|
+
value: function getWrapperoffset() {
|
|
465
|
+
var inverse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
466
|
+
var focusValue = inverse ? !this.focused : this.focused;
|
|
467
|
+
return focusValue ? 0 : tableControlsSpacing;
|
|
468
|
+
}
|
|
469
|
+
}, {
|
|
470
|
+
key: "getWrapperRefTop",
|
|
471
|
+
value: function getWrapperRefTop(wrapper) {
|
|
472
|
+
return Math.round(getTop(wrapper)) + this.getWrapperoffset();
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// TODO: rename!
|
|
476
|
+
}, {
|
|
477
|
+
key: "getScrolledTableTop",
|
|
478
|
+
value: function getScrolledTableTop(wrapper) {
|
|
479
|
+
return this.getWrapperRefTop(wrapper) - this.topPosEditorElement;
|
|
480
|
+
}
|
|
481
|
+
}, {
|
|
482
|
+
key: "getCurrentTableTop",
|
|
483
|
+
value: function getCurrentTableTop(tree) {
|
|
484
|
+
return this.getScrolledTableTop(tree.wrapper) + tree.table.clientHeight;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/* emit external events */
|
|
488
|
+
}, {
|
|
489
|
+
key: "emitOn",
|
|
490
|
+
value: function emitOn(top, padding) {
|
|
491
|
+
if (top === this.top && padding === this.padding) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
this.top = top;
|
|
495
|
+
this.padding = padding;
|
|
496
|
+
var pos = this.getPos();
|
|
497
|
+
if (Number.isFinite(pos)) {
|
|
498
|
+
updateStickyState({
|
|
499
|
+
pos: pos,
|
|
500
|
+
top: top,
|
|
501
|
+
sticky: true,
|
|
502
|
+
padding: padding
|
|
503
|
+
})(this.view.state, this.view.dispatch, this.view);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}, {
|
|
507
|
+
key: "emitOff",
|
|
508
|
+
value: function emitOff(isEditorDestroyed) {
|
|
509
|
+
if (this.top === 0 && this.padding === 0) {
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
this.top = 0;
|
|
513
|
+
this.padding = 0;
|
|
514
|
+
var pos = this.getPos();
|
|
515
|
+
if (!isEditorDestroyed && Number.isFinite(pos)) {
|
|
516
|
+
updateStickyState({
|
|
517
|
+
pos: pos,
|
|
518
|
+
sticky: false,
|
|
519
|
+
top: this.top,
|
|
520
|
+
padding: this.padding
|
|
521
|
+
})(this.view.state, this.view.dispatch, this.view);
|
|
515
522
|
}
|
|
516
|
-
return true;
|
|
517
523
|
}
|
|
518
524
|
}]);
|
|
519
|
-
return
|
|
520
|
-
}();
|
|
525
|
+
return TableRow;
|
|
526
|
+
}(TableNodeView);
|
|
527
|
+
export { TableRow as default };
|