@prosekit/web 0.8.0-beta.0 → 0.8.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +88 -54
- package/dist/prosekit-web-inline-popover.d.ts.map +1 -1
- package/dist/prosekit-web-inline-popover.js +129 -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 +28 -23
- 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 +98 -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-table-handle.js","names":["overlayPositionerProps","overlayPositionerEvents","overlayPositionerProps"],"sources":["../src/components/table-handle/context.ts","../src/components/table-handle/table-handle-column-root/setup.ts","../src/components/table-handle/table-handle-column-root/types.ts","../src/components/table-handle/table-handle-column-root/element.gen.ts","../src/components/table-handle/hooks/use-empty-image.ts","../src/components/table-handle/table-handle-column-trigger/setup.ts","../src/components/table-handle/table-handle-column-trigger/types.ts","../src/components/table-handle/table-handle-column-trigger/element.gen.ts","../src/components/table-handle/dnd.ts","../src/utils/clone-element.ts","../src/utils/css-feature-detection.ts","../src/utils/fade-color.ts","../src/utils/get-effective-background-color.ts","../src/utils/inject-style.ts","../src/components/table-handle/table-handle-drag-preview/render-preview.ts","../src/components/table-handle/table-handle-drag-preview/updater.ts","../src/components/table-handle/table-handle-drag-preview/setup.ts","../src/components/table-handle/table-handle-drag-preview/types.ts","../src/components/table-handle/table-handle-drag-preview/element.gen.ts","../src/components/table-handle/table-handle-drop-indicator/calc-drag-over.ts","../src/components/table-handle/table-handle-drop-indicator/updater.ts","../src/components/table-handle/table-handle-drop-indicator/setup.ts","../src/components/table-handle/table-handle-drop-indicator/types.ts","../src/components/table-handle/table-handle-drop-indicator/element.gen.ts","../src/components/table-handle/table-handle-popover-content/setup.ts","../src/components/table-handle/table-handle-popover-content/types.ts","../src/components/table-handle/table-handle-popover-content/element.gen.ts","../src/components/table-handle/table-handle-popover-item/setup.ts","../src/components/table-handle/table-handle-popover-item/types.ts","../src/components/table-handle/table-handle-popover-item/element.gen.ts","../src/hooks/use-editor-typing.ts","../src/hooks/use-selecting.ts","../src/components/table-handle/hooks/use-drop.ts","../src/components/table-handle/utils.ts","../src/components/table-handle/table-handle-root/setup.ts","../src/components/table-handle/table-handle-root/types.ts","../src/components/table-handle/table-handle-root/element.gen.ts","../src/components/table-handle/table-handle-row-root/setup.ts","../src/components/table-handle/table-handle-row-root/types.ts","../src/components/table-handle/table-handle-row-root/element.gen.ts","../src/components/table-handle/table-handle-row-trigger/setup.ts","../src/components/table-handle/table-handle-row-trigger/types.ts","../src/components/table-handle/table-handle-row-trigger/element.gen.ts"],"sourcesContent":["import { createContext, type Context } from '@aria-ui/core'\n\nimport type { DndInfo, HoveringCellInfo } from './utils.ts'\n\n/**\n * @internal\n */\nexport type TableHandleRootContext = HoveringCellInfo | null\n\n/**\n * @internal\n */\nexport const tableHandleRootContext: Context<TableHandleRootContext> = createContext(\n 'prosekit-table-handle-root-context',\n null,\n)\n\n/**\n * @internal\n */\nexport type TableHandleDndContext = DndInfo\n\n/**\n * @internal\n */\nexport const defaultTableHandleDndContext: TableHandleDndContext = {\n dragging: false,\n direction: 'row',\n draggingIndex: -1,\n droppingIndex: -1,\n x: -1,\n y: -1,\n startX: -1,\n startY: -1,\n}\n\n/**\n * @internal\n */\nexport const tableHandleDndContext: Context<TableHandleDndContext> = createContext(\n 'prosekit-table-handle-dnd-context',\n defaultTableHandleDndContext,\n)\n","import { createComputed, createSignal, useAttribute, useEffect, type ConnectableElement, type SignalState } from '@aria-ui/core'\nimport { menuRootProps, useMenuRoot, type MenuRootProps } from '@aria-ui/menu/elements'\nimport { useOverlayPositionerState } from '@aria-ui/overlay/elements'\nimport { usePresence } from '@aria-ui/presence'\n\nimport { getStateWithDefaults } from '../../../utils/get-default-state.ts'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view.ts'\nimport { tableHandleRootContext } from '../context.ts'\n\nimport type { TableHandleColumnRootProps } from './types.ts'\n\n/**\n * @internal\n */\nexport function useTableHandleColumnRoot(\n host: ConnectableElement,\n { state }: { state: SignalState<TableHandleColumnRootProps> },\n): void {\n const { editor, ...overlayState } = state\n\n const rootContext = tableHandleRootContext.consume(host)\n\n const colFirstCellPos = createComputed<number | undefined>(() => {\n return rootContext.get()?.colFirstCellPos\n })\n\n const referenceCell = createComputed<HTMLElement | null>(() => {\n const pos = colFirstCellPos.get()\n const view = getSafeEditorView(editor.get())\n if (!pos || !view) return null\n return view.nodeDOM(pos) as HTMLElement | null\n })\n\n const contentOpen = createSignal(false)\n\n // Close the menu when the hovering element is changed\n // TODO: add a delay\n useEffect(host, () => {\n colFirstCellPos.get()\n contentOpen.set(false)\n })\n\n useOverlayPositionerState(host, overlayState, {\n reference: referenceCell,\n })\n\n const presence = createComputed(() => !!referenceCell.get())\n useAttribute(host, 'data-state', () => (presence.get() ? 'open' : 'closed'))\n usePresence(host, presence)\n\n const menuRootState: SignalState<MenuRootProps> = getStateWithDefaults(\n { open: contentOpen },\n menuRootProps,\n )\n\n useMenuRoot(host, {\n state: menuRootState,\n emit: () => void 0,\n })\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport {\n overlayPositionerEvents,\n overlayPositionerProps,\n type OverlayPositionerEvents,\n type OverlayPositionerProps,\n} from '@aria-ui/overlay'\nimport type { Placement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nexport interface TableHandleColumnRootProps extends Omit<OverlayPositionerProps, 'placement' | 'hoist' | 'flip' | 'shift' | 'hide'> {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * The placement of the popover, relative to the hovered table cell.\n *\n * @default \"top\"\n */\n placement: Placement\n\n /**\n * Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)\n * to place the floating element on top of other page content.\n *\n * @default false\n */\n hoist: boolean\n\n /**\n * @default false\n * @hidden\n */\n flip: boolean\n\n /**\n * @default false\n * @hidden\n */\n shift: boolean\n\n /**\n * @default true\n * @hidden\n */\n hide: boolean\n}\n\n/** @internal */\nexport const tableHandleColumnRootProps: PropDeclarations<TableHandleColumnRootProps> = Object.freeze({\n ...overlayPositionerProps,\n editor: { default: null },\n placement: { default: 'top' },\n\n // Enabling `hoist` will cause the popover to have a small delay when\n // scrolling the page.\n hoist: { default: false },\n\n flip: { default: false },\n shift: { default: false },\n hide: { default: true },\n})\n\n/** @internal */\nexport interface TableHandleColumnRootEvents extends OverlayPositionerEvents {}\n\n/** @internal */\nexport const tableHandleColumnRootEvents: EventDeclarations<TableHandleColumnRootEvents> = overlayPositionerEvents\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useTableHandleColumnRoot } from \"./setup.ts\"\nimport { tableHandleColumnRootEvents, tableHandleColumnRootProps, type TableHandleColumnRootEvents, type TableHandleColumnRootProps } from \"./types.ts\"\n\nconst TableHandleColumnRootElementBase: BaseElementConstructor<TableHandleColumnRootProps> = defineCustomElement<\n TableHandleColumnRootProps,\n TableHandleColumnRootEvents\n>({\n props: tableHandleColumnRootProps,\n events: tableHandleColumnRootEvents,\n setup: useTableHandleColumnRoot,\n})\nclass TableHandleColumnRootElement extends TableHandleColumnRootElementBase {}\n\nregisterCustomElement('prosekit-table-handle-column-root', TableHandleColumnRootElement)\n \nexport { TableHandleColumnRootElement }\n","import type { ConnectableElement } from '@aria-ui/core'\nimport { useEffect } from '@aria-ui/core'\n\n/**\n * Returns a function that returns a 1x1 transparent image. This is used to\n * prevent the browser from showing the default drag image. An earth icon in\n * chrome is used as the default drag image. This image must be loaded before\n * the dragStart event triggers.\n *\n * See https://stackoverflow.com/a/40923520\n *\n * @internal\n */\nexport function useEmptyImage(\n host: ConnectableElement,\n): () => HTMLImageElement | undefined {\n let image: HTMLImageElement | undefined\n\n useEffect(host, () => {\n image = new Image(1, 1)\n image.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'\n\n return () => {\n image?.remove()\n image = undefined\n }\n })\n\n return () => image\n}\n","import { useEffect, useEventListener, type ConnectableElement, type SetupOptions } from '@aria-ui/core'\nimport { useMenuTrigger } from '@aria-ui/menu/elements'\nimport { selectTableColumn } from '@prosekit/extensions/table'\n\nimport { tableHandleDndContext, tableHandleRootContext } from '../context.ts'\nimport { useEmptyImage } from '../hooks/use-empty-image.ts'\n\nimport type { TableHandleColumnTriggerEvents, TableHandleColumnTriggerProps } from './types.ts'\n\n/**\n * @internal\n */\nexport function useTableHandleColumnTrigger(\n host: ConnectableElement,\n { state }: SetupOptions<TableHandleColumnTriggerProps, TableHandleColumnTriggerEvents>,\n): void {\n useMenuTrigger(host)\n\n const context = tableHandleRootContext.consume(host)\n\n const dndContext = tableHandleDndContext.consume(host)\n\n useEventListener(host, 'pointerdown', () => {\n const editor = state.editor.peek()\n const cellPos = context.peek()?.cellPos\n if (!editor || !cellPos) return\n editor.exec(selectTableColumn({ head: cellPos }))\n })\n\n useEffect(host, () => {\n host.draggable = true\n })\n\n const getEmptyImage = useEmptyImage(host)\n\n useEventListener(host, 'dragstart', (event: DragEvent) => {\n const dataTransfer = event.dataTransfer\n if (dataTransfer) {\n dataTransfer.effectAllowed = 'move'\n const emptyImage = getEmptyImage()\n if (emptyImage) {\n dataTransfer.setDragImage(emptyImage, 0, 0)\n }\n dataTransfer.setData('application/x-prosekit-table-handle-drag', '')\n }\n const prev = dndContext.peek()\n const index = context.peek()?.colIndex\n\n if (index == null || index < 0) {\n console.warn('[prosekit] Invalid column index for drag operation:', index)\n event.preventDefault()\n return\n }\n\n dndContext.set({\n ...prev,\n direction: 'col',\n dragging: true,\n draggingIndex: index,\n startX: event.clientX,\n startY: event.clientY,\n })\n })\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\nimport type { defineTableCommands } from '@prosekit/extensions/table'\n\ntype TableCommandsExtension = ReturnType<typeof defineTableCommands>\n\nexport interface TableHandleColumnTriggerProps {\n editor: Editor<TableCommandsExtension> | null\n}\n\n/** @internal */\nexport const tableHandleColumnTriggerProps: PropDeclarations<TableHandleColumnTriggerProps> = {\n editor: { default: null },\n}\n\n/** @internal */\nexport interface TableHandleColumnTriggerEvents {}\n\n/** @internal */\nexport const tableHandleColumnTriggerEvents: EventDeclarations<TableHandleColumnTriggerEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useTableHandleColumnTrigger } from \"./setup.ts\"\nimport { tableHandleColumnTriggerEvents, tableHandleColumnTriggerProps, type TableHandleColumnTriggerEvents, type TableHandleColumnTriggerProps } from \"./types.ts\"\n\nconst TableHandleColumnTriggerElementBase: BaseElementConstructor<TableHandleColumnTriggerProps> = defineCustomElement<\n TableHandleColumnTriggerProps,\n TableHandleColumnTriggerEvents\n>({\n props: tableHandleColumnTriggerProps,\n events: tableHandleColumnTriggerEvents,\n setup: useTableHandleColumnTrigger,\n})\nclass TableHandleColumnTriggerElement extends TableHandleColumnTriggerElementBase {}\n\nregisterCustomElement('prosekit-table-handle-column-trigger', TableHandleColumnTriggerElement)\n \nexport { TableHandleColumnTriggerElement }\n","import { createComputed, useEffect, type ConnectableElement, type ReadonlySignal } from '@aria-ui/core'\nimport { computePosition, offset } from '@floating-ui/dom'\nimport { isHTMLElement } from '@ocavue/utils'\nimport type { Editor } from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { assignStyles } from '../../utils/assign-styles.ts'\nimport { getSafeEditorView } from '../../utils/get-safe-editor-view.ts'\n\nimport { tableHandleDndContext, tableHandleRootContext } from './context.ts'\n\nexport type OnInitParams = {\n host: ConnectableElement\n direction: 'row' | 'col'\n dragging: boolean\n draggingIndex: number\n table: HTMLTableElement\n cell: HTMLTableCellElement\n}\n\nexport function useInitDndPosition(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n onInit: (params: OnInitParams) => void,\n): void {\n const dndContext = tableHandleDndContext.consume(host)\n const rootContext = tableHandleRootContext.consume(host)\n\n const draggingSignal = createComputed(() => {\n const context = dndContext.get()\n return context.dragging\n })\n\n const directionSignal = createComputed(() => {\n const context = dndContext.get()\n return context.direction\n })\n\n const draggingIndexSignal = createComputed(() => {\n const context = dndContext.get()\n return context.draggingIndex\n })\n\n useEffect(host, () => {\n const view = getSafeEditorView(editor.get())\n if (!view) return\n\n const dragging = draggingSignal.get()\n const direction = directionSignal.get()\n\n host.dataset.direction = direction\n host.dataset.dragging = dragging.toString()\n\n const draggingIndex = draggingIndexSignal.get()\n\n const relatedDOMs = getDndRelatedDOMs(view, rootContext.peek()?.cellPos, draggingIndex, direction)\n if (!relatedDOMs) return\n const { table, cell } = relatedDOMs\n\n onInit({\n host,\n direction,\n dragging,\n draggingIndex,\n table,\n cell,\n })\n\n if (!dragging) return\n\n let cancelled = false\n\n void computePosition(cell, host, {\n placement: direction === 'row' ? 'right' : 'bottom',\n middleware: [\n offset(({ rects }) => {\n if (direction === 'col') {\n return -rects.reference.height\n }\n return -rects.reference.width\n }),\n ],\n }).then(({ x, y }) => {\n if (cancelled) return\n assignStyles(host, {\n left: `${x}px`,\n top: `${y}px`,\n })\n })\n\n return () => {\n cancelled = true\n }\n })\n}\n\nfunction getTableDOMByPos(view: EditorView, pos: number): HTMLTableElement | undefined {\n const dom = view.domAtPos(pos).node\n if (!dom) return\n const element = isHTMLElement(dom) ? dom : dom.parentElement\n const table = element?.closest('table')\n return table ?? undefined\n}\n\nfunction getTargetFirstCellDOM(table: HTMLTableElement, index: number, direction: 'row' | 'col'): HTMLTableCellElement | undefined {\n if (direction === 'row') {\n const row = table.querySelectorAll('tr')[index]\n const cell = row?.querySelector<HTMLTableCellElement>('td, th')\n return cell ?? undefined\n } else {\n const row = table.querySelector('tr')\n const cell = row?.querySelectorAll<HTMLTableCellElement>('td, th')[index]\n return cell ?? undefined\n }\n}\n\nexport function getDndRelatedDOMs(\n view: EditorView,\n cellPos: number | undefined,\n draggingIndex: number,\n direction: 'row' | 'col',\n): { table: HTMLTableElement; cell: HTMLTableCellElement } | undefined {\n if (cellPos == null) return\n const table = getTableDOMByPos(view, cellPos)\n if (!table) return\n const cell = getTargetFirstCellDOM(table, draggingIndex, direction)\n if (!cell) return\n return { table, cell }\n}\n","import { getId } from '@ocavue/utils'\n\n/**\n * Creates a deep clone of an Element, including all computed styles so that\n * it looks almost exactly the same as the original element.\n */\nexport function deepCloneElement<T extends Element>(element: T, important = false): [T, string] {\n const clonedElement = element.cloneNode(true) as T\n const style = deepCopyStyles(element, clonedElement, important)\n return [clonedElement, style]\n}\n\n/**\n * Creates a clone of an Element, including all computed styles so that\n * it looks similar enough to the original element.\n */\nexport function cloneElement<T extends Element>(element: T, important = false): [T, string] {\n const clonedElement = element.cloneNode() as T\n const style = copyStyles(element, clonedElement, important)\n return [clonedElement, style]\n}\n\nfunction deepCopyStyles(source: Element, target: Element, important: boolean): string {\n const sources = [source]\n const targets = [target]\n const styles: string[] = []\n\n while (sources.length > 0 && sources.length === targets.length) {\n const source = sources.pop()\n const target = targets.pop()\n\n if (!source || !target) {\n break\n }\n\n const style = copyStyles(source, target, important)\n if (style) {\n styles.push(style)\n }\n\n sources.push(...source.children)\n targets.push(...target.children)\n }\n\n return styles.join('\\n')\n}\n\nfunction copyStyles(source: Element, target: Element, important: boolean): string {\n if (!source || !target) {\n return ''\n }\n\n const view = source.ownerDocument?.defaultView\n if (!view) {\n return ''\n }\n\n // Known issue: pseudo styles are not copied.\n const sourceStyle = view.getComputedStyle(source)\n const targetStyle = (target as HTMLElement | SVGElement | MathMLElement).style\n\n if (!sourceStyle || !targetStyle) {\n return ''\n }\n\n for (const key of sourceStyle) {\n targetStyle.setProperty(\n key,\n sourceStyle.getPropertyValue(key),\n // Enforce important to avoid the style being overridden when the element\n // is connected to the page.\n // See https://github.com/prosekit/prosekit/issues/1185 for more details.\n important ? 'important' : (sourceStyle.getPropertyPriority(key) || ''),\n )\n }\n\n const styles: string[] = []\n for (const pseudoSelector of [':before', ':after']) {\n const sourcePseudoStyle = view.getComputedStyle(source, pseudoSelector)\n const targetPseudoStyle = view.getComputedStyle(target, pseudoSelector)\n\n if (!sourcePseudoStyle) {\n continue\n }\n\n const content = sourcePseudoStyle.getPropertyValue('content')\n const hasPseudoElement = content && content !== 'none' && content !== 'normal'\n\n if (!hasPseudoElement) {\n continue\n }\n\n const cssProps: string[] = []\n for (const property of sourcePseudoStyle) {\n const sourceValue = sourcePseudoStyle.getPropertyValue(property)\n const sourcePriority = sourcePseudoStyle.getPropertyPriority(property)\n const targetValue = targetPseudoStyle.getPropertyValue(property)\n const targetPriority = targetPseudoStyle.getPropertyPriority(property)\n if (sourceValue !== targetValue || sourcePriority !== targetPriority) {\n cssProps.push(`${property}: ${sourceValue}${sourcePriority ? ' !important' : ''};`)\n }\n }\n\n const uniqueClassName = `clone-pseudo-element-${getId()}`\n target.classList.add(uniqueClassName)\n styles.push(`.${uniqueClassName}${pseudoSelector} { ${cssProps.join(' ')} }`)\n }\n\n return styles.join('\\n')\n}\n","import { once } from '@ocavue/utils'\n\nexport const isColorMixSupported: () => boolean = once(() => {\n try {\n return CSS.supports('background-color', 'color-mix(in srgb, red, blue)')\n } catch {\n return false\n }\n})\n","import { isColorMixSupported } from './css-feature-detection.ts'\n\n/**\n * Convert a color to a color with opacity\n * @param color - The color to convert\n * @param opacity - The opacity to apply\n * @returns The converted color if color-mix is supported, otherwise undefined\n */\nexport function fadeColor(color: CSSStyleValue, opacity: number): string | undefined {\n if (isColorMixSupported()) {\n const transparentWeight = (1 - opacity) * 100\n const colorWeight = opacity * 100\n return `color-mix(in srgb, ${color} ${colorWeight}%, transparent ${transparentWeight}%)`\n }\n}\n","export function getEffectiveBackgroundColor(element: HTMLElement): string | undefined {\n let current: HTMLElement | null = element\n\n while (current) {\n const style = current.ownerDocument.defaultView?.getComputedStyle(current)\n const backgroundColor = style?.backgroundColor\n\n if (\n backgroundColor\n && backgroundColor !== 'transparent'\n // Chrome returns `rgba(0, 0, 0, 0)` for transparent colors.\n && backgroundColor !== 'rgba(0, 0, 0, 0)'\n ) {\n return backgroundColor\n }\n\n current = current.parentElement\n }\n\n return undefined\n}\n","import { getDocument } from '@ocavue/utils'\n\nexport function injectStyle(container: HTMLElement, styleText: string): void {\n if (!styleText) {\n return\n }\n const document = getDocument(container)\n const style = document.createElement('style')\n style.textContent = styleText\n container.appendChild(style)\n}\n","import { assignStyles } from '../../../utils/assign-styles.ts'\nimport { cloneElement, deepCloneElement } from '../../../utils/clone-element.ts'\nimport { fadeColor } from '../../../utils/fade-color.ts'\nimport { getEffectiveBackgroundColor } from '../../../utils/get-effective-background-color.ts'\nimport { injectStyle } from '../../../utils/inject-style.ts'\n\nexport function clearPreviewDOM(previewRoot: HTMLElement): void {\n while (previewRoot.firstChild) {\n previewRoot.removeChild(previewRoot.firstChild)\n }\n}\n\nexport function createPreviewDOM(\n table: HTMLTableElement,\n previewRoot: HTMLElement,\n index: number,\n direction: 'row' | 'col',\n): void {\n clearPreviewDOM(previewRoot)\n\n const [previewTable, previewTableStyle] = cloneElement(table)\n injectStyle(previewRoot, previewTableStyle)\n unsetSize(previewTable)\n\n const tableBody = table.querySelector('tbody')\n const [previewTableBody, previewTableBodyStyle] = tableBody\n ? cloneElement(tableBody)\n : [table.ownerDocument.createElement('tbody'), '']\n injectStyle(previewRoot, previewTableBodyStyle)\n unsetSize(previewTableBody)\n\n // Get effective background color and apply it with some opacity\n const backgroundColor = getEffectiveBackgroundColor(table)\n if (backgroundColor) {\n const backgroundColorWithOpacity = fadeColor(backgroundColor, 0.8)\n if (backgroundColorWithOpacity) {\n assignStyles(previewTable, { backgroundColor: backgroundColorWithOpacity })\n }\n }\n\n previewTable.appendChild(previewTableBody)\n previewRoot.appendChild(previewTable)\n\n const rows = table.querySelectorAll('tr')\n\n if (direction === 'row') {\n const row = rows[index]\n const [previewRow, previewRowStyle] = deepCloneElement(row)\n injectStyle(previewRoot, previewRowStyle)\n previewTableBody.appendChild(previewRow)\n } else {\n rows.forEach((row) => {\n const [previewRow, previewRowStyle] = cloneElement(row)\n injectStyle(previewRoot, previewRowStyle)\n unsetSize(previewRow)\n const cells = row.querySelectorAll('td, th')\n const cell = cells[index]\n if (cell) {\n const [previewCell, previewCellStyle] = deepCloneElement(cell)\n injectStyle(previewRoot, previewCellStyle)\n previewRow.appendChild(previewCell)\n previewTableBody.appendChild(previewRow)\n }\n })\n }\n}\n\nfunction unsetSize(element: HTMLElement) {\n assignStyles(element, {\n width: 'unset',\n height: 'unset',\n minWidth: 'unset',\n minHeight: 'unset',\n maxWidth: 'unset',\n maxHeight: 'unset',\n })\n}\n","import { createComputed, useEffect, type ConnectableElement, type ReadonlySignal } from '@aria-ui/core'\nimport { computePosition, type ReferenceElement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nimport { assignStyles } from '../../../utils/assign-styles.ts'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view.ts'\nimport { tableHandleDndContext, tableHandleRootContext } from '../context.ts'\nimport { getDndRelatedDOMs } from '../dnd.ts'\n\nexport function useUpdatePreviewPosition(host: ConnectableElement, editor: ReadonlySignal<Editor | null>): void {\n const dndContext = tableHandleDndContext.consume(host)\n const rootContext = tableHandleRootContext.consume(host)\n\n const draggingSignal = createComputed(() => {\n const context = dndContext.get()\n return context.dragging\n })\n\n const clientXSignal = createComputed(() => {\n const context = dndContext.get()\n return context.x\n })\n\n const clientYSignal = createComputed(() => {\n const context = dndContext.get()\n return context.y\n })\n\n useEffect(host, () => {\n const view = getSafeEditorView(editor.get())\n if (!view) return\n\n if (!draggingSignal.get()) return\n\n const { draggingIndex, direction } = dndContext.peek()\n const x = clientXSignal.get()\n const y = clientYSignal.get()\n\n const relatedDOMs = getDndRelatedDOMs(view, rootContext.peek()?.cellPos, draggingIndex, direction)\n if (!relatedDOMs) return\n const { cell } = relatedDOMs\n\n let cancelled = false\n\n void computePosition(\n getVirtualElement(cell, x, y),\n host,\n { placement: direction === 'row' ? 'right' : 'bottom' },\n ).then(({ x, y }) => {\n if (cancelled) return\n\n if (direction === 'row') {\n assignStyles(host, {\n top: `${y}px`,\n })\n return\n }\n\n if (direction === 'col') {\n assignStyles(host, {\n left: `${x}px`,\n })\n return\n }\n })\n\n return () => {\n cancelled = true\n }\n })\n}\n\nfunction getVirtualElement(cell: HTMLTableCellElement, x: number, y: number): ReferenceElement {\n return {\n contextElement: cell,\n getBoundingClientRect: () => {\n const rect = cell.getBoundingClientRect()\n return {\n width: rect.width,\n height: rect.height,\n right: x + rect.width / 2,\n bottom: y + rect.height / 2,\n top: y - rect.height / 2,\n left: x - rect.width / 2,\n x: x - rect.width / 2,\n y: y - rect.height / 2,\n }\n },\n }\n}\n","import { useEffect, type ConnectableElement, type SignalState } from '@aria-ui/core'\n\nimport { assignStyles } from '../../../utils/assign-styles.ts'\nimport { useInitDndPosition, type OnInitParams } from '../dnd.ts'\n\nimport { clearPreviewDOM, createPreviewDOM } from './render-preview.ts'\nimport type { TableHandleDragPreviewProps } from './types.ts'\nimport { useUpdatePreviewPosition } from './updater.ts'\n\n/**\n * @internal\n */\nexport function useTableHandleDragPreview(host: ConnectableElement, { state }: { state: SignalState<TableHandleDragPreviewProps> }): void {\n const { editor } = state\n\n useEffect(host, () => {\n assignStyles(host, {\n position: 'absolute',\n // Make sure drop on preview will trigger drop event on the host\n pointerEvents: 'none',\n })\n })\n\n useInitDndPosition(host, editor, onInitPreviewPosition)\n\n useUpdatePreviewPosition(host, editor)\n}\n\nfunction onInitPreviewPosition({ host, direction, dragging, table, cell, draggingIndex }: OnInitParams): void {\n assignStyles(host, {\n display: dragging ? 'block' : 'none',\n })\n\n if (!dragging) {\n clearPreviewDOM(host)\n return\n }\n\n createPreviewDOM(table, host, draggingIndex, direction)\n\n const tableRect = table.getBoundingClientRect()\n const cellRect = cell.getBoundingClientRect()\n\n if (direction === 'col') {\n assignStyles(host, {\n width: `${cellRect.width}px`,\n height: `${tableRect.height}px`,\n })\n }\n\n if (direction === 'row') {\n assignStyles(host, {\n width: `${tableRect.width}px`,\n height: `${cellRect.height}px`,\n })\n }\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nexport interface TableHandleDragPreviewProps {\n editor: Editor | null\n}\n\nexport const tableHandleDragPreviewProps: PropDeclarations<TableHandleDragPreviewProps> = {\n editor: { default: null },\n}\n\nexport interface TableHandleDragPreviewEvents {}\n\nexport const tableHandleDragPreviewEvents: EventDeclarations<TableHandleDragPreviewEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useTableHandleDragPreview } from \"./setup.ts\"\nimport { tableHandleDragPreviewEvents, tableHandleDragPreviewProps, type TableHandleDragPreviewEvents, type TableHandleDragPreviewProps } from \"./types.ts\"\n\nconst TableHandleDragPreviewElementBase: BaseElementConstructor<TableHandleDragPreviewProps> = defineCustomElement<\n TableHandleDragPreviewProps,\n TableHandleDragPreviewEvents\n>({\n props: tableHandleDragPreviewProps,\n events: tableHandleDragPreviewEvents,\n setup: useTableHandleDragPreview,\n})\nclass TableHandleDragPreviewElement extends TableHandleDragPreviewElementBase {}\n\nregisterCustomElement('prosekit-table-handle-drag-preview', TableHandleDragPreviewElement)\n \nexport { TableHandleDragPreviewElement }\n","function findDragOverElement(\n elements: Element[],\n pointer: number,\n axis: 'x' | 'y',\n): [Element, number] | undefined {\n const startProp = axis === 'x' ? 'left' : 'top'\n const endProp = axis === 'x' ? 'right' : 'bottom'\n const lastIndex = elements.length - 1\n\n const index = elements.findIndex((el, index) => {\n const rect = el.getBoundingClientRect()\n const boundaryStart = rect[startProp]\n const boundaryEnd = rect[endProp]\n\n // The pointer is within the boundary of the current element.\n if (boundaryStart <= pointer && pointer <= boundaryEnd) return true\n // The pointer is beyond the last element.\n if (index === lastIndex && pointer > boundaryEnd) return true\n // The pointer is before the first element.\n if (index === 0 && pointer < boundaryStart) return true\n\n return false\n })\n\n return index >= 0 ? [elements[index], index] : undefined\n}\n\nexport function getDragOverColumn(\n table: HTMLTableElement,\n pointerX: number,\n): [element: Element, index: number] | undefined {\n const firstRow = table.querySelector('tr')\n if (!firstRow) return\n const cells = Array.from(firstRow.children)\n return findDragOverElement(cells, pointerX, 'x')\n}\n\nexport function getDragOverRow(\n table: HTMLTableElement,\n pointerY: number,\n): [element: Element, index: number] | undefined {\n const rows = Array.from(table.querySelectorAll('tr'))\n return findDragOverElement(rows, pointerY, 'y')\n}\n","import { createComputed, useEffect, type ConnectableElement, type ReadonlySignal } from '@aria-ui/core'\nimport { computePosition, offset } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nimport { assignStyles } from '../../../utils/assign-styles.ts'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view.ts'\nimport { tableHandleDndContext, tableHandleRootContext } from '../context.ts'\nimport { getDndRelatedDOMs } from '../dnd.ts'\n\nimport { getDragOverColumn, getDragOverRow } from './calc-drag-over.ts'\n\nexport function useUpdateIndicatorPosition(host: ConnectableElement, editor: ReadonlySignal<Editor | null>, handleWidth: number): void {\n const dndContext = tableHandleDndContext.consume(host)\n const rootContext = tableHandleRootContext.consume(host)\n\n const draggingSignal = createComputed(() => {\n const context = dndContext.get()\n return context.dragging\n })\n\n const clientXSignal = createComputed(() => {\n const context = dndContext.get()\n return context.x\n })\n\n const clientYSignal = createComputed(() => {\n const context = dndContext.get()\n return context.y\n })\n\n const startXSignal = createComputed(() => {\n return dndContext.get().startX\n })\n\n const startYSignal = createComputed(() => {\n return dndContext.get().startY\n })\n\n useEffect(host, () => {\n const view = getSafeEditorView(editor.get())\n if (!view) return\n\n if (!draggingSignal.get()) return\n\n const { draggingIndex, direction } = dndContext.peek()\n const x = clientXSignal.get()\n const y = clientYSignal.get()\n\n const relatedDOMs = getDndRelatedDOMs(view, rootContext.peek()?.cellPos, draggingIndex, direction)\n if (!relatedDOMs) return\n const { table } = relatedDOMs\n\n let cancelled = false\n const cleanup = () => {\n cancelled = true\n }\n\n if (direction === 'col') {\n const direction = startXSignal.get() > x ? 'left' : 'right'\n const dragOverColumn = getDragOverColumn(table, x)\n\n if (dragOverColumn) {\n const [col, index] = dragOverColumn\n dndContext.set({ ...dndContext.peek(), droppingIndex: index })\n void computePosition(col, host, {\n placement: direction === 'left' ? 'left' : 'right',\n middleware: [offset(direction === 'left' ? -1 * handleWidth : 0)],\n }).then(({ x }) => {\n if (cancelled) return\n assignStyles(host, { left: `${x}px` })\n })\n }\n\n return cleanup\n }\n\n if (direction === 'row') {\n const direction = startYSignal.get() > y ? 'up' : 'down'\n const dragOverRow = getDragOverRow(table, y)\n\n if (dragOverRow) {\n const [row, index] = dragOverRow\n dndContext.set({ ...dndContext.peek(), droppingIndex: index })\n void computePosition(row, host, {\n placement: direction === 'up' ? 'top' : 'bottom',\n middleware: [offset(direction === 'up' ? -1 * handleWidth : 0)],\n }).then(({ y }) => {\n if (cancelled) return\n assignStyles(host, { top: `${y}px` })\n })\n }\n\n return cleanup\n }\n })\n}\n","import { useEffect, type ConnectableElement, type SignalState } from '@aria-ui/core'\n\nimport { assignStyles } from '../../../utils/assign-styles.ts'\nimport { useInitDndPosition, type OnInitParams } from '../dnd.ts'\n\nimport type { TableHandleDropIndicatorProps } from './types.ts'\nimport { useUpdateIndicatorPosition } from './updater.ts'\n\nconst HANDLE_WIDTH = 2\n\n/**\n * @internal\n */\nexport function useTableHandleDropIndicator(\n host: ConnectableElement,\n { state }: { state: SignalState<TableHandleDropIndicatorProps> },\n): void {\n const { editor } = state\n\n useEffect(host, () => {\n assignStyles(host, {\n pointerEvents: 'none',\n position: 'absolute',\n })\n })\n\n useInitDndPosition(host, editor, onInitIndicatorPosition)\n\n useUpdateIndicatorPosition(host, editor, HANDLE_WIDTH)\n}\n\nfunction onInitIndicatorPosition({ host, direction, dragging, table }: OnInitParams): void {\n assignStyles(host, {\n display: dragging ? 'block' : 'none',\n })\n\n const tableRect = table.getBoundingClientRect()\n\n if (direction === 'col') {\n assignStyles(host, {\n width: `${HANDLE_WIDTH}px`,\n height: `${tableRect.height}px`,\n })\n }\n\n if (direction === 'row') {\n assignStyles(host, {\n width: `${tableRect.width}px`,\n height: `${HANDLE_WIDTH}px`,\n })\n }\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\nimport type { TableCommandsExtension } from '@prosekit/extensions/table'\n\nexport interface TableHandleDropIndicatorProps {\n editor: Editor<TableCommandsExtension> | null\n}\n\nexport const tableHandleDropIndicatorProps: PropDeclarations<TableHandleDropIndicatorProps> = {\n editor: { default: null },\n}\n\nexport interface TableHandleDropIndicatorEvents {}\n\nexport const tableHandleDropIndicatorEvents: EventDeclarations<TableHandleDropIndicatorEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useTableHandleDropIndicator } from \"./setup.ts\"\nimport { tableHandleDropIndicatorEvents, tableHandleDropIndicatorProps, type TableHandleDropIndicatorEvents, type TableHandleDropIndicatorProps } from \"./types.ts\"\n\nconst TableHandleDropIndicatorElementBase: BaseElementConstructor<TableHandleDropIndicatorProps> = defineCustomElement<\n TableHandleDropIndicatorProps,\n TableHandleDropIndicatorEvents\n>({\n props: tableHandleDropIndicatorProps,\n events: tableHandleDropIndicatorEvents,\n setup: useTableHandleDropIndicator,\n})\nclass TableHandleDropIndicatorElement extends TableHandleDropIndicatorElementBase {}\n\nregisterCustomElement('prosekit-table-handle-drop-indicator', TableHandleDropIndicatorElement)\n \nexport { TableHandleDropIndicatorElement }\n","import {\n createComputed,\n createSignal,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type SetupOptions,\n type SignalState,\n type TypedEventTarget,\n} from '@aria-ui/core'\nimport { menuContentProps, useMenuContent, type MenuContentProps } from '@aria-ui/menu/elements'\n\nimport { getStateWithDefaults } from '../../../utils/get-default-state.ts'\nimport { tableHandleRootContext } from '../context.ts'\n\nimport type { TableHandlePopoverContentEvents, TableHandlePopoverContentProps } from './types.ts'\n\n/**\n * @internal\n */\nexport function useTableHandlePopoverContent(\n host: ConnectableElement,\n {\n state,\n emit,\n }: SetupOptions<\n TableHandlePopoverContentProps,\n TableHandlePopoverContentEvents\n >,\n): void {\n const rootContext = tableHandleRootContext.consume(host)\n const open = createComputed(() => !!rootContext.get())\n const keyDownTarget = useKeyDownTarget(host, open)\n\n const menuContentState: SignalState<MenuContentProps> = getStateWithDefaults(\n {\n placement: state.placement,\n offset: state.offset,\n eventTarget: createSignal(keyDownTarget),\n },\n menuContentProps,\n )\n\n useMenuContent(host, { state: menuContentState, emit })\n}\n\nfunction useKeyDownTarget(\n element: ConnectableElement,\n open: ReadonlySignal<boolean>,\n): TypedEventTarget<'keydown'> {\n const keydownHandlers: Array<(event: KeyboardEvent) => void> = []\n\n useEffect(element, () => {\n const handleKeydown = (event: KeyboardEvent) => {\n if (event.isComposing || event.defaultPrevented || !open.get()) {\n return false\n }\n keydownHandlers.forEach((handler) => handler(event))\n }\n\n document.addEventListener('keydown', handleKeydown)\n\n return () => {\n document.removeEventListener('keydown', handleKeydown)\n }\n })\n\n return {\n addEventListener: (type, listener) => {\n if (type === 'keydown') {\n keydownHandlers.push(listener)\n }\n },\n removeEventListener: (type, listener) => {\n if (type === 'keydown') {\n const index = keydownHandlers.indexOf(listener)\n if (index !== -1) {\n keydownHandlers.splice(index, 1)\n }\n }\n },\n }\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport { menuContentEvents, menuContentProps, type MenuContentEvents, type MenuContentProps } from '@aria-ui/menu/elements'\nimport type { Editor } from '@prosekit/core'\n\nexport interface TableHandlePopoverContentProps extends Omit<MenuContentProps, 'placement' | 'offset'> {\n /**\n * @default 'bottom-start'\n */\n placement: MenuContentProps['placement']\n\n /**\n * @default {mainAxis: -4, crossAxis: 4}\n */\n offset: MenuContentProps['offset']\n\n editor: Editor | null\n}\n\n/** @internal */\nexport const tableHandlePopoverContentProps: PropDeclarations<TableHandlePopoverContentProps> = Object.freeze({\n ...menuContentProps,\n placement: { default: 'right-start' },\n offset: { default: { mainAxis: -4, crossAxis: 4 } },\n editor: { default: null },\n})\n\nexport interface TableHandlePopoverContentEvents extends MenuContentEvents {}\n\n/** @internal */\nexport const tableHandlePopoverContentEvents: EventDeclarations<TableHandlePopoverContentEvents> = Object.freeze({\n ...menuContentEvents,\n})\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useTableHandlePopoverContent } from \"./setup.ts\"\nimport { tableHandlePopoverContentEvents, tableHandlePopoverContentProps, type TableHandlePopoverContentEvents, type TableHandlePopoverContentProps } from \"./types.ts\"\n\nconst TableHandlePopoverContentElementBase: BaseElementConstructor<TableHandlePopoverContentProps> = defineCustomElement<\n TableHandlePopoverContentProps,\n TableHandlePopoverContentEvents\n>({\n props: tableHandlePopoverContentProps,\n events: tableHandlePopoverContentEvents,\n setup: useTableHandlePopoverContent,\n})\nclass TableHandlePopoverContentElement extends TableHandlePopoverContentElementBase {}\n\nregisterCustomElement('prosekit-table-handle-popover-content', TableHandlePopoverContentElement)\n \nexport { TableHandlePopoverContentElement }\n","import type { ConnectableElement, SetupOptions } from '@aria-ui/core'\nimport { useMenuItem } from '@aria-ui/menu/elements'\n\nimport type { TableHandlePopoverItemEvents, TableHandlePopoverItemProps } from './types.ts'\n\n/**\n * @internal\n */\nexport function useTableHandlePopoverItem(\n element: ConnectableElement,\n {\n state,\n emit,\n }: SetupOptions<TableHandlePopoverItemProps, TableHandlePopoverItemEvents>,\n): void {\n useMenuItem(element, { state, emit })\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport { menuItemEvents, menuItemProps, type MenuItemEvents, type MenuItemProps } from '@aria-ui/menu'\n\nexport interface TableHandlePopoverItemProps extends MenuItemProps {}\n\n/** @internal */\nexport const tableHandlePopoverItemProps: PropDeclarations<TableHandlePopoverItemProps> = {\n ...menuItemProps,\n}\n\nexport interface TableHandlePopoverItemEvents extends MenuItemEvents {}\n\n/** @internal */\nexport const tableHandlePopoverItemEvents: EventDeclarations<TableHandlePopoverItemEvents> = {\n ...menuItemEvents,\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useTableHandlePopoverItem } from \"./setup.ts\"\nimport { tableHandlePopoverItemEvents, tableHandlePopoverItemProps, type TableHandlePopoverItemEvents, type TableHandlePopoverItemProps } from \"./types.ts\"\n\nconst TableHandlePopoverItemElementBase: BaseElementConstructor<TableHandlePopoverItemProps> = defineCustomElement<\n TableHandlePopoverItemProps,\n TableHandlePopoverItemEvents\n>({\n props: tableHandlePopoverItemProps,\n events: tableHandlePopoverItemEvents,\n setup: useTableHandlePopoverItem,\n})\nclass TableHandlePopoverItemElement extends TableHandlePopoverItemElementBase {}\n\nregisterCustomElement('prosekit-table-handle-popover-item', TableHandlePopoverItemElement)\n \nexport { TableHandlePopoverItemElement }\n","import { createSignal, type ConnectableElement, type ReadonlySignal } from '@aria-ui/core'\nimport { defineDOMEventHandler, union, type Editor } from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension.ts'\n\nexport function useEditorTyping(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n): ReadonlySignal<boolean> {\n const typing = createSignal(false)\n\n const handleKeypress = () => {\n typing.set(true)\n }\n\n const handlePointerMove = () => {\n typing.set(false)\n }\n\n const extension = union(\n defineDOMEventHandler('keypress', handleKeypress),\n defineDOMEventHandler('pointermove', handlePointerMove),\n )\n\n useEditorExtension(host, editor, extension)\n\n return typing\n}\n","import type { ReadonlySignal } from '@aria-ui/core'\nimport { createSignal, useEffect, type ConnectableElement } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nimport { getSafeEditorView } from '../utils/get-safe-editor-view.ts'\n\n/**\n * Detect if the user is selecting text inside the editor, in which case some\n * components should be disabled or hidden.\n */\nexport function useSelecting(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n enabled: ReadonlySignal<boolean>,\n): ReadonlySignal<boolean> {\n const selecting = createSignal(false)\n const isPointerDown = createSignal(false)\n\n useEffect(host, () => {\n if (!enabled.get()) {\n return\n }\n\n const view = getSafeEditorView(editor.peek())\n if (!view) return\n\n const { dom, root } = view\n if (!root) return\n\n // When the user starts selecting text, we set the selecting signal to true.\n const handlePointerDown = () => {\n selecting.set(true)\n isPointerDown.set(true)\n }\n const handlePointerUp = () => {\n isPointerDown.set(false)\n }\n // When the user moves the pointer and the pointer is not down, we set the\n // selecting signal to false again.\n const handleMouseMove = () => {\n if (!isPointerDown.get()) {\n selecting.set(false)\n }\n }\n\n // Only listen to pointer down events on the editor\n dom.addEventListener('pointerdown', handlePointerDown)\n root.addEventListener('pointerup', handlePointerUp)\n root.addEventListener('pointermove', handleMouseMove)\n\n return () => {\n dom.removeEventListener('pointerdown', handlePointerDown)\n root.removeEventListener('pointerup', handlePointerUp)\n root.removeEventListener('pointermove', handleMouseMove)\n }\n })\n\n return selecting\n}\n","import { createComputed, useEffect, type ConnectableElement, type ReadonlySignal, type Signal } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\nimport { moveTableColumn, moveTableRow } from '@prosekit/extensions/table'\n\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view.ts'\nimport type { TableHandleDndContext } from '../context.ts'\n\nexport function useDrop(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n dndContext: Signal<TableHandleDndContext>,\n): void {\n const dragging = createComputed(() => dndContext.get().dragging)\n\n useEffect(host, () => {\n const view = getSafeEditorView(editor.get())\n if (!view || !view.editable) return\n\n const ownerDocument = view.dom?.ownerDocument\n if (!ownerDocument) return\n\n const handleDrop = () => {\n if (!dragging.peek()) return\n const editorValue = editor.peek()\n if (!editorValue) return\n const { droppingIndex, draggingIndex, direction } = dndContext.peek()\n\n // Validate indices\n if (draggingIndex < 0 || droppingIndex < 0) {\n console.warn('[prosekit] Invalid drag indices:', { draggingIndex, droppingIndex })\n return\n }\n\n if (direction === 'row') {\n editorValue.exec(moveTableRow({\n from: draggingIndex,\n to: droppingIndex,\n }))\n return\n }\n if (direction === 'col') {\n editorValue.exec(moveTableColumn({\n from: draggingIndex,\n to: droppingIndex,\n }))\n return\n }\n }\n\n // To make `drop` event work, we need to prevent the default behavior of the\n // `dragover` event for drop zone. Here we set the whole document as the\n // drop zone so that even the mouse moves outside the editor, the `drop`\n // event will still be triggered.\n const handleDragOver = (event: DragEvent) => {\n if (!dragging.peek()) return\n event.preventDefault()\n const prev = dndContext.peek()\n\n dndContext.set({\n ...prev,\n dragging: true,\n x: event.clientX,\n y: event.clientY,\n })\n }\n\n const handleDragEnd = () => {\n if (!dragging.peek()) return\n const prev = dndContext.peek()\n dndContext.set({\n ...prev,\n dragging: false,\n })\n }\n\n ownerDocument.addEventListener('dragover', handleDragOver)\n ownerDocument.addEventListener('drop', handleDrop)\n ownerDocument.addEventListener('dragend', handleDragEnd)\n return () => {\n ownerDocument.removeEventListener('dragover', handleDragOver)\n ownerDocument.removeEventListener('drop', handleDrop)\n ownerDocument.removeEventListener('dragend', handleDragEnd)\n }\n })\n}\n","import type { EditorView } from '@prosekit/pm/view'\nimport { cellAround, TableMap } from 'prosemirror-tables'\n\nexport interface HoveringCellInfo {\n rowIndex: number\n colIndex: number\n cellPos: number\n rowFirstCellPos: number\n colFirstCellPos: number\n}\n\nexport interface DndInfo {\n dragging: boolean\n direction: 'row' | 'col'\n draggingIndex: number\n droppingIndex: number\n x: number\n y: number\n startX: number\n startY: number\n}\n\nexport function isHoveringCellInfoEqual(\n a?: HoveringCellInfo | null,\n b?: HoveringCellInfo | null,\n): boolean {\n if (!a && !b) return true\n if (!a || !b) return false\n return (\n a.rowIndex === b.rowIndex\n && a.colIndex === b.colIndex\n && a.cellPos === b.cellPos\n && a.rowFirstCellPos === b.rowFirstCellPos\n && a.colFirstCellPos === b.colFirstCellPos\n )\n}\n\n/**\n * Copied from https://github.com/ProseMirror/prosemirror-tables/blob/v1.5.0/src/columnresizing.ts#L256\n *\n * @internal\n */\nfunction domCellAround(target: HTMLElement | null): HTMLElement | null {\n while (target && target.nodeName != 'TD' && target.nodeName != 'TH') {\n target = target.classList?.contains('ProseMirror')\n ? null\n : (target.parentNode as HTMLElement | null)\n }\n return target\n}\n\nexport function getHoveringCell(\n view: EditorView,\n event: MouseEvent,\n): HoveringCellInfo | undefined {\n const domCell = domCellAround(event.target as HTMLElement | null)\n if (!domCell) return\n\n const { left, top, width, height } = domCell.getBoundingClientRect()\n const eventPos = view.posAtCoords({\n // Use the center coordinates of the cell to ensure we're within the\n // selected cell. This prevents potential issues when the mouse is on the\n // border of two cells.\n left: left + width / 2,\n top: top + height / 2,\n })\n if (!eventPos) return\n\n const $cellPos = cellAround(view.state.doc.resolve(eventPos.pos))\n if (!$cellPos) return\n\n const map = TableMap.get($cellPos.node(-1))\n const tableStart = $cellPos.start(-1)\n const cellRect = map.findCell($cellPos.pos - tableStart)\n const rowIndex = cellRect.top\n const colIndex = cellRect.left\n\n return {\n rowIndex,\n colIndex,\n cellPos: $cellPos.pos,\n rowFirstCellPos: getCellPos(map, tableStart, rowIndex, 0),\n colFirstCellPos: getCellPos(map, tableStart, 0, colIndex),\n }\n}\n\nfunction getCellPos(\n map: TableMap,\n tableStart: number,\n rowIndex: number,\n colIndex: number,\n) {\n const cellIndex = getCellIndex(map, rowIndex, colIndex)\n const posInTable = map.map[cellIndex]\n return tableStart + posInTable\n}\n\nfunction getCellIndex(\n map: TableMap,\n rowIndex: number,\n colIndex: number,\n): number {\n return map.width * rowIndex + colIndex\n}\n","import {\n createComputed,\n createSignal,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type Signal,\n type SignalState,\n} from '@aria-ui/core'\nimport { defineDOMEventHandler, type Editor } from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { useEditorExtension } from '../../../hooks/use-editor-extension.ts'\nimport { useEditorTyping } from '../../../hooks/use-editor-typing.ts'\nimport { useScrolling } from '../../../hooks/use-scrolling.ts'\nimport { useSelecting } from '../../../hooks/use-selecting.ts'\nimport {\n defaultTableHandleDndContext,\n tableHandleDndContext,\n tableHandleRootContext,\n type TableHandleDndContext,\n type TableHandleRootContext,\n} from '../context.ts'\nimport { useDrop } from '../hooks/use-drop.ts'\nimport { getHoveringCell, isHoveringCellInfoEqual, type HoveringCellInfo } from '../utils.ts'\n\nimport type { TableHandleRootProps } from './types.ts'\n\n/**\n * @internal\n */\nexport function useTableHandleRoot(\n host: ConnectableElement,\n { state }: { state: SignalState<TableHandleRootProps> },\n): void {\n const { editor } = state\n\n const context = createSignal<TableHandleRootContext>(null)\n const dndContext = createSignal<TableHandleDndContext>(defaultTableHandleDndContext)\n\n const hoveringCell = useHoveringCell(host, editor)\n const typing = useEditorTyping(host, editor)\n const isInTable = createComputed(() => !!hoveringCell.get())\n const selecting = useSelecting(host, editor, isInTable)\n const scrolling = useScrolling(host)\n const canShow = createComputed(() => {\n return !typing.get() && !selecting.get() && !scrolling.get()\n })\n\n useEffect(host, () => {\n context.set(canShow.get() ? hoveringCell.get() : null)\n })\n\n tableHandleRootContext.provide(host, context)\n tableHandleDndContext.provide(host, dndContext)\n\n useDrop(host, editor, dndContext)\n}\n\nfunction useHoveringCell(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n): Signal<HoveringCellInfo | null> {\n const hoveringCell = createSignal<HoveringCellInfo | null>(null)\n\n const extension = defineCellHoverHandler((curr: HoveringCellInfo | null) => {\n const prev = hoveringCell.peek()\n if (!isHoveringCellInfoEqual(prev, curr)) {\n hoveringCell.set(curr)\n }\n })\n\n useEditorExtension(host, editor, extension)\n\n return hoveringCell\n}\n\nfunction defineCellHoverHandler(\n handler: (hoveringCell: HoveringCellInfo | null) => void,\n) {\n const pointerHandler = (view: EditorView, event: PointerEvent) => {\n const hoveringCell = getHoveringCell(view, event)\n return handler(hoveringCell ?? null)\n }\n return defineDOMEventHandler('pointerover', pointerHandler)\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nexport interface TableHandleRootProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const tableHandleRootProps: PropDeclarations<TableHandleRootProps> = {\n editor: { default: null },\n}\n\n/** @internal */\nexport interface TableHandleRootEvents {}\n\n/** @internal */\nexport const tableHandleRootEvents: EventDeclarations<TableHandleRootEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useTableHandleRoot } from \"./setup.ts\"\nimport { tableHandleRootEvents, tableHandleRootProps, type TableHandleRootEvents, type TableHandleRootProps } from \"./types.ts\"\n\nconst TableHandleRootElementBase: BaseElementConstructor<TableHandleRootProps> = defineCustomElement<\n TableHandleRootProps,\n TableHandleRootEvents\n>({\n props: tableHandleRootProps,\n events: tableHandleRootEvents,\n setup: useTableHandleRoot,\n})\nclass TableHandleRootElement extends TableHandleRootElementBase {}\n\nregisterCustomElement('prosekit-table-handle-root', TableHandleRootElement)\n \nexport { TableHandleRootElement }\n","import {\n createComputed,\n createSignal,\n defineEmit,\n useAttribute,\n useEffect,\n type ConnectableElement,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { menuRootEvents, menuRootProps, useMenuRoot } from '@aria-ui/menu/elements'\nimport { useOverlayPositionerState } from '@aria-ui/overlay/elements'\nimport { usePresence } from '@aria-ui/presence'\n\nimport { getStateWithDefaults } from '../../../utils/get-default-state.ts'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view.ts'\nimport { tableHandleRootContext } from '../context.ts'\n\nimport type { TableHandleRowRootEvents, TableHandleRowRootProps } from './types.ts'\n\n/**\n * @internal\n */\nexport function useTableHandleRowRoot(\n host: ConnectableElement,\n { state }: SetupOptions<TableHandleRowRootProps, TableHandleRowRootEvents>,\n): void {\n const { editor, ...overlayState } = state\n\n const rootContext = tableHandleRootContext.consume(host)\n\n const rowFirstCellPos = createComputed<number | undefined>(() => {\n return rootContext.get()?.rowFirstCellPos\n })\n\n const referenceCell = createComputed<HTMLElement | null>(() => {\n const pos = rowFirstCellPos.get()\n const view = getSafeEditorView(editor.get())\n if (!pos || !view) return null\n return view.nodeDOM(pos) as HTMLElement | null\n })\n\n const contentOpen = createSignal(false)\n\n // Close the menu when the hovering element is changed\n // TODO: add a delay\n useEffect(host, () => {\n rowFirstCellPos.get()\n contentOpen.set(false)\n })\n\n useOverlayPositionerState(host, overlayState, {\n reference: referenceCell,\n })\n\n const presence = createComputed(() => !!referenceCell.get())\n useAttribute(host, 'data-state', () => (presence.get() ? 'open' : 'closed'))\n usePresence(host, presence)\n\n const menuRootState = getStateWithDefaults(\n {\n open: contentOpen,\n },\n menuRootProps,\n )\n\n useMenuRoot(host, {\n state: menuRootState,\n emit: defineEmit(host, menuRootEvents),\n })\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport { overlayPositionerProps, type OverlayPositionerEvents, type OverlayPositionerProps } from '@aria-ui/overlay'\nimport type { Placement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nexport interface TableHandleRowRootProps extends Omit<OverlayPositionerProps, 'placement' | 'hoist' | 'flip' | 'shift' | 'hide'> {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * The placement of the popover, relative to the hovered table cell.\n *\n * @default \"left\"\n */\n placement: Placement\n\n /**\n * Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)\n * to place the floating element on top of other page content.\n *\n * @default false\n */\n hoist: boolean\n\n /**\n * @default false\n * @hidden\n */\n flip: boolean\n\n /**\n * @default false\n * @hidden\n */\n shift: boolean\n\n /**\n * @default true\n * @hidden\n */\n hide: boolean\n}\n\n/** @internal */\nexport const tableHandleRowRootProps: PropDeclarations<TableHandleRowRootProps> = {\n ...overlayPositionerProps,\n editor: { default: null },\n placement: { default: 'left' },\n\n // Enabling `hoist` will cause the popover to have a small delay when\n // scrolling the page.\n hoist: { default: false },\n\n flip: { default: false },\n shift: { default: false },\n hide: { default: true },\n}\n\n/** @internal */\nexport interface TableHandleRowRootEvents extends OverlayPositionerEvents {}\n\n/** @internal */\nexport const tableHandleRowRootEvents: EventDeclarations<TableHandleRowRootEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useTableHandleRowRoot } from \"./setup.ts\"\nimport { tableHandleRowRootEvents, tableHandleRowRootProps, type TableHandleRowRootEvents, type TableHandleRowRootProps } from \"./types.ts\"\n\nconst TableHandleRowRootElementBase: BaseElementConstructor<TableHandleRowRootProps> = defineCustomElement<\n TableHandleRowRootProps,\n TableHandleRowRootEvents\n>({\n props: tableHandleRowRootProps,\n events: tableHandleRowRootEvents,\n setup: useTableHandleRowRoot,\n})\nclass TableHandleRowRootElement extends TableHandleRowRootElementBase {}\n\nregisterCustomElement('prosekit-table-handle-row-root', TableHandleRowRootElement)\n \nexport { TableHandleRowRootElement }\n","import { useEffect, useEventListener, type ConnectableElement, type SetupOptions } from '@aria-ui/core'\nimport { useMenuTrigger } from '@aria-ui/menu/elements'\nimport { selectTableRow } from '@prosekit/extensions/table'\n\nimport { tableHandleDndContext, tableHandleRootContext } from '../context.ts'\nimport { useEmptyImage } from '../hooks/use-empty-image.ts'\n\nimport type { TableHandleRowTriggerEvents, TableHandleRowTriggerProps } from './types.ts'\n\n/**\n * @internal\n */\nexport function useTableHandleRowTrigger(\n host: ConnectableElement,\n { state }: SetupOptions<TableHandleRowTriggerProps, TableHandleRowTriggerEvents>,\n): void {\n useMenuTrigger(host)\n\n const context = tableHandleRootContext.consume(host)\n\n const dndContext = tableHandleDndContext.consume(host)\n\n useEventListener(host, 'pointerdown', () => {\n const editor = state.editor.peek()\n const cellPos = context.peek()?.cellPos\n if (!editor || !cellPos) return\n editor.exec(selectTableRow({ head: cellPos }))\n })\n\n useEffect(host, () => {\n host.draggable = true\n })\n\n const getEmptyImage = useEmptyImage(host)\n\n useEventListener(host, 'dragstart', (event: DragEvent) => {\n const dataTransfer = event.dataTransfer\n if (dataTransfer) {\n dataTransfer.effectAllowed = 'move'\n const emptyImage = getEmptyImage()\n if (emptyImage) {\n dataTransfer.setDragImage(emptyImage, 0, 0)\n }\n }\n const prev = dndContext.peek()\n const index = context.peek()?.rowIndex\n\n if (index == null || index < 0) {\n console.warn('[prosekit] Invalid row index for drag operation:', index)\n event.preventDefault()\n return\n }\n\n dndContext.set({\n ...prev,\n direction: 'row',\n dragging: true,\n draggingIndex: index,\n startX: event.clientX,\n startY: event.clientY,\n })\n })\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\nimport type { defineTableCommands } from '@prosekit/extensions/table'\n\ntype TableCommandsExtension = ReturnType<typeof defineTableCommands>\n\nexport interface TableHandleRowTriggerProps {\n editor: Editor<TableCommandsExtension> | null\n}\n\n/** @internal */\nexport const tableHandleRowTriggerProps: PropDeclarations<TableHandleRowTriggerProps> = {\n editor: { default: null },\n}\n\nexport interface TableHandleRowTriggerEvents {\n select: CustomEvent<void>\n}\n\n/** @internal */\nexport const tableHandleRowTriggerEvents: EventDeclarations<TableHandleRowTriggerEvents> = {\n select: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useTableHandleRowTrigger } from \"./setup.ts\"\nimport { tableHandleRowTriggerEvents, tableHandleRowTriggerProps, type TableHandleRowTriggerEvents, type TableHandleRowTriggerProps } from \"./types.ts\"\n\nconst TableHandleRowTriggerElementBase: BaseElementConstructor<TableHandleRowTriggerProps> = defineCustomElement<\n TableHandleRowTriggerProps,\n TableHandleRowTriggerEvents\n>({\n props: tableHandleRowTriggerProps,\n events: tableHandleRowTriggerEvents,\n setup: useTableHandleRowTrigger,\n})\nclass TableHandleRowTriggerElement extends TableHandleRowTriggerElementBase {}\n\nregisterCustomElement('prosekit-table-handle-row-trigger', TableHandleRowTriggerElement)\n \nexport { TableHandleRowTriggerElement }\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAYA,MAAa,yBAA0D,cACrE,sCACA,KACD;;;;AAUD,MAAa,+BAAsD;CACjE,UAAU;CACV,WAAW;CACX,eAAe;CACf,eAAe;CACf,GAAG;CACH,GAAG;CACH,QAAQ;CACR,QAAQ;CACT;;;;AAKD,MAAa,wBAAwD,cACnE,qCACA,6BACD;;;;;;AC5BD,SAAgB,yBACd,MACA,EAAE,SACI;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,EAAE,SAAS,MAAM,EAC1B;;AAOD,MAAa,8BAA8E,EACzF,QAAQ,EAAE,EACX;;;ACjBD,MAAM,mCAAuF,oBAG3F;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,+BAAN,cAA2C,iCAAiC;AAE5E,sBAAsB,qCAAqC,6BAA6B"}
|
|
1
|
+
{"version":3,"file":"prosekit-web-table-handle.js","names":[],"sources":["../src/components/table-handle/store.ts","../src/components/table-handle/table-handle-column-popup.ts","../src/utils/use-html-element-at.ts","../src/components/table-handle/shared.ts","../src/components/table-handle/table-handle-column-positioner.ts","../src/components/table-handle/table-handle-column-menu-root.ts","../src/components/table-handle/use-empty-image.ts","../src/components/table-handle/table-handle-column-menu-trigger.ts","../src/components/table-handle/dnd.ts","../src/utils/clone-element.ts","../src/utils/css-feature-detection.ts","../src/utils/fade-color.ts","../src/utils/get-effective-background-color.ts","../src/utils/inject-style.ts","../src/components/table-handle/render-preview.ts","../src/components/table-handle/table-handle-drag-preview.ts","../src/components/table-handle/calc-drag-over.ts","../src/components/table-handle/table-handle-drop-indicator.ts","../src/hooks/use-editor-typing.ts","../src/hooks/use-selecting.ts","../src/components/table-handle/use-drop.ts","../src/components/table-handle/utils.ts","../src/components/table-handle/table-handle-root.ts","../src/components/table-handle/table-handle-row-popup.ts","../src/components/table-handle/table-handle-row-positioner.ts","../src/components/table-handle/table-handle-row-menu-root.ts","../src/components/table-handle/table-handle-row-menu-trigger.ts"],"sourcesContent":["import { computed, createContext, createSignal, type Context, type Signal } from '@aria-ui/core'\nimport type { OpenChangeEvent } from '@aria-ui/elements/overlay'\nimport { createOverlayStore, type OverlayStore } from '@aria-ui/elements/overlay'\n\nimport type { HoveringCellInfo } from './utils.ts'\n\nfunction noop(): void {}\nfunction returnTrue(): boolean {\n return true\n}\nfunction returnFalse(): boolean {\n return false\n}\n\nclass DndStore {\n readonly dragging: Signal<boolean> = createSignal(false)\n readonly direction: Signal<'row' | 'col'> = createSignal<'row' | 'col'>('row')\n readonly draggingIndex: Signal<number> = createSignal(-1)\n readonly droppingIndex: Signal<number> = createSignal(-1)\n readonly x: Signal<number> = createSignal(-1)\n readonly y: Signal<number> = createSignal(-1)\n readonly startX: Signal<number> = createSignal(-1)\n readonly startY: Signal<number> = createSignal(-1)\n}\n\n/**\n * @internal\n */\nexport interface TableHandleStore {\n readonly dndStore: DndStore\n readonly setIsColumnMenuOpen: (open: boolean) => void\n readonly setIsRowMenuOpen: (open: boolean) => void\n readonly columnOverlayStore: OverlayStore\n readonly rowOverlayStore: OverlayStore\n readonly getReferenceCell: () => HoveringCellInfo | undefined\n}\n\n/**\n * @internal\n */\nexport function createTableHandleStore(\n getHoveringCellInfo: () => HoveringCellInfo | undefined,\n getCanShow: () => boolean,\n): TableHandleStore {\n const isColumnMenuOpen = createSignal(false)\n const isRowMenuOpen = createSignal(false)\n\n const getHasMenuOpen = (): boolean => {\n return isColumnMenuOpen.get() || isRowMenuOpen.get()\n }\n\n const setIsRowMenuOpen = (open: boolean): void => {\n isRowMenuOpen.set(open)\n }\n\n const setIsColumnMenuOpen = (open: boolean): void => {\n isColumnMenuOpen.set(open)\n }\n\n const referenceCellInfo = createSignal<HoveringCellInfo | undefined>(undefined)\n\n let prevHoveringCellInfo: HoveringCellInfo | undefined = undefined\n\n const getReferenceCell = computed((): HoveringCellInfo | undefined => {\n if (!getCanShow()) {\n referenceCellInfo.set(undefined)\n return\n }\n\n // Do not toggle/update the menu when hovering another cell if the menu is already open\n if (getHasMenuOpen()) {\n return prevHoveringCellInfo\n }\n\n prevHoveringCellInfo = getHoveringCellInfo()\n return prevHoveringCellInfo\n })\n\n const getOpen = computed((): boolean => {\n return !!getReferenceCell()\n })\n\n const handleOpenChange = (event: OpenChangeEvent) => {\n if (getHasMenuOpen()) {\n event.preventDefault()\n }\n }\n\n const columnOverlayStore = createOverlayStore(\n getOpen,\n noop,\n returnTrue,\n returnFalse,\n handleOpenChange,\n )\n const rowOverlayStore = createOverlayStore(\n getOpen,\n noop,\n returnTrue,\n returnFalse,\n handleOpenChange,\n )\n\n return {\n dndStore: new DndStore(),\n setIsRowMenuOpen,\n setIsColumnMenuOpen,\n columnOverlayStore,\n rowOverlayStore,\n getReferenceCell,\n }\n}\n\n/**\n * @internal\n */\nexport const tableHandleStoreContext: Context<TableHandleStore> = createContext<TableHandleStore>('prosekit-table-handle-store')\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { setupOverlayPopup } from '@aria-ui/elements/overlay'\n\nimport { tableHandleStoreContext } from './store.ts'\n\nexport interface TableHandleColumnPopupProps {}\n\n/** @internal */\nexport const TableHandleColumnPopupPropsDeclaration: PropsDeclaration<TableHandleColumnPopupProps> = defineProps<\n TableHandleColumnPopupProps\n>({})\n\n/** @internal */\nexport function setupTableHandleColumnPopup(\n host: HostElement,\n _props: State<TableHandleColumnPopupProps>,\n): void {\n const getStore = tableHandleStoreContext.consume(host)\n const getOverlayStore = () => getStore()?.columnOverlayStore\n setupOverlayPopup(host, getOverlayStore)\n}\n\nconst TableHandleColumnPopupElementBase: HostElementConstructor<TableHandleColumnPopupProps> = defineCustomElement(\n setupTableHandleColumnPopup,\n TableHandleColumnPopupPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class TableHandleColumnPopupElement extends TableHandleColumnPopupElementBase {}\n\n/** @internal */\nexport function registerTableHandleColumnPopupElement(): void {\n registerCustomElement('prosekit-table-handle-column-popup', TableHandleColumnPopupElement)\n}\n","import { computed } from '@aria-ui/core'\nimport { isHTMLElement } from '@ocavue/utils'\nimport type { Editor } from '@prosekit/core'\n\nexport function useHTMLElementAt(\n getEditor: () => Editor | null | undefined,\n getPos: () => number | null | undefined,\n): () => HTMLElement | undefined {\n return computed(() => {\n const editor = getEditor()\n const pos = getPos()\n if (!editor || !pos) return\n const view = editor.view\n const element = view.nodeDOM(pos)\n if (element && isHTMLElement(element)) return element\n })\n}\n","import { defineProps, type PropsDeclaration } from '@aria-ui/core'\nimport { OverlayPositionerPropsDeclaration, type OverlayPositionerProps } from '@aria-ui/elements/overlay'\nimport type { Editor } from '@prosekit/core'\n\n/**\n * @internal\n */\nexport interface SharedTableHandlePositionerProps extends Omit<OverlayPositionerProps, 'hoist' | 'flip' | 'shift' | 'hide' | 'offset'> {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)\n * to place the floating element on top of other page content.\n *\n * @default false\n */\n hoist: OverlayPositionerProps['hoist']\n\n /**\n * @default false\n * @hidden\n */\n flip: OverlayPositionerProps['flip']\n\n /**\n * @default false\n * @hidden\n */\n shift: OverlayPositionerProps['shift']\n\n /**\n * @default true\n * @hidden\n */\n hide: OverlayPositionerProps['hide']\n\n /**\n * @default 0\n * @hidden\n */\n offset: OverlayPositionerProps['offset']\n}\n\n/** @internal */\nexport const SharedTableHandlePositionerPropsDeclaration: PropsDeclaration<SharedTableHandlePositionerProps> = defineProps<\n SharedTableHandlePositionerProps\n>({\n ...OverlayPositionerPropsDeclaration,\n editor: { default: null, attribute: false, type: 'json' },\n hoist: { default: false, attribute: false, type: 'boolean' },\n flip: { default: false, attribute: false, type: 'json' },\n shift: { default: false, attribute: false, type: 'boolean' },\n hide: { default: true, attribute: false, type: 'boolean' },\n offset: { default: 0, attribute: false, type: 'json' },\n})\n","import {\n computed,\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEffect,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { setupOverlayPositioner } from '@aria-ui/elements/overlay'\nimport type { Placement } from '@floating-ui/dom'\n\nimport { useHTMLElementAt } from '../../utils/use-html-element-at.ts'\n\nimport { SharedTableHandlePositionerPropsDeclaration, type SharedTableHandlePositionerProps } from './shared.ts'\nimport { tableHandleStoreContext } from './store.ts'\n\nexport interface TableHandleColumnPositionerProps extends Omit<SharedTableHandlePositionerProps, 'placement'> {\n /**\n * The placement of the popover, relative to the hovered table cell.\n *\n * @default \"top\"\n */\n placement: Placement\n}\n\n/** @internal */\nexport const TableHandleColumnPositionerPropsDeclaration: PropsDeclaration<TableHandleColumnPositionerProps> = defineProps<\n TableHandleColumnPositionerProps\n>({\n ...SharedTableHandlePositionerPropsDeclaration,\n placement: { default: 'top', attribute: 'placement', type: 'string' },\n})\n\n/** @internal */\nexport function setupTableHandleColumnPositioner(\n host: HostElement,\n props: State<TableHandleColumnPositionerProps>,\n): void {\n const getStore = tableHandleStoreContext.consume(host)\n const getOverlayStore = () => getStore()?.columnOverlayStore\n setupOverlayPositioner(host, props, getOverlayStore)\n\n const getEditor = props.editor.get\n const getColumnFirstCellPos = computed(() => getStore()?.getReferenceCell()?.colFirstCellPos)\n const getReferenceCell = useHTMLElementAt(getEditor, getColumnFirstCellPos)\n useEffect(host, () => {\n getOverlayStore()?.setAnchorElement(getReferenceCell())\n })\n}\n\nconst TableHandleColumnPositionerElementBase: HostElementConstructor<TableHandleColumnPositionerProps> = defineCustomElement(\n setupTableHandleColumnPositioner,\n TableHandleColumnPositionerPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class TableHandleColumnPositionerElement extends TableHandleColumnPositionerElementBase {}\n\n/** @internal */\nexport function registerTableHandleColumnPositionerElement(): void {\n registerCustomElement('prosekit-table-handle-column-positioner', TableHandleColumnPositionerElement)\n}\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEffect,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { MenuRootPropsDeclaration, setupMenuRoot, type MenuRootProps } from '@aria-ui/elements/menu'\n\nimport { tableHandleStoreContext } from './store.ts'\n\nexport interface TableHandleColumnMenuRootProps extends MenuRootProps {}\n\n/** @internal */\nexport const TableHandleColumnMenuRootPropsDeclaration: PropsDeclaration<TableHandleColumnMenuRootProps> = defineProps<\n TableHandleColumnMenuRootProps\n>(MenuRootPropsDeclaration)\n\n/** @internal */\nexport function setupTableHandleColumnMenuRoot(\n host: HostElement,\n props: State<TableHandleColumnMenuRootProps>,\n): void {\n setupMenuRoot(host, props)\n const getStore = tableHandleStoreContext.consume(host)\n\n useEffect(host, () => {\n const open = props.open.get() || false\n const store = getStore?.()\n if (!store) return\n store.setIsColumnMenuOpen(open)\n })\n}\n\nconst TableHandleColumnMenuRootElementBase: HostElementConstructor<TableHandleColumnMenuRootProps> = defineCustomElement(\n setupTableHandleColumnMenuRoot,\n TableHandleColumnMenuRootPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class TableHandleColumnMenuRootElement extends TableHandleColumnMenuRootElementBase {}\n\n/** @internal */\nexport function registerTableHandleColumnMenuRootElement(): void {\n registerCustomElement('prosekit-table-handle-column-menu-root', TableHandleColumnMenuRootElement)\n}\n","import { useEffect, type HostElement } from '@aria-ui/core'\n\n/**\n * Returns a function that returns a 1x1 transparent image. This is used to\n * prevent the browser from showing the default drag image. An earth icon in\n * chrome is used as the default drag image. This image must be loaded before\n * the dragStart event triggers.\n *\n * See https://stackoverflow.com/a/40923520\n *\n * @internal\n */\nexport function useEmptyImage(\n host: HostElement,\n): () => HTMLImageElement | undefined {\n let image: HTMLImageElement | undefined\n\n useEffect(host, () => {\n image = new Image(1, 1)\n image.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'\n\n return () => {\n image?.remove()\n image = undefined\n }\n })\n\n return () => image\n}\n","import {\n createSignal,\n defineCustomElement,\n defineProps,\n onMount,\n registerCustomElement,\n useEventListener,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { setupMenuTrigger, type MenuTriggerProps } from '@aria-ui/elements/menu'\nimport type { Editor } from '@prosekit/core'\nimport { selectTableColumn, type defineTableCommands } from '@prosekit/extensions/table'\n\nimport { tableHandleStoreContext } from './store.ts'\nimport { useEmptyImage } from './use-empty-image.ts'\n\ntype TableCommandsExtension = ReturnType<typeof defineTableCommands>\n\nexport interface TableHandleColumnMenuTriggerProps {\n /**\n * @default null\n * @hidden\n */\n editor: Editor<TableCommandsExtension> | null\n}\n\n/** @internal */\nexport const TableHandleColumnMenuTriggerPropsDeclaration: PropsDeclaration<TableHandleColumnMenuTriggerProps> = defineProps<\n TableHandleColumnMenuTriggerProps\n>({\n editor: { default: null, attribute: false, type: 'json' },\n})\n\n/** @internal */\nexport function setupTableHandleColumnMenuTrigger(\n host: HostElement,\n props: State<TableHandleColumnMenuTriggerProps>,\n): void {\n const getEditor = props.editor.get\n const getStore = tableHandleStoreContext.consume(host)\n\n const triggerProps: State<MenuTriggerProps> = {\n disabled: createSignal(false),\n }\n setupMenuTrigger(host, triggerProps)\n\n useEventListener(host, 'pointerdown', () => {\n const editor = getEditor()\n const cellPos = getStore()?.getReferenceCell()?.cellPos\n if (!editor || !cellPos) return\n editor.exec(selectTableColumn({ head: cellPos }))\n })\n\n onMount(host, () => {\n host.draggable = true\n })\n\n const getEmptyImage = useEmptyImage(host)\n\n useEventListener(host, 'dragstart', (event: DragEvent) => {\n const dataTransfer = event.dataTransfer\n if (dataTransfer) {\n dataTransfer.effectAllowed = 'move'\n const emptyImage = getEmptyImage()\n if (emptyImage) {\n dataTransfer.setDragImage(emptyImage, 0, 0)\n }\n dataTransfer.setData('application/x-prosekit-table-handle-drag', '')\n }\n const store = getStore()\n if (!store) return\n const index = store.getReferenceCell()?.colIndex\n\n if (index == null || index < 0) {\n console.warn('[prosekit] Invalid column index for drag operation:', index)\n event.preventDefault()\n return\n }\n\n const dndStore = store.dndStore\n dndStore.direction.set('col')\n dndStore.dragging.set(true)\n dndStore.draggingIndex.set(index)\n dndStore.startX.set(event.clientX)\n dndStore.startY.set(event.clientY)\n })\n}\n\nconst TableHandleColumnMenuTriggerElementBase: HostElementConstructor<TableHandleColumnMenuTriggerProps> = defineCustomElement(\n setupTableHandleColumnMenuTrigger,\n TableHandleColumnMenuTriggerPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class TableHandleColumnMenuTriggerElement extends TableHandleColumnMenuTriggerElementBase {}\n\n/**\n * @internal\n */\nexport function registerTableHandleColumnMenuTriggerElement(): void {\n registerCustomElement('prosekit-table-handle-column-menu-trigger', TableHandleColumnMenuTriggerElement)\n}\n","import { useEffect, type HostElement } from '@aria-ui/core'\nimport { computePosition, offset } from '@floating-ui/dom'\nimport { isHTMLElement } from '@ocavue/utils'\nimport type { Editor } from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { assignStyles } from '../../utils/assign-styles.ts'\nimport { getSafeEditorView } from '../../utils/get-safe-editor-view.ts'\n\nimport { tableHandleStoreContext } from './store.ts'\n\nexport type OnInitParams = {\n host: HostElement\n direction: 'row' | 'col'\n dragging: boolean\n draggingIndex: number\n table: HTMLTableElement\n cell: HTMLTableCellElement\n}\n\nexport function useInitDndPosition(\n host: HostElement,\n getEditor: () => Editor | null,\n onInit: (params: OnInitParams) => void,\n): void {\n const getStore = tableHandleStoreContext.consume(host)\n\n useEffect(host, () => {\n const view = getSafeEditorView(getEditor())\n if (!view) return\n\n const store = getStore()\n if (!store) return\n\n const dndStore = store.dndStore\n\n const dragging = dndStore.dragging.get()\n const direction = dndStore.direction.get()\n\n host.dataset.direction = direction\n host.dataset.dragging = dragging.toString()\n\n const draggingIndex = dndStore.draggingIndex.get()\n\n const relatedDOMs = getDndRelatedDOMs(view, store.getReferenceCell()?.cellPos, draggingIndex, direction)\n if (!relatedDOMs) return\n const { table, cell } = relatedDOMs\n\n onInit({\n host,\n direction,\n dragging,\n draggingIndex,\n table,\n cell,\n })\n\n if (!dragging) return\n\n let cancelled = false\n\n void computePosition(cell, host, {\n placement: direction === 'row' ? 'right' : 'bottom',\n middleware: [\n offset(({ rects }) => {\n if (direction === 'col') {\n return -rects.reference.height\n }\n return -rects.reference.width\n }),\n ],\n }).then(({ x, y }) => {\n if (cancelled) return\n assignStyles(host, {\n left: `${x}px`,\n top: `${y}px`,\n })\n })\n\n return () => {\n cancelled = true\n }\n })\n}\n\nfunction getTableDOMByPos(view: EditorView, pos: number): HTMLTableElement | undefined {\n const dom = view.domAtPos(pos).node\n if (!dom) return\n const element = isHTMLElement(dom) ? dom : dom.parentElement\n const table = element?.closest('table')\n return table ?? undefined\n}\n\nfunction getTargetFirstCellDOM(table: HTMLTableElement, index: number, direction: 'row' | 'col'): HTMLTableCellElement | undefined {\n if (direction === 'row') {\n const row = table.querySelectorAll('tr')[index]\n const cell = row?.querySelector<HTMLTableCellElement>('td, th')\n return cell ?? undefined\n } else {\n const row = table.querySelector('tr')\n const cell = row?.querySelectorAll<HTMLTableCellElement>('td, th')[index]\n return cell ?? undefined\n }\n}\n\nexport function getDndRelatedDOMs(\n view: EditorView,\n cellPos: number | undefined,\n draggingIndex: number,\n direction: 'row' | 'col',\n): { table: HTMLTableElement; cell: HTMLTableCellElement } | undefined {\n if (cellPos == null) return\n const table = getTableDOMByPos(view, cellPos)\n if (!table) return\n const cell = getTargetFirstCellDOM(table, draggingIndex, direction)\n if (!cell) return\n return { table, cell }\n}\n","import { getId } from '@ocavue/utils'\n\n/**\n * Creates a deep clone of an Element, including all computed styles so that\n * it looks almost exactly the same as the original element.\n */\nexport function deepCloneElement<T extends Element>(element: T, important = false): [T, string] {\n const clonedElement = element.cloneNode(true) as T\n const style = deepCopyStyles(element, clonedElement, important)\n return [clonedElement, style]\n}\n\n/**\n * Creates a clone of an Element, including all computed styles so that\n * it looks similar enough to the original element.\n */\nexport function cloneElement<T extends Element>(element: T, important = false): [T, string] {\n const clonedElement = element.cloneNode() as T\n const style = copyStyles(element, clonedElement, important)\n return [clonedElement, style]\n}\n\nfunction deepCopyStyles(source: Element, target: Element, important: boolean): string {\n const sources = [source]\n const targets = [target]\n const styles: string[] = []\n\n while (sources.length > 0 && sources.length === targets.length) {\n const source = sources.pop()\n const target = targets.pop()\n\n if (!source || !target) {\n break\n }\n\n const style = copyStyles(source, target, important)\n if (style) {\n styles.push(style)\n }\n\n sources.push(...source.children)\n targets.push(...target.children)\n }\n\n return styles.join('\\n')\n}\n\nfunction copyStyles(source: Element, target: Element, important: boolean): string {\n if (!source || !target) {\n return ''\n }\n\n const view = source.ownerDocument?.defaultView\n if (!view) {\n return ''\n }\n\n // Known issue: pseudo styles are not copied.\n const sourceStyle = view.getComputedStyle(source)\n const targetStyle = (target as HTMLElement | SVGElement | MathMLElement).style\n\n if (!sourceStyle || !targetStyle) {\n return ''\n }\n\n for (const key of sourceStyle) {\n targetStyle.setProperty(\n key,\n sourceStyle.getPropertyValue(key),\n // Enforce important to avoid the style being overridden when the element\n // is connected to the page.\n // See https://github.com/prosekit/prosekit/issues/1185 for more details.\n important ? 'important' : (sourceStyle.getPropertyPriority(key) || ''),\n )\n }\n\n const styles: string[] = []\n for (const pseudoSelector of [':before', ':after']) {\n const sourcePseudoStyle = view.getComputedStyle(source, pseudoSelector)\n const targetPseudoStyle = view.getComputedStyle(target, pseudoSelector)\n\n if (!sourcePseudoStyle) {\n continue\n }\n\n const content = sourcePseudoStyle.getPropertyValue('content')\n const hasPseudoElement = content && content !== 'none' && content !== 'normal'\n\n if (!hasPseudoElement) {\n continue\n }\n\n const cssProps: string[] = []\n for (const property of sourcePseudoStyle) {\n const sourceValue = sourcePseudoStyle.getPropertyValue(property)\n const sourcePriority = sourcePseudoStyle.getPropertyPriority(property)\n const targetValue = targetPseudoStyle.getPropertyValue(property)\n const targetPriority = targetPseudoStyle.getPropertyPriority(property)\n if (sourceValue !== targetValue || sourcePriority !== targetPriority) {\n cssProps.push(`${property}: ${sourceValue}${sourcePriority ? ' !important' : ''};`)\n }\n }\n\n const uniqueClassName = `clone-pseudo-element-${getId()}`\n target.classList.add(uniqueClassName)\n styles.push(`.${uniqueClassName}${pseudoSelector} { ${cssProps.join(' ')} }`)\n }\n\n return styles.join('\\n')\n}\n","import { once } from '@ocavue/utils'\n\nexport const isColorMixSupported: () => boolean = once(() => {\n try {\n return CSS.supports('background-color', 'color-mix(in srgb, red, blue)')\n } catch {\n return false\n }\n})\n","import { isColorMixSupported } from './css-feature-detection.ts'\n\n/**\n * Convert a color to a color with opacity\n * @param color - The color to convert\n * @param opacity - The opacity to apply\n * @returns The converted color if color-mix is supported, otherwise undefined\n */\nexport function fadeColor(color: CSSStyleValue, opacity: number): string | undefined {\n if (isColorMixSupported()) {\n const transparentWeight = (1 - opacity) * 100\n const colorWeight = opacity * 100\n return `color-mix(in srgb, ${color} ${colorWeight}%, transparent ${transparentWeight}%)`\n }\n}\n","export function getEffectiveBackgroundColor(element: HTMLElement): string | undefined {\n let current: HTMLElement | null = element\n\n while (current) {\n const style = current.ownerDocument.defaultView?.getComputedStyle(current)\n const backgroundColor = style?.backgroundColor\n\n if (\n backgroundColor\n && backgroundColor !== 'transparent'\n // Chrome returns `rgba(0, 0, 0, 0)` for transparent colors.\n && backgroundColor !== 'rgba(0, 0, 0, 0)'\n ) {\n return backgroundColor\n }\n\n current = current.parentElement\n }\n\n return undefined\n}\n","import { getDocument } from '@ocavue/utils'\n\nexport function injectStyle(container: HTMLElement, styleText: string): void {\n if (!styleText) {\n return\n }\n const document = getDocument(container)\n const style = document.createElement('style')\n style.textContent = styleText\n container.appendChild(style)\n}\n","import { assignStyles } from '../../utils/assign-styles.ts'\nimport { cloneElement, deepCloneElement } from '../../utils/clone-element.ts'\nimport { fadeColor } from '../../utils/fade-color.ts'\nimport { getEffectiveBackgroundColor } from '../../utils/get-effective-background-color.ts'\nimport { injectStyle } from '../../utils/inject-style.ts'\n\nexport function clearPreviewDOM(previewRoot: HTMLElement): void {\n while (previewRoot.firstChild) {\n previewRoot.removeChild(previewRoot.firstChild)\n }\n}\n\nexport function createPreviewDOM(\n table: HTMLTableElement,\n previewRoot: HTMLElement,\n index: number,\n direction: 'row' | 'col',\n): void {\n clearPreviewDOM(previewRoot)\n\n const [previewTable, previewTableStyle] = cloneElement(table)\n injectStyle(previewRoot, previewTableStyle)\n unsetSize(previewTable)\n\n const tableBody = table.querySelector('tbody')\n const [previewTableBody, previewTableBodyStyle] = tableBody\n ? cloneElement(tableBody)\n : [table.ownerDocument.createElement('tbody'), '']\n injectStyle(previewRoot, previewTableBodyStyle)\n unsetSize(previewTableBody)\n\n // Get effective background color and apply it with some opacity\n const backgroundColor = getEffectiveBackgroundColor(table)\n if (backgroundColor) {\n const backgroundColorWithOpacity = fadeColor(backgroundColor, 0.8)\n if (backgroundColorWithOpacity) {\n assignStyles(previewTable, { backgroundColor: backgroundColorWithOpacity })\n }\n }\n\n previewTable.appendChild(previewTableBody)\n previewRoot.appendChild(previewTable)\n\n const rows = table.querySelectorAll('tr')\n\n if (direction === 'row') {\n const row = rows[index]\n const [previewRow, previewRowStyle] = deepCloneElement(row)\n injectStyle(previewRoot, previewRowStyle)\n previewTableBody.appendChild(previewRow)\n } else {\n rows.forEach((row) => {\n const [previewRow, previewRowStyle] = cloneElement(row)\n injectStyle(previewRoot, previewRowStyle)\n unsetSize(previewRow)\n const cells = row.querySelectorAll('td, th')\n const cell = cells[index]\n if (cell) {\n const [previewCell, previewCellStyle] = deepCloneElement(cell)\n injectStyle(previewRoot, previewCellStyle)\n previewRow.appendChild(previewCell)\n previewTableBody.appendChild(previewRow)\n }\n })\n }\n}\n\nfunction unsetSize(element: HTMLElement) {\n assignStyles(element, {\n width: 'unset',\n height: 'unset',\n minWidth: 'unset',\n minHeight: 'unset',\n maxWidth: 'unset',\n maxHeight: 'unset',\n })\n}\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEffect,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { computePosition, type ReferenceElement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nimport { assignStyles } from '../../utils/assign-styles.ts'\nimport { getSafeEditorView } from '../../utils/get-safe-editor-view.ts'\n\nimport { getDndRelatedDOMs, useInitDndPosition, type OnInitParams } from './dnd.ts'\nimport { clearPreviewDOM, createPreviewDOM } from './render-preview.ts'\nimport { tableHandleStoreContext } from './store.ts'\n\nexport interface TableHandleDragPreviewProps {\n /**\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const TableHandleDragPreviewPropsDeclaration: PropsDeclaration<TableHandleDragPreviewProps> = defineProps<\n TableHandleDragPreviewProps\n>({\n editor: { default: null, attribute: false, type: 'json' },\n})\n\n/**\n * @internal\n */\nexport function setupTableHandleDragPreview(\n host: HostElement,\n props: State<TableHandleDragPreviewProps>,\n): void {\n const getEditor = props.editor.get\n\n useEffect(host, () => {\n assignStyles(host, {\n position: 'absolute',\n pointerEvents: 'none',\n })\n })\n\n useInitDndPosition(host, getEditor, onInitPreviewPosition)\n\n useUpdatePreviewPosition(host, getEditor)\n}\n\nfunction onInitPreviewPosition({ host, direction, dragging, table, cell, draggingIndex }: OnInitParams): void {\n assignStyles(host, {\n display: dragging ? 'block' : 'none',\n })\n\n if (!dragging) {\n clearPreviewDOM(host)\n return\n }\n\n createPreviewDOM(table, host, draggingIndex, direction)\n\n const tableRect = table.getBoundingClientRect()\n const cellRect = cell.getBoundingClientRect()\n\n if (direction === 'col') {\n assignStyles(host, {\n width: `${cellRect.width}px`,\n height: `${tableRect.height}px`,\n })\n }\n\n if (direction === 'row') {\n assignStyles(host, {\n width: `${tableRect.width}px`,\n height: `${cellRect.height}px`,\n })\n }\n}\n\nfunction useUpdatePreviewPosition(host: HostElement, getEditor: () => Editor | null): void {\n const getStore = tableHandleStoreContext.consume(host)\n\n useEffect(host, () => {\n const view = getSafeEditorView(getEditor())\n if (!view) return\n\n const store = getStore()\n if (!store) return\n const dndStore = store.dndStore\n\n if (!dndStore.dragging.get()) return\n\n const draggingIndex = dndStore.draggingIndex.get()\n const direction = dndStore.direction.get()\n const x = dndStore.x.get()\n const y = dndStore.y.get()\n\n const relatedDOMs = getDndRelatedDOMs(view, store.getReferenceCell()?.cellPos, draggingIndex, direction)\n if (!relatedDOMs) return\n const { cell } = relatedDOMs\n\n let cancelled = false\n\n void computePosition(\n getVirtualElement(cell, x, y),\n host,\n { placement: direction === 'row' ? 'right' : 'bottom' },\n ).then(({ x, y }) => {\n if (cancelled) return\n\n if (direction === 'row') {\n assignStyles(host, { top: `${y}px` })\n return\n }\n\n if (direction === 'col') {\n assignStyles(host, { left: `${x}px` })\n return\n }\n })\n\n return () => {\n cancelled = true\n }\n })\n}\n\nfunction getVirtualElement(cell: HTMLTableCellElement, x: number, y: number): ReferenceElement {\n return {\n contextElement: cell,\n getBoundingClientRect: () => {\n const rect = cell.getBoundingClientRect()\n return {\n width: rect.width,\n height: rect.height,\n right: x + rect.width / 2,\n bottom: y + rect.height / 2,\n top: y - rect.height / 2,\n left: x - rect.width / 2,\n x: x - rect.width / 2,\n y: y - rect.height / 2,\n }\n },\n }\n}\n\nconst TableHandleDragPreviewElementBase: HostElementConstructor<TableHandleDragPreviewProps> = defineCustomElement(\n setupTableHandleDragPreview,\n TableHandleDragPreviewPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class TableHandleDragPreviewElement extends TableHandleDragPreviewElementBase {}\n\n/**\n * @internal\n */\nexport function registerTableHandleDragPreviewElement(): void {\n registerCustomElement('prosekit-table-handle-drag-preview', TableHandleDragPreviewElement)\n}\n","function findDragOverElement(\n elements: Element[],\n pointer: number,\n axis: 'x' | 'y',\n): [Element, number] | undefined {\n const startProp = axis === 'x' ? 'left' : 'top'\n const endProp = axis === 'x' ? 'right' : 'bottom'\n const lastIndex = elements.length - 1\n\n const index = elements.findIndex((el, index) => {\n const rect = el.getBoundingClientRect()\n const boundaryStart = rect[startProp]\n const boundaryEnd = rect[endProp]\n\n // The pointer is within the boundary of the current element.\n if (boundaryStart <= pointer && pointer <= boundaryEnd) return true\n // The pointer is beyond the last element.\n if (index === lastIndex && pointer > boundaryEnd) return true\n // The pointer is before the first element.\n if (index === 0 && pointer < boundaryStart) return true\n\n return false\n })\n\n return index >= 0 ? [elements[index], index] : undefined\n}\n\nexport function getDragOverColumn(\n table: HTMLTableElement,\n pointerX: number,\n): [element: Element, index: number] | undefined {\n const firstRow = table.querySelector('tr')\n if (!firstRow) return\n const cells = Array.from(firstRow.children)\n return findDragOverElement(cells, pointerX, 'x')\n}\n\nexport function getDragOverRow(\n table: HTMLTableElement,\n pointerY: number,\n): [element: Element, index: number] | undefined {\n const rows = Array.from(table.querySelectorAll('tr'))\n return findDragOverElement(rows, pointerY, 'y')\n}\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEffect,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { computePosition, offset } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\nimport type { defineTableCommands } from '@prosekit/extensions/table'\n\nimport { assignStyles } from '../../utils/assign-styles.ts'\nimport { getSafeEditorView } from '../../utils/get-safe-editor-view.ts'\n\nimport { getDragOverColumn, getDragOverRow } from './calc-drag-over.ts'\nimport { getDndRelatedDOMs, useInitDndPosition, type OnInitParams } from './dnd.ts'\nimport { tableHandleStoreContext } from './store.ts'\n\ntype TableCommandsExtension = ReturnType<typeof defineTableCommands>\n\nconst HANDLE_WIDTH = 2\n\nexport interface TableHandleDropIndicatorProps {\n /**\n * @default null\n * @hidden\n */\n editor: Editor<TableCommandsExtension> | null\n}\n\n/** @internal */\nexport const TableHandleDropIndicatorPropsDeclaration: PropsDeclaration<TableHandleDropIndicatorProps> = defineProps<\n TableHandleDropIndicatorProps\n>({\n editor: { default: null, attribute: false, type: 'json' },\n})\n\n/**\n * @internal\n */\nexport function setupTableHandleDropIndicator(\n host: HostElement,\n props: State<TableHandleDropIndicatorProps>,\n): void {\n const getEditor = props.editor.get\n\n useEffect(host, () => {\n assignStyles(host, {\n pointerEvents: 'none',\n position: 'absolute',\n })\n })\n\n useInitDndPosition(host, getEditor, onInitIndicatorPosition)\n\n useUpdateIndicatorPosition(host, getEditor, HANDLE_WIDTH)\n}\n\nfunction onInitIndicatorPosition({ host, direction, dragging, table }: OnInitParams): void {\n assignStyles(host, {\n display: dragging ? 'block' : 'none',\n })\n\n const tableRect = table.getBoundingClientRect()\n\n if (direction === 'col') {\n assignStyles(host, {\n width: `${HANDLE_WIDTH}px`,\n height: `${tableRect.height}px`,\n })\n }\n\n if (direction === 'row') {\n assignStyles(host, {\n width: `${tableRect.width}px`,\n height: `${HANDLE_WIDTH}px`,\n })\n }\n}\n\nfunction useUpdateIndicatorPosition(host: HostElement, getEditor: () => Editor | null, handleWidth: number): void {\n const getStore = tableHandleStoreContext.consume(host)\n\n useEffect(host, () => {\n const view = getSafeEditorView(getEditor())\n if (!view) return\n\n const store = getStore()\n if (!store) return\n\n const dndStore = store.dndStore\n if (!dndStore.dragging.get()) return\n\n const draggingIndex = dndStore.draggingIndex.get()\n const direction = dndStore.direction.get()\n const x = dndStore.x.get()\n const y = dndStore.y.get()\n\n const relatedDOMs = getDndRelatedDOMs(view, store.getReferenceCell()?.cellPos, draggingIndex, direction)\n if (!relatedDOMs) return\n const { table } = relatedDOMs\n\n let cancelled = false\n const cleanup = () => {\n cancelled = true\n }\n\n if (direction === 'col') {\n const dir = dndStore.startX.get() > x ? 'left' : 'right'\n const dragOverColumn = getDragOverColumn(table, x)\n\n if (dragOverColumn) {\n const [col, index] = dragOverColumn\n dndStore.droppingIndex.set(index)\n void computePosition(col, host, {\n placement: dir === 'left' ? 'left' : 'right',\n middleware: [offset(dir === 'left' ? -1 * handleWidth : 0)],\n }).then(({ x }) => {\n if (cancelled) return\n assignStyles(host, { left: `${x}px` })\n })\n }\n\n return cleanup\n }\n\n if (direction === 'row') {\n const dir = dndStore.startY.get() > y ? 'up' : 'down'\n const dragOverRow = getDragOverRow(table, y)\n\n if (dragOverRow) {\n const [row, index] = dragOverRow\n dndStore.droppingIndex.set(index)\n void computePosition(row, host, {\n placement: dir === 'up' ? 'top' : 'bottom',\n middleware: [offset(dir === 'up' ? -1 * handleWidth : 0)],\n }).then(({ y }) => {\n if (cancelled) return\n assignStyles(host, { top: `${y}px` })\n })\n }\n\n return cleanup\n }\n })\n}\n\nconst TableHandleDropIndicatorElementBase: HostElementConstructor<TableHandleDropIndicatorProps> = defineCustomElement(\n setupTableHandleDropIndicator,\n TableHandleDropIndicatorPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class TableHandleDropIndicatorElement extends TableHandleDropIndicatorElementBase {}\n\n/**\n * @internal\n */\nexport function registerTableHandleDropIndicatorElement(): void {\n registerCustomElement('prosekit-table-handle-drop-indicator', TableHandleDropIndicatorElement)\n}\n","import { createSignal, type HostElement } from '@aria-ui/core'\nimport { defineDOMEventHandler, union, type Editor } from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension.ts'\n\nexport function useEditorTyping(\n host: HostElement,\n getEditor: () => Editor | null,\n): () => boolean {\n const typing = createSignal(false)\n\n const extension = union(\n defineDOMEventHandler('keypress', () => {\n typing.set(true)\n }),\n defineDOMEventHandler('pointermove', () => {\n typing.set(false)\n }),\n )\n\n useEditorExtension(host, getEditor, extension)\n\n return typing.get\n}\n","import { createSignal, useEffect, type HostElement } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nimport { getSafeEditorView } from '../utils/get-safe-editor-view.ts'\n\n/**\n * Detect if the user is selecting text inside the editor, in which case some\n * components should be disabled or hidden.\n */\nexport function useSelecting(\n host: HostElement,\n getEditor: () => Editor | null,\n getEnabled: () => boolean,\n): () => boolean {\n const selecting = createSignal(false)\n const isPointerDown = createSignal(false)\n\n useEffect(host, () => {\n if (!getEnabled()) return\n\n const view = getSafeEditorView(getEditor())\n if (!view) return\n\n const { dom, root } = view\n if (!root) return\n\n const handlePointerDown = () => {\n selecting.set(true)\n isPointerDown.set(true)\n }\n const handlePointerUp = () => {\n isPointerDown.set(false)\n }\n const handleMouseMove = () => {\n if (!isPointerDown.get()) {\n selecting.set(false)\n }\n }\n\n dom.addEventListener('pointerdown', handlePointerDown)\n root.addEventListener('pointerup', handlePointerUp)\n root.addEventListener('pointermove', handleMouseMove)\n\n return () => {\n dom.removeEventListener('pointerdown', handlePointerDown)\n root.removeEventListener('pointerup', handlePointerUp)\n root.removeEventListener('pointermove', handleMouseMove)\n }\n })\n\n return selecting.get\n}\n","import { computed, useEffect, type HostElement } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\nimport { moveTableColumn, moveTableRow } from '@prosekit/extensions/table'\n\nimport { getSafeEditorView } from '../../utils/get-safe-editor-view.ts'\n\nimport type { TableHandleStore } from './store.ts'\n\nexport function useDrop(\n host: HostElement,\n getEditor: () => Editor | null,\n store: TableHandleStore,\n): void {\n const getDndStore = () => store.dndStore\n const getDragging = computed(() => getDndStore().dragging.get())\n\n useEffect(host, () => {\n const view = getSafeEditorView(getEditor())\n if (!view || !view.editable) return\n\n const ownerDocument = view.dom?.ownerDocument\n if (!ownerDocument) return\n\n const handleDrop = () => {\n if (!getDragging()) return\n const editor = getEditor()\n if (!editor) return\n\n const dndStore = getDndStore()\n\n const droppingIndex = dndStore.droppingIndex.get()\n const draggingIndex = dndStore.draggingIndex.get()\n const direction = dndStore.direction.get()\n\n if (draggingIndex < 0 || droppingIndex < 0) {\n console.warn('[prosekit] Invalid drag indices:', { draggingIndex, droppingIndex })\n return\n }\n\n if (direction === 'row') {\n editor.exec(moveTableRow({ from: draggingIndex, to: droppingIndex }))\n return\n }\n if (direction === 'col') {\n editor.exec(moveTableColumn({ from: draggingIndex, to: droppingIndex }))\n return\n }\n }\n\n const handleDragOver = (event: DragEvent) => {\n if (!getDragging()) return\n event.preventDefault()\n const dndStore = getDndStore()\n dndStore.dragging.set(true)\n dndStore.x.set(event.clientX)\n dndStore.y.set(event.clientY)\n }\n\n const handleDragEnd = () => {\n if (!getDragging()) return\n const dndStore = getDndStore()\n dndStore.dragging.set(false)\n }\n\n ownerDocument.addEventListener('dragover', handleDragOver)\n ownerDocument.addEventListener('drop', handleDrop)\n ownerDocument.addEventListener('dragend', handleDragEnd)\n return () => {\n ownerDocument.removeEventListener('dragover', handleDragOver)\n ownerDocument.removeEventListener('drop', handleDrop)\n ownerDocument.removeEventListener('dragend', handleDragEnd)\n }\n })\n}\n","import type { EditorView } from '@prosekit/pm/view'\nimport { cellAround, TableMap } from 'prosemirror-tables'\n\nexport interface HoveringCellInfo {\n rowIndex: number\n colIndex: number\n cellPos: number\n rowFirstCellPos: number\n colFirstCellPos: number\n}\n\nexport function isHoveringCellInfoEqual(\n a?: HoveringCellInfo | null,\n b?: HoveringCellInfo | null,\n): boolean {\n if (!a && !b) return true\n if (!a || !b) return false\n return (\n a.rowIndex === b.rowIndex\n && a.colIndex === b.colIndex\n && a.cellPos === b.cellPos\n && a.rowFirstCellPos === b.rowFirstCellPos\n && a.colFirstCellPos === b.colFirstCellPos\n )\n}\n\n/**\n * Copied from https://github.com/ProseMirror/prosemirror-tables/blob/v1.5.0/src/columnresizing.ts#L256\n *\n * @internal\n */\nfunction domCellAround(target: HTMLElement | null): HTMLElement | null {\n while (target && target.nodeName != 'TD' && target.nodeName != 'TH') {\n target = target.classList?.contains('ProseMirror')\n ? null\n : (target.parentNode as HTMLElement | null)\n }\n return target\n}\n\nexport function getHoveringCell(\n view: EditorView,\n event: MouseEvent,\n): HoveringCellInfo | undefined {\n const domCell = domCellAround(event.target as HTMLElement | null)\n if (!domCell) return\n\n const { left, top, width, height } = domCell.getBoundingClientRect()\n const eventPos = view.posAtCoords({\n // Use the center coordinates of the cell to ensure we're within the\n // selected cell. This prevents potential issues when the mouse is on the\n // border of two cells.\n left: left + width / 2,\n top: top + height / 2,\n })\n if (!eventPos) return\n\n const $cellPos = cellAround(view.state.doc.resolve(eventPos.pos))\n if (!$cellPos) return\n\n const map = TableMap.get($cellPos.node(-1))\n const tableStart = $cellPos.start(-1)\n const cellRect = map.findCell($cellPos.pos - tableStart)\n const rowIndex = cellRect.top\n const colIndex = cellRect.left\n\n return {\n rowIndex,\n colIndex,\n cellPos: $cellPos.pos,\n rowFirstCellPos: getCellPos(map, tableStart, rowIndex, 0),\n colFirstCellPos: getCellPos(map, tableStart, 0, colIndex),\n }\n}\n\nfunction getCellPos(\n map: TableMap,\n tableStart: number,\n rowIndex: number,\n colIndex: number,\n) {\n const cellIndex = getCellIndex(map, rowIndex, colIndex)\n const posInTable = map.map[cellIndex]\n return tableStart + posInTable\n}\n\nfunction getCellIndex(\n map: TableMap,\n rowIndex: number,\n colIndex: number,\n): number {\n return map.width * rowIndex + colIndex\n}\n","import {\n computed,\n createSignal,\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { defineDOMEventHandler, type Editor } from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { useEditorExtension } from '../../hooks/use-editor-extension.ts'\nimport { useEditorTyping } from '../../hooks/use-editor-typing.ts'\nimport { useScrolling } from '../../hooks/use-scrolling.ts'\nimport { useSelecting } from '../../hooks/use-selecting.ts'\n\nimport { createTableHandleStore, tableHandleStoreContext } from './store.ts'\nimport { useDrop } from './use-drop.ts'\nimport { getHoveringCell, isHoveringCellInfoEqual, type HoveringCellInfo } from './utils.ts'\n\nexport interface TableHandleRootProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const TableHandleRootPropsDeclaration: PropsDeclaration<TableHandleRootProps> = defineProps<TableHandleRootProps>({\n editor: { default: null, attribute: false, type: 'json' },\n})\n\n/**\n * @internal\n */\nexport function setupTableHandleRoot(\n host: HostElement,\n props: State<TableHandleRootProps>,\n): void {\n const getEditor = props.editor.get\n\n const getHoveringCellInfo = useHoveringCell(host, getEditor)\n const getTyping = useEditorTyping(host, getEditor)\n const getIsInTable = computed(() => !!getHoveringCellInfo())\n const getSelecting = useSelecting(host, getEditor, getIsInTable)\n const getScrolling = useScrolling(host)\n const getCanShow = computed(() => !getTyping() && !getSelecting() && !getScrolling())\n\n const store = createTableHandleStore(getHoveringCellInfo, getCanShow)\n tableHandleStoreContext.provide(host, store)\n\n useDrop(host, getEditor, store)\n}\n\nfunction useHoveringCell(\n host: HostElement,\n getEditor: () => Editor | null,\n): () => HoveringCellInfo | undefined {\n const hoveringCell = createSignal<HoveringCellInfo | undefined>(undefined)\n\n const extension = defineCellHoverHandler((curr: HoveringCellInfo | undefined) => {\n const prev = hoveringCell.get()\n if (isHoveringCellInfoEqual(prev, curr)) return\n hoveringCell.set(curr)\n })\n\n useEditorExtension(host, getEditor, extension)\n\n return hoveringCell.get\n}\n\nfunction defineCellHoverHandler(\n handler: (hoveringCell: HoveringCellInfo | undefined) => void,\n) {\n const pointerHandler = (view: EditorView, event: PointerEvent) => {\n const hoveringCell = getHoveringCell(view, event)\n return handler(hoveringCell)\n }\n return defineDOMEventHandler('pointerover', pointerHandler)\n}\n\nconst TableHandleRootElementBase: HostElementConstructor<TableHandleRootProps> = defineCustomElement(\n setupTableHandleRoot,\n TableHandleRootPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class TableHandleRootElement extends TableHandleRootElementBase {}\n\n/**\n * @internal\n */\nexport function registerTableHandleRootElement(): void {\n registerCustomElement('prosekit-table-handle-root', TableHandleRootElement)\n}\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { setupOverlayPopup } from '@aria-ui/elements/overlay'\n\nimport { tableHandleStoreContext } from './store.ts'\n\nexport interface TableHandleRowPopupProps {}\n\n/** @internal */\nexport const TableHandleRowPopupPropsDeclaration: PropsDeclaration<TableHandleRowPopupProps> = defineProps<TableHandleRowPopupProps>({})\n\n/** @internal */\nexport function setupTableHandleRowPopup(\n host: HostElement,\n _props: State<TableHandleRowPopupProps>,\n): void {\n const getStore = tableHandleStoreContext.consume(host)\n const getOverlayStore = () => getStore()?.rowOverlayStore\n setupOverlayPopup(host, getOverlayStore)\n}\n\nconst TableHandleRowPopupElementBase: HostElementConstructor<TableHandleRowPopupProps> = defineCustomElement(\n setupTableHandleRowPopup,\n TableHandleRowPopupPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class TableHandleRowPopupElement extends TableHandleRowPopupElementBase {}\n\n/** @internal */\nexport function registerTableHandleRowPopupElement(): void {\n registerCustomElement('prosekit-table-handle-row-popup', TableHandleRowPopupElement)\n}\n","import {\n computed,\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEffect,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { setupOverlayPositioner } from '@aria-ui/elements/overlay'\nimport type { Placement } from '@floating-ui/dom'\n\nimport { useHTMLElementAt } from '../../utils/use-html-element-at.ts'\n\nimport { SharedTableHandlePositionerPropsDeclaration, type SharedTableHandlePositionerProps } from './shared.ts'\nimport { tableHandleStoreContext } from './store.ts'\n\nexport interface TableHandleRowPositionerProps extends Omit<SharedTableHandlePositionerProps, 'placement'> {\n /**\n * The placement of the popover, relative to the hovered table cell.\n *\n * @default \"left\"\n */\n placement: Placement\n}\n\n/** @internal */\nexport const TableHandleRowPositionerPropsDeclaration: PropsDeclaration<TableHandleRowPositionerProps> = defineProps<\n TableHandleRowPositionerProps\n>({\n ...SharedTableHandlePositionerPropsDeclaration,\n placement: { default: 'left', attribute: 'placement', type: 'string' },\n})\n\n/** @internal */\nexport function setupTableHandleRowPositioner(\n host: HostElement,\n props: State<TableHandleRowPositionerProps>,\n): void {\n const getStore = tableHandleStoreContext.consume(host)\n const getOverlayStore = () => getStore()?.rowOverlayStore\n setupOverlayPositioner(host, props, getOverlayStore)\n\n const getEditor = props.editor.get\n const getRowFirstCellPos = computed(() => getStore()?.getReferenceCell()?.rowFirstCellPos)\n const getReferenceCell = useHTMLElementAt(getEditor, getRowFirstCellPos)\n useEffect(host, () => {\n getOverlayStore()?.setAnchorElement(getReferenceCell())\n })\n}\n\nconst TableHandleRowPositionerElementBase: HostElementConstructor<TableHandleRowPositionerProps> = defineCustomElement(\n setupTableHandleRowPositioner,\n TableHandleRowPositionerPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class TableHandleRowPositionerElement extends TableHandleRowPositionerElementBase {}\n\n/** @internal */\nexport function registerTableHandleRowPositionerElement(): void {\n registerCustomElement('prosekit-table-handle-row-positioner', TableHandleRowPositionerElement)\n}\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEffect,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { MenuRootPropsDeclaration, setupMenuRoot, type MenuRootProps } from '@aria-ui/elements/menu'\n\nimport { tableHandleStoreContext } from './store.ts'\n\nexport interface TableHandleRowMenuRootProps extends MenuRootProps {}\n\n/** @internal */\nexport const TableHandleRowMenuRootPropsDeclaration: PropsDeclaration<TableHandleRowMenuRootProps> = defineProps<\n TableHandleRowMenuRootProps\n>(MenuRootPropsDeclaration)\n\n/** @internal */\nexport function setupTableHandleRowMenuRoot(\n host: HostElement,\n props: State<TableHandleRowMenuRootProps>,\n): void {\n setupMenuRoot(host, props)\n const getStore = tableHandleStoreContext.consume(host)\n\n useEffect(host, () => {\n const open = props.open.get() || false\n const store = getStore?.()\n if (!store) return\n store.setIsRowMenuOpen(open)\n })\n}\n\nconst TableHandleRowMenuRootElementBase: HostElementConstructor<TableHandleRowMenuRootProps> = defineCustomElement(\n setupTableHandleRowMenuRoot,\n TableHandleRowMenuRootPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class TableHandleRowMenuRootElement extends TableHandleRowMenuRootElementBase {}\n\n/** @internal */\nexport function registerTableHandleRowMenuRootElement(): void {\n registerCustomElement('prosekit-table-handle-row-menu-root', TableHandleRowMenuRootElement)\n}\n","import {\n createSignal,\n defineCustomElement,\n defineProps,\n onMount,\n registerCustomElement,\n useEventListener,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { setupMenuTrigger, type MenuTriggerProps } from '@aria-ui/elements/menu'\nimport type { Editor } from '@prosekit/core'\nimport { selectTableRow, type defineTableCommands } from '@prosekit/extensions/table'\n\nimport { tableHandleStoreContext } from './store.ts'\nimport { useEmptyImage } from './use-empty-image.ts'\n\ntype TableCommandsExtension = ReturnType<typeof defineTableCommands>\n\nexport interface TableHandleRowMenuTriggerProps {\n /**\n * @default null\n * @hidden\n */\n editor: Editor<TableCommandsExtension> | null\n}\n\n/** @internal */\nexport const TableHandleRowMenuTriggerPropsDeclaration: PropsDeclaration<TableHandleRowMenuTriggerProps> = defineProps<\n TableHandleRowMenuTriggerProps\n>({\n editor: { default: null, attribute: false, type: 'json' },\n})\n\n/** @internal */\nexport function setupTableHandleRowMenuTrigger(\n host: HostElement,\n props: State<TableHandleRowMenuTriggerProps>,\n): void {\n const getEditor = props.editor.get\n const getStore = tableHandleStoreContext.consume(host)\n\n const triggerProps: State<MenuTriggerProps> = {\n disabled: createSignal(false),\n }\n setupMenuTrigger(host, triggerProps)\n\n useEventListener(host, 'pointerdown', () => {\n const editor = getEditor()\n const cellPos = getStore()?.getReferenceCell()?.cellPos\n if (!editor || !cellPos) return\n editor.exec(selectTableRow({ head: cellPos }))\n })\n\n onMount(host, () => {\n host.draggable = true\n })\n\n const getEmptyImage = useEmptyImage(host)\n\n useEventListener(host, 'dragstart', (event: DragEvent) => {\n const dataTransfer = event.dataTransfer\n if (dataTransfer) {\n dataTransfer.effectAllowed = 'move'\n const emptyImage = getEmptyImage()\n if (emptyImage) {\n dataTransfer.setDragImage(emptyImage, 0, 0)\n }\n }\n const store = getStore()\n if (!store) return\n const index = store.getReferenceCell()?.rowIndex\n\n if (index == null || index < 0) {\n console.warn('[prosekit] Invalid row index for drag operation:', index)\n event.preventDefault()\n return\n }\n\n const dndStore = store.dndStore\n\n dndStore.direction.set('row')\n dndStore.dragging.set(true)\n dndStore.draggingIndex.set(index)\n dndStore.startX.set(event.clientX)\n dndStore.startY.set(event.clientY)\n })\n}\n\nconst TableHandleRowMenuTriggerElementBase: HostElementConstructor<TableHandleRowMenuTriggerProps> = defineCustomElement(\n setupTableHandleRowMenuTrigger,\n TableHandleRowMenuTriggerPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class TableHandleRowMenuTriggerElement extends TableHandleRowMenuTriggerElementBase {}\n\n/**\n * @internal\n */\nexport function registerTableHandleRowMenuTriggerElement(): void {\n registerCustomElement('prosekit-table-handle-row-menu-trigger', TableHandleRowMenuTriggerElement)\n}\n"],"mappings":";;;;;;;;;;;;AAMA,SAAS,OAAa;AACtB,SAAS,aAAsB;AAC7B,QAAO;;AAET,SAAS,cAAuB;AAC9B,QAAO;;AAGT,IAAM,WAAN,MAAe;;kBACwB,aAAa,MAAM;mBACZ,aAA4B,MAAM;uBACrC,aAAa,GAAG;uBAChB,aAAa,GAAG;WAC5B,aAAa,GAAG;WAChB,aAAa,GAAG;gBACX,aAAa,GAAG;gBAChB,aAAa,GAAG;;;;;;AAkBpD,SAAgB,uBACd,qBACA,YACkB;CAClB,MAAM,mBAAmB,aAAa,MAAM;CAC5C,MAAM,gBAAgB,aAAa,MAAM;CAEzC,MAAM,uBAAgC;AACpC,SAAO,iBAAiB,KAAK,IAAI,cAAc,KAAK;;CAGtD,MAAM,oBAAoB,SAAwB;AAChD,gBAAc,IAAI,KAAK;;CAGzB,MAAM,uBAAuB,SAAwB;AACnD,mBAAiB,IAAI,KAAK;;CAG5B,MAAM,oBAAoB,aAA2C,KAAA,EAAU;CAE/E,IAAI,uBAAqD,KAAA;CAEzD,MAAM,mBAAmB,eAA6C;AACpE,MAAI,CAAC,YAAY,EAAE;AACjB,qBAAkB,IAAI,KAAA,EAAU;AAChC;;AAIF,MAAI,gBAAgB,CAClB,QAAO;AAGT,yBAAuB,qBAAqB;AAC5C,SAAO;GACP;CAEF,MAAM,UAAU,eAAwB;AACtC,SAAO,CAAC,CAAC,kBAAkB;GAC3B;CAEF,MAAM,oBAAoB,UAA2B;AACnD,MAAI,gBAAgB,CAClB,OAAM,gBAAgB;;CAI1B,MAAM,qBAAqB,mBACzB,SACA,MACA,YACA,aACA,iBACD;CACD,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AQ,MAAM,kBAAkB,EAAE;AAExC,MAAI,SAAS,QAAQ,QAAQ,GAAG;AAC9B,WAAQ,KAAK,oDAAoD,MAAM;AACvE,SAAM,gBAAgB;AACtB;;EAGF,MAAM,WAAW,MAAM;AAEvB,WAAS,UAAU,IAAI,MAAM;AAC7B,WAAS,SAAS,IAAI,KAAK;AAC3B,WAAS,cAAc,IAAI,MAAM;AACjC,WAAS,OAAO,IAAI,MAAM,QAAQ;AAClC,WAAS,OAAO,IAAI,MAAM,QAAQ;GAClC;;AAGJ,MAAM,uCAA+F,oBACnG,gCACA,0CACD;;;;AAKD,IAAa,mCAAb,cAAsD,qCAAqC;;;;AAK3F,SAAgB,2CAAiD;AAC/D,uBAAsB,0CAA0C,iCAAiC"}
|
|
@@ -1,29 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TooltipContentEvents as TooltipContentEvents$1, TooltipContentProps as TooltipContentProps$1, TooltipRootEvents as TooltipRootEvents$1, TooltipRootProps as TooltipRootProps$1, TooltipTriggerEvents as TooltipTriggerEvents$1, TooltipTriggerProps as TooltipTriggerProps$1, tooltipContentEvents, tooltipContentProps, tooltipRootEvents, tooltipRootProps, tooltipTriggerEvents, tooltipTriggerProps, useTooltipContent, useTooltipRoot, useTooltipTrigger } from "@aria-ui/tooltip/elements";
|
|
1
|
+
import { OpenChangeEvent, TooltipPopupElement, TooltipPopupProps, TooltipPopupPropsDeclaration, TooltipPositionerElement, TooltipPositionerProps, TooltipPositionerPropsDeclaration, TooltipRootElement, TooltipRootEvents, TooltipRootProps, TooltipRootPropsDeclaration, TooltipTriggerElement, TooltipTriggerProps, TooltipTriggerPropsDeclaration, setupTooltipPopup, setupTooltipPositioner, setupTooltipRoot, setupTooltipTrigger } from "@aria-ui/elements/tooltip";
|
|
3
2
|
|
|
4
|
-
//#region src/components/tooltip/
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
//#region src/components/tooltip/index.d.ts
|
|
4
|
+
declare function registerTooltipRootElement(): void;
|
|
5
|
+
declare function registerTooltipTriggerElement(): void;
|
|
6
|
+
declare function registerTooltipPopupElement(): void;
|
|
7
|
+
declare function registerTooltipPositionerElement(): void;
|
|
7
8
|
//#endregion
|
|
8
|
-
|
|
9
|
-
declare const TooltipContentElementBase: BaseElementConstructor<TooltipContentProps>;
|
|
10
|
-
declare class TooltipContentElement extends TooltipContentElementBase {}
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/components/tooltip/tooltip-root/types.d.ts
|
|
13
|
-
interface TooltipRootProps extends TooltipRootProps$1 {}
|
|
14
|
-
interface TooltipRootEvents extends TooltipRootEvents$1 {}
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/components/tooltip/tooltip-root/element.gen.d.ts
|
|
17
|
-
declare const TooltipRootElementBase: BaseElementConstructor<TooltipRootProps>;
|
|
18
|
-
declare class TooltipRootElement extends TooltipRootElementBase {}
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/components/tooltip/tooltip-trigger/types.d.ts
|
|
21
|
-
interface TooltipTriggerProps extends TooltipTriggerProps$1 {}
|
|
22
|
-
interface TooltipTriggerEvents extends TooltipTriggerEvents$1 {}
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/components/tooltip/tooltip-trigger/element.gen.d.ts
|
|
25
|
-
declare const TooltipTriggerElementBase: BaseElementConstructor<TooltipTriggerProps>;
|
|
26
|
-
declare class TooltipTriggerElement extends TooltipTriggerElementBase {}
|
|
27
|
-
//#endregion
|
|
28
|
-
export { TooltipContentElement, type TooltipContentEvents, type TooltipContentProps, TooltipRootElement, type TooltipRootEvents, type TooltipRootProps, TooltipTriggerElement, type TooltipTriggerEvents, type TooltipTriggerProps, tooltipContentEvents, tooltipContentProps, tooltipRootEvents, tooltipRootProps, tooltipTriggerEvents, tooltipTriggerProps, useTooltipContent, useTooltipRoot, useTooltipTrigger };
|
|
9
|
+
export { OpenChangeEvent, TooltipPopupElement, type TooltipPopupProps, TooltipPopupPropsDeclaration, TooltipPositionerElement, type TooltipPositionerProps, TooltipPositionerPropsDeclaration, TooltipRootElement, type TooltipRootEvents, type TooltipRootProps, TooltipRootPropsDeclaration, TooltipTriggerElement, type TooltipTriggerProps, TooltipTriggerPropsDeclaration, registerTooltipPopupElement, registerTooltipPositionerElement, registerTooltipRootElement, registerTooltipTriggerElement, setupTooltipPopup, setupTooltipPositioner, setupTooltipRoot, setupTooltipTrigger };
|
|
29
10
|
//# sourceMappingURL=prosekit-web-tooltip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-tooltip.d.ts","names":[],"sources":["../src/components/tooltip/
|
|
1
|
+
{"version":3,"file":"prosekit-web-tooltip.d.ts","names":[],"sources":["../src/components/tooltip/index.ts"],"mappings":";;;iBAwCgB,0BAAA,CAAA;AAAA,iBAGA,6BAAA,CAAA;AAAA,iBAGA,2BAAA,CAAA;AAAA,iBAGA,gCAAA,CAAA"}
|
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
//#region src/components/tooltip/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import { registerCustomElement } from "@aria-ui/core";
|
|
2
|
+
import { OpenChangeEvent, TooltipPopupElement, TooltipPopupElement as TooltipPopupElement$1, TooltipPopupPropsDeclaration, TooltipPositionerElement, TooltipPositionerElement as TooltipPositionerElement$1, TooltipPositionerPropsDeclaration, TooltipRootElement, TooltipRootElement as TooltipRootElement$1, TooltipRootPropsDeclaration, TooltipTriggerElement, TooltipTriggerElement as TooltipTriggerElement$1, TooltipTriggerPropsDeclaration, setupTooltipPopup, setupTooltipPositioner, setupTooltipRoot, setupTooltipTrigger } from "@aria-ui/elements/tooltip";
|
|
3
|
+
//#region src/components/tooltip/index.ts
|
|
4
|
+
/**
|
|
5
|
+
|
|
6
|
+
@module
|
|
7
|
+
|
|
8
|
+
## Anatomy
|
|
9
|
+
|
|
10
|
+
```html
|
|
11
|
+
<prosekit-tooltip-root>
|
|
12
|
+
<prosekit-tooltip-trigger>...</prosekit-tooltip-trigger>
|
|
13
|
+
<prosekit-tooltip-positioner>
|
|
14
|
+
<prosekit-tooltip-popup>...</prosekit-tooltip-popup>
|
|
15
|
+
</prosekit-tooltip-positioner>
|
|
16
|
+
</prosekit-tooltip-root>
|
|
17
|
+
```
|
|
18
|
+
*/
|
|
19
|
+
function registerTooltipRootElement() {
|
|
20
|
+
registerCustomElement("prosekit-tooltip-root", TooltipRootElement$1);
|
|
21
|
+
}
|
|
22
|
+
function registerTooltipTriggerElement() {
|
|
23
|
+
registerCustomElement("prosekit-tooltip-trigger", TooltipTriggerElement$1);
|
|
24
|
+
}
|
|
25
|
+
function registerTooltipPopupElement() {
|
|
26
|
+
registerCustomElement("prosekit-tooltip-popup", TooltipPopupElement$1);
|
|
27
|
+
}
|
|
28
|
+
function registerTooltipPositionerElement() {
|
|
29
|
+
registerCustomElement("prosekit-tooltip-positioner", TooltipPositionerElement$1);
|
|
30
|
+
}
|
|
29
31
|
//#endregion
|
|
30
|
-
export {
|
|
32
|
+
export { OpenChangeEvent, TooltipPopupElement, TooltipPopupPropsDeclaration, TooltipPositionerElement, TooltipPositionerPropsDeclaration, TooltipRootElement, TooltipRootPropsDeclaration, TooltipTriggerElement, TooltipTriggerPropsDeclaration, registerTooltipPopupElement, registerTooltipPositionerElement, registerTooltipRootElement, registerTooltipTriggerElement, setupTooltipPopup, setupTooltipPositioner, setupTooltipRoot, setupTooltipTrigger };
|
|
31
33
|
|
|
32
34
|
//# sourceMappingURL=prosekit-web-tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-tooltip.js","names":[
|
|
1
|
+
{"version":3,"file":"prosekit-web-tooltip.js","names":["TooltipRootElement","TooltipTriggerElement","TooltipPopupElement","TooltipPositionerElement"],"sources":["../src/components/tooltip/index.ts"],"sourcesContent":["/**\n\n@module\n\n## Anatomy\n\n```html\n<prosekit-tooltip-root>\n <prosekit-tooltip-trigger>...</prosekit-tooltip-trigger>\n <prosekit-tooltip-positioner>\n <prosekit-tooltip-popup>...</prosekit-tooltip-popup>\n </prosekit-tooltip-positioner>\n</prosekit-tooltip-root>\n```\n*/\n\nimport { registerCustomElement } from '@aria-ui/core'\nimport { TooltipPopupElement, TooltipPositionerElement, TooltipRootElement, TooltipTriggerElement } from '@aria-ui/elements/tooltip'\n\nexport {\n OpenChangeEvent,\n setupTooltipPopup,\n setupTooltipPositioner,\n setupTooltipRoot,\n setupTooltipTrigger,\n TooltipPopupElement,\n TooltipPopupPropsDeclaration,\n TooltipPositionerElement,\n TooltipPositionerPropsDeclaration,\n TooltipRootElement,\n TooltipRootPropsDeclaration,\n TooltipTriggerElement,\n TooltipTriggerPropsDeclaration,\n type TooltipPopupProps,\n type TooltipPositionerProps,\n type TooltipRootEvents,\n type TooltipRootProps,\n type TooltipTriggerProps,\n} from '@aria-ui/elements/tooltip'\n\nexport function registerTooltipRootElement(): void {\n registerCustomElement('prosekit-tooltip-root', TooltipRootElement)\n}\nexport function registerTooltipTriggerElement(): void {\n registerCustomElement('prosekit-tooltip-trigger', TooltipTriggerElement)\n}\nexport function registerTooltipPopupElement(): void {\n registerCustomElement('prosekit-tooltip-popup', TooltipPopupElement)\n}\nexport function registerTooltipPositionerElement(): void {\n registerCustomElement('prosekit-tooltip-positioner', TooltipPositionerElement)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwCA,SAAgB,6BAAmC;AACjD,uBAAsB,yBAAyBA,qBAAmB;;AAEpE,SAAgB,gCAAsC;AACpD,uBAAsB,4BAA4BC,wBAAsB;;AAE1E,SAAgB,8BAAoC;AAClD,uBAAsB,0BAA0BC,sBAAoB;;AAEtE,SAAgB,mCAAyC;AACvD,uBAAsB,+BAA+BC,2BAAyB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useEffect } from "@aria-ui/core";
|
|
2
2
|
//#region src/hooks/use-editor-extension.ts
|
|
3
|
-
function useEditorExtension(host,
|
|
3
|
+
function useEditorExtension(host, getEditor, extension) {
|
|
4
4
|
useEffect(host, () => {
|
|
5
|
-
return
|
|
5
|
+
return getEditor()?.use(extension);
|
|
6
6
|
});
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-editor-extension.js","names":[],"sources":["../src/hooks/use-editor-extension.ts"],"sourcesContent":["import { useEffect, type
|
|
1
|
+
{"version":3,"file":"use-editor-extension.js","names":[],"sources":["../src/hooks/use-editor-extension.ts"],"sourcesContent":["import { useEffect, type HostElement } from '@aria-ui/core'\nimport type { Editor, Extension } from '@prosekit/core'\n\nexport function useEditorExtension(\n host: HostElement,\n getEditor: () => Editor | null,\n extension: Extension,\n): void {\n useEffect(host, () => {\n return getEditor()?.use(extension)\n })\n}\n"],"mappings":";;AAGA,SAAgB,mBACd,MACA,WACA,WACM;AACN,WAAU,YAAY;AACpB,SAAO,WAAW,EAAE,IAAI,UAAU;GAClC"}
|
package/dist/use-scrolling.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createSignal, useEffect } from "@aria-ui/core";
|
|
2
|
-
import { getNearestOverflowAncestor } from "@
|
|
2
|
+
import { getNearestOverflowAncestor } from "@aria-ui/utils";
|
|
3
3
|
//#region src/utils/assign-styles.ts
|
|
4
4
|
/**
|
|
5
5
|
* A type-safe version of `Object.assign` for `element.style`.
|
|
@@ -19,16 +19,25 @@ function useScrolling(host) {
|
|
|
19
19
|
const handleMouseMove = () => {
|
|
20
20
|
scrolling.set(false);
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const abortController = new AbortController();
|
|
23
|
+
const abortSignal = abortController.signal;
|
|
24
|
+
scrollableParent.addEventListener("scroll", handleScroll, {
|
|
25
|
+
passive: true,
|
|
26
|
+
signal: abortSignal
|
|
27
|
+
});
|
|
28
|
+
window.addEventListener("mousemove", handleMouseMove, {
|
|
29
|
+
passive: true,
|
|
30
|
+
signal: abortSignal
|
|
31
|
+
});
|
|
32
|
+
window.addEventListener("pointermove", handleMouseMove, {
|
|
33
|
+
passive: true,
|
|
34
|
+
signal: abortSignal
|
|
35
|
+
});
|
|
25
36
|
return () => {
|
|
26
|
-
|
|
27
|
-
window.removeEventListener("mousemove", handleMouseMove);
|
|
28
|
-
window.removeEventListener("pointermove", handleMouseMove);
|
|
37
|
+
abortController.abort();
|
|
29
38
|
};
|
|
30
39
|
});
|
|
31
|
-
return scrolling;
|
|
40
|
+
return scrolling.get;
|
|
32
41
|
}
|
|
33
42
|
//#endregion
|
|
34
43
|
export { assignStyles as n, useScrolling as t };
|