@prosekit/web 0.7.7 → 0.7.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-web-autocomplete.d.ts","names":[],"sources":["../src/components/autocomplete/autocomplete-empty/types.ts","../src/components/autocomplete/autocomplete-empty/element.gen.ts","../src/components/autocomplete/autocomplete-empty/setup.ts","../src/components/autocomplete/autocomplete-item/types.ts","../src/components/autocomplete/autocomplete-item/element.gen.ts","../src/components/autocomplete/autocomplete-item/setup.ts","../src/components/autocomplete/autocomplete-list/types.ts","../src/components/autocomplete/autocomplete-list/element.gen.ts","../src/components/autocomplete/autocomplete-list/setup.ts","../src/components/autocomplete/autocomplete-popover/types.ts","../src/components/autocomplete/autocomplete-popover/element.gen.ts","../src/components/autocomplete/autocomplete-popover/setup.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAMiB,sBAAA;;cAGJ,wBAAwB,iBAAiB;;AAHrC,UAMA,uBAAA,CANsB,CAGvC;AAGA;AAGa,cAAA,uBAA2C,EAAlB,iBAAkB,CAAA,uBAAD,CAAA;;;cCVjD,8BAA8B,uBAAuB;cAQrD,wBAAA,SAAiC,4BAAA;;;;;;cCR1B,6BAA6B;;;UCIzB,qBAAA;;;;;AHHjB;AAGA;AAGA;EAGa,KAAA,EAAA,MAAA;;;cGMA,uBAAuB,iBAAiB;AFhB/C,UEsBW,sBAAA,SAA+B,iBFtBW,CAAA,CAAD;;cEyB7C,wBAAwB,kBAAkB;;;cCzBjD,6BAA6B,uBAAuB;cAQpD,uBAAA,SAAgC,2BAAA;;;;;;iBCKtB,mBAAA,UACL;;;GACQ,aAAa,uBAAuB;;;UCRtC,qBAAA,SAA8B,KAAK;;;;ANNpD;AAGA;AAGA;EAGa,MAAA,EMIH,MNJG,GAAA,IAAA;;cMOA,uBAAuB,iBAAiB;UAKpC,sBAAA,SAA+B,eLxBoF;AAU9H,cKgBO,sBLhB0B,EKgBF,iBLhBE,CKgBgB,sBLhBY,CAAA;;;cMR7D,6BAA6B,uBAAuB;cAQpD,uBAAA,SAAgC,2BAAA;;;;;;iBCsBtB,mBAAA,UACL;;;GACQ,aAAa,uBAAuB;;;UCzBtC,wBAAA,SAAiC;;;;ATNlD;AAGA;AAGA;EAGa,MAAA,ESIH,MTJG,GAAA,IAAA;;;;ACZuH;AAE1E;SQqBjD;;;APrBT;;;aO4Ba;ENxBI;AAYjB;AAMA;AAGA;;UMUU;;ALrCsH;AAEvE;UKwC/C;;;AJ3BV;EACW,KAAA,EI+BF,sBJ/BE,CAAA,OAAA,CAAA;EACP;;;EAAmD,WAAA,EImCxC,sBJnCwC,CAAA,aAAA,CAAA;EAApC;;;YIwCP;;AHhDZ;;EAOU,eAAA,EG8CS,sBH9CT,CAAA,iBAAA,CAAA;;;AAGG,cGkDA,wBHlDwC,EGkDd,gBHlDH,CGkDoB,wBHlDJ,CAAA;AAKnC,UG0DA,yBAAA,SAAkC,uBH1DU,CAAA;EAEhD;;;cG4DC;EFpFR;AAAmD;;eEyF1C;;AD3Df;AACW,cC8DE,yBD9DF,EC8D6B,iBD9D7B,CC8D+C,yBD9D/C,CAAA;;;cE/BL,gCAAgC,uBAAuB;cAQvD,0BAAA,SAAmC,8BAAA;;;;;;iBC8BzB,sBAAA,OACR;;;GAIH,aAAa,0BAA0B"}
1
+ {"version":3,"file":"prosekit-web-autocomplete.d.ts","names":[],"sources":["../src/components/autocomplete/autocomplete-empty/types.ts","../src/components/autocomplete/autocomplete-empty/element.gen.ts","../src/components/autocomplete/autocomplete-empty/setup.ts","../src/components/autocomplete/autocomplete-item/types.ts","../src/components/autocomplete/autocomplete-item/element.gen.ts","../src/components/autocomplete/autocomplete-item/setup.ts","../src/components/autocomplete/autocomplete-list/types.ts","../src/components/autocomplete/autocomplete-list/element.gen.ts","../src/components/autocomplete/autocomplete-list/setup.ts","../src/components/autocomplete/autocomplete-popover/types.ts","../src/components/autocomplete/autocomplete-popover/element.gen.ts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;;;AAGG,cGkDA,wBHlDwC,EGkDd,gBHlDc,CGkDG,wBHlDJ,CAAA;AAKnC,UG0DA,yBAAA,SAAkC,uBH1DU,CAAA;EAEhD;;;cG4DC;EFpFR;AAAmD;;eEyF1C;;AD3Df;AACW,cC8DE,yBD9DF,EC8D6B,iBD9D7B,CC8D+C,yBD9D/C,CAAA;;;cE/BL,gCAAgC,uBAAuB;cAQvD,0BAAA,SAAmC,8BAAA;;;;;;iBC8BzB,sBAAA,OACR;;;GAIH,aAAa,0BAA0B"}
@@ -227,7 +227,7 @@ function useAutocompleteExtension(host, editor, regex, reference, query, onDismi
227
227
  }
228
228
  function createAutocompleteRule(editor, regex, reference, query, onDismiss, onSubmit) {
229
229
  const handleEnter = (options) => {
230
- const span = getSafeEditorView(editor)?.dom.querySelector(".prosemirror-prediction-match");
230
+ const span = getSafeEditorView(editor)?.dom.querySelector(".prosekit-autocomplete-match");
231
231
  if (span) reference.set(span);
232
232
  query.set(defaultQueryBuilder(options.match));
233
233
  onDismiss.set(options.ignoreMatch);
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-web-autocomplete.js","names":["useAutocompleteEmpty: typeof useListboxEmpty","autocompleteEmptyProps: PropDeclarations<AutocompleteEmptyProps>","autocompleteEmptyEvents: EventDeclarations<AutocompleteEmptyEvents>","AutocompleteEmptyElementBase: BaseElementConstructor<AutocompleteEmptyProps>","queryContext: Context<string>","onSubmitContext: Context<VoidFunction | null>","openContext: Context<boolean>","autocompleteItemProps: PropDeclarations<AutocompleteItemProps>","autocompleteItemEvents: EventDeclarations<AutocompleteItemEvents>","AutocompleteItemElementBase: BaseElementConstructor<AutocompleteItemProps>","keydownHandlers: ((event: KeyboardEvent) => void)[]","autocompleteListProps: PropDeclarations<AutocompleteListProps>","listboxProps","autocompleteListEvents: EventDeclarations<AutocompleteListEvents>","AutocompleteListElementBase: BaseElementConstructor<AutocompleteListProps>","handleEnter: MatchHandler","autocompletePopoverProps: PropDeclarations<AutocompletePopoverProps>","autocompletePopoverEvents: EventDeclarations<AutocompletePopoverEvents>","AutocompletePopoverElementBase: BaseElementConstructor<AutocompletePopoverProps>"],"sources":["../src/components/autocomplete/autocomplete-empty/setup.ts","../src/components/autocomplete/autocomplete-empty/types.ts","../src/components/autocomplete/autocomplete-empty/element.gen.ts","../src/components/autocomplete/context.ts","../src/components/autocomplete/autocomplete-item/setup.ts","../src/components/autocomplete/autocomplete-item/types.ts","../src/components/autocomplete/autocomplete-item/element.gen.ts","../src/components/autocomplete/autocomplete-list/setup.ts","../src/components/autocomplete/autocomplete-list/types.ts","../src/components/autocomplete/autocomplete-list/element.gen.ts","../src/hooks/use-first-rendering.ts","../src/components/autocomplete/autocomplete-popover/helpers.ts","../src/components/autocomplete/autocomplete-popover/setup.ts","../src/components/autocomplete/autocomplete-popover/types.ts","../src/components/autocomplete/autocomplete-popover/element.gen.ts"],"sourcesContent":["import { useListboxEmpty } from '@aria-ui/listbox/elements'\n\n/**\n * @internal\n */\nexport const useAutocompleteEmpty: typeof useListboxEmpty = useListboxEmpty\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\n\n/** @internal */\nexport interface AutocompleteEmptyProps {}\n\n/** @internal */\nexport const autocompleteEmptyProps: PropDeclarations<AutocompleteEmptyProps> = {}\n\n/** @internal */\nexport interface AutocompleteEmptyEvents {}\n\n/** @internal */\nexport const autocompleteEmptyEvents: EventDeclarations<AutocompleteEmptyEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useAutocompleteEmpty } from \"./setup\"\nimport { autocompleteEmptyEvents, autocompleteEmptyProps, type AutocompleteEmptyEvents, type AutocompleteEmptyProps } from \"./types\"\n\nconst AutocompleteEmptyElementBase: BaseElementConstructor<AutocompleteEmptyProps> = defineCustomElement<\n AutocompleteEmptyProps,\n AutocompleteEmptyEvents\n>({\n props: autocompleteEmptyProps,\n events: autocompleteEmptyEvents,\n setup: useAutocompleteEmpty,\n})\nclass AutocompleteEmptyElement extends AutocompleteEmptyElementBase {}\n\nregisterCustomElement('prosekit-autocomplete-empty', AutocompleteEmptyElement)\n \nexport { AutocompleteEmptyElement }\n","import {\n createContext,\n type Context,\n} from '@aria-ui/core'\n\nexport const queryContext: Context<string> = createContext(\n 'prosekit/autocomplete-popover/query',\n '',\n)\n\nexport const onSubmitContext: Context<VoidFunction | null> = createContext(\n 'prosekit/autocomplete-popover/onSubmit',\n null,\n)\n\nexport const openContext: Context<boolean> = createContext(\n 'prosekit/autocomplete-popover/open',\n false,\n)\n","import {\n useEffect,\n useEventListener,\n type ConnectableElement,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { useListboxItem } from '@aria-ui/listbox/elements'\n\nimport { openContext } from '../context'\n\nimport type {\n AutocompleteItemEvents,\n AutocompleteItemProps,\n} from './types'\n\n/**\n * @internal\n */\nexport function useAutocompleteItem(\n element: ConnectableElement,\n { state, emit }: SetupOptions<AutocompleteItemProps, AutocompleteItemEvents>,\n): void {\n useListboxItem(element, { state, emit })\n\n const open = openContext.consume(element)\n\n useEffect(element, () => {\n // Check the text content again when the open state changes\n if (!state.value.peek() && open.get()) {\n state.value.set(element.textContent ?? '')\n }\n })\n\n useEventListener(element, 'pointerdown', (event) => {\n // Prevent the editor from losing focus\n event.preventDefault()\n })\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n listboxItemEvents,\n type ListboxItemEvents,\n} from '@aria-ui/listbox'\n\nexport interface AutocompleteItemProps {\n /**\n * The value of the item, which will be matched against the query.\n *\n * If not provided, the value is the item's text content.\n *\n * @default \"\"\n */\n value: string\n}\n\n/** @internal */\nexport const autocompleteItemProps: PropDeclarations<AutocompleteItemProps> = {\n value: {\n default: '',\n },\n}\n\nexport interface AutocompleteItemEvents extends ListboxItemEvents {}\n\n/** @internal */\nexport const autocompleteItemEvents: EventDeclarations<AutocompleteItemEvents> = listboxItemEvents\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useAutocompleteItem } from \"./setup\"\nimport { autocompleteItemEvents, autocompleteItemProps, type AutocompleteItemEvents, type AutocompleteItemProps } from \"./types\"\n\nconst AutocompleteItemElementBase: BaseElementConstructor<AutocompleteItemProps> = defineCustomElement<\n AutocompleteItemProps,\n AutocompleteItemEvents\n>({\n props: autocompleteItemProps,\n events: autocompleteItemEvents,\n setup: useAutocompleteItem,\n})\nclass AutocompleteItemElement extends AutocompleteItemElementBase {}\n\nregisterCustomElement('prosekit-autocomplete-item', AutocompleteItemElement)\n \nexport { AutocompleteItemElement }\n","import {\n createSignal,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type SetupOptions,\n type TypedEventTarget,\n} from '@aria-ui/core'\nimport {\n listboxProps,\n useListbox,\n type ListboxProps,\n} from '@aria-ui/listbox/elements'\nimport {\n defineDOMEventHandler,\n Priority,\n withPriority,\n type Editor,\n} from '@prosekit/core'\n\nimport { getStateWithDefaults } from '../../../utils/get-default-state'\nimport {\n onSubmitContext,\n openContext,\n queryContext,\n} from '../context'\n\nimport type {\n AutocompleteListEvents,\n AutocompleteListProps,\n} from './types'\n\n/**\n * @internal\n */\nexport function useAutocompleteList(\n element: ConnectableElement,\n { state, emit }: SetupOptions<AutocompleteListProps, AutocompleteListEvents>,\n): void {\n const open = openContext.consume(element)\n const query = queryContext.consume(element)\n const onSubmit = onSubmitContext.consume(element)\n\n const keydownTarget = useKeyDownTarget(element, open, state.editor)\n\n const listboxState = getStateWithDefaults<ListboxProps>(\n { filter: state.filter, eventTarget: createSignal(keydownTarget) },\n listboxProps,\n )\n\n useEffect(element, () => {\n element.addEventListener('valueChange', () => {\n if (onSubmit) {\n onSubmit.get()?.()\n }\n })\n })\n\n useListbox(element, { state: listboxState, emit })\n\n useEffect(element, () => {\n listboxState.query.set(query.get())\n })\n\n useEffect(element, () => {\n if (!open.get()) {\n listboxState.value.set('')\n query.set('')\n }\n })\n\n // Reset the focused item when the popover is open\n useEffect(element, () => {\n if (!open.get()) {\n listboxState.autoFocus.set(false)\n } else {\n let canceled = false\n\n requestAnimationFrame(() => {\n if (canceled) return\n listboxState.autoFocus.set(true)\n })\n\n return () => {\n canceled = true\n }\n }\n })\n\n // The autocomplete list should not be focusable because the editor will get\n // the focus during typing.\n useEffect(element, () => {\n element.tabIndex = -1\n })\n}\n\nfunction useKeyDownTarget(\n element: ConnectableElement,\n open: ReadonlySignal<boolean>,\n editor: ReadonlySignal<Editor | null>,\n): TypedEventTarget<'keydown'> {\n const keydownHandlers: ((event: KeyboardEvent) => void)[] = []\n\n useEffect(element, () => {\n const editorValue = editor.get()\n\n if (!editorValue) {\n return\n }\n\n const extension = defineDOMEventHandler(\n 'keydown',\n (view, event): boolean => {\n if (view.composing || event.defaultPrevented || !open.get()) {\n return false\n }\n keydownHandlers.forEach((handler) => handler(event))\n return event.defaultPrevented\n },\n )\n\n return editorValue.use(withPriority(extension, Priority.highest))\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 {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n listboxEvents,\n listboxProps,\n type ListboxEvents,\n type ListboxProps,\n} from '@aria-ui/listbox'\nimport type { Editor } from '@prosekit/core'\n\nexport interface AutocompleteListProps extends Pick<ListboxProps, 'filter'> {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\nexport const autocompleteListProps: PropDeclarations<AutocompleteListProps> = {\n filter: listboxProps.filter,\n editor: { default: null },\n}\n\nexport interface AutocompleteListEvents extends ListboxEvents {}\n\nexport const autocompleteListEvents: EventDeclarations<AutocompleteListEvents> = { ...listboxEvents }\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useAutocompleteList } from \"./setup\"\nimport { autocompleteListEvents, autocompleteListProps, type AutocompleteListEvents, type AutocompleteListProps } from \"./types\"\n\nconst AutocompleteListElementBase: BaseElementConstructor<AutocompleteListProps> = defineCustomElement<\n AutocompleteListProps,\n AutocompleteListEvents\n>({\n props: autocompleteListProps,\n events: autocompleteListEvents,\n setup: useAutocompleteList,\n})\nclass AutocompleteListElement extends AutocompleteListElementBase {}\n\nregisterCustomElement('prosekit-autocomplete-list', AutocompleteListElement)\n \nexport { AutocompleteListElement }\n","import {\n createSignal,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n} from '@aria-ui/core'\n\nexport function useFirstRendering(\n host: ConnectableElement,\n): ReadonlySignal<boolean> {\n const firstRendering = createSignal(true)\n\n useEffect(host, () => {\n requestAnimationFrame(() => {\n firstRendering.set(false)\n })\n })\n\n return firstRendering\n}\n","export function defaultQueryBuilder(match: RegExpExecArray): string {\n return match[0]\n .toLowerCase()\n .replace(/[!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~]/g, '')\n .replace(/\\s\\s+/g, ' ')\n .trim()\n}\n","import {\n createComputed,\n createSignal,\n useAnimationFrame,\n useAttribute,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type SetupOptions,\n type Signal,\n} from '@aria-ui/core'\nimport { useOverlayPositionerState } from '@aria-ui/overlay/elements'\nimport { usePresence } from '@aria-ui/presence'\nimport {\n defineKeymap,\n Priority,\n withPriority,\n type Editor,\n} from '@prosekit/core'\nimport {\n AutocompleteRule,\n defineAutocomplete,\n type MatchHandler,\n} from '@prosekit/extensions/autocomplete'\n\nimport { useEditorExtension } from '../../../hooks/use-editor-extension'\nimport { useFirstRendering } from '../../../hooks/use-first-rendering'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport {\n onSubmitContext,\n openContext,\n queryContext,\n} from '../context'\n\nimport { defaultQueryBuilder } from './helpers'\nimport type {\n AutocompletePopoverEvents,\n AutocompletePopoverProps,\n} from './types'\n\n/**\n * @internal\n */\nexport function useAutocompletePopover(\n host: ConnectableElement,\n {\n state,\n emit,\n }: SetupOptions<AutocompletePopoverProps, AutocompletePopoverEvents>,\n): void {\n const { editor, regex, ...overlayState } = state\n\n const reference = createSignal<Element | null>(null)\n const query = createSignal<string>('')\n const onDismiss = createSignal<VoidFunction | null>(null)\n const onSubmit = createSignal<VoidFunction | null>(null)\n const presence = createComputed(() => !!reference.get())\n\n queryContext.provide(host, query)\n onSubmitContext.provide(host, onSubmit)\n openContext.provide(host, presence)\n\n useEscapeKeydown(host, editor, createKeymapHandler(onDismiss, presence))\n\n useAutocompleteExtension(\n host,\n editor,\n regex,\n reference,\n query,\n onDismiss,\n onSubmit,\n )\n\n useOverlayPositionerState(host, overlayState, { reference })\n\n useAttribute(host, 'data-state', () => (presence.get() ? 'open' : 'closed'))\n usePresence(host, presence)\n\n const firstRendering = useFirstRendering(host)\n\n useEffect(host, () => {\n const queryValue = query.get()\n\n if (!firstRendering.peek()) {\n emit('queryChange', queryValue)\n }\n })\n\n useAnimationFrame(host, () => {\n const presenceValue = presence.get()\n return () => {\n emit('openChange', presenceValue)\n }\n })\n}\n\nfunction useAutocompleteExtension(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n regex: ReadonlySignal<RegExp | null>,\n reference: Signal<Element | null>,\n query: Signal<string>,\n onDismiss: Signal<VoidFunction | null>,\n onSubmit: Signal<VoidFunction | null>,\n) {\n useEffect(host, () => {\n const editorValue = editor.get()\n const regexValue = regex.get()\n\n if (!editorValue || !regexValue) {\n return\n }\n\n const rule = createAutocompleteRule(\n editorValue,\n regexValue,\n reference,\n query,\n onDismiss,\n onSubmit,\n )\n const extension = defineAutocomplete(rule)\n return editorValue.use(extension)\n })\n}\n\nfunction createAutocompleteRule(\n editor: Editor,\n regex: RegExp,\n reference: Signal<Element | null>,\n query: Signal<string>,\n onDismiss: Signal<VoidFunction | null>,\n onSubmit: Signal<VoidFunction | null>,\n) {\n const handleEnter: MatchHandler = (options) => {\n const view = getSafeEditorView(editor)\n const span = view?.dom.querySelector('.prosemirror-prediction-match')\n\n if (span) {\n reference.set(span)\n }\n\n query.set(defaultQueryBuilder(options.match))\n onDismiss.set(options.ignoreMatch)\n onSubmit.set(options.deleteMatch)\n }\n\n const handleLeave = () => {\n reference.set(null)\n query.set('')\n }\n\n return new AutocompleteRule({\n regex,\n onEnter: handleEnter,\n onLeave: handleLeave,\n })\n}\n\nfunction createKeymapHandler(\n handler: ReadonlySignal<VoidFunction | null>,\n enabled: ReadonlySignal<boolean>,\n) {\n return (): boolean => {\n if (!enabled.get()) {\n return false\n }\n\n const fn = handler.peek()\n if (!fn) return false\n fn()\n return true\n }\n}\n\nfunction useEscapeKeydown(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: () => boolean,\n): void {\n const keymap = { Escape: handler }\n const extension = withPriority(defineKeymap(keymap), Priority.highest)\n useEditorExtension(host, editor, extension)\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n overlayPositionerEvents,\n overlayPositionerProps,\n type OverlayPositionerEvents,\n type OverlayPositionerProps,\n} from '@aria-ui/overlay/elements'\nimport type { Editor } from '@prosekit/core'\n\nexport interface AutocompletePopoverProps extends OverlayPositionerProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * The regular expression to match the query text to autocomplete.\n *\n * @default null\n */\n regex: RegExp | null\n\n /**\n * The placement of the popover, relative to the text cursor.\n *\n * @default \"bottom-start\"\n */\n placement: OverlayPositionerProps['placement']\n\n /**\n * The distance between the popover and the hovered block.\n *\n * @default 4\n */\n offset: OverlayPositionerProps['offset']\n\n /**\n * @default true\n */\n inline: OverlayPositionerProps['inline']\n\n /**\n * @default true\n */\n hoist: OverlayPositionerProps['hoist']\n\n /**\n * @default true\n */\n fitViewport: OverlayPositionerProps['fitViewport']\n\n /**\n * @default \"The body element\"\n */\n boundary: OverlayPositionerProps['boundary']\n\n /**\n * @default 8\n */\n overflowPadding: OverlayPositionerProps['overflowPadding']\n}\n\nconst body = typeof document !== 'undefined' && document.querySelector('body')\nconst defaultBoundary = body || 'clippingAncestors'\n\n/** @internal */\nexport const autocompletePopoverProps: PropDeclarations<AutocompletePopoverProps> = {\n ...overlayPositionerProps,\n editor: { default: null },\n regex: { default: null },\n placement: { default: 'bottom-start' },\n offset: { default: 4 },\n inline: { default: true },\n hoist: { default: true },\n fitViewport: { default: true },\n boundary: { default: defaultBoundary },\n overflowPadding: { default: 8 },\n}\n\nexport interface AutocompletePopoverEvents extends OverlayPositionerEvents {\n /**\n * Fired when the open state changes.\n */\n openChange: CustomEvent<boolean>\n\n /**\n * Fired when the query changes.\n */\n queryChange: CustomEvent<string>\n}\n\n/** @internal */\nexport const autocompletePopoverEvents: EventDeclarations<AutocompletePopoverEvents> = {\n ...overlayPositionerEvents,\n openChange: {},\n queryChange: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useAutocompletePopover } from \"./setup\"\nimport { autocompletePopoverEvents, autocompletePopoverProps, type AutocompletePopoverEvents, type AutocompletePopoverProps } from \"./types\"\n\nconst AutocompletePopoverElementBase: BaseElementConstructor<AutocompletePopoverProps> = defineCustomElement<\n AutocompletePopoverProps,\n AutocompletePopoverEvents\n>({\n props: autocompletePopoverProps,\n events: autocompletePopoverEvents,\n setup: useAutocompletePopover,\n})\nclass AutocompletePopoverElement extends AutocompletePopoverElementBase {}\n\nregisterCustomElement('prosekit-autocomplete-popover', AutocompletePopoverElement)\n \nexport { AutocompletePopoverElement }\n"],"mappings":";;;;;;;;;;;;;;;AAKA,MAAaA,uBAA+C;;;;;ACI5D,MAAaC,yBAAmE,EAAE;;AAMlF,MAAaC,0BAAsE,EAAE;;;;ACVrF,MAAMC,+BAA+E,oBAGnF;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,2BAAN,cAAuC,6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iB;CACtC,iBAAiB,EAAE,SAAS,GAAG;CAChC;;AAeD,MAAaC,4BAA0E;CACrF,GAAG;CACH,YAAY,EAAE;CACd,aAAa,EAAE;CAChB;;;;ACjGD,MAAMC,iCAAmF,oBAGvF;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,6BAAN,cAAyC,+BAA+B;AAExE,sBAAsB,iCAAiC,2BAA2B"}
1
+ {"version":3,"file":"prosekit-web-autocomplete.js","names":["useAutocompleteEmpty: typeof useListboxEmpty","autocompleteEmptyProps: PropDeclarations<AutocompleteEmptyProps>","autocompleteEmptyEvents: EventDeclarations<AutocompleteEmptyEvents>","AutocompleteEmptyElementBase: BaseElementConstructor<AutocompleteEmptyProps>","queryContext: Context<string>","onSubmitContext: Context<VoidFunction | null>","openContext: Context<boolean>","autocompleteItemProps: PropDeclarations<AutocompleteItemProps>","autocompleteItemEvents: EventDeclarations<AutocompleteItemEvents>","AutocompleteItemElementBase: BaseElementConstructor<AutocompleteItemProps>","keydownHandlers: ((event: KeyboardEvent) => void)[]","autocompleteListProps: PropDeclarations<AutocompleteListProps>","listboxProps","autocompleteListEvents: EventDeclarations<AutocompleteListEvents>","AutocompleteListElementBase: BaseElementConstructor<AutocompleteListProps>","handleEnter: MatchHandler","autocompletePopoverProps: PropDeclarations<AutocompletePopoverProps>","autocompletePopoverEvents: EventDeclarations<AutocompletePopoverEvents>","AutocompletePopoverElementBase: BaseElementConstructor<AutocompletePopoverProps>"],"sources":["../src/components/autocomplete/autocomplete-empty/setup.ts","../src/components/autocomplete/autocomplete-empty/types.ts","../src/components/autocomplete/autocomplete-empty/element.gen.ts","../src/components/autocomplete/context.ts","../src/components/autocomplete/autocomplete-item/setup.ts","../src/components/autocomplete/autocomplete-item/types.ts","../src/components/autocomplete/autocomplete-item/element.gen.ts","../src/components/autocomplete/autocomplete-list/setup.ts","../src/components/autocomplete/autocomplete-list/types.ts","../src/components/autocomplete/autocomplete-list/element.gen.ts","../src/hooks/use-first-rendering.ts","../src/components/autocomplete/autocomplete-popover/helpers.ts","../src/components/autocomplete/autocomplete-popover/setup.ts","../src/components/autocomplete/autocomplete-popover/types.ts","../src/components/autocomplete/autocomplete-popover/element.gen.ts"],"sourcesContent":["import { useListboxEmpty } from '@aria-ui/listbox/elements'\n\n/**\n * @internal\n */\nexport const useAutocompleteEmpty: typeof useListboxEmpty = useListboxEmpty\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\n\n/** @internal */\nexport interface AutocompleteEmptyProps {}\n\n/** @internal */\nexport const autocompleteEmptyProps: PropDeclarations<AutocompleteEmptyProps> = {}\n\n/** @internal */\nexport interface AutocompleteEmptyEvents {}\n\n/** @internal */\nexport const autocompleteEmptyEvents: EventDeclarations<AutocompleteEmptyEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useAutocompleteEmpty } from \"./setup\"\nimport { autocompleteEmptyEvents, autocompleteEmptyProps, type AutocompleteEmptyEvents, type AutocompleteEmptyProps } from \"./types\"\n\nconst AutocompleteEmptyElementBase: BaseElementConstructor<AutocompleteEmptyProps> = defineCustomElement<\n AutocompleteEmptyProps,\n AutocompleteEmptyEvents\n>({\n props: autocompleteEmptyProps,\n events: autocompleteEmptyEvents,\n setup: useAutocompleteEmpty,\n})\nclass AutocompleteEmptyElement extends AutocompleteEmptyElementBase {}\n\nregisterCustomElement('prosekit-autocomplete-empty', AutocompleteEmptyElement)\n \nexport { AutocompleteEmptyElement }\n","import {\n createContext,\n type Context,\n} from '@aria-ui/core'\n\nexport const queryContext: Context<string> = createContext(\n 'prosekit/autocomplete-popover/query',\n '',\n)\n\nexport const onSubmitContext: Context<VoidFunction | null> = createContext(\n 'prosekit/autocomplete-popover/onSubmit',\n null,\n)\n\nexport const openContext: Context<boolean> = createContext(\n 'prosekit/autocomplete-popover/open',\n false,\n)\n","import {\n useEffect,\n useEventListener,\n type ConnectableElement,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { useListboxItem } from '@aria-ui/listbox/elements'\n\nimport { openContext } from '../context'\n\nimport type {\n AutocompleteItemEvents,\n AutocompleteItemProps,\n} from './types'\n\n/**\n * @internal\n */\nexport function useAutocompleteItem(\n element: ConnectableElement,\n { state, emit }: SetupOptions<AutocompleteItemProps, AutocompleteItemEvents>,\n): void {\n useListboxItem(element, { state, emit })\n\n const open = openContext.consume(element)\n\n useEffect(element, () => {\n // Check the text content again when the open state changes\n if (!state.value.peek() && open.get()) {\n state.value.set(element.textContent ?? '')\n }\n })\n\n useEventListener(element, 'pointerdown', (event) => {\n // Prevent the editor from losing focus\n event.preventDefault()\n })\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n listboxItemEvents,\n type ListboxItemEvents,\n} from '@aria-ui/listbox'\n\nexport interface AutocompleteItemProps {\n /**\n * The value of the item, which will be matched against the query.\n *\n * If not provided, the value is the item's text content.\n *\n * @default \"\"\n */\n value: string\n}\n\n/** @internal */\nexport const autocompleteItemProps: PropDeclarations<AutocompleteItemProps> = {\n value: {\n default: '',\n },\n}\n\nexport interface AutocompleteItemEvents extends ListboxItemEvents {}\n\n/** @internal */\nexport const autocompleteItemEvents: EventDeclarations<AutocompleteItemEvents> = listboxItemEvents\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useAutocompleteItem } from \"./setup\"\nimport { autocompleteItemEvents, autocompleteItemProps, type AutocompleteItemEvents, type AutocompleteItemProps } from \"./types\"\n\nconst AutocompleteItemElementBase: BaseElementConstructor<AutocompleteItemProps> = defineCustomElement<\n AutocompleteItemProps,\n AutocompleteItemEvents\n>({\n props: autocompleteItemProps,\n events: autocompleteItemEvents,\n setup: useAutocompleteItem,\n})\nclass AutocompleteItemElement extends AutocompleteItemElementBase {}\n\nregisterCustomElement('prosekit-autocomplete-item', AutocompleteItemElement)\n \nexport { AutocompleteItemElement }\n","import {\n createSignal,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type SetupOptions,\n type TypedEventTarget,\n} from '@aria-ui/core'\nimport {\n listboxProps,\n useListbox,\n type ListboxProps,\n} from '@aria-ui/listbox/elements'\nimport {\n defineDOMEventHandler,\n Priority,\n withPriority,\n type Editor,\n} from '@prosekit/core'\n\nimport { getStateWithDefaults } from '../../../utils/get-default-state'\nimport {\n onSubmitContext,\n openContext,\n queryContext,\n} from '../context'\n\nimport type {\n AutocompleteListEvents,\n AutocompleteListProps,\n} from './types'\n\n/**\n * @internal\n */\nexport function useAutocompleteList(\n element: ConnectableElement,\n { state, emit }: SetupOptions<AutocompleteListProps, AutocompleteListEvents>,\n): void {\n const open = openContext.consume(element)\n const query = queryContext.consume(element)\n const onSubmit = onSubmitContext.consume(element)\n\n const keydownTarget = useKeyDownTarget(element, open, state.editor)\n\n const listboxState = getStateWithDefaults<ListboxProps>(\n { filter: state.filter, eventTarget: createSignal(keydownTarget) },\n listboxProps,\n )\n\n useEffect(element, () => {\n element.addEventListener('valueChange', () => {\n if (onSubmit) {\n onSubmit.get()?.()\n }\n })\n })\n\n useListbox(element, { state: listboxState, emit })\n\n useEffect(element, () => {\n listboxState.query.set(query.get())\n })\n\n useEffect(element, () => {\n if (!open.get()) {\n listboxState.value.set('')\n query.set('')\n }\n })\n\n // Reset the focused item when the popover is open\n useEffect(element, () => {\n if (!open.get()) {\n listboxState.autoFocus.set(false)\n } else {\n let canceled = false\n\n requestAnimationFrame(() => {\n if (canceled) return\n listboxState.autoFocus.set(true)\n })\n\n return () => {\n canceled = true\n }\n }\n })\n\n // The autocomplete list should not be focusable because the editor will get\n // the focus during typing.\n useEffect(element, () => {\n element.tabIndex = -1\n })\n}\n\nfunction useKeyDownTarget(\n element: ConnectableElement,\n open: ReadonlySignal<boolean>,\n editor: ReadonlySignal<Editor | null>,\n): TypedEventTarget<'keydown'> {\n const keydownHandlers: ((event: KeyboardEvent) => void)[] = []\n\n useEffect(element, () => {\n const editorValue = editor.get()\n\n if (!editorValue) {\n return\n }\n\n const extension = defineDOMEventHandler(\n 'keydown',\n (view, event): boolean => {\n if (view.composing || event.defaultPrevented || !open.get()) {\n return false\n }\n keydownHandlers.forEach((handler) => handler(event))\n return event.defaultPrevented\n },\n )\n\n return editorValue.use(withPriority(extension, Priority.highest))\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 {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n listboxEvents,\n listboxProps,\n type ListboxEvents,\n type ListboxProps,\n} from '@aria-ui/listbox'\nimport type { Editor } from '@prosekit/core'\n\nexport interface AutocompleteListProps extends Pick<ListboxProps, 'filter'> {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\nexport const autocompleteListProps: PropDeclarations<AutocompleteListProps> = {\n filter: listboxProps.filter,\n editor: { default: null },\n}\n\nexport interface AutocompleteListEvents extends ListboxEvents {}\n\nexport const autocompleteListEvents: EventDeclarations<AutocompleteListEvents> = { ...listboxEvents }\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useAutocompleteList } from \"./setup\"\nimport { autocompleteListEvents, autocompleteListProps, type AutocompleteListEvents, type AutocompleteListProps } from \"./types\"\n\nconst AutocompleteListElementBase: BaseElementConstructor<AutocompleteListProps> = defineCustomElement<\n AutocompleteListProps,\n AutocompleteListEvents\n>({\n props: autocompleteListProps,\n events: autocompleteListEvents,\n setup: useAutocompleteList,\n})\nclass AutocompleteListElement extends AutocompleteListElementBase {}\n\nregisterCustomElement('prosekit-autocomplete-list', AutocompleteListElement)\n \nexport { AutocompleteListElement }\n","import {\n createSignal,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n} from '@aria-ui/core'\n\nexport function useFirstRendering(\n host: ConnectableElement,\n): ReadonlySignal<boolean> {\n const firstRendering = createSignal(true)\n\n useEffect(host, () => {\n requestAnimationFrame(() => {\n firstRendering.set(false)\n })\n })\n\n return firstRendering\n}\n","export function defaultQueryBuilder(match: RegExpExecArray): string {\n return match[0]\n .toLowerCase()\n .replace(/[!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~]/g, '')\n .replace(/\\s\\s+/g, ' ')\n .trim()\n}\n","import {\n createComputed,\n createSignal,\n useAnimationFrame,\n useAttribute,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type SetupOptions,\n type Signal,\n} from '@aria-ui/core'\nimport { useOverlayPositionerState } from '@aria-ui/overlay/elements'\nimport { usePresence } from '@aria-ui/presence'\nimport {\n defineKeymap,\n Priority,\n withPriority,\n type Editor,\n} from '@prosekit/core'\nimport {\n AutocompleteRule,\n defineAutocomplete,\n type MatchHandler,\n} from '@prosekit/extensions/autocomplete'\n\nimport { useEditorExtension } from '../../../hooks/use-editor-extension'\nimport { useFirstRendering } from '../../../hooks/use-first-rendering'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport {\n onSubmitContext,\n openContext,\n queryContext,\n} from '../context'\n\nimport { defaultQueryBuilder } from './helpers'\nimport type {\n AutocompletePopoverEvents,\n AutocompletePopoverProps,\n} from './types'\n\n/**\n * @internal\n */\nexport function useAutocompletePopover(\n host: ConnectableElement,\n {\n state,\n emit,\n }: SetupOptions<AutocompletePopoverProps, AutocompletePopoverEvents>,\n): void {\n const { editor, regex, ...overlayState } = state\n\n const reference = createSignal<Element | null>(null)\n const query = createSignal<string>('')\n const onDismiss = createSignal<VoidFunction | null>(null)\n const onSubmit = createSignal<VoidFunction | null>(null)\n const presence = createComputed(() => !!reference.get())\n\n queryContext.provide(host, query)\n onSubmitContext.provide(host, onSubmit)\n openContext.provide(host, presence)\n\n useEscapeKeydown(host, editor, createKeymapHandler(onDismiss, presence))\n\n useAutocompleteExtension(\n host,\n editor,\n regex,\n reference,\n query,\n onDismiss,\n onSubmit,\n )\n\n useOverlayPositionerState(host, overlayState, { reference })\n\n useAttribute(host, 'data-state', () => (presence.get() ? 'open' : 'closed'))\n usePresence(host, presence)\n\n const firstRendering = useFirstRendering(host)\n\n useEffect(host, () => {\n const queryValue = query.get()\n\n if (!firstRendering.peek()) {\n emit('queryChange', queryValue)\n }\n })\n\n useAnimationFrame(host, () => {\n const presenceValue = presence.get()\n return () => {\n emit('openChange', presenceValue)\n }\n })\n}\n\nfunction useAutocompleteExtension(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n regex: ReadonlySignal<RegExp | null>,\n reference: Signal<Element | null>,\n query: Signal<string>,\n onDismiss: Signal<VoidFunction | null>,\n onSubmit: Signal<VoidFunction | null>,\n) {\n useEffect(host, () => {\n const editorValue = editor.get()\n const regexValue = regex.get()\n\n if (!editorValue || !regexValue) {\n return\n }\n\n const rule = createAutocompleteRule(\n editorValue,\n regexValue,\n reference,\n query,\n onDismiss,\n onSubmit,\n )\n const extension = defineAutocomplete(rule)\n return editorValue.use(extension)\n })\n}\n\nfunction createAutocompleteRule(\n editor: Editor,\n regex: RegExp,\n reference: Signal<Element | null>,\n query: Signal<string>,\n onDismiss: Signal<VoidFunction | null>,\n onSubmit: Signal<VoidFunction | null>,\n) {\n const handleEnter: MatchHandler = (options) => {\n const view = getSafeEditorView(editor)\n const span = view?.dom.querySelector('.prosekit-autocomplete-match')\n\n if (span) {\n reference.set(span)\n }\n\n query.set(defaultQueryBuilder(options.match))\n onDismiss.set(options.ignoreMatch)\n onSubmit.set(options.deleteMatch)\n }\n\n const handleLeave = () => {\n reference.set(null)\n query.set('')\n }\n\n return new AutocompleteRule({\n regex,\n onEnter: handleEnter,\n onLeave: handleLeave,\n })\n}\n\nfunction createKeymapHandler(\n handler: ReadonlySignal<VoidFunction | null>,\n enabled: ReadonlySignal<boolean>,\n) {\n return (): boolean => {\n if (!enabled.get()) {\n return false\n }\n\n const fn = handler.peek()\n if (!fn) return false\n fn()\n return true\n }\n}\n\nfunction useEscapeKeydown(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: () => boolean,\n): void {\n const keymap = { Escape: handler }\n const extension = withPriority(defineKeymap(keymap), Priority.highest)\n useEditorExtension(host, editor, extension)\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n overlayPositionerEvents,\n overlayPositionerProps,\n type OverlayPositionerEvents,\n type OverlayPositionerProps,\n} from '@aria-ui/overlay/elements'\nimport type { Editor } from '@prosekit/core'\n\nexport interface AutocompletePopoverProps extends OverlayPositionerProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * The regular expression to match the query text to autocomplete.\n *\n * @default null\n */\n regex: RegExp | null\n\n /**\n * The placement of the popover, relative to the text cursor.\n *\n * @default \"bottom-start\"\n */\n placement: OverlayPositionerProps['placement']\n\n /**\n * The distance between the popover and the hovered block.\n *\n * @default 4\n */\n offset: OverlayPositionerProps['offset']\n\n /**\n * @default true\n */\n inline: OverlayPositionerProps['inline']\n\n /**\n * @default true\n */\n hoist: OverlayPositionerProps['hoist']\n\n /**\n * @default true\n */\n fitViewport: OverlayPositionerProps['fitViewport']\n\n /**\n * @default \"The body element\"\n */\n boundary: OverlayPositionerProps['boundary']\n\n /**\n * @default 8\n */\n overflowPadding: OverlayPositionerProps['overflowPadding']\n}\n\nconst body = typeof document !== 'undefined' && document.querySelector('body')\nconst defaultBoundary = body || 'clippingAncestors'\n\n/** @internal */\nexport const autocompletePopoverProps: PropDeclarations<AutocompletePopoverProps> = {\n ...overlayPositionerProps,\n editor: { default: null },\n regex: { default: null },\n placement: { default: 'bottom-start' },\n offset: { default: 4 },\n inline: { default: true },\n hoist: { default: true },\n fitViewport: { default: true },\n boundary: { default: defaultBoundary },\n overflowPadding: { default: 8 },\n}\n\nexport interface AutocompletePopoverEvents extends OverlayPositionerEvents {\n /**\n * Fired when the open state changes.\n */\n openChange: CustomEvent<boolean>\n\n /**\n * Fired when the query changes.\n */\n queryChange: CustomEvent<string>\n}\n\n/** @internal */\nexport const autocompletePopoverEvents: EventDeclarations<AutocompletePopoverEvents> = {\n ...overlayPositionerEvents,\n openChange: {},\n queryChange: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useAutocompletePopover } from \"./setup\"\nimport { autocompletePopoverEvents, autocompletePopoverProps, type AutocompletePopoverEvents, type AutocompletePopoverProps } from \"./types\"\n\nconst AutocompletePopoverElementBase: BaseElementConstructor<AutocompletePopoverProps> = defineCustomElement<\n AutocompletePopoverProps,\n AutocompletePopoverEvents\n>({\n props: autocompletePopoverProps,\n events: autocompletePopoverEvents,\n setup: useAutocompletePopover,\n})\nclass AutocompletePopoverElement extends AutocompletePopoverElementBase {}\n\nregisterCustomElement('prosekit-autocomplete-popover', AutocompletePopoverElement)\n \nexport { AutocompletePopoverElement }\n"],"mappings":";;;;;;;;;;;;;;;AAKA,MAAaA,uBAA+C;;;;;ACI5D,MAAaC,yBAAmE,EAAE;;AAMlF,MAAaC,0BAAsE,EAAE;;;;ACVrF,MAAMC,+BAA+E,oBAGnF;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,2BAAN,cAAuC,6BAA6B;AAEpE,sBAAsB,+BAA+B,yBAAyB;;;;ACV9E,MAAaC,eAAgC,cAC3C,uCACA,GACD;AAED,MAAaC,kBAAgD,cAC3D,0CACA,KACD;AAED,MAAaC,cAAgC,cAC3C,sCACA,MACD;;;;;;;ACAD,SAAgB,oBACd,SACA,EAAE,OAAO,QACH;AACN,gBAAe,SAAS;EAAE;EAAO;EAAM,CAAC;CAExC,MAAM,OAAO,YAAY,QAAQ,QAAQ;AAEzC,WAAU,eAAe;AAEvB,MAAI,CAAC,MAAM,MAAM,MAAM,IAAI,KAAK,KAAK,CACnC,OAAM,MAAM,IAAI,QAAQ,e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YAAU,IAAI,QAAQ,YAAY;AAClC,WAAS,IAAI,QAAQ,YAAY;;CAGnC,MAAM,oBAAoB;AACxB,YAAU,IAAI,KAAK;AACnB,QAAM,IAAI,GAAG;;AAGf,QAAO,IAAI,iBAAiB;EAC1B;EACA,SAAS;EACT,SAAS;EACV,CAAC;;AAGJ,SAAS,oBACP,SACA,SACA;AACA,cAAsB;AACpB,MAAI,CAAC,QAAQ,KAAK,CAChB,QAAO;EAGT,MAAM,KAAK,QAAQ,MAAM;AACzB,MAAI,CAAC,GAAI,QAAO;AAChB,MAAI;AACJ,SAAO;;;AAIX,SAAS,iBACP,MACA,QACA,SACM;AAGN,oBAAmB,MAAM,QADP,aAAa,aADhB,EAAE,QAAQ,SAAS,CACiB,EAAE,SAAS,QAAQ,CAC3B;;;;;AClH7C,MAAM,kBADO,OAAO,aAAa,eAAe,SAAS,cAAc,OAAO,IAC9C;;AAGhC,MAAaC,2BAAuE;CAClF,GAAG;CACH,QAAQ,EAAE,SAAS,MAAM;CACzB,OAAO,EAAE,SAAS,MAAM;CACxB,WAAW,EAAE,SAAS,gBAAgB;CACtC,QAAQ,EAAE,SAAS,GAAG;CACtB,QAAQ,EAAE,SAAS,MAAM;CACzB,OAAO,EAAE,SAAS,MAAM;CACxB,aAAa,EAAE,SAAS,MAAM;CAC9B,UAAU,EAAE,SAAS,iBAAiB;CACtC,iBAAiB,EAAE,SAAS,GAAG;CAChC;;AAeD,MAAaC,4BAA0E;CACrF,GAAG;CACH,YAAY,EAAE;CACd,aAAa,EAAE;CAChB;;;;ACjGD,MAAMC,iCAAmF,oBAGvF;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,6BAAN,cAAyC,+BAA+B;AAExE,sBAAsB,iCAAiC,2BAA2B"}
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-web-block-handle.d.ts","names":[],"sources":["../src/components/block-handle/block-handle-add/types.ts","../src/components/block-handle/block-handle-add/element.gen.ts","../src/components/block-handle/block-handle-add/setup.ts","../src/components/block-handle/block-handle-draggable/types.ts","../src/components/block-handle/block-handle-draggable/element.gen.ts","../src/components/block-handle/block-handle-draggable/setup.ts","../src/components/block-handle/block-handle-popover/types.ts","../src/components/block-handle/block-handle-popover/element.gen.ts","../src/components/block-handle/block-handle-popover/setup.ts"],"sourcesContent":[],"mappings":";;;;;;;UAMiB,mBAAA;;;;;AAAjB;AAWA;EAKiB,MAAA,EATP,MASO,GAAA,IAAA;AAGjB;;cARa,qBAAqB,iBAAiB;;ACZ7C,UDiBW,oBAAA,CCVf,CAPqD;;cDoB1C,sBAAsB,kBAAkB;;;cCpB/C,2BAA2B,uBAAuB;cAQlD,qBAAA,SAA8B,yBAAA;;;;;;iBCCpB,iBAAA,OACR;;AFTR;SEUsB,YAAY;AFVlC,CAAA,CAAA,EAAiB,IAAA;;;UGAA,yBAAA;;;;;AHAjB;AAWA;EAKiB,MAAA,EGTP,MHSO,GAAA,IAAA;AAGjB;;cGRa,2BAA2B,iBAAiB;;AFZnD,UEiBW,0BAAA,CFVf,CAPqD;;cEoB1C,4BAA4B,kBAAkB;;;cCpBrD,iCAAiC,uBAAuB;cAQxD,2BAAA,SAAoC,+BAAA;;;;;;iBCoB1B,uBAAA,OACR;;AL5BR;SK6BsB,YAAY;AL7BlC,CAAA,CAAA,EAAiB,IAAA;;;UMQA,uBAAA,SAAgC,KAAK;;ANRtD;AAWA;AAKA;AAGA;;UMJU;;ALlB8G;AAEjE;;;aKuB1C;EJdG;;;;;;;;;ACRhB;AAWA;EAKiB,IAAA,EAAA,OAAA;EAGJ;;;;ECpBP,KAAA,EAAA,OAAA;EAQA;;;;ECoBU,IAAA,EAAA,OAAA;;;AAEkB,cCuBrB,uBDvBqB,ECuBI,gBDvBJ,CCuBqB,uBDvBrB,CAAA;AAAZ,UCqCL,wBAAA,SAAiC,uBDrC5B,CAAA;EAAW;;;eCyClB;IA9DE,IAAA,EA8DkB,eA9DlB;IAAqC,GAAA,EAAA,MAAA;EAO5C,CAAA,GAAA,IAAA,CAAA;;;AAP2C,cAkExC,wBAlEwC,EAkEd,iBAlEc,CAkEI,wBAlEJ,CAAA;;;cCT/C,+BAA+B,uBAAuB;cAQtD,yBAAA,SAAkC,6BAAA;;;;;;iBCqBxB,qBAAA,OACR;;;GACW,aAAa,yBAAyB"}
1
+ {"version":3,"file":"prosekit-web-block-handle.d.ts","names":[],"sources":["../src/components/block-handle/block-handle-add/types.ts","../src/components/block-handle/block-handle-add/element.gen.ts","../src/components/block-handle/block-handle-add/setup.ts","../src/components/block-handle/block-handle-draggable/types.ts","../src/components/block-handle/block-handle-draggable/element.gen.ts","../src/components/block-handle/block-handle-draggable/setup.ts","../src/components/block-handle/block-handle-popover/types.ts","../src/components/block-handle/block-handle-popover/element.gen.ts","../src/components/block-handle/block-handle-popover/setup.ts"],"sourcesContent":[],"mappings":";;;;;;;UAMiB,mBAAA;;;;;AAAjB;AAWA;EAKiB,MAAA,EATP,MASO,GAAA,IAAA;AAGjB;;cARa,qBAAqB,iBAAiB;;ACZ7C,UDiBW,oBAAA,CCVf,CAPqD;;cDoB1C,sBAAsB,kBAAkB;;;cCpB/C,2BAA2B,uBAAuB;cAQlD,qBAAA,SAA8B,yBAAA;;;;;;iBCCpB,iBAAA,OACR;;AFTR;SEUsB,YAAY;AFVlC,CAAA,CAAA,EAAiB,IAAA;;;UGAA,yBAAA;;;;;AHAjB;AAWA;EAKiB,MAAA,EGTP,MHSO,GAAA,IAAA;AAGjB;;cGRa,2BAA2B,iBAAiB;;AFZnD,UEiBW,0BAAA,CFjBuC,CAAD;;cEoB1C,4BAA4B,kBAAkB;;;cCpBrD,iCAAiC,uBAAuB;cAQxD,2BAAA,SAAoC,+BAAA;;;;;;iBCoB1B,uBAAA,OACR;;AL5BR;SK6BsB,YAAY;AL7BlC,CAAA,CAAA,EAAiB,IAAA;;;UMQA,uBAAA,SAAgC,KAAK;;ANRtD;AAWA;AAKA;AAGA;;UMJU;;ALlB8G;AAEjE;;;aKuB1C;EJdG;;;;;;;;;ACRhB;AAWA;EAKiB,IAAA,EAAA,OAAA;EAGJ;;;;ECpBP,KAAA,EAAA,OAAA;EAQA;;;;ECoBU,IAAA,EAAA,OAAA;;;AAEkB,cCuBrB,uBDvBqB,ECuBI,gBDvBJ,CCuBqB,uBDvBrB,CAAA;AAAZ,UCqCL,wBAAA,SAAiC,uBDrC5B,CAAA;EAAW;;;eCyClB;IA9DE,IAAA,EA8DkB,eA9DlB;IAAqC,GAAA,EAAA,MAAA;EAO5C,CAAA,GAAA,IAAA,CAAA;;;AAP2C,cAkExC,wBAlEwC,EAkEd,iBAlEc,CAkEI,wBAlEJ,CAAA;;;cCT/C,+BAA+B,uBAAuB;cAQtD,yBAAA,SAAkC,6BAAA;;;;;;iBCqBxB,qBAAA,OACR;;;GACW,aAAa,yBAAyB"}
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-web-inline-popover.d.ts","names":[],"sources":["../src/components/inline-popover/inline-popover/types.ts","../src/components/inline-popover/inline-popover/element.gen.ts","../src/components/inline-popover/inline-popover/setup.ts"],"sourcesContent":[],"mappings":";;;;;UAYiB,kBAAA,SACf,KACE;;AAFJ;;;;;EAyDQ,MAAA,EA7CE,MA6CF,GAAA,IAAA;EAKG;;;;;AAcX;AAeA;AAQA;;;;EC1GM;AAAgD;;;;ACsBtD;;;EAEW,IAAA,EAAA,OAAA;EAAqB;;;;;;;;;;aF8BnB;;;;UAKH;;;;QAKF;;;;WAKG;;;;UAKD;;;;mBAKS;;;cAIN,oBAAoB,iBAAiB;UAejC,mBAAA,SAA4B;;;;cAI/B;;;cAID,qBAAqB,kBAAkB;;;cC1G9C,0BAA0B,uBAAuB;cAQjD,oBAAA,SAA6B,wBAAA;;;;;;ADDlB,iBEeD,gBAAA,CFfoB,IAAA,EEgB5B,kBFhB4B,EAAA;EAAA,KAAA;EAAA;AAAA,CAAA,EEiBjB,YFjBiB,CEiBJ,kBFjBI,EEiBgB,mBFjBhB,CAAA,CAAA,EAAA,IAAA"}
1
+ {"version":3,"file":"prosekit-web-inline-popover.d.ts","names":[],"sources":["../src/components/inline-popover/inline-popover/types.ts","../src/components/inline-popover/inline-popover/element.gen.ts","../src/components/inline-popover/inline-popover/setup.ts"],"sourcesContent":[],"mappings":";;;;;UAYiB,kBAAA,SACf,KACE;;AAFJ;;;;;EAyDQ,MAAA,EA7CE,MA6CF,GAAA,IAAA;EAKG;;;;;AAcX;AAeA;AAQA;;;;EC1GM;AAAgD;;;;ACuBtD;;;EAEW,IAAA,EAAA,OAAA;EAAqB;;;;;;;;;;aF6BnB;;;;UAKH;;;;QAKF;;;;WAKG;;;;UAKD;;;;mBAKS;;;cAIN,oBAAoB,iBAAiB;UAejC,mBAAA,SAA4B;;;;cAI/B;;;cAID,qBAAqB,kBAAkB;;;cC1G9C,0BAA0B,uBAAuB;cAQjD,oBAAA,SAA6B,wBAAA;;;;;;ADDlB,iBEgBD,gBAAA,CFhBoB,IAAA,EEiB5B,kBFjB4B,EAAA;EAAA,KAAA;EAAA;AAAA,CAAA,EEkBjB,YFlBiB,CEkBJ,kBFlBI,EEkBgB,mBFlBhB,CAAA,CAAA,EAAA,IAAA"}
@@ -99,8 +99,13 @@ function useInlinePopoverReference(host, editor) {
99
99
  useEditorFocusChangeEvent(host, editor, (focus) => {
100
100
  editorFocused = focus;
101
101
  });
102
+ let prevSelection;
102
103
  useEditorUpdateEvent(host, editor, (view) => {
103
104
  if (!editorFocused && host.contains(host.ownerDocument.activeElement)) return;
105
+ const { selection } = view.state;
106
+ const selectionUnchanged = prevSelection?.eq(selection);
107
+ prevSelection = selection;
108
+ if (selectionUnchanged) return;
104
109
  reference.set(getVirtualSelectionElement(view) || null);
105
110
  });
106
111
  return reference;
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-web-inline-popover.js","names":["inlinePopoverProps: PropDeclarations<InlinePopoverProps>","overlayPositionerProps","inlinePopoverEvents: EventDeclarations<InlinePopoverEvents>","overlayPositionerEvents","InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps>"],"sources":["../src/hooks/use-editor-focus-event.ts","../src/hooks/use-editor-update-event.ts","../src/hooks/use-keymap.ts","../src/components/inline-popover/inline-popover/virtual-selection-element.ts","../src/components/inline-popover/inline-popover/setup.ts","../src/components/inline-popover/inline-popover/types.ts","../src/components/inline-popover/inline-popover/element.gen.ts"],"sourcesContent":["import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineFocusChangeHandler,\n type Editor,\n type FocusChangeHandler,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\n/**\n * @internal\n */\nexport function useEditorFocusChangeEvent(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: FocusChangeHandler,\n): void {\n const extension = defineFocusChangeHandler(handler)\n useEditorExtension(host, editor, extension)\n}\n","import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineUpdateHandler,\n type Editor,\n type UpdateHandler,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\n/**\n * @internal\n */\nexport function useEditorUpdateEvent(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: UpdateHandler,\n): void {\n const extension = defineUpdateHandler(handler)\n useEditorExtension(host, editor, extension)\n}\n","import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineKeymap,\n type Editor,\n type Keymap,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\nexport function useKeymap(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n keymap: Keymap,\n): void {\n const extension = defineKeymap(keymap)\n useEditorExtension(host, editor, extension)\n}\n","import type { ReferenceElement } from '@floating-ui/dom'\nimport {\n containsInlineNode,\n isInCodeBlock,\n isTextSelection,\n} from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nexport function getVirtualSelectionElement(\n view: EditorView,\n): ReferenceElement | undefined {\n if (typeof window === 'undefined' || view.isDestroyed) {\n return\n }\n\n const selection = view.state.selection\n\n if (\n !selection.empty\n && !isInCodeBlock(selection)\n && isTextSelection(selection)\n && containsInlineNode(view.state.doc, selection.from, selection.to)\n ) {\n return getDomDecoration(view) || getInlineDecoration(view)\n }\n}\n\nfunction getDomDecoration(view: EditorView): ReferenceElement | undefined {\n const range = getDomRange(view)\n if (range) {\n // To get it work properly in Safari, we cannot return the range directly.\n // We have to return a contextElement.\n return {\n contextElement: view.dom,\n getBoundingClientRect: () => range.getBoundingClientRect(),\n getClientRects: () => range.getClientRects(),\n }\n }\n}\n\nfunction getDomRange(view: EditorView): Range | undefined {\n const win = view.dom.ownerDocument.defaultView\n const selection = win?.getSelection()\n if (!selection || selection.isCollapsed) {\n return\n }\n\n const range = typeof selection.rangeCount === 'number'\n && selection.rangeCount > 0\n && selection.getRangeAt(0)\n\n if (!range) {\n return\n }\n\n return range\n}\n\nfunction getInlineDecoration(view: EditorView): ReferenceElement | undefined {\n const match = view.dom.querySelectorAll('.prosekit-virtual-selection')\n\n if (match.length === 0) {\n return\n }\n if (match.length === 1) {\n return match[0]\n }\n\n const items = Array.from(match)\n return {\n contextElement: items[0],\n getBoundingClientRect: () => items[0].getBoundingClientRect(),\n getClientRects: () => items.map((item) => item.getBoundingClientRect()),\n }\n}\n","import {\n createComputed,\n createSignal,\n useAttribute,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { useOverlayPositionerState } from '@aria-ui/overlay/elements'\nimport { usePresence } from '@aria-ui/presence'\nimport type { ReferenceElement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nimport { useEditorFocusChangeEvent } from '../../../hooks/use-editor-focus-event'\nimport { useEditorUpdateEvent } from '../../../hooks/use-editor-update-event'\nimport { useKeymap } from '../../../hooks/use-keymap'\n\nimport type {\n InlinePopoverEvents,\n InlinePopoverProps,\n} from './types'\nimport { getVirtualSelectionElement } from './virtual-selection-element'\n\n/**\n * @internal\n */\nexport function useInlinePopover(\n host: ConnectableElement,\n { state, emit }: SetupOptions<InlinePopoverProps, InlinePopoverEvents>,\n): void {\n const { editor, defaultOpen, open, ...overlayState } = state\n\n const reference = useInlinePopoverReference(host, editor)\n const hasReference = createComputed(() => !!reference.get())\n\n useEffect(host, () => {\n const hasReferenceValue = hasReference.get()\n const defaultOpenValue = defaultOpen.peek()\n const openValue = open.peek()\n\n if (defaultOpenValue || openValue) {\n emit('openChange', hasReferenceValue)\n }\n })\n\n useEffect(host, () => {\n const hasReferenceValue = hasReference.get()\n const defaultOpenValue = defaultOpen.peek()\n\n if (hasReferenceValue && defaultOpenValue) {\n open.set(true)\n } else if (!hasReferenceValue) {\n open.set(false)\n }\n })\n\n useKeymap(host, editor, {\n Escape: () => {\n if (!state.dismissOnEscape.peek() || !open.peek()) {\n return false\n }\n open.set(false)\n emit('openChange', false)\n return true\n },\n })\n\n useOverlayPositionerState(host, overlayState, { reference })\n\n useAttribute(host, 'data-state', () => (open.get() ? 'open' : 'closed'))\n usePresence(host, open)\n}\n\nfunction useInlinePopoverReference(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n) {\n const reference = createSignal<ReferenceElement | null>(null)\n let editorFocused = false\n\n useEditorFocusChangeEvent(host, editor, (focus) => {\n editorFocused = focus\n })\n\n useEditorUpdateEvent(host, editor, (view) => {\n const isPopoverFocused = !editorFocused && host.contains(host.ownerDocument.activeElement)\n\n if (isPopoverFocused) {\n return\n }\n\n reference.set(getVirtualSelectionElement(view) || null)\n })\n\n return reference\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n overlayPositionerEvents,\n overlayPositionerProps,\n type OverlayPositionerEvents,\n type OverlayPositionerProps,\n} from '@aria-ui/overlay'\nimport type { Editor } from '@prosekit/core'\n\nexport interface InlinePopoverProps extends\n Omit<\n OverlayPositionerProps,\n 'placement' | 'offset' | 'hide' | 'overlap' | 'inline' | 'overflowPadding'\n >\n{\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * Whether the popover is open by default when some inline content is\n * selected.\n *\n * When `defaultOpen` is true, the popover will open or close based on the\n * inline selection. When `defaultOpen` is false, the popover will never be\n * opened unless the `open` prop is true.\n *\n * @default true\n */\n defaultOpen: boolean\n\n /**\n * Whether the popover is open.\n *\n * Notice that the popover will be always hidden if the inline selection is\n * empty.\n *\n * @default false\n */\n open: boolean\n\n /**\n * Whether the inline popover should be dismissed when the editor receives an\n * Escape key press.\n *\n * @default true\n */\n dismissOnEscape: boolean\n\n /**\n * @default \"top\"\n */\n placement: OverlayPositionerProps['placement']\n\n /**\n * @default 12\n */\n offset: OverlayPositionerProps['offset']\n\n /**\n * @default true\n */\n hide: OverlayPositionerProps['hide']\n\n /**\n * @default true\n */\n overlap: OverlayPositionerProps['overlap']\n\n /**\n * @default true\n */\n inline: OverlayPositionerProps['inline']\n\n /**\n * @default 8\n */\n overflowPadding: OverlayPositionerProps['overflowPadding']\n}\n\n/** @internal */\nexport const inlinePopoverProps: PropDeclarations<InlinePopoverProps> = Object.freeze({\n ...overlayPositionerProps,\n editor: { default: null },\n defaultOpen: { default: true },\n open: { default: false },\n dismissOnEscape: { default: true },\n\n placement: { default: 'top' },\n offset: { default: 12 },\n hide: { default: true },\n overlap: { default: true },\n inline: { default: true },\n overflowPadding: { default: 8 },\n})\n\nexport interface InlinePopoverEvents extends OverlayPositionerEvents {\n /**\n * Fired when the open state changes.\n */\n openChange: CustomEvent<boolean>\n}\n\n/** @internal */\nexport const inlinePopoverEvents: EventDeclarations<InlinePopoverEvents> = {\n ...overlayPositionerEvents,\n openChange: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useInlinePopover } from \"./setup\"\nimport { inlinePopoverEvents, inlinePopoverProps, type InlinePopoverEvents, type InlinePopoverProps } from \"./types\"\n\nconst InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps> = defineCustomElement<\n InlinePopoverProps,\n InlinePopoverEvents\n>({\n props: inlinePopoverProps,\n events: inlinePopoverEvents,\n setup: useInlinePopover,\n})\nclass InlinePopoverElement extends InlinePopoverElementBase {}\n\nregisterCustomElement('prosekit-inline-popover', InlinePopoverElement)\n \nexport { InlinePopoverElement }\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,0BACd,MACA,QACA,SACM;AAEN,oBAAmB,MAAM,QADP,yBAAyB,QAAQ,CACR;;;;;;;;ACN7C,SAAgB,qBACd,MACA,QACA,SACM;AAEN,oBAAmB,MAAM,QADP,oBAAoB,QAAQ,CACH;;;;;ACT7C,SAAgB,UACd,MACA,QACA,QACM;AAEN,oBAAmB,MAAM,QADP,aAAa,OAAO,CACK;;;;;ACV7C,SAAgB,2BACd,MAC8B;AAC9B,KAAI,OAAO,WAAW,eAAe,KAAK,YACxC;CAGF,MAAM,YAAY,KAAK,MAAM;AAE7B,KACE,CAAC,UAAU,SACR,CAAC,cAAc,UAAU,IACzB,gBAAgB,UAAU,IAC1B,mBAAmB,KAAK,MAAM,KAAK,UAAU,MAAM,UAAU,GAAG,CAEnE,QAAO,iBAAiB,KAAK,IAAI,oBAAoB,KAAK;;AAI9D,SAAS,iBAAiB,MAAgD;CACxE,MAAM,QAAQ,YAAY,KAAK;AAC/B,KAAI,MAGF,QAAO;EACL,gBAAgB,KAAK;EACrB,6BAA6B,MAAM,uBAAuB;EAC1D,sBAAsB,MAAM,gBAAgB;EAC7C;;AAIL,SAAS,YAAY,MAAqC;CAExD,MAAM,YADM,KAAK,IAAI,cAAc,aACZ,cAAc;AACrC,KAAI,CAAC,aAAa,UAAU,YAC1B;CAGF,MAAM,QAAQ,OAAO,UAAU,eAAe,YACzC,UAAU,aAAa,KACvB,UAAU,WAAW,EAAE;AAE5B,KAAI,CAAC,MACH;AAGF,QAAO;;AAGT,SAAS,oBAAoB,MAAgD;CAC3E,MAAM,QAAQ,KAAK,IAAI,iBAAiB,8BAA8B;AAEtE,KAA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AM,SAAS,SAAS;AAG3C,MAFyB,CAAC,iBAAiB,KAAK,SAAS,KAAK,cAAc,cAAc,CAGxF;AAGF,YAAU,IAAI,2BAA2B,KAAK,IAAI,KAAK;GACvD;AAEF,QAAO;;;;;;ACPT,MAAaA,qBAA2D,OAAO,OAAO;CACpF,GAAGC;CACH,QAAQ,EAAE,SAAS,MAAM;CACzB,aAAa,EAAE,SAAS,MAAM;CAC9B,MAAM,EAAE,SAAS,OAAO;CACxB,iBAAiB,EAAE,SAAS,MAAM;CAElC,WAAW,EAAE,SAAS,OAAO;CAC7B,QAAQ,EAAE,SAAS,IAAI;CACvB,MAAM,EAAE,SAAS,MAAM;CACvB,SAAS,EAAE,SAAS,MAAM;CAC1B,QAAQ,EAAE,SAAS,MAAM;CACzB,iBAAiB,EAAE,SAAS,GAAG;CAChC,CAAC;;AAUF,MAAaC,sBAA8D;CACzE,GAAGC;CACH,YAAY,EAAE;CACf;;;;AC7GD,MAAMC,2BAAuE,oBAG3E;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,uBAAN,cAAmC,yBAAyB;AAE5D,sBAAsB,2BAA2B,qBAAqB"}
1
+ {"version":3,"file":"prosekit-web-inline-popover.js","names":["prevSelection: Selection | undefined","inlinePopoverProps: PropDeclarations<InlinePopoverProps>","overlayPositionerProps","inlinePopoverEvents: EventDeclarations<InlinePopoverEvents>","overlayPositionerEvents","InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps>"],"sources":["../src/hooks/use-editor-focus-event.ts","../src/hooks/use-editor-update-event.ts","../src/hooks/use-keymap.ts","../src/components/inline-popover/inline-popover/virtual-selection-element.ts","../src/components/inline-popover/inline-popover/setup.ts","../src/components/inline-popover/inline-popover/types.ts","../src/components/inline-popover/inline-popover/element.gen.ts"],"sourcesContent":["import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineFocusChangeHandler,\n type Editor,\n type FocusChangeHandler,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\n/**\n * @internal\n */\nexport function useEditorFocusChangeEvent(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: FocusChangeHandler,\n): void {\n const extension = defineFocusChangeHandler(handler)\n useEditorExtension(host, editor, extension)\n}\n","import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineUpdateHandler,\n type Editor,\n type UpdateHandler,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\n/**\n * @internal\n */\nexport function useEditorUpdateEvent(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: UpdateHandler,\n): void {\n const extension = defineUpdateHandler(handler)\n useEditorExtension(host, editor, extension)\n}\n","import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineKeymap,\n type Editor,\n type Keymap,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\nexport function useKeymap(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n keymap: Keymap,\n): void {\n const extension = defineKeymap(keymap)\n useEditorExtension(host, editor, extension)\n}\n","import type { ReferenceElement } from '@floating-ui/dom'\nimport {\n containsInlineNode,\n isInCodeBlock,\n isTextSelection,\n} from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nexport function getVirtualSelectionElement(\n view: EditorView,\n): ReferenceElement | undefined {\n if (typeof window === 'undefined' || view.isDestroyed) {\n return\n }\n\n const selection = view.state.selection\n\n if (\n !selection.empty\n && !isInCodeBlock(selection)\n && isTextSelection(selection)\n && containsInlineNode(view.state.doc, selection.from, selection.to)\n ) {\n return getDomDecoration(view) || getInlineDecoration(view)\n }\n}\n\nfunction getDomDecoration(view: EditorView): ReferenceElement | undefined {\n const range = getDomRange(view)\n if (range) {\n // To get it work properly in Safari, we cannot return the range directly.\n // We have to return a contextElement.\n return {\n contextElement: view.dom,\n getBoundingClientRect: () => range.getBoundingClientRect(),\n getClientRects: () => range.getClientRects(),\n }\n }\n}\n\nfunction getDomRange(view: EditorView): Range | undefined {\n const win = view.dom.ownerDocument.defaultView\n const selection = win?.getSelection()\n if (!selection || selection.isCollapsed) {\n return\n }\n\n const range = typeof selection.rangeCount === 'number'\n && selection.rangeCount > 0\n && selection.getRangeAt(0)\n\n if (!range) {\n return\n }\n\n return range\n}\n\nfunction getInlineDecoration(view: EditorView): ReferenceElement | undefined {\n const match = view.dom.querySelectorAll('.prosekit-virtual-selection')\n\n if (match.length === 0) {\n return\n }\n if (match.length === 1) {\n return match[0]\n }\n\n const items = Array.from(match)\n return {\n contextElement: items[0],\n getBoundingClientRect: () => items[0].getBoundingClientRect(),\n getClientRects: () => items.map((item) => item.getBoundingClientRect()),\n }\n}\n","import {\n createComputed,\n createSignal,\n useAttribute,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { useOverlayPositionerState } from '@aria-ui/overlay/elements'\nimport { usePresence } from '@aria-ui/presence'\nimport type { ReferenceElement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\nimport type { Selection } from '@prosekit/pm/state'\n\nimport { useEditorFocusChangeEvent } from '../../../hooks/use-editor-focus-event'\nimport { useEditorUpdateEvent } from '../../../hooks/use-editor-update-event'\nimport { useKeymap } from '../../../hooks/use-keymap'\n\nimport type {\n InlinePopoverEvents,\n InlinePopoverProps,\n} from './types'\nimport { getVirtualSelectionElement } from './virtual-selection-element'\n\n/**\n * @internal\n */\nexport function useInlinePopover(\n host: ConnectableElement,\n { state, emit }: SetupOptions<InlinePopoverProps, InlinePopoverEvents>,\n): void {\n const { editor, defaultOpen, open, ...overlayState } = state\n\n const reference = useInlinePopoverReference(host, editor)\n const hasReference = createComputed(() => !!reference.get())\n\n useEffect(host, () => {\n const hasReferenceValue = hasReference.get()\n const defaultOpenValue = defaultOpen.peek()\n const openValue = open.peek()\n\n if (defaultOpenValue || openValue) {\n emit('openChange', hasReferenceValue)\n }\n })\n\n useEffect(host, () => {\n const hasReferenceValue = hasReference.get()\n const defaultOpenValue = defaultOpen.peek()\n\n if (hasReferenceValue && defaultOpenValue) {\n open.set(true)\n } else if (!hasReferenceValue) {\n open.set(false)\n }\n })\n\n useKeymap(host, editor, {\n Escape: () => {\n if (!state.dismissOnEscape.peek() || !open.peek()) {\n return false\n }\n open.set(false)\n emit('openChange', false)\n return true\n },\n })\n\n useOverlayPositionerState(host, overlayState, { reference })\n\n useAttribute(host, 'data-state', () => (open.get() ? 'open' : 'closed'))\n usePresence(host, open)\n}\n\nfunction useInlinePopoverReference(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n) {\n const reference = createSignal<ReferenceElement | null>(null)\n let editorFocused = false\n\n useEditorFocusChangeEvent(host, editor, (focus) => {\n editorFocused = focus\n })\n\n let prevSelection: Selection | undefined\n\n useEditorUpdateEvent(host, editor, (view) => {\n const isPopoverFocused = !editorFocused && host.contains(host.ownerDocument.activeElement)\n\n if (isPopoverFocused) {\n return\n }\n\n const { selection } = view.state\n const selectionUnchanged = prevSelection?.eq(selection)\n prevSelection = selection\n\n // Skip reference update if only the document content has changed, not the\n // selection itself.\n //\n // Example: If the user selects text and then applies mark bold using the\n // popover, the selection may widen, but we don't want to reposition the\n // popover.\n if (selectionUnchanged) {\n return\n }\n\n reference.set(getVirtualSelectionElement(view) || null)\n })\n\n return reference\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n overlayPositionerEvents,\n overlayPositionerProps,\n type OverlayPositionerEvents,\n type OverlayPositionerProps,\n} from '@aria-ui/overlay'\nimport type { Editor } from '@prosekit/core'\n\nexport interface InlinePopoverProps extends\n Omit<\n OverlayPositionerProps,\n 'placement' | 'offset' | 'hide' | 'overlap' | 'inline' | 'overflowPadding'\n >\n{\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * Whether the popover is open by default when some inline content is\n * selected.\n *\n * When `defaultOpen` is true, the popover will open or close based on the\n * inline selection. When `defaultOpen` is false, the popover will never be\n * opened unless the `open` prop is true.\n *\n * @default true\n */\n defaultOpen: boolean\n\n /**\n * Whether the popover is open.\n *\n * Notice that the popover will be always hidden if the inline selection is\n * empty.\n *\n * @default false\n */\n open: boolean\n\n /**\n * Whether the inline popover should be dismissed when the editor receives an\n * Escape key press.\n *\n * @default true\n */\n dismissOnEscape: boolean\n\n /**\n * @default \"top\"\n */\n placement: OverlayPositionerProps['placement']\n\n /**\n * @default 12\n */\n offset: OverlayPositionerProps['offset']\n\n /**\n * @default true\n */\n hide: OverlayPositionerProps['hide']\n\n /**\n * @default true\n */\n overlap: OverlayPositionerProps['overlap']\n\n /**\n * @default true\n */\n inline: OverlayPositionerProps['inline']\n\n /**\n * @default 8\n */\n overflowPadding: OverlayPositionerProps['overflowPadding']\n}\n\n/** @internal */\nexport const inlinePopoverProps: PropDeclarations<InlinePopoverProps> = Object.freeze({\n ...overlayPositionerProps,\n editor: { default: null },\n defaultOpen: { default: true },\n open: { default: false },\n dismissOnEscape: { default: true },\n\n placement: { default: 'top' },\n offset: { default: 12 },\n hide: { default: true },\n overlap: { default: true },\n inline: { default: true },\n overflowPadding: { default: 8 },\n})\n\nexport interface InlinePopoverEvents extends OverlayPositionerEvents {\n /**\n * Fired when the open state changes.\n */\n openChange: CustomEvent<boolean>\n}\n\n/** @internal */\nexport const inlinePopoverEvents: EventDeclarations<InlinePopoverEvents> = {\n ...overlayPositionerEvents,\n openChange: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useInlinePopover } from \"./setup\"\nimport { inlinePopoverEvents, inlinePopoverProps, type InlinePopoverEvents, type InlinePopoverProps } from \"./types\"\n\nconst InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps> = defineCustomElement<\n InlinePopoverProps,\n InlinePopoverEvents\n>({\n props: inlinePopoverProps,\n events: inlinePopoverEvents,\n setup: useInlinePopover,\n})\nclass InlinePopoverElement extends InlinePopoverElementBase {}\n\nregisterCustomElement('prosekit-inline-popover', InlinePopoverElement)\n \nexport { InlinePopoverElement }\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,0BACd,MACA,QACA,SACM;AAEN,oBAAmB,MAAM,QADP,yBAAyB,QAAQ,CACR;;;;;;;;ACN7C,SAAgB,qBACd,MACA,QACA,SACM;AAEN,oBAAmB,MAAM,QADP,oBAAoB,QAAQ,CACH;;;;;ACT7C,SAAgB,UACd,MACA,QACA,QACM;AAEN,oBAAmB,MAAM,QADP,aAAa,OAAO,CACK;;;;;ACV7C,SAAgB,2BACd,MAC8B;AAC9B,KAAI,OAAO,WAAW,eAAe,KAAK,YACxC;CAGF,MAAM,YAAY,KAAK,MAAM;AAE7B,KACE,CAAC,UAAU,SACR,CAAC,cAAc,UAAU,IACzB,gBAAgB,UAAU,IAC1B,mBAAmB,KAAK,MAAM,KAAK,UAAU,MAAM,UAAU,GAAG,CAEnE,QAAO,iBAAiB,KAAK,IAAI,oBAAoB,KAAK;;AAI9D,SAAS,iBAAiB,MAAgD;CACxE,MAAM,QAAQ,YAAY,KAAK;AAC/B,KAAI,MAGF,QAAO;EACL,gBAAgB,KAAK;EACrB,6BAA6B,MAAM,uBAAuB;EAC1D,sBAAsB,MAAM,gBAAgB;EAC7C;;AAIL,SAAS,YAAY,MAAqC;CAExD,MAAM,YADM,KAAK,IAAI,cAAc,aACZ,cAAc;AACrC,KAAI,CAAC,aAAa,UAAU,YAC1B;CAGF,MAAM,QAAQ,OAAO,UAAU,eAAe,YACzC,UAAU,aAAa,KACvB,UAAU,WAAW,EAAE;AAE5B,KAAI,CAAC,MACH;AAGF,QAAO;;AAGT,SAAS,oBAAoB,MAAgD;CAC3E,MAAM,QAAQ,KAAK,IAAI,iBAAiB,8BAA8B;AAEtE,KAAI,MAAM,WAAW,EACnB;AAEF,KAAI,MAAM,WAAW,EACnB,QAAO,MAAM;CAGf,MAAM,QAAQ,MAAM,KAA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GxF;EAGF,MAAM,EAAE,cAAc,KAAK;EAC3B,MAAM,qBAAqB,eAAe,GAAG,UAAU;AACvD,kBAAgB;AAQhB,MAAI,mBACF;AAGF,YAAU,IAAI,2BAA2B,KAAK,IAAI,KAAK;GACvD;AAEF,QAAO;;;;;;ACxBT,MAAaC,qBAA2D,OAAO,OAAO;CACpF,GAAGC;CACH,QAAQ,EAAE,SAAS,MAAM;CACzB,aAAa,EAAE,SAAS,MAAM;CAC9B,MAAM,EAAE,SAAS,OAAO;CACxB,iBAAiB,EAAE,SAAS,MAAM;CAElC,WAAW,EAAE,SAAS,OAAO;CAC7B,QAAQ,EAAE,SAAS,IAAI;CACvB,MAAM,EAAE,SAAS,MAAM;CACvB,SAAS,EAAE,SAAS,MAAM;CAC1B,QAAQ,EAAE,SAAS,MAAM;CACzB,iBAAiB,EAAE,SAAS,GAAG;CAChC,CAAC;;AAUF,MAAaC,sBAA8D;CACzE,GAAGC;CACH,YAAY,EAAE;CACf;;;;AC7GD,MAAMC,2BAAuE,oBAG3E;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,uBAAN,cAAmC,yBAAyB;AAE5D,sBAAsB,2BAA2B,qBAAqB"}
@@ -241,8 +241,8 @@ function getTableDOMByPos(view, pos) {
241
241
  return (isHTMLElement(dom) ? dom : dom.parentElement)?.closest("table") ?? void 0;
242
242
  }
243
243
  function getTargetFirstCellDOM(table, index, direction) {
244
- if (direction === "row") return table.querySelectorAll("tr")[index]?.querySelector("td") ?? void 0;
245
- else return table.querySelector("tr")?.querySelectorAll("td")[index] ?? void 0;
244
+ if (direction === "row") return table.querySelectorAll("tr")[index]?.querySelector("td, th") ?? void 0;
245
+ else return table.querySelector("tr")?.querySelectorAll("td, th")[index] ?? void 0;
246
246
  }
247
247
  function getDndRelatedDOMs(view, cellPos, draggingIndex, direction) {
248
248
  if (cellPos == null) return;
@@ -323,7 +323,7 @@ function createPreviewDOM(table, previewRoot, index, direction) {
323
323
  const [previewRow, previewRowStyle] = cloneElement(row);
324
324
  injectStyle(previewRoot, previewRowStyle);
325
325
  unsetSize(previewRow);
326
- const cell = row.querySelectorAll("td")[index];
326
+ const cell = row.querySelectorAll("td, th")[index];
327
327
  if (cell) {
328
328
  const [previewCell, previewCellStyle] = deepCloneElement(cell);
329
329
  injectStyle(previewRoot, previewCellStyle);
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-web-table-handle.js","names":["tableHandleRootContext: Context<TableHandleRootContext>","defaultTableHandleDndContext: TableHandleDndContext","tableHandleDndContext: Context<TableHandleDndContext>","tableHandleColumnRootProps: PropDeclarations<TableHandleColumnRootProps>","overlayPositionerProps","tableHandleColumnRootEvents: EventDeclarations<TableHandleColumnRootEvents>","overlayPositionerEvents","TableHandleColumnRootElementBase: BaseElementConstructor<TableHandleColumnRootProps>","image: HTMLImageElement | undefined","tableHandleColumnTriggerProps: PropDeclarations<TableHandleColumnTriggerProps>","tableHandleColumnTriggerEvents: EventDeclarations<TableHandleColumnTriggerEvents>","TableHandleColumnTriggerElementBase: BaseElementConstructor<TableHandleColumnTriggerProps>","isColorMixSupported: () => boolean","current: HTMLElement | null","y","x","tableHandleDragPreviewProps: PropDeclarations<TableHandleDragPreviewProps>","tableHandleDragPreviewEvents: EventDeclarations<TableHandleDragPreviewEvents>","TableHandleDragPreviewElementBase: BaseElementConstructor<TableHandleDragPreviewProps>","index","direction","x","y","tableHandleDropIndicatorProps: PropDeclarations<TableHandleDropIndicatorProps>","tableHandleDropIndicatorEvents: EventDeclarations<TableHandleDropIndicatorEvents>","TableHandleDropIndicatorElementBase: BaseElementConstructor<TableHandleDropIndicatorProps>","keydownHandlers: Array<(event: KeyboardEvent) => void>","tableHandlePopoverContentProps: PropDeclarations<TableHandlePopoverContentProps>","tableHandlePopoverContentEvents: EventDeclarations<TableHandlePopoverContentEvents>","TableHandlePopoverContentElementBase: BaseElementConstructor<TableHandlePopoverContentProps>","tableHandlePopoverItemProps: PropDeclarations<TableHandlePopoverItemProps>","tableHandlePopoverItemEvents: EventDeclarations<TableHandlePopoverItemEvents>","TableHandlePopoverItemElementBase: BaseElementConstructor<TableHandlePopoverItemProps>","tableHandleRootProps: PropDeclarations<TableHandleRootProps>","tableHandleRootEvents: EventDeclarations<TableHandleRootEvents>","TableHandleRootElementBase: BaseElementConstructor<TableHandleRootProps>","tableHandleRowRootProps: PropDeclarations<TableHandleRowRootProps>","overlayPositionerProps","tableHandleRowRootEvents: EventDeclarations<TableHandleRowRootEvents>","TableHandleRowRootElementBase: BaseElementConstructor<TableHandleRowRootProps>","tableHandleRowTriggerProps: PropDeclarations<TableHandleRowTriggerProps>","tableHandleRowTriggerEvents: EventDeclarations<TableHandleRowTriggerEvents>","TableHandleRowTriggerElementBase: BaseElementConstructor<TableHandleRowTriggerProps>"],"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/css-feature-detection.ts","../src/utils/fade-color.ts","../src/utils/get-effective-background-color.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 {\n createContext,\n type Context,\n} from '@aria-ui/core'\n\nimport type {\n DndInfo,\n HoveringCellInfo,\n} from './utils'\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 {\n createComputed,\n createSignal,\n useAttribute,\n useEffect,\n type ConnectableElement,\n type SignalState,\n} from '@aria-ui/core'\nimport {\n menuRootProps,\n useMenuRoot,\n type MenuRootProps,\n} 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'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport { tableHandleRootContext } from '../context'\n\nimport type { TableHandleColumnRootProps } from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} 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\"\nimport { tableHandleColumnRootEvents, tableHandleColumnRootProps, type TableHandleColumnRootEvents, type TableHandleColumnRootProps } from \"./types\"\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 {\n useEffect,\n useEventListener,\n type ConnectableElement,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { useMenuTrigger } from '@aria-ui/menu/elements'\nimport { selectTableColumn } from '@prosekit/extensions/table'\n\nimport {\n tableHandleDndContext,\n tableHandleRootContext,\n} from '../context'\nimport { useEmptyImage } from '../hooks/use-empty-image'\n\nimport type {\n TableHandleColumnTriggerEvents,\n TableHandleColumnTriggerProps,\n} from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} 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\"\nimport { tableHandleColumnTriggerEvents, tableHandleColumnTriggerProps, type TableHandleColumnTriggerEvents, type TableHandleColumnTriggerProps } from \"./types\"\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 {\n createComputed,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n computePosition,\n offset,\n} 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'\nimport { getSafeEditorView } from '../../utils/get-safe-editor-view'\n\nimport {\n tableHandleDndContext,\n tableHandleRootContext,\n} from './context'\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('td')\n return cell ?? undefined\n } else {\n const row = table.querySelector('tr')\n const cell = row?.querySelectorAll('td')[index]\n return cell ?? undefined\n }\n}\n\nexport function getDndRelatedDOMs(view: EditorView, cellPos: number | undefined, draggingIndex: number, direction: 'row' | 'col'): { 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 { 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'\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 { assignStyles } from '../../../utils/assign-styles'\nimport {\n cloneElement,\n deepCloneElement,\n} from '../../../utils/clone-element'\nimport { fadeColor } from '../../../utils/fade-color'\nimport { getEffectiveBackgroundColor } from '../../../utils/get-effective-background-color'\nimport { injectStyle } from '../../../utils/inject-style'\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')\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 createComputed,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n computePosition,\n type ReferenceElement,\n} from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nimport { assignStyles } from '../../../utils/assign-styles'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport {\n tableHandleDndContext,\n tableHandleRootContext,\n} from '../context'\nimport { getDndRelatedDOMs } from '../dnd'\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 {\n useEffect,\n type ConnectableElement,\n type SignalState,\n} from '@aria-ui/core'\n\nimport { assignStyles } from '../../../utils/assign-styles'\nimport {\n useInitDndPosition,\n type OnInitParams,\n} from '../dnd'\n\nimport {\n clearPreviewDOM,\n createPreviewDOM,\n} from './render-preview'\nimport type { TableHandleDragPreviewProps } from './types'\nimport { useUpdatePreviewPosition } from './updater'\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 {\n EventDeclarations,\n PropDeclarations,\n} 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\"\nimport { tableHandleDragPreviewEvents, tableHandleDragPreviewProps, type TableHandleDragPreviewEvents, type TableHandleDragPreviewProps } from \"./types\"\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 {\n createComputed,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n computePosition,\n offset,\n} from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nimport { assignStyles } from '../../../utils/assign-styles'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport {\n tableHandleDndContext,\n tableHandleRootContext,\n} from '../context'\nimport { getDndRelatedDOMs } from '../dnd'\n\nimport {\n getDragOverColumn,\n getDragOverRow,\n} from './calc-drag-over'\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 let 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 {\n useEffect,\n type ConnectableElement,\n type SignalState,\n} from '@aria-ui/core'\n\nimport { assignStyles } from '../../../utils/assign-styles'\nimport {\n useInitDndPosition,\n type OnInitParams,\n} from '../dnd'\n\nimport type { TableHandleDropIndicatorProps } from './types'\nimport { useUpdateIndicatorPosition } from './updater'\n\nconst HANDLE_WIDTH = 2\n\n/**\n * @internal\n */\nexport function useTableHandleDropIndicator(host: ConnectableElement, { state }: { state: SignalState<TableHandleDropIndicatorProps> }): 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 {\n EventDeclarations,\n PropDeclarations,\n} 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\"\nimport { tableHandleDropIndicatorEvents, tableHandleDropIndicatorProps, type TableHandleDropIndicatorEvents, type TableHandleDropIndicatorProps } from \"./types\"\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 {\n menuContentProps,\n useMenuContent,\n type MenuContentProps,\n} from '@aria-ui/menu/elements'\n\nimport { getStateWithDefaults } from '../../../utils/get-default-state'\nimport { tableHandleRootContext } from '../context'\n\nimport type {\n TableHandlePopoverContentEvents,\n TableHandlePopoverContentProps,\n} from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n menuContentEvents,\n menuContentProps,\n type MenuContentEvents,\n type MenuContentProps,\n} 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\"\nimport { tableHandlePopoverContentEvents, tableHandlePopoverContentProps, type TableHandlePopoverContentEvents, type TableHandlePopoverContentProps } from \"./types\"\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 {\n ConnectableElement,\n SetupOptions,\n} from '@aria-ui/core'\nimport { useMenuItem } from '@aria-ui/menu/elements'\n\nimport type {\n TableHandlePopoverItemEvents,\n TableHandlePopoverItemProps,\n} from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n menuItemEvents,\n menuItemProps,\n type MenuItemEvents,\n type MenuItemProps,\n} 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\"\nimport { tableHandlePopoverItemEvents, tableHandlePopoverItemProps, type TableHandlePopoverItemEvents, type TableHandlePopoverItemProps } from \"./types\"\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 {\n createSignal,\n type ConnectableElement,\n type ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineDOMEventHandler,\n union,\n type Editor,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\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 {\n createSignal,\n useEffect,\n type ConnectableElement,\n} from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nimport { getSafeEditorView } from '../utils/get-safe-editor-view'\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 {\n createComputed,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type Signal,\n} from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\nimport {\n moveTableColumn,\n moveTableRow,\n} from '@prosekit/extensions/table'\n\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport type { TableHandleDndContext } from '../context'\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 {\n cellAround,\n TableMap,\n} 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 {\n defineDOMEventHandler,\n type Editor,\n} from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { useEditorExtension } from '../../../hooks/use-editor-extension'\nimport { useEditorTyping } from '../../../hooks/use-editor-typing'\nimport { useScrolling } from '../../../hooks/use-scrolling'\nimport { useSelecting } from '../../../hooks/use-selecting'\nimport {\n defaultTableHandleDndContext,\n tableHandleDndContext,\n tableHandleRootContext,\n type TableHandleDndContext,\n type TableHandleRootContext,\n} from '../context'\nimport { useDrop } from '../hooks/use-drop'\nimport {\n getHoveringCell,\n isHoveringCellInfoEqual,\n type HoveringCellInfo,\n} from '../utils'\n\nimport type { TableHandleRootProps } from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} 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\"\nimport { tableHandleRootEvents, tableHandleRootProps, type TableHandleRootEvents, type TableHandleRootProps } from \"./types\"\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 {\n menuRootEvents,\n menuRootProps,\n useMenuRoot,\n} 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'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport { tableHandleRootContext } from '../context'\n\nimport type {\n TableHandleRowRootEvents,\n TableHandleRowRootProps,\n} from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\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 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\"\nimport { tableHandleRowRootEvents, tableHandleRowRootProps, type TableHandleRowRootEvents, type TableHandleRowRootProps } from \"./types\"\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 {\n useEffect,\n useEventListener,\n type ConnectableElement,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { useMenuTrigger } from '@aria-ui/menu/elements'\nimport { selectTableRow } from '@prosekit/extensions/table'\n\nimport {\n tableHandleDndContext,\n tableHandleRootContext,\n} from '../context'\nimport { useEmptyImage } from '../hooks/use-empty-image'\n\nimport type {\n TableHandleRowTriggerEvents,\n TableHandleRowTriggerProps,\n} from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} 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\"\nimport { tableHandleRowTriggerEvents, tableHandleRowTriggerProps, type TableHandleRowTriggerEvents, type TableHandleRowTriggerProps } from \"./types\"\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":";;;;;;;;;;;;;;;;;;;;;AAkBA,MAAaA,yBAA0D,cACrE,sCACA,KACD;;;;AAUD,MAAaC,+BAAsD;CACjE,UAAU;CACV,WAAW;CACX,eAAe;CACf,eAAe;CACf,GAAG;CACH,GAAG;CACH,QAAQ;CACR,QAAQ;CACT;;;;AAKD,MAAaC,wBAAwD,cACnE,qCACA,6BACD;;;;;;;ACvBD,SAAgB,yBACd,MACA,EAAE,SACI;CACN,MAAM,EAAE,QAAQ,GAAG,iBAAiB;CAEpC,MAAM,cAAc,uBAAu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AAC3B,MAAI,cAAc;AAChB,gBAAa,gBAAgB;GAC7B,MAAM,aAAa,eAAe;AAClC,OAAI,WACF,cAAa,aAAa,YAAY,GAAG,EAAE;;EAG/C,MAAM,OAAO,WAAW,MAAM;EAC9B,MAAM,QAAQ,QAAQ,MAAM,EAAE;AAE9B,MAAI,SAAS,QAAQ,QAAQ,GAAG;AAC9B,WAAQ,KAAK,oDAAoD,MAAM;AACvE,SAAM,gBAAgB;AACtB;;AAGF,aAAW,IAAI;GACb,GAAG;GACH,WAAW;GACX,UAAU;GACV,eAAe;GACf,QAAQ,MAAM;GACd,QAAQ,MAAM;GACf,CAAC;GACF;;;;;;AC1DJ,MAAaC,6BAA2E,EACtF,QAAQ,EAAE,SAAS,MAAM,EAC1B;;AAOD,MAAaC,8BAA8E,EACzF,QAAQ,EAAE,EACX;;;;ACpBD,MAAMC,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":["tableHandleRootContext: Context<TableHandleRootContext>","defaultTableHandleDndContext: TableHandleDndContext","tableHandleDndContext: Context<TableHandleDndContext>","tableHandleColumnRootProps: PropDeclarations<TableHandleColumnRootProps>","overlayPositionerProps","tableHandleColumnRootEvents: EventDeclarations<TableHandleColumnRootEvents>","overlayPositionerEvents","TableHandleColumnRootElementBase: BaseElementConstructor<TableHandleColumnRootProps>","image: HTMLImageElement | undefined","tableHandleColumnTriggerProps: PropDeclarations<TableHandleColumnTriggerProps>","tableHandleColumnTriggerEvents: EventDeclarations<TableHandleColumnTriggerEvents>","TableHandleColumnTriggerElementBase: BaseElementConstructor<TableHandleColumnTriggerProps>","isColorMixSupported: () => boolean","current: HTMLElement | null","y","x","tableHandleDragPreviewProps: PropDeclarations<TableHandleDragPreviewProps>","tableHandleDragPreviewEvents: EventDeclarations<TableHandleDragPreviewEvents>","TableHandleDragPreviewElementBase: BaseElementConstructor<TableHandleDragPreviewProps>","index","direction","x","y","tableHandleDropIndicatorProps: PropDeclarations<TableHandleDropIndicatorProps>","tableHandleDropIndicatorEvents: EventDeclarations<TableHandleDropIndicatorEvents>","TableHandleDropIndicatorElementBase: BaseElementConstructor<TableHandleDropIndicatorProps>","keydownHandlers: Array<(event: KeyboardEvent) => void>","tableHandlePopoverContentProps: PropDeclarations<TableHandlePopoverContentProps>","tableHandlePopoverContentEvents: EventDeclarations<TableHandlePopoverContentEvents>","TableHandlePopoverContentElementBase: BaseElementConstructor<TableHandlePopoverContentProps>","tableHandlePopoverItemProps: PropDeclarations<TableHandlePopoverItemProps>","tableHandlePopoverItemEvents: EventDeclarations<TableHandlePopoverItemEvents>","TableHandlePopoverItemElementBase: BaseElementConstructor<TableHandlePopoverItemProps>","tableHandleRootProps: PropDeclarations<TableHandleRootProps>","tableHandleRootEvents: EventDeclarations<TableHandleRootEvents>","TableHandleRootElementBase: BaseElementConstructor<TableHandleRootProps>","tableHandleRowRootProps: PropDeclarations<TableHandleRowRootProps>","overlayPositionerProps","tableHandleRowRootEvents: EventDeclarations<TableHandleRowRootEvents>","TableHandleRowRootElementBase: BaseElementConstructor<TableHandleRowRootProps>","tableHandleRowTriggerProps: PropDeclarations<TableHandleRowTriggerProps>","tableHandleRowTriggerEvents: EventDeclarations<TableHandleRowTriggerEvents>","TableHandleRowTriggerElementBase: BaseElementConstructor<TableHandleRowTriggerProps>"],"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/css-feature-detection.ts","../src/utils/fade-color.ts","../src/utils/get-effective-background-color.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 {\n createContext,\n type Context,\n} from '@aria-ui/core'\n\nimport type {\n DndInfo,\n HoveringCellInfo,\n} from './utils'\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 {\n createComputed,\n createSignal,\n useAttribute,\n useEffect,\n type ConnectableElement,\n type SignalState,\n} from '@aria-ui/core'\nimport {\n menuRootProps,\n useMenuRoot,\n type MenuRootProps,\n} 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'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport { tableHandleRootContext } from '../context'\n\nimport type { TableHandleColumnRootProps } from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} 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\"\nimport { tableHandleColumnRootEvents, tableHandleColumnRootProps, type TableHandleColumnRootEvents, type TableHandleColumnRootProps } from \"./types\"\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 {\n useEffect,\n useEventListener,\n type ConnectableElement,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { useMenuTrigger } from '@aria-ui/menu/elements'\nimport { selectTableColumn } from '@prosekit/extensions/table'\n\nimport {\n tableHandleDndContext,\n tableHandleRootContext,\n} from '../context'\nimport { useEmptyImage } from '../hooks/use-empty-image'\n\nimport type {\n TableHandleColumnTriggerEvents,\n TableHandleColumnTriggerProps,\n} from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} 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\"\nimport { tableHandleColumnTriggerEvents, tableHandleColumnTriggerProps, type TableHandleColumnTriggerEvents, type TableHandleColumnTriggerProps } from \"./types\"\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 {\n createComputed,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n computePosition,\n offset,\n} 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'\nimport { getSafeEditorView } from '../../utils/get-safe-editor-view'\n\nimport {\n tableHandleDndContext,\n tableHandleRootContext,\n} from './context'\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(view: EditorView, cellPos: number | undefined, draggingIndex: number, direction: 'row' | 'col'): { 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 { 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'\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 { assignStyles } from '../../../utils/assign-styles'\nimport {\n cloneElement,\n deepCloneElement,\n} from '../../../utils/clone-element'\nimport { fadeColor } from '../../../utils/fade-color'\nimport { getEffectiveBackgroundColor } from '../../../utils/get-effective-background-color'\nimport { injectStyle } from '../../../utils/inject-style'\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 createComputed,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n computePosition,\n type ReferenceElement,\n} from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nimport { assignStyles } from '../../../utils/assign-styles'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport {\n tableHandleDndContext,\n tableHandleRootContext,\n} from '../context'\nimport { getDndRelatedDOMs } from '../dnd'\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 {\n useEffect,\n type ConnectableElement,\n type SignalState,\n} from '@aria-ui/core'\n\nimport { assignStyles } from '../../../utils/assign-styles'\nimport {\n useInitDndPosition,\n type OnInitParams,\n} from '../dnd'\n\nimport {\n clearPreviewDOM,\n createPreviewDOM,\n} from './render-preview'\nimport type { TableHandleDragPreviewProps } from './types'\nimport { useUpdatePreviewPosition } from './updater'\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 {\n EventDeclarations,\n PropDeclarations,\n} 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\"\nimport { tableHandleDragPreviewEvents, tableHandleDragPreviewProps, type TableHandleDragPreviewEvents, type TableHandleDragPreviewProps } from \"./types\"\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 {\n createComputed,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n computePosition,\n offset,\n} from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nimport { assignStyles } from '../../../utils/assign-styles'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport {\n tableHandleDndContext,\n tableHandleRootContext,\n} from '../context'\nimport { getDndRelatedDOMs } from '../dnd'\n\nimport {\n getDragOverColumn,\n getDragOverRow,\n} from './calc-drag-over'\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 let 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 {\n useEffect,\n type ConnectableElement,\n type SignalState,\n} from '@aria-ui/core'\n\nimport { assignStyles } from '../../../utils/assign-styles'\nimport {\n useInitDndPosition,\n type OnInitParams,\n} from '../dnd'\n\nimport type { TableHandleDropIndicatorProps } from './types'\nimport { useUpdateIndicatorPosition } from './updater'\n\nconst HANDLE_WIDTH = 2\n\n/**\n * @internal\n */\nexport function useTableHandleDropIndicator(host: ConnectableElement, { state }: { state: SignalState<TableHandleDropIndicatorProps> }): 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 {\n EventDeclarations,\n PropDeclarations,\n} 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\"\nimport { tableHandleDropIndicatorEvents, tableHandleDropIndicatorProps, type TableHandleDropIndicatorEvents, type TableHandleDropIndicatorProps } from \"./types\"\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 {\n menuContentProps,\n useMenuContent,\n type MenuContentProps,\n} from '@aria-ui/menu/elements'\n\nimport { getStateWithDefaults } from '../../../utils/get-default-state'\nimport { tableHandleRootContext } from '../context'\n\nimport type {\n TableHandlePopoverContentEvents,\n TableHandlePopoverContentProps,\n} from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n menuContentEvents,\n menuContentProps,\n type MenuContentEvents,\n type MenuContentProps,\n} 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\"\nimport { tableHandlePopoverContentEvents, tableHandlePopoverContentProps, type TableHandlePopoverContentEvents, type TableHandlePopoverContentProps } from \"./types\"\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 {\n ConnectableElement,\n SetupOptions,\n} from '@aria-ui/core'\nimport { useMenuItem } from '@aria-ui/menu/elements'\n\nimport type {\n TableHandlePopoverItemEvents,\n TableHandlePopoverItemProps,\n} from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n menuItemEvents,\n menuItemProps,\n type MenuItemEvents,\n type MenuItemProps,\n} 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\"\nimport { tableHandlePopoverItemEvents, tableHandlePopoverItemProps, type TableHandlePopoverItemEvents, type TableHandlePopoverItemProps } from \"./types\"\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 {\n createSignal,\n type ConnectableElement,\n type ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineDOMEventHandler,\n union,\n type Editor,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\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 {\n createSignal,\n useEffect,\n type ConnectableElement,\n} from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nimport { getSafeEditorView } from '../utils/get-safe-editor-view'\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 {\n createComputed,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type Signal,\n} from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\nimport {\n moveTableColumn,\n moveTableRow,\n} from '@prosekit/extensions/table'\n\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport type { TableHandleDndContext } from '../context'\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 {\n cellAround,\n TableMap,\n} 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 {\n defineDOMEventHandler,\n type Editor,\n} from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { useEditorExtension } from '../../../hooks/use-editor-extension'\nimport { useEditorTyping } from '../../../hooks/use-editor-typing'\nimport { useScrolling } from '../../../hooks/use-scrolling'\nimport { useSelecting } from '../../../hooks/use-selecting'\nimport {\n defaultTableHandleDndContext,\n tableHandleDndContext,\n tableHandleRootContext,\n type TableHandleDndContext,\n type TableHandleRootContext,\n} from '../context'\nimport { useDrop } from '../hooks/use-drop'\nimport {\n getHoveringCell,\n isHoveringCellInfoEqual,\n type HoveringCellInfo,\n} from '../utils'\n\nimport type { TableHandleRootProps } from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} 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\"\nimport { tableHandleRootEvents, tableHandleRootProps, type TableHandleRootEvents, type TableHandleRootProps } from \"./types\"\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 {\n menuRootEvents,\n menuRootProps,\n useMenuRoot,\n} 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'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport { tableHandleRootContext } from '../context'\n\nimport type {\n TableHandleRowRootEvents,\n TableHandleRowRootProps,\n} from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\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 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\"\nimport { tableHandleRowRootEvents, tableHandleRowRootProps, type TableHandleRowRootEvents, type TableHandleRowRootProps } from \"./types\"\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 {\n useEffect,\n useEventListener,\n type ConnectableElement,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { useMenuTrigger } from '@aria-ui/menu/elements'\nimport { selectTableRow } from '@prosekit/extensions/table'\n\nimport {\n tableHandleDndContext,\n tableHandleRootContext,\n} from '../context'\nimport { useEmptyImage } from '../hooks/use-empty-image'\n\nimport type {\n TableHandleRowTriggerEvents,\n TableHandleRowTriggerProps,\n} from './types'\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 {\n EventDeclarations,\n PropDeclarations,\n} 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\"\nimport { tableHandleRowTriggerEvents, tableHandleRowTriggerProps, type TableHandleRowTriggerEvents, type TableHandleRowTriggerProps } from \"./types\"\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":";;;;;;;;;;;;;;;;;;;;;AAkBA,MAAaA,yBAA0D,cACrE,sCACA,KACD;;;;AAUD,MAAaC,+BAAsD;CACjE,UAAU;CACV,WAAW;CACX,eAAe;CACf,eAAe;CACf,GAAG;CACH,GAAG;CACH,QAAQ;CACR,QAAQ;CACT;;;;AAKD,MAAaC,wBAAwD,cACnE,qCACA,6BACD;;;;;;;ACvBD,SAAgB,yBACd,MACA,EAAE,SACI;CACN,MAAM,EAAE,QAAQ,GAAG,iBAAiB;CAEpC,MAAM,cAAc,uBAAuB,QAAQ,KAAK;CAExD,MAAM,kBAAkB,qBAAyC;AAC/D,SAAO,YAAY,KAAK,EAAE;GAC1B;CAEF,MAAM,gBAAgB,qBAAyC;EAC7D,MAAM,MAAM,gBAAgB,KAAK;EACjC,MAAM,OAAO,kBAAkB,OAAO,KAAK,CAAC;AAC5C,MAAI,CAAC,OAAO,CAAC,KAAM,QAAO;AAC1B,SAAO,KAAK,QAAQ,IAAI;GACxB;CAEF,MAAM,cAAc,aAAa,MAAM;AAIvC,WAAU,YAAY;AACpB,kBAAgB,KAAK;AACrB,cAAY,IAAI,MAAM;GACtB;AAEF,2BAA0B,MAAM,cAAc,EAC5C,WAAW,eACZ,CAAC;CAEF,MAAM,WAAW,qBAAqB,CAAC,CAAC,cAAc,KAAK,CAAC;AAC5D,cAAa,MAAM,oBAAqB,SAAS,KAAK,GAAG,SAAS,SAAU;AAC5E,aAAY,MAAM,SAAS;AAO3B,aAAY,MAAM;EAChB,OANgD,qBAChD,EAAE,MAAM,aAAa,EACrB,cACD;EAIC,YAAY,KAAK;EAClB,CAAC;;;;;;ACZJ,MAAaC,6BAA2E,OAAO,OAAO;CACpG,GAAGC;CACH,QAAQ,EAAE,SAAS,MAAM;CACzB,WAAW,EAAE,SAAS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0.7.9",
5
5
  "private": false,
6
6
  "description": "A collection of web components for ProseKit",
7
7
  "author": {
@@ -76,18 +76,18 @@
76
76
  "@aria-ui/presence": "^0.0.20",
77
77
  "@aria-ui/tooltip": "^0.0.30",
78
78
  "@floating-ui/dom": "^1.7.4",
79
- "@ocavue/utils": "^0.8.1",
80
- "@zag-js/dom-query": "^1.28.0",
81
- "prosemirror-tables": "^1.8.1",
82
- "@prosekit/core": "^0.8.7",
83
- "@prosekit/extensions": "^0.12.2",
84
- "@prosekit/pm": "^0.1.14"
79
+ "@ocavue/utils": "^1.2.0",
80
+ "@zag-js/dom-query": "^1.31.0",
81
+ "prosemirror-tables": "^1.8.3",
82
+ "@prosekit/pm": "^0.1.15",
83
+ "@prosekit/extensions": "^0.13.0",
84
+ "@prosekit/core": "^0.9.0"
85
85
  },
86
86
  "devDependencies": {
87
- "tsdown": "^0.16.5",
88
- "type-fest": "^5.2.0",
87
+ "tsdown": "^0.17.0",
88
+ "type-fest": "^5.3.1",
89
89
  "typescript": "~5.9.3",
90
- "vitest": "^4.0.10",
90
+ "vitest": "^4.0.15",
91
91
  "@prosekit/config-tsdown": "0.0.0",
92
92
  "@prosekit/config-vitest": "0.0.0"
93
93
  },
@@ -135,7 +135,7 @@ function createAutocompleteRule(
135
135
  ) {
136
136
  const handleEnter: MatchHandler = (options) => {
137
137
  const view = getSafeEditorView(editor)
138
- const span = view?.dom.querySelector('.prosemirror-prediction-match')
138
+ const span = view?.dom.querySelector('.prosekit-autocomplete-match')
139
139
 
140
140
  if (span) {
141
141
  reference.set(span)
@@ -11,6 +11,7 @@ import { useOverlayPositionerState } from '@aria-ui/overlay/elements'
11
11
  import { usePresence } from '@aria-ui/presence'
12
12
  import type { ReferenceElement } from '@floating-ui/dom'
13
13
  import type { Editor } from '@prosekit/core'
14
+ import type { Selection } from '@prosekit/pm/state'
14
15
 
15
16
  import { useEditorFocusChangeEvent } from '../../../hooks/use-editor-focus-event'
16
17
  import { useEditorUpdateEvent } from '../../../hooks/use-editor-update-event'
@@ -83,6 +84,8 @@ function useInlinePopoverReference(
83
84
  editorFocused = focus
84
85
  })
85
86
 
87
+ let prevSelection: Selection | undefined
88
+
86
89
  useEditorUpdateEvent(host, editor, (view) => {
87
90
  const isPopoverFocused = !editorFocused && host.contains(host.ownerDocument.activeElement)
88
91
 
@@ -90,6 +93,20 @@ function useInlinePopoverReference(
90
93
  return
91
94
  }
92
95
 
96
+ const { selection } = view.state
97
+ const selectionUnchanged = prevSelection?.eq(selection)
98
+ prevSelection = selection
99
+
100
+ // Skip reference update if only the document content has changed, not the
101
+ // selection itself.
102
+ //
103
+ // Example: If the user selects text and then applies mark bold using the
104
+ // popover, the selection may widen, but we don't want to reposition the
105
+ // popover.
106
+ if (selectionUnchanged) {
107
+ return
108
+ }
109
+
93
110
  reference.set(getVirtualSelectionElement(view) || null)
94
111
  })
95
112
 
@@ -116,11 +116,11 @@ function getTableDOMByPos(view: EditorView, pos: number): HTMLTableElement | und
116
116
  function getTargetFirstCellDOM(table: HTMLTableElement, index: number, direction: 'row' | 'col'): HTMLTableCellElement | undefined {
117
117
  if (direction === 'row') {
118
118
  const row = table.querySelectorAll('tr')[index]
119
- const cell = row?.querySelector('td')
119
+ const cell = row?.querySelector<HTMLTableCellElement>('td, th')
120
120
  return cell ?? undefined
121
121
  } else {
122
122
  const row = table.querySelector('tr')
123
- const cell = row?.querySelectorAll('td')[index]
123
+ const cell = row?.querySelectorAll<HTMLTableCellElement>('td, th')[index]
124
124
  return cell ?? undefined
125
125
  }
126
126
  }
@@ -56,7 +56,7 @@ export function createPreviewDOM(
56
56
  const [previewRow, previewRowStyle] = cloneElement(row)
57
57
  injectStyle(previewRoot, previewRowStyle)
58
58
  unsetSize(previewRow)
59
- const cells = row.querySelectorAll('td')
59
+ const cells = row.querySelectorAll('td, th')
60
60
  const cell = cells[index]
61
61
  if (cell) {
62
62
  const [previewCell, previewCellStyle] = deepCloneElement(cell)