@prosekit/web 0.8.0-beta.0 → 0.8.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/prosekit-web-autocomplete.d.ts +112 -90
- package/dist/prosekit-web-autocomplete.d.ts.map +1 -1
- package/dist/prosekit-web-autocomplete.js +292 -217
- package/dist/prosekit-web-autocomplete.js.map +1 -1
- package/dist/prosekit-web-block-handle.d.ts +95 -62
- package/dist/prosekit-web-block-handle.d.ts.map +1 -1
- package/dist/prosekit-web-block-handle.js +219 -114
- package/dist/prosekit-web-block-handle.js.map +1 -1
- package/dist/prosekit-web-drop-indicator.d.ts +13 -15
- package/dist/prosekit-web-drop-indicator.d.ts.map +1 -1
- package/dist/prosekit-web-drop-indicator.js +34 -30
- package/dist/prosekit-web-drop-indicator.js.map +1 -1
- package/dist/prosekit-web-inline-popover.d.ts +94 -53
- package/dist/prosekit-web-inline-popover.d.ts.map +1 -1
- package/dist/prosekit-web-inline-popover.js +134 -79
- package/dist/prosekit-web-inline-popover.js.map +1 -1
- package/dist/prosekit-web-menu.d.ts +13 -0
- package/dist/prosekit-web-menu.d.ts.map +1 -0
- package/dist/prosekit-web-menu.js +53 -0
- package/dist/prosekit-web-menu.js.map +1 -0
- package/dist/prosekit-web-popover.d.ts +7 -26
- package/dist/prosekit-web-popover.d.ts.map +1 -1
- package/dist/prosekit-web-popover.js +31 -29
- package/dist/prosekit-web-popover.js.map +1 -1
- package/dist/prosekit-web-resizable.d.ts +92 -51
- package/dist/prosekit-web-resizable.d.ts.map +1 -1
- package/dist/prosekit-web-resizable.js +139 -131
- package/dist/prosekit-web-resizable.js.map +1 -1
- package/dist/prosekit-web-table-handle.d.ts +166 -199
- package/dist/prosekit-web-table-handle.d.ts.map +1 -1
- package/dist/prosekit-web-table-handle.js +495 -496
- package/dist/prosekit-web-table-handle.js.map +1 -1
- package/dist/prosekit-web-tooltip.d.ts +7 -26
- package/dist/prosekit-web-tooltip.d.ts.map +1 -1
- package/dist/prosekit-web-tooltip.js +31 -29
- package/dist/prosekit-web-tooltip.js.map +1 -1
- package/dist/use-editor-extension.js +2 -2
- package/dist/use-editor-extension.js.map +1 -1
- package/dist/use-scrolling.js +17 -8
- package/dist/use-scrolling.js.map +1 -1
- package/package.json +26 -21
- package/src/components/autocomplete/autocomplete-empty.ts +45 -0
- package/src/components/autocomplete/autocomplete-item.ts +65 -0
- package/src/components/autocomplete/autocomplete-popup.ts +95 -0
- package/src/components/autocomplete/autocomplete-positioner.ts +98 -0
- package/src/components/autocomplete/autocomplete-root.ts +280 -0
- package/src/components/autocomplete/context.ts +16 -14
- package/src/components/autocomplete/index.ts +65 -0
- package/src/components/block-handle/block-handle-add.ts +71 -0
- package/src/components/block-handle/block-handle-draggable.ts +158 -0
- package/src/components/block-handle/block-handle-popup.ts +43 -0
- package/src/components/block-handle/block-handle-positioner.ts +89 -0
- package/src/components/block-handle/block-handle-root.ts +116 -0
- package/src/components/block-handle/context.ts +9 -18
- package/src/components/block-handle/hover-state.ts +16 -0
- package/src/components/block-handle/index.ts +59 -0
- package/src/components/block-handle/{block-handle-popover/pointer-move.ts → pointer-move.ts} +8 -7
- package/src/components/block-handle/{block-handle-draggable/set-drag-preview.ts → set-drag-preview.ts} +4 -4
- package/src/components/block-handle/use-hover-extension.ts +65 -0
- package/src/components/drop-indicator/drop-indicator.ts +128 -0
- package/src/components/drop-indicator/index.ts +18 -0
- package/src/components/inline-popover/index.ts +41 -0
- package/src/components/inline-popover/inline-popover-popup.ts +52 -0
- package/src/components/inline-popover/inline-popover-positioner.ts +118 -0
- package/src/components/inline-popover/inline-popover-root.ts +122 -0
- package/src/components/inline-popover/store.ts +6 -0
- package/src/components/menu/index.ts +92 -0
- package/src/components/popover/index.ts +53 -0
- package/src/components/resizable/{resizable-handle/calc-resize.ts → calc-resize.ts} +1 -1
- package/src/components/resizable/context.ts +3 -6
- package/src/components/resizable/index.ts +32 -0
- package/src/components/resizable/resizable-handle.ts +134 -0
- package/src/components/resizable/resizable-root.ts +184 -0
- package/src/components/table-handle/dnd.ts +16 -27
- package/src/components/table-handle/index.ts +125 -0
- package/src/components/table-handle/{table-handle-drag-preview/render-preview.ts → render-preview.ts} +5 -5
- package/src/components/table-handle/shared.ts +61 -0
- package/src/components/table-handle/store.ts +117 -0
- package/src/components/table-handle/table-handle-column-menu-root.ts +51 -0
- package/src/components/table-handle/table-handle-column-menu-trigger.ts +107 -0
- package/src/components/table-handle/table-handle-column-popup.ts +44 -0
- package/src/components/table-handle/table-handle-column-positioner.ts +67 -0
- package/src/components/table-handle/table-handle-drag-preview.ts +169 -0
- package/src/components/table-handle/table-handle-drop-indicator.ts +166 -0
- package/src/components/table-handle/table-handle-root.ts +103 -0
- package/src/components/table-handle/table-handle-row-menu-root.ts +51 -0
- package/src/components/table-handle/table-handle-row-menu-trigger.ts +107 -0
- package/src/components/table-handle/table-handle-row-popup.ts +42 -0
- package/src/components/table-handle/table-handle-row-positioner.ts +67 -0
- package/src/components/table-handle/use-drop.ts +74 -0
- package/src/components/table-handle/{hooks/use-empty-image.ts → use-empty-image.ts} +2 -3
- package/src/components/table-handle/utils.ts +0 -11
- package/src/components/tooltip/index.ts +52 -0
- package/src/hooks/use-editor-extension.ts +4 -4
- package/src/hooks/use-editor-focus-event.ts +4 -4
- package/src/hooks/use-editor-typing.ts +12 -16
- package/src/hooks/use-editor-update-event.ts +4 -4
- package/src/hooks/use-keymap.ts +4 -4
- package/src/hooks/use-scrolling.ts +11 -10
- package/src/hooks/use-selecting.ts +8 -15
- package/src/utils/event.ts +28 -0
- package/src/utils/lazy-signal.spec.ts +68 -0
- package/src/utils/lazy-signal.ts +17 -0
- package/src/utils/prefers-reduced-motion.ts +6 -0
- package/src/utils/prevent-default.ts +3 -0
- package/src/utils/use-html-element-at.ts +17 -0
- package/src/utils/use-no-focus.ts +7 -0
- package/dist/get-default-state.js +0 -11
- package/dist/get-default-state.js.map +0 -1
- package/src/components/autocomplete/autocomplete-empty/element.gen.ts +0 -18
- package/src/components/autocomplete/autocomplete-empty/setup.ts +0 -6
- package/src/components/autocomplete/autocomplete-empty/types.ts +0 -13
- package/src/components/autocomplete/autocomplete-item/element.gen.ts +0 -18
- package/src/components/autocomplete/autocomplete-item/setup.ts +0 -30
- package/src/components/autocomplete/autocomplete-item/types.ts +0 -25
- package/src/components/autocomplete/autocomplete-list/element.gen.ts +0 -18
- package/src/components/autocomplete/autocomplete-list/setup.ts +0 -125
- package/src/components/autocomplete/autocomplete-list/types.ts +0 -22
- package/src/components/autocomplete/autocomplete-popover/element.gen.ts +0 -18
- package/src/components/autocomplete/autocomplete-popover/setup.ts +0 -169
- package/src/components/autocomplete/autocomplete-popover/types.ts +0 -100
- package/src/components/autocomplete/index.gen.ts +0 -17
- package/src/components/block-handle/block-handle-add/element.gen.ts +0 -18
- package/src/components/block-handle/block-handle-add/setup.ts +0 -33
- package/src/components/block-handle/block-handle-add/types.ts +0 -23
- package/src/components/block-handle/block-handle-draggable/element.gen.ts +0 -18
- package/src/components/block-handle/block-handle-draggable/setup.ts +0 -113
- package/src/components/block-handle/block-handle-draggable/types.ts +0 -23
- package/src/components/block-handle/block-handle-popover/element.gen.ts +0 -18
- package/src/components/block-handle/block-handle-popover/setup.ts +0 -68
- package/src/components/block-handle/block-handle-popover/types.ts +0 -81
- package/src/components/block-handle/index.gen.ts +0 -13
- package/src/components/drop-indicator/drop-indicator/element.gen.ts +0 -18
- package/src/components/drop-indicator/drop-indicator/setup.ts +0 -75
- package/src/components/drop-indicator/drop-indicator/types.ts +0 -31
- package/src/components/drop-indicator/index.gen.ts +0 -5
- package/src/components/inline-popover/index.gen.ts +0 -5
- package/src/components/inline-popover/inline-popover/element.gen.ts +0 -18
- package/src/components/inline-popover/inline-popover/setup.ts +0 -111
- package/src/components/inline-popover/inline-popover/types.ts +0 -112
- package/src/components/popover/index.gen.ts +0 -13
- package/src/components/popover/popover-content/element.gen.ts +0 -18
- package/src/components/popover/popover-content/setup.ts +0 -1
- package/src/components/popover/popover-content/types.ts +0 -6
- package/src/components/popover/popover-root/element.gen.ts +0 -18
- package/src/components/popover/popover-root/setup.ts +0 -1
- package/src/components/popover/popover-root/types.ts +0 -6
- package/src/components/popover/popover-trigger/element.gen.ts +0 -18
- package/src/components/popover/popover-trigger/setup.ts +0 -1
- package/src/components/popover/popover-trigger/types.ts +0 -6
- package/src/components/resizable/index.gen.ts +0 -9
- package/src/components/resizable/resizable-handle/element.gen.ts +0 -18
- package/src/components/resizable/resizable-handle/setup.ts +0 -106
- package/src/components/resizable/resizable-handle/types.ts +0 -29
- package/src/components/resizable/resizable-root/element.gen.ts +0 -18
- package/src/components/resizable/resizable-root/setup.ts +0 -84
- package/src/components/resizable/resizable-root/types.ts +0 -59
- package/src/components/table-handle/context.ts +0 -43
- package/src/components/table-handle/hooks/use-drop.ts +0 -85
- package/src/components/table-handle/index.gen.ts +0 -37
- package/src/components/table-handle/table-handle-column-root/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-column-root/setup.ts +0 -60
- package/src/components/table-handle/table-handle-column-root/types.ts +0 -73
- package/src/components/table-handle/table-handle-column-trigger/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-column-trigger/setup.ts +0 -64
- package/src/components/table-handle/table-handle-column-trigger/types.ts +0 -20
- package/src/components/table-handle/table-handle-drag-preview/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-drag-preview/setup.ts +0 -57
- package/src/components/table-handle/table-handle-drag-preview/types.ts +0 -14
- package/src/components/table-handle/table-handle-drag-preview/updater.ts +0 -90
- package/src/components/table-handle/table-handle-drop-indicator/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-drop-indicator/setup.ts +0 -52
- package/src/components/table-handle/table-handle-drop-indicator/types.ts +0 -15
- package/src/components/table-handle/table-handle-drop-indicator/updater.ts +0 -96
- package/src/components/table-handle/table-handle-popover-content/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-popover-content/setup.ts +0 -83
- package/src/components/table-handle/table-handle-popover-content/types.ts +0 -32
- package/src/components/table-handle/table-handle-popover-item/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-popover-item/setup.ts +0 -17
- package/src/components/table-handle/table-handle-popover-item/types.ts +0 -16
- package/src/components/table-handle/table-handle-root/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-root/setup.ts +0 -86
- package/src/components/table-handle/table-handle-root/types.ts +0 -23
- package/src/components/table-handle/table-handle-row-root/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-row-root/setup.ts +0 -70
- package/src/components/table-handle/table-handle-row-root/types.ts +0 -68
- package/src/components/table-handle/table-handle-row-trigger/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-row-trigger/setup.ts +0 -63
- package/src/components/table-handle/table-handle-row-trigger/types.ts +0 -23
- package/src/components/tooltip/index.gen.ts +0 -13
- package/src/components/tooltip/tooltip-content/element.gen.ts +0 -18
- package/src/components/tooltip/tooltip-content/setup.ts +0 -1
- package/src/components/tooltip/tooltip-content/types.ts +0 -6
- package/src/components/tooltip/tooltip-root/element.gen.ts +0 -18
- package/src/components/tooltip/tooltip-root/setup.ts +0 -1
- package/src/components/tooltip/tooltip-root/types.ts +0 -6
- package/src/components/tooltip/tooltip-trigger/element.gen.ts +0 -18
- package/src/components/tooltip/tooltip-trigger/setup.ts +0 -1
- package/src/components/tooltip/tooltip-trigger/types.ts +0 -6
- package/src/hooks/use-first-rendering.ts +0 -15
- package/src/utils/get-default-state.spec.ts +0 -42
- package/src/utils/get-default-state.ts +0 -18
- /package/src/components/autocomplete/{autocomplete-popover/helpers.spec.ts → helpers.spec.ts} +0 -0
- /package/src/components/autocomplete/{autocomplete-popover/helpers.ts → helpers.ts} +0 -0
- /package/src/components/inline-popover/{inline-popover/virtual-selection-element.ts → virtual-selection-element.ts} +0 -0
- /package/src/components/resizable/{resizable-handle/calc-resize.spec.ts → calc-resize.spec.ts} +0 -0
- /package/src/components/table-handle/{table-handle-drop-indicator/calc-drag-over.ts → calc-drag-over.ts} +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// This file is generated by packages/dev/src/gen-components.ts
|
|
2
|
-
|
|
3
|
-
export { TableHandleColumnRootElement } from './table-handle-column-root/element.gen.ts'
|
|
4
|
-
export { tableHandleColumnRootEvents, tableHandleColumnRootProps, type TableHandleColumnRootEvents, type TableHandleColumnRootProps } from './table-handle-column-root/types.ts'
|
|
5
|
-
export { useTableHandleColumnRoot } from './table-handle-column-root/setup.ts'
|
|
6
|
-
|
|
7
|
-
export { TableHandleColumnTriggerElement } from './table-handle-column-trigger/element.gen.ts'
|
|
8
|
-
export { tableHandleColumnTriggerEvents, tableHandleColumnTriggerProps, type TableHandleColumnTriggerEvents, type TableHandleColumnTriggerProps } from './table-handle-column-trigger/types.ts'
|
|
9
|
-
export { useTableHandleColumnTrigger } from './table-handle-column-trigger/setup.ts'
|
|
10
|
-
|
|
11
|
-
export { TableHandleDragPreviewElement } from './table-handle-drag-preview/element.gen.ts'
|
|
12
|
-
export { tableHandleDragPreviewEvents, tableHandleDragPreviewProps, type TableHandleDragPreviewEvents, type TableHandleDragPreviewProps } from './table-handle-drag-preview/types.ts'
|
|
13
|
-
export { useTableHandleDragPreview } from './table-handle-drag-preview/setup.ts'
|
|
14
|
-
|
|
15
|
-
export { TableHandleDropIndicatorElement } from './table-handle-drop-indicator/element.gen.ts'
|
|
16
|
-
export { tableHandleDropIndicatorEvents, tableHandleDropIndicatorProps, type TableHandleDropIndicatorEvents, type TableHandleDropIndicatorProps } from './table-handle-drop-indicator/types.ts'
|
|
17
|
-
export { useTableHandleDropIndicator } from './table-handle-drop-indicator/setup.ts'
|
|
18
|
-
|
|
19
|
-
export { TableHandlePopoverContentElement } from './table-handle-popover-content/element.gen.ts'
|
|
20
|
-
export { tableHandlePopoverContentEvents, tableHandlePopoverContentProps, type TableHandlePopoverContentEvents, type TableHandlePopoverContentProps } from './table-handle-popover-content/types.ts'
|
|
21
|
-
export { useTableHandlePopoverContent } from './table-handle-popover-content/setup.ts'
|
|
22
|
-
|
|
23
|
-
export { TableHandlePopoverItemElement } from './table-handle-popover-item/element.gen.ts'
|
|
24
|
-
export { tableHandlePopoverItemEvents, tableHandlePopoverItemProps, type TableHandlePopoverItemEvents, type TableHandlePopoverItemProps } from './table-handle-popover-item/types.ts'
|
|
25
|
-
export { useTableHandlePopoverItem } from './table-handle-popover-item/setup.ts'
|
|
26
|
-
|
|
27
|
-
export { TableHandleRootElement } from './table-handle-root/element.gen.ts'
|
|
28
|
-
export { tableHandleRootEvents, tableHandleRootProps, type TableHandleRootEvents, type TableHandleRootProps } from './table-handle-root/types.ts'
|
|
29
|
-
export { useTableHandleRoot } from './table-handle-root/setup.ts'
|
|
30
|
-
|
|
31
|
-
export { TableHandleRowRootElement } from './table-handle-row-root/element.gen.ts'
|
|
32
|
-
export { tableHandleRowRootEvents, tableHandleRowRootProps, type TableHandleRowRootEvents, type TableHandleRowRootProps } from './table-handle-row-root/types.ts'
|
|
33
|
-
export { useTableHandleRowRoot } from './table-handle-row-root/setup.ts'
|
|
34
|
-
|
|
35
|
-
export { TableHandleRowTriggerElement } from './table-handle-row-trigger/element.gen.ts'
|
|
36
|
-
export { tableHandleRowTriggerEvents, tableHandleRowTriggerProps, type TableHandleRowTriggerEvents, type TableHandleRowTriggerProps } from './table-handle-row-trigger/types.ts'
|
|
37
|
-
export { useTableHandleRowTrigger } from './table-handle-row-trigger/setup.ts'
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
|
|
2
|
-
|
|
3
|
-
import { useTableHandleColumnRoot } from "./setup.ts"
|
|
4
|
-
import { tableHandleColumnRootEvents, tableHandleColumnRootProps, type TableHandleColumnRootEvents, type TableHandleColumnRootProps } from "./types.ts"
|
|
5
|
-
|
|
6
|
-
const TableHandleColumnRootElementBase: BaseElementConstructor<TableHandleColumnRootProps> = defineCustomElement<
|
|
7
|
-
TableHandleColumnRootProps,
|
|
8
|
-
TableHandleColumnRootEvents
|
|
9
|
-
>({
|
|
10
|
-
props: tableHandleColumnRootProps,
|
|
11
|
-
events: tableHandleColumnRootEvents,
|
|
12
|
-
setup: useTableHandleColumnRoot,
|
|
13
|
-
})
|
|
14
|
-
class TableHandleColumnRootElement extends TableHandleColumnRootElementBase {}
|
|
15
|
-
|
|
16
|
-
registerCustomElement('prosekit-table-handle-column-root', TableHandleColumnRootElement)
|
|
17
|
-
|
|
18
|
-
export { TableHandleColumnRootElement }
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { createComputed, createSignal, useAttribute, useEffect, type ConnectableElement, type SignalState } from '@aria-ui/core'
|
|
2
|
-
import { menuRootProps, useMenuRoot, type MenuRootProps } from '@aria-ui/menu/elements'
|
|
3
|
-
import { useOverlayPositionerState } from '@aria-ui/overlay/elements'
|
|
4
|
-
import { usePresence } from '@aria-ui/presence'
|
|
5
|
-
|
|
6
|
-
import { getStateWithDefaults } from '../../../utils/get-default-state.ts'
|
|
7
|
-
import { getSafeEditorView } from '../../../utils/get-safe-editor-view.ts'
|
|
8
|
-
import { tableHandleRootContext } from '../context.ts'
|
|
9
|
-
|
|
10
|
-
import type { TableHandleColumnRootProps } from './types.ts'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export function useTableHandleColumnRoot(
|
|
16
|
-
host: ConnectableElement,
|
|
17
|
-
{ state }: { state: SignalState<TableHandleColumnRootProps> },
|
|
18
|
-
): void {
|
|
19
|
-
const { editor, ...overlayState } = state
|
|
20
|
-
|
|
21
|
-
const rootContext = tableHandleRootContext.consume(host)
|
|
22
|
-
|
|
23
|
-
const colFirstCellPos = createComputed<number | undefined>(() => {
|
|
24
|
-
return rootContext.get()?.colFirstCellPos
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
const referenceCell = createComputed<HTMLElement | null>(() => {
|
|
28
|
-
const pos = colFirstCellPos.get()
|
|
29
|
-
const view = getSafeEditorView(editor.get())
|
|
30
|
-
if (!pos || !view) return null
|
|
31
|
-
return view.nodeDOM(pos) as HTMLElement | null
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
const contentOpen = createSignal(false)
|
|
35
|
-
|
|
36
|
-
// Close the menu when the hovering element is changed
|
|
37
|
-
// TODO: add a delay
|
|
38
|
-
useEffect(host, () => {
|
|
39
|
-
colFirstCellPos.get()
|
|
40
|
-
contentOpen.set(false)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
useOverlayPositionerState(host, overlayState, {
|
|
44
|
-
reference: referenceCell,
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
const presence = createComputed(() => !!referenceCell.get())
|
|
48
|
-
useAttribute(host, 'data-state', () => (presence.get() ? 'open' : 'closed'))
|
|
49
|
-
usePresence(host, presence)
|
|
50
|
-
|
|
51
|
-
const menuRootState: SignalState<MenuRootProps> = getStateWithDefaults(
|
|
52
|
-
{ open: contentOpen },
|
|
53
|
-
menuRootProps,
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
useMenuRoot(host, {
|
|
57
|
-
state: menuRootState,
|
|
58
|
-
emit: () => void 0,
|
|
59
|
-
})
|
|
60
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'
|
|
2
|
-
import {
|
|
3
|
-
overlayPositionerEvents,
|
|
4
|
-
overlayPositionerProps,
|
|
5
|
-
type OverlayPositionerEvents,
|
|
6
|
-
type OverlayPositionerProps,
|
|
7
|
-
} from '@aria-ui/overlay'
|
|
8
|
-
import type { Placement } from '@floating-ui/dom'
|
|
9
|
-
import type { Editor } from '@prosekit/core'
|
|
10
|
-
|
|
11
|
-
export interface TableHandleColumnRootProps extends Omit<OverlayPositionerProps, 'placement' | 'hoist' | 'flip' | 'shift' | 'hide'> {
|
|
12
|
-
/**
|
|
13
|
-
* The ProseKit editor instance.
|
|
14
|
-
*
|
|
15
|
-
* @default null
|
|
16
|
-
* @hidden
|
|
17
|
-
*/
|
|
18
|
-
editor: Editor | null
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The placement of the popover, relative to the hovered table cell.
|
|
22
|
-
*
|
|
23
|
-
* @default "top"
|
|
24
|
-
*/
|
|
25
|
-
placement: Placement
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
29
|
-
* to place the floating element on top of other page content.
|
|
30
|
-
*
|
|
31
|
-
* @default false
|
|
32
|
-
*/
|
|
33
|
-
hoist: boolean
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @default false
|
|
37
|
-
* @hidden
|
|
38
|
-
*/
|
|
39
|
-
flip: boolean
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @default false
|
|
43
|
-
* @hidden
|
|
44
|
-
*/
|
|
45
|
-
shift: boolean
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @default true
|
|
49
|
-
* @hidden
|
|
50
|
-
*/
|
|
51
|
-
hide: boolean
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** @internal */
|
|
55
|
-
export const tableHandleColumnRootProps: PropDeclarations<TableHandleColumnRootProps> = Object.freeze({
|
|
56
|
-
...overlayPositionerProps,
|
|
57
|
-
editor: { default: null },
|
|
58
|
-
placement: { default: 'top' },
|
|
59
|
-
|
|
60
|
-
// Enabling `hoist` will cause the popover to have a small delay when
|
|
61
|
-
// scrolling the page.
|
|
62
|
-
hoist: { default: false },
|
|
63
|
-
|
|
64
|
-
flip: { default: false },
|
|
65
|
-
shift: { default: false },
|
|
66
|
-
hide: { default: true },
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
/** @internal */
|
|
70
|
-
export interface TableHandleColumnRootEvents extends OverlayPositionerEvents {}
|
|
71
|
-
|
|
72
|
-
/** @internal */
|
|
73
|
-
export const tableHandleColumnRootEvents: EventDeclarations<TableHandleColumnRootEvents> = overlayPositionerEvents
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
|
|
2
|
-
|
|
3
|
-
import { useTableHandleColumnTrigger } from "./setup.ts"
|
|
4
|
-
import { tableHandleColumnTriggerEvents, tableHandleColumnTriggerProps, type TableHandleColumnTriggerEvents, type TableHandleColumnTriggerProps } from "./types.ts"
|
|
5
|
-
|
|
6
|
-
const TableHandleColumnTriggerElementBase: BaseElementConstructor<TableHandleColumnTriggerProps> = defineCustomElement<
|
|
7
|
-
TableHandleColumnTriggerProps,
|
|
8
|
-
TableHandleColumnTriggerEvents
|
|
9
|
-
>({
|
|
10
|
-
props: tableHandleColumnTriggerProps,
|
|
11
|
-
events: tableHandleColumnTriggerEvents,
|
|
12
|
-
setup: useTableHandleColumnTrigger,
|
|
13
|
-
})
|
|
14
|
-
class TableHandleColumnTriggerElement extends TableHandleColumnTriggerElementBase {}
|
|
15
|
-
|
|
16
|
-
registerCustomElement('prosekit-table-handle-column-trigger', TableHandleColumnTriggerElement)
|
|
17
|
-
|
|
18
|
-
export { TableHandleColumnTriggerElement }
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { useEffect, useEventListener, type ConnectableElement, type SetupOptions } from '@aria-ui/core'
|
|
2
|
-
import { useMenuTrigger } from '@aria-ui/menu/elements'
|
|
3
|
-
import { selectTableColumn } from '@prosekit/extensions/table'
|
|
4
|
-
|
|
5
|
-
import { tableHandleDndContext, tableHandleRootContext } from '../context.ts'
|
|
6
|
-
import { useEmptyImage } from '../hooks/use-empty-image.ts'
|
|
7
|
-
|
|
8
|
-
import type { TableHandleColumnTriggerEvents, TableHandleColumnTriggerProps } from './types.ts'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export function useTableHandleColumnTrigger(
|
|
14
|
-
host: ConnectableElement,
|
|
15
|
-
{ state }: SetupOptions<TableHandleColumnTriggerProps, TableHandleColumnTriggerEvents>,
|
|
16
|
-
): void {
|
|
17
|
-
useMenuTrigger(host)
|
|
18
|
-
|
|
19
|
-
const context = tableHandleRootContext.consume(host)
|
|
20
|
-
|
|
21
|
-
const dndContext = tableHandleDndContext.consume(host)
|
|
22
|
-
|
|
23
|
-
useEventListener(host, 'pointerdown', () => {
|
|
24
|
-
const editor = state.editor.peek()
|
|
25
|
-
const cellPos = context.peek()?.cellPos
|
|
26
|
-
if (!editor || !cellPos) return
|
|
27
|
-
editor.exec(selectTableColumn({ head: cellPos }))
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
useEffect(host, () => {
|
|
31
|
-
host.draggable = true
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
const getEmptyImage = useEmptyImage(host)
|
|
35
|
-
|
|
36
|
-
useEventListener(host, 'dragstart', (event: DragEvent) => {
|
|
37
|
-
const dataTransfer = event.dataTransfer
|
|
38
|
-
if (dataTransfer) {
|
|
39
|
-
dataTransfer.effectAllowed = 'move'
|
|
40
|
-
const emptyImage = getEmptyImage()
|
|
41
|
-
if (emptyImage) {
|
|
42
|
-
dataTransfer.setDragImage(emptyImage, 0, 0)
|
|
43
|
-
}
|
|
44
|
-
dataTransfer.setData('application/x-prosekit-table-handle-drag', '')
|
|
45
|
-
}
|
|
46
|
-
const prev = dndContext.peek()
|
|
47
|
-
const index = context.peek()?.colIndex
|
|
48
|
-
|
|
49
|
-
if (index == null || index < 0) {
|
|
50
|
-
console.warn('[prosekit] Invalid column index for drag operation:', index)
|
|
51
|
-
event.preventDefault()
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
dndContext.set({
|
|
56
|
-
...prev,
|
|
57
|
-
direction: 'col',
|
|
58
|
-
dragging: true,
|
|
59
|
-
draggingIndex: index,
|
|
60
|
-
startX: event.clientX,
|
|
61
|
-
startY: event.clientY,
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'
|
|
2
|
-
import type { Editor } from '@prosekit/core'
|
|
3
|
-
import type { defineTableCommands } from '@prosekit/extensions/table'
|
|
4
|
-
|
|
5
|
-
type TableCommandsExtension = ReturnType<typeof defineTableCommands>
|
|
6
|
-
|
|
7
|
-
export interface TableHandleColumnTriggerProps {
|
|
8
|
-
editor: Editor<TableCommandsExtension> | null
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** @internal */
|
|
12
|
-
export const tableHandleColumnTriggerProps: PropDeclarations<TableHandleColumnTriggerProps> = {
|
|
13
|
-
editor: { default: null },
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** @internal */
|
|
17
|
-
export interface TableHandleColumnTriggerEvents {}
|
|
18
|
-
|
|
19
|
-
/** @internal */
|
|
20
|
-
export const tableHandleColumnTriggerEvents: EventDeclarations<TableHandleColumnTriggerEvents> = {}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
|
|
2
|
-
|
|
3
|
-
import { useTableHandleDragPreview } from "./setup.ts"
|
|
4
|
-
import { tableHandleDragPreviewEvents, tableHandleDragPreviewProps, type TableHandleDragPreviewEvents, type TableHandleDragPreviewProps } from "./types.ts"
|
|
5
|
-
|
|
6
|
-
const TableHandleDragPreviewElementBase: BaseElementConstructor<TableHandleDragPreviewProps> = defineCustomElement<
|
|
7
|
-
TableHandleDragPreviewProps,
|
|
8
|
-
TableHandleDragPreviewEvents
|
|
9
|
-
>({
|
|
10
|
-
props: tableHandleDragPreviewProps,
|
|
11
|
-
events: tableHandleDragPreviewEvents,
|
|
12
|
-
setup: useTableHandleDragPreview,
|
|
13
|
-
})
|
|
14
|
-
class TableHandleDragPreviewElement extends TableHandleDragPreviewElementBase {}
|
|
15
|
-
|
|
16
|
-
registerCustomElement('prosekit-table-handle-drag-preview', TableHandleDragPreviewElement)
|
|
17
|
-
|
|
18
|
-
export { TableHandleDragPreviewElement }
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { useEffect, type ConnectableElement, type SignalState } from '@aria-ui/core'
|
|
2
|
-
|
|
3
|
-
import { assignStyles } from '../../../utils/assign-styles.ts'
|
|
4
|
-
import { useInitDndPosition, type OnInitParams } from '../dnd.ts'
|
|
5
|
-
|
|
6
|
-
import { clearPreviewDOM, createPreviewDOM } from './render-preview.ts'
|
|
7
|
-
import type { TableHandleDragPreviewProps } from './types.ts'
|
|
8
|
-
import { useUpdatePreviewPosition } from './updater.ts'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export function useTableHandleDragPreview(host: ConnectableElement, { state }: { state: SignalState<TableHandleDragPreviewProps> }): void {
|
|
14
|
-
const { editor } = state
|
|
15
|
-
|
|
16
|
-
useEffect(host, () => {
|
|
17
|
-
assignStyles(host, {
|
|
18
|
-
position: 'absolute',
|
|
19
|
-
// Make sure drop on preview will trigger drop event on the host
|
|
20
|
-
pointerEvents: 'none',
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
useInitDndPosition(host, editor, onInitPreviewPosition)
|
|
25
|
-
|
|
26
|
-
useUpdatePreviewPosition(host, editor)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function onInitPreviewPosition({ host, direction, dragging, table, cell, draggingIndex }: OnInitParams): void {
|
|
30
|
-
assignStyles(host, {
|
|
31
|
-
display: dragging ? 'block' : 'none',
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
if (!dragging) {
|
|
35
|
-
clearPreviewDOM(host)
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
createPreviewDOM(table, host, draggingIndex, direction)
|
|
40
|
-
|
|
41
|
-
const tableRect = table.getBoundingClientRect()
|
|
42
|
-
const cellRect = cell.getBoundingClientRect()
|
|
43
|
-
|
|
44
|
-
if (direction === 'col') {
|
|
45
|
-
assignStyles(host, {
|
|
46
|
-
width: `${cellRect.width}px`,
|
|
47
|
-
height: `${tableRect.height}px`,
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (direction === 'row') {
|
|
52
|
-
assignStyles(host, {
|
|
53
|
-
width: `${tableRect.width}px`,
|
|
54
|
-
height: `${cellRect.height}px`,
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'
|
|
2
|
-
import type { Editor } from '@prosekit/core'
|
|
3
|
-
|
|
4
|
-
export interface TableHandleDragPreviewProps {
|
|
5
|
-
editor: Editor | null
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const tableHandleDragPreviewProps: PropDeclarations<TableHandleDragPreviewProps> = {
|
|
9
|
-
editor: { default: null },
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface TableHandleDragPreviewEvents {}
|
|
13
|
-
|
|
14
|
-
export const tableHandleDragPreviewEvents: EventDeclarations<TableHandleDragPreviewEvents> = {}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { createComputed, useEffect, type ConnectableElement, type ReadonlySignal } from '@aria-ui/core'
|
|
2
|
-
import { computePosition, type ReferenceElement } from '@floating-ui/dom'
|
|
3
|
-
import type { Editor } from '@prosekit/core'
|
|
4
|
-
|
|
5
|
-
import { assignStyles } from '../../../utils/assign-styles.ts'
|
|
6
|
-
import { getSafeEditorView } from '../../../utils/get-safe-editor-view.ts'
|
|
7
|
-
import { tableHandleDndContext, tableHandleRootContext } from '../context.ts'
|
|
8
|
-
import { getDndRelatedDOMs } from '../dnd.ts'
|
|
9
|
-
|
|
10
|
-
export function useUpdatePreviewPosition(host: ConnectableElement, editor: ReadonlySignal<Editor | null>): void {
|
|
11
|
-
const dndContext = tableHandleDndContext.consume(host)
|
|
12
|
-
const rootContext = tableHandleRootContext.consume(host)
|
|
13
|
-
|
|
14
|
-
const draggingSignal = createComputed(() => {
|
|
15
|
-
const context = dndContext.get()
|
|
16
|
-
return context.dragging
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
const clientXSignal = createComputed(() => {
|
|
20
|
-
const context = dndContext.get()
|
|
21
|
-
return context.x
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const clientYSignal = createComputed(() => {
|
|
25
|
-
const context = dndContext.get()
|
|
26
|
-
return context.y
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
useEffect(host, () => {
|
|
30
|
-
const view = getSafeEditorView(editor.get())
|
|
31
|
-
if (!view) return
|
|
32
|
-
|
|
33
|
-
if (!draggingSignal.get()) return
|
|
34
|
-
|
|
35
|
-
const { draggingIndex, direction } = dndContext.peek()
|
|
36
|
-
const x = clientXSignal.get()
|
|
37
|
-
const y = clientYSignal.get()
|
|
38
|
-
|
|
39
|
-
const relatedDOMs = getDndRelatedDOMs(view, rootContext.peek()?.cellPos, draggingIndex, direction)
|
|
40
|
-
if (!relatedDOMs) return
|
|
41
|
-
const { cell } = relatedDOMs
|
|
42
|
-
|
|
43
|
-
let cancelled = false
|
|
44
|
-
|
|
45
|
-
void computePosition(
|
|
46
|
-
getVirtualElement(cell, x, y),
|
|
47
|
-
host,
|
|
48
|
-
{ placement: direction === 'row' ? 'right' : 'bottom' },
|
|
49
|
-
).then(({ x, y }) => {
|
|
50
|
-
if (cancelled) return
|
|
51
|
-
|
|
52
|
-
if (direction === 'row') {
|
|
53
|
-
assignStyles(host, {
|
|
54
|
-
top: `${y}px`,
|
|
55
|
-
})
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (direction === 'col') {
|
|
60
|
-
assignStyles(host, {
|
|
61
|
-
left: `${x}px`,
|
|
62
|
-
})
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
return () => {
|
|
68
|
-
cancelled = true
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function getVirtualElement(cell: HTMLTableCellElement, x: number, y: number): ReferenceElement {
|
|
74
|
-
return {
|
|
75
|
-
contextElement: cell,
|
|
76
|
-
getBoundingClientRect: () => {
|
|
77
|
-
const rect = cell.getBoundingClientRect()
|
|
78
|
-
return {
|
|
79
|
-
width: rect.width,
|
|
80
|
-
height: rect.height,
|
|
81
|
-
right: x + rect.width / 2,
|
|
82
|
-
bottom: y + rect.height / 2,
|
|
83
|
-
top: y - rect.height / 2,
|
|
84
|
-
left: x - rect.width / 2,
|
|
85
|
-
x: x - rect.width / 2,
|
|
86
|
-
y: y - rect.height / 2,
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
|
|
2
|
-
|
|
3
|
-
import { useTableHandleDropIndicator } from "./setup.ts"
|
|
4
|
-
import { tableHandleDropIndicatorEvents, tableHandleDropIndicatorProps, type TableHandleDropIndicatorEvents, type TableHandleDropIndicatorProps } from "./types.ts"
|
|
5
|
-
|
|
6
|
-
const TableHandleDropIndicatorElementBase: BaseElementConstructor<TableHandleDropIndicatorProps> = defineCustomElement<
|
|
7
|
-
TableHandleDropIndicatorProps,
|
|
8
|
-
TableHandleDropIndicatorEvents
|
|
9
|
-
>({
|
|
10
|
-
props: tableHandleDropIndicatorProps,
|
|
11
|
-
events: tableHandleDropIndicatorEvents,
|
|
12
|
-
setup: useTableHandleDropIndicator,
|
|
13
|
-
})
|
|
14
|
-
class TableHandleDropIndicatorElement extends TableHandleDropIndicatorElementBase {}
|
|
15
|
-
|
|
16
|
-
registerCustomElement('prosekit-table-handle-drop-indicator', TableHandleDropIndicatorElement)
|
|
17
|
-
|
|
18
|
-
export { TableHandleDropIndicatorElement }
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { useEffect, type ConnectableElement, type SignalState } from '@aria-ui/core'
|
|
2
|
-
|
|
3
|
-
import { assignStyles } from '../../../utils/assign-styles.ts'
|
|
4
|
-
import { useInitDndPosition, type OnInitParams } from '../dnd.ts'
|
|
5
|
-
|
|
6
|
-
import type { TableHandleDropIndicatorProps } from './types.ts'
|
|
7
|
-
import { useUpdateIndicatorPosition } from './updater.ts'
|
|
8
|
-
|
|
9
|
-
const HANDLE_WIDTH = 2
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
export function useTableHandleDropIndicator(
|
|
15
|
-
host: ConnectableElement,
|
|
16
|
-
{ state }: { state: SignalState<TableHandleDropIndicatorProps> },
|
|
17
|
-
): void {
|
|
18
|
-
const { editor } = state
|
|
19
|
-
|
|
20
|
-
useEffect(host, () => {
|
|
21
|
-
assignStyles(host, {
|
|
22
|
-
pointerEvents: 'none',
|
|
23
|
-
position: 'absolute',
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
useInitDndPosition(host, editor, onInitIndicatorPosition)
|
|
28
|
-
|
|
29
|
-
useUpdateIndicatorPosition(host, editor, HANDLE_WIDTH)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function onInitIndicatorPosition({ host, direction, dragging, table }: OnInitParams): void {
|
|
33
|
-
assignStyles(host, {
|
|
34
|
-
display: dragging ? 'block' : 'none',
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const tableRect = table.getBoundingClientRect()
|
|
38
|
-
|
|
39
|
-
if (direction === 'col') {
|
|
40
|
-
assignStyles(host, {
|
|
41
|
-
width: `${HANDLE_WIDTH}px`,
|
|
42
|
-
height: `${tableRect.height}px`,
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (direction === 'row') {
|
|
47
|
-
assignStyles(host, {
|
|
48
|
-
width: `${tableRect.width}px`,
|
|
49
|
-
height: `${HANDLE_WIDTH}px`,
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'
|
|
2
|
-
import type { Editor } from '@prosekit/core'
|
|
3
|
-
import type { TableCommandsExtension } from '@prosekit/extensions/table'
|
|
4
|
-
|
|
5
|
-
export interface TableHandleDropIndicatorProps {
|
|
6
|
-
editor: Editor<TableCommandsExtension> | null
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const tableHandleDropIndicatorProps: PropDeclarations<TableHandleDropIndicatorProps> = {
|
|
10
|
-
editor: { default: null },
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface TableHandleDropIndicatorEvents {}
|
|
14
|
-
|
|
15
|
-
export const tableHandleDropIndicatorEvents: EventDeclarations<TableHandleDropIndicatorEvents> = {}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { createComputed, useEffect, type ConnectableElement, type ReadonlySignal } from '@aria-ui/core'
|
|
2
|
-
import { computePosition, offset } from '@floating-ui/dom'
|
|
3
|
-
import type { Editor } from '@prosekit/core'
|
|
4
|
-
|
|
5
|
-
import { assignStyles } from '../../../utils/assign-styles.ts'
|
|
6
|
-
import { getSafeEditorView } from '../../../utils/get-safe-editor-view.ts'
|
|
7
|
-
import { tableHandleDndContext, tableHandleRootContext } from '../context.ts'
|
|
8
|
-
import { getDndRelatedDOMs } from '../dnd.ts'
|
|
9
|
-
|
|
10
|
-
import { getDragOverColumn, getDragOverRow } from './calc-drag-over.ts'
|
|
11
|
-
|
|
12
|
-
export function useUpdateIndicatorPosition(host: ConnectableElement, editor: ReadonlySignal<Editor | null>, handleWidth: number): void {
|
|
13
|
-
const dndContext = tableHandleDndContext.consume(host)
|
|
14
|
-
const rootContext = tableHandleRootContext.consume(host)
|
|
15
|
-
|
|
16
|
-
const draggingSignal = createComputed(() => {
|
|
17
|
-
const context = dndContext.get()
|
|
18
|
-
return context.dragging
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
const clientXSignal = createComputed(() => {
|
|
22
|
-
const context = dndContext.get()
|
|
23
|
-
return context.x
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
const clientYSignal = createComputed(() => {
|
|
27
|
-
const context = dndContext.get()
|
|
28
|
-
return context.y
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
const startXSignal = createComputed(() => {
|
|
32
|
-
return dndContext.get().startX
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
const startYSignal = createComputed(() => {
|
|
36
|
-
return dndContext.get().startY
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
useEffect(host, () => {
|
|
40
|
-
const view = getSafeEditorView(editor.get())
|
|
41
|
-
if (!view) return
|
|
42
|
-
|
|
43
|
-
if (!draggingSignal.get()) return
|
|
44
|
-
|
|
45
|
-
const { draggingIndex, direction } = dndContext.peek()
|
|
46
|
-
const x = clientXSignal.get()
|
|
47
|
-
const y = clientYSignal.get()
|
|
48
|
-
|
|
49
|
-
const relatedDOMs = getDndRelatedDOMs(view, rootContext.peek()?.cellPos, draggingIndex, direction)
|
|
50
|
-
if (!relatedDOMs) return
|
|
51
|
-
const { table } = relatedDOMs
|
|
52
|
-
|
|
53
|
-
let cancelled = false
|
|
54
|
-
const cleanup = () => {
|
|
55
|
-
cancelled = true
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (direction === 'col') {
|
|
59
|
-
const direction = startXSignal.get() > x ? 'left' : 'right'
|
|
60
|
-
const dragOverColumn = getDragOverColumn(table, x)
|
|
61
|
-
|
|
62
|
-
if (dragOverColumn) {
|
|
63
|
-
const [col, index] = dragOverColumn
|
|
64
|
-
dndContext.set({ ...dndContext.peek(), droppingIndex: index })
|
|
65
|
-
void computePosition(col, host, {
|
|
66
|
-
placement: direction === 'left' ? 'left' : 'right',
|
|
67
|
-
middleware: [offset(direction === 'left' ? -1 * handleWidth : 0)],
|
|
68
|
-
}).then(({ x }) => {
|
|
69
|
-
if (cancelled) return
|
|
70
|
-
assignStyles(host, { left: `${x}px` })
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return cleanup
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (direction === 'row') {
|
|
78
|
-
const direction = startYSignal.get() > y ? 'up' : 'down'
|
|
79
|
-
const dragOverRow = getDragOverRow(table, y)
|
|
80
|
-
|
|
81
|
-
if (dragOverRow) {
|
|
82
|
-
const [row, index] = dragOverRow
|
|
83
|
-
dndContext.set({ ...dndContext.peek(), droppingIndex: index })
|
|
84
|
-
void computePosition(row, host, {
|
|
85
|
-
placement: direction === 'up' ? 'top' : 'bottom',
|
|
86
|
-
middleware: [offset(direction === 'up' ? -1 * handleWidth : 0)],
|
|
87
|
-
}).then(({ y }) => {
|
|
88
|
-
if (cancelled) return
|
|
89
|
-
assignStyles(host, { top: `${y}px` })
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return cleanup
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
}
|