@prosekit/web 0.7.4 → 0.7.5

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.
Files changed (31) hide show
  1. package/dist/{get-default-state-CIEy7xrl.js → get-default-state-BzBimBWi.js} +2 -2
  2. package/dist/{get-default-state-CIEy7xrl.js.map → get-default-state-BzBimBWi.js.map} +1 -1
  3. package/dist/{get-safe-editor-view-DENm4avv.js → get-safe-editor-view-Dt9Amrcn.js} +2 -2
  4. package/dist/{get-safe-editor-view-DENm4avv.js.map → get-safe-editor-view-Dt9Amrcn.js.map} +1 -1
  5. package/dist/{inject-style-BJQNFufI.js → inject-style-Dm6W58W3.js} +4 -6
  6. package/dist/{inject-style-BJQNFufI.js.map → inject-style-Dm6W58W3.js.map} +1 -1
  7. package/dist/prosekit-web-autocomplete.d.ts.map +1 -1
  8. package/dist/prosekit-web-autocomplete.js +5 -7
  9. package/dist/prosekit-web-autocomplete.js.map +1 -1
  10. package/dist/prosekit-web-block-handle.d.ts.map +1 -1
  11. package/dist/prosekit-web-block-handle.js +23 -19
  12. package/dist/prosekit-web-block-handle.js.map +1 -1
  13. package/dist/prosekit-web-drop-indicator.d.ts.map +1 -1
  14. package/dist/prosekit-web-drop-indicator.js +4 -5
  15. package/dist/prosekit-web-drop-indicator.js.map +1 -1
  16. package/dist/prosekit-web-inline-popover.d.ts.map +1 -1
  17. package/dist/prosekit-web-inline-popover.js +4 -7
  18. package/dist/prosekit-web-inline-popover.js.map +1 -1
  19. package/dist/prosekit-web-resizable.d.ts.map +1 -1
  20. package/dist/prosekit-web-resizable.js +3 -6
  21. package/dist/prosekit-web-resizable.js.map +1 -1
  22. package/dist/prosekit-web-table-handle.d.ts.map +1 -1
  23. package/dist/prosekit-web-table-handle.js +23 -36
  24. package/dist/prosekit-web-table-handle.js.map +1 -1
  25. package/dist/prosekit-web.d.ts +1 -1
  26. package/dist/{use-editor-extension-Cc7ZG7uj.js → use-editor-extension-B2WuUfnd.js} +2 -2
  27. package/dist/{use-editor-extension-Cc7ZG7uj.js.map → use-editor-extension-B2WuUfnd.js.map} +1 -1
  28. package/dist/{use-scrolling-BNfsQs3S.js → use-scrolling-BOvyjDvH.js} +2 -2
  29. package/dist/{use-scrolling-BNfsQs3S.js.map → use-scrolling-BOvyjDvH.js.map} +1 -1
  30. package/package.json +9 -9
  31. package/src/components/block-handle/block-handle-popover/pointer-move.ts +19 -0
@@ -8,5 +8,5 @@ function getStateWithDefaults(state, props) {
8
8
  }
9
9
 
10
10
  //#endregion
11
- export { getStateWithDefaults };
12
- //# sourceMappingURL=get-default-state-CIEy7xrl.js.map
11
+ export { getStateWithDefaults as t };
12
+ //# sourceMappingURL=get-default-state-BzBimBWi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-default-state-CIEy7xrl.js","names":[],"sources":["../src/utils/get-default-state.ts"],"sourcesContent":["import {\n createSignal,\n type PropDeclarations,\n type SignalState,\n} from '@aria-ui/core'\n\nexport function getStateWithDefaults<\n Props extends Record<string, any> = Record<string, any>,\n>(\n state: Partial<SignalState<Props>>,\n props: PropDeclarations<Props>,\n): SignalState<Props> {\n const merged = { ...state } as SignalState<Props>\n\n for (const key of Object.keys(props) as (keyof Props)[]) {\n if (!merged[key]) {\n merged[key] = createSignal(props[key].default)\n }\n }\n\n return merged\n}\n"],"mappings":";;;AAMA,SAAgB,qBAGd,OACA,OACoB;CACpB,MAAM,SAAS,EAAE,GAAG,OAAO;AAE3B,MAAK,MAAM,OAAO,OAAO,KAAK,MAAM,CAClC,KAAI,CAAC,OAAO,KACV,QAAO,OAAO,aAAa,MAAM,KAAK,QAAQ;AAIlD,QAAO"}
1
+ {"version":3,"file":"get-default-state-BzBimBWi.js","names":[],"sources":["../src/utils/get-default-state.ts"],"sourcesContent":["import {\n createSignal,\n type PropDeclarations,\n type SignalState,\n} from '@aria-ui/core'\n\nexport function getStateWithDefaults<\n Props extends Record<string, any> = Record<string, any>,\n>(\n state: Partial<SignalState<Props>>,\n props: PropDeclarations<Props>,\n): SignalState<Props> {\n const merged = { ...state } as SignalState<Props>\n\n for (const key of Object.keys(props) as (keyof Props)[]) {\n if (!merged[key]) {\n merged[key] = createSignal(props[key].default)\n }\n }\n\n return merged\n}\n"],"mappings":";;;AAMA,SAAgB,qBAGd,OACA,OACoB;CACpB,MAAM,SAAS,EAAE,GAAG,OAAO;AAE3B,MAAK,MAAM,OAAO,OAAO,KAAK,MAAM,CAClC,KAAI,CAAC,OAAO,KACV,QAAO,OAAO,aAAa,MAAM,KAAK,QAAQ;AAIlD,QAAO"}
@@ -8,5 +8,5 @@ function getSafeEditorView(editor) {
8
8
  }
9
9
 
10
10
  //#endregion
11
- export { getSafeEditorView };
12
- //# sourceMappingURL=get-safe-editor-view-DENm4avv.js.map
11
+ export { getSafeEditorView as t };
12
+ //# sourceMappingURL=get-safe-editor-view-Dt9Amrcn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-safe-editor-view-DENm4avv.js","names":[],"sources":["../src/utils/get-safe-editor-view.ts"],"sourcesContent":["import type { Editor } from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\n/**\n * @internal\n */\nexport function getSafeEditorView(editor?: Editor | null): EditorView | undefined {\n if (!editor || !editor.mounted) return\n return editor.view\n}\n"],"mappings":";;;;AAMA,SAAgB,kBAAkB,QAAgD;AAChF,KAAI,CAAC,UAAU,CAAC,OAAO,QAAS;AAChC,QAAO,OAAO"}
1
+ {"version":3,"file":"get-safe-editor-view-Dt9Amrcn.js","names":[],"sources":["../src/utils/get-safe-editor-view.ts"],"sourcesContent":["import type { Editor } from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\n/**\n * @internal\n */\nexport function getSafeEditorView(editor?: Editor | null): EditorView | undefined {\n if (!editor || !editor.mounted) return\n return editor.view\n}\n"],"mappings":";;;;AAMA,SAAgB,kBAAkB,QAAgD;AAChF,KAAI,CAAC,UAAU,CAAC,OAAO,QAAS;AAChC,QAAO,OAAO"}
@@ -7,8 +7,7 @@ import { getDocument, getId } from "@ocavue/utils";
7
7
  */
8
8
  function deepCloneElement(element, important = false) {
9
9
  const clonedElement = element.cloneNode(true);
10
- const style = deepCopyStyles(element, clonedElement, important);
11
- return [clonedElement, style];
10
+ return [clonedElement, deepCopyStyles(element, clonedElement, important)];
12
11
  }
13
12
  /**
14
13
  * Creates a clone of an Element, including all computed styles so that
@@ -16,8 +15,7 @@ function deepCloneElement(element, important = false) {
16
15
  */
17
16
  function cloneElement(element, important = false) {
18
17
  const clonedElement = element.cloneNode();
19
- const style = copyStyles(element, clonedElement, important);
20
- return [clonedElement, style];
18
+ return [clonedElement, copyStyles(element, clonedElement, important)];
21
19
  }
22
20
  function deepCopyStyles(source, target, important) {
23
21
  const sources = [source];
@@ -74,5 +72,5 @@ function injectStyle(container, styleText) {
74
72
  }
75
73
 
76
74
  //#endregion
77
- export { cloneElement, deepCloneElement, injectStyle };
78
- //# sourceMappingURL=inject-style-BJQNFufI.js.map
75
+ export { cloneElement as n, deepCloneElement as r, injectStyle as t };
76
+ //# sourceMappingURL=inject-style-Dm6W58W3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inject-style-BJQNFufI.js","names":["styles: string[]","source","target","cssProps: string[]"],"sources":["../src/utils/clone-element.ts","../src/utils/inject-style.ts"],"sourcesContent":["import { getId } from '@ocavue/utils'\n\n/**\n * Creates a deep clone of an Element, including all computed styles so that\n * it looks almost exactly the same as the original element.\n */\nexport function deepCloneElement<T extends Element>(element: T, important = false): [T, string] {\n const clonedElement = element.cloneNode(true) as T\n const style = deepCopyStyles(element, clonedElement, important)\n return [clonedElement, style]\n}\n\n/**\n * Creates a clone of an Element, including all computed styles so that\n * it looks similar enough to the original element.\n */\nexport function cloneElement<T extends Element>(element: T, important = false): [T, string] {\n const clonedElement = element.cloneNode() as T\n const style = copyStyles(element, clonedElement, important)\n return [clonedElement, style]\n}\n\nfunction deepCopyStyles(source: Element, target: Element, important: boolean): string {\n const sources = [source]\n const targets = [target]\n const styles: string[] = []\n\n while (sources.length > 0 && sources.length === targets.length) {\n const source = sources.pop()\n const target = targets.pop()\n\n if (!source || !target) {\n break\n }\n\n const style = copyStyles(source, target, important)\n if (style) {\n styles.push(style)\n }\n\n sources.push(...source.children)\n targets.push(...target.children)\n }\n\n return styles.join('\\n')\n}\n\nfunction copyStyles(source: Element, target: Element, important: boolean): string {\n if (!source || !target) {\n return ''\n }\n\n const view = source.ownerDocument?.defaultView\n if (!view) {\n return ''\n }\n\n // Known issue: pseudo styles are not copied.\n const sourceStyle = view.getComputedStyle(source)\n const targetStyle = (target as HTMLElement | SVGElement | MathMLElement).style\n\n if (!sourceStyle || !targetStyle) {\n return ''\n }\n\n for (const key of sourceStyle) {\n targetStyle.setProperty(\n key,\n sourceStyle.getPropertyValue(key),\n // Enforce important to avoid the style being overridden when the element\n // is connected to the page.\n // See https://github.com/prosekit/prosekit/issues/1185 for more details.\n important ? 'important' : (sourceStyle.getPropertyPriority(key) || ''),\n )\n }\n\n const styles: string[] = []\n for (const pseudoSelector of [':before', ':after']) {\n const sourcePseudoStyle = view.getComputedStyle(source, pseudoSelector)\n const targetPseudoStyle = view.getComputedStyle(target, pseudoSelector)\n\n if (!sourcePseudoStyle) {\n continue\n }\n\n const content = sourcePseudoStyle.getPropertyValue('content')\n const hasPseudoElement = content && content !== 'none' && content !== 'normal'\n\n if (!hasPseudoElement) {\n continue\n }\n\n const cssProps: string[] = []\n for (const property of sourcePseudoStyle) {\n const sourceValue = sourcePseudoStyle.getPropertyValue(property)\n const sourcePriority = sourcePseudoStyle.getPropertyPriority(property)\n const targetValue = targetPseudoStyle.getPropertyValue(property)\n const targetPriority = targetPseudoStyle.getPropertyPriority(property)\n if (sourceValue !== targetValue || sourcePriority !== targetPriority) {\n cssProps.push(`${property}: ${sourceValue}${sourcePriority ? ' !important' : ''};`)\n }\n }\n\n const uniqueClassName = `clone-pseudo-element-${getId()}`\n target.classList.add(uniqueClassName)\n styles.push(`.${uniqueClassName}${pseudoSelector} { ${cssProps.join(' ')} }`)\n }\n\n return styles.join('\\n')\n}\n","import { getDocument } from '@ocavue/utils'\n\nexport function injectStyle(container: HTMLElement, styleText: string): void {\n if (!styleText) {\n return\n }\n const document = getDocument(container)\n const style = document.createElement('style')\n style.textContent = styleText\n container.appendChild(style)\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,iBAAoC,SAAY,YAAY,OAAoB;CAC9F,MAAM,gBAAgB,QAAQ,UAAU,KAAK;CAC7C,MAAM,QAAQ,eAAe,SAAS,eAAe,UAAU;AAC/D,QAAO,CAAC,eAAe,MAAM;;;;;;AAO/B,SAAgB,aAAgC,SAAY,YAAY,OAAoB;CAC1F,MAAM,gBAAgB,QAAQ,WAAW;CACzC,MAAM,QAAQ,WAAW,SAAS,eAAe,UAAU;AAC3D,QAAO,CAAC,eAAe,MAAM;;AAG/B,SAAS,eAAe,QAAiB,QAAiB,WAA4B;CACpF,MAAM,UAAU,CAAC,OAAO;CACxB,MAAM,UAAU,CAAC,OAAO;CACxB,MAAMA,SAAmB,EAAE;AAE3B,QAAO,QAAQ,SAAS,KAAK,QAAQ,WAAW,QAAQ,QAAQ;EAC9D,MAAMC,WAAS,QAAQ,KAAK;EAC5B,MAAMC,WAAS,QAAQ,KAAK;AAE5B,MAAI,CAACD,YAAU,CAACC,SACd;EAGF,MAAM,QAAQ,WAAWD,UAAQC,UAAQ,UAAU;AACnD,MAAI,MACF,QAAO,KAAK,MAAM;AAGpB,UAAQ,KAAK,GAAGD,SAAO,SAAS;AAChC,UAAQ,KAAK,GAAGC,SAAO,SAAS;;AAGlC,QAAO,OAAO,KAAK,KAAK;;AAG1B,SAAS,WAAW,QAAiB,QAAiB,WAA4B;AAChF,KAAI,CAAC,UAAU,CAAC,OACd,QAAO;CAGT,MAAM,OAAO,OAAO,eAAe;AACnC,KAAI,CAAC,KACH,QAAO;CAIT,MAAM,cAAc,KAAK,iBAAiB,OAAO;CACjD,MAAM,cAAe,OAAoD;AAEzE,KAAI,CAAC,eAAe,CAAC,YACnB,QAAO;AAGT,MAAK,MAAM,OAAO,YAChB,aAAY,YACV,KACA,YAAY,iBAAiB,IAAI,EAIjC,YAAY,cAAe,YAAY,oBAAoB,IAAI,IAAI,GACpE;CAGH,MAAMF,SAAmB,EAAE;AAC3B,MAAK,MAAM,kBAAkB,CAAC,WAAW,SAAS,EAAE;EAClD,MAAM,oBAAoB,KAAK,iBAAiB,QAAQ,eAAe;EACvE,MAAM,oBAAoB,KAAK,iBAAiB,QAAQ,eAAe;AAEvE,MAAI,CAAC,kBACH;EAGF,MAAM,UAAU,kBAAkB,iBAAiB,UAAU;AAG7D,MAAI,EAFqB,WAAW,YAAY,UAAU,YAAY,UAGpE;EAGF,MAAMG,WAAqB,EAAE;AAC7B,OAAK,MAAM,YAAY,mBAAmB;GACxC,MAAM,cAAc,kBAAkB,iBAAiB,SAAS;GAChE,MAAM,iBAAiB,kBAAkB,oBAAoB,SAAS;GACtE,MAAM,cAAc,kBAAkB,iBAAiB,SAAS;GAChE,MAAM,iBAAiB,kBAAkB,oBAAoB,SAAS;AACtE,OAAI,gBAAgB,eAAe,mBAAmB,eACpD,UAAS,KAAK,GAAG,SAAS,IAAI,cAAc,iBAAiB,gBAAgB,GAAG,GAAG;;EAIvF,MAAM,kBAAkB,wBAAwB,OAAO;AACvD,SAAO,UAAU,IAAI,gBAAgB;AACrC,SAAO,KAAK,IAAI,kBAAkB,eAAe,KAAK,SAAS,KAAK,IAAI,CAAC,IAAI;;AAG/E,QAAO,OAAO,KAAK,KAAK;;;;;AC1G1B,SAAgB,YAAY,WAAwB,WAAyB;AAC3E,KAAI,CAAC,UACH;CAGF,MAAM,QADW,YAAY,UAAU,CAChB,cAAc,QAAQ;AAC7C,OAAM,cAAc;AACpB,WAAU,YAAY,MAAM"}
1
+ {"version":3,"file":"inject-style-Dm6W58W3.js","names":["styles: string[]","source","target","cssProps: string[]"],"sources":["../src/utils/clone-element.ts","../src/utils/inject-style.ts"],"sourcesContent":["import { getId } from '@ocavue/utils'\n\n/**\n * Creates a deep clone of an Element, including all computed styles so that\n * it looks almost exactly the same as the original element.\n */\nexport function deepCloneElement<T extends Element>(element: T, important = false): [T, string] {\n const clonedElement = element.cloneNode(true) as T\n const style = deepCopyStyles(element, clonedElement, important)\n return [clonedElement, style]\n}\n\n/**\n * Creates a clone of an Element, including all computed styles so that\n * it looks similar enough to the original element.\n */\nexport function cloneElement<T extends Element>(element: T, important = false): [T, string] {\n const clonedElement = element.cloneNode() as T\n const style = copyStyles(element, clonedElement, important)\n return [clonedElement, style]\n}\n\nfunction deepCopyStyles(source: Element, target: Element, important: boolean): string {\n const sources = [source]\n const targets = [target]\n const styles: string[] = []\n\n while (sources.length > 0 && sources.length === targets.length) {\n const source = sources.pop()\n const target = targets.pop()\n\n if (!source || !target) {\n break\n }\n\n const style = copyStyles(source, target, important)\n if (style) {\n styles.push(style)\n }\n\n sources.push(...source.children)\n targets.push(...target.children)\n }\n\n return styles.join('\\n')\n}\n\nfunction copyStyles(source: Element, target: Element, important: boolean): string {\n if (!source || !target) {\n return ''\n }\n\n const view = source.ownerDocument?.defaultView\n if (!view) {\n return ''\n }\n\n // Known issue: pseudo styles are not copied.\n const sourceStyle = view.getComputedStyle(source)\n const targetStyle = (target as HTMLElement | SVGElement | MathMLElement).style\n\n if (!sourceStyle || !targetStyle) {\n return ''\n }\n\n for (const key of sourceStyle) {\n targetStyle.setProperty(\n key,\n sourceStyle.getPropertyValue(key),\n // Enforce important to avoid the style being overridden when the element\n // is connected to the page.\n // See https://github.com/prosekit/prosekit/issues/1185 for more details.\n important ? 'important' : (sourceStyle.getPropertyPriority(key) || ''),\n )\n }\n\n const styles: string[] = []\n for (const pseudoSelector of [':before', ':after']) {\n const sourcePseudoStyle = view.getComputedStyle(source, pseudoSelector)\n const targetPseudoStyle = view.getComputedStyle(target, pseudoSelector)\n\n if (!sourcePseudoStyle) {\n continue\n }\n\n const content = sourcePseudoStyle.getPropertyValue('content')\n const hasPseudoElement = content && content !== 'none' && content !== 'normal'\n\n if (!hasPseudoElement) {\n continue\n }\n\n const cssProps: string[] = []\n for (const property of sourcePseudoStyle) {\n const sourceValue = sourcePseudoStyle.getPropertyValue(property)\n const sourcePriority = sourcePseudoStyle.getPropertyPriority(property)\n const targetValue = targetPseudoStyle.getPropertyValue(property)\n const targetPriority = targetPseudoStyle.getPropertyPriority(property)\n if (sourceValue !== targetValue || sourcePriority !== targetPriority) {\n cssProps.push(`${property}: ${sourceValue}${sourcePriority ? ' !important' : ''};`)\n }\n }\n\n const uniqueClassName = `clone-pseudo-element-${getId()}`\n target.classList.add(uniqueClassName)\n styles.push(`.${uniqueClassName}${pseudoSelector} { ${cssProps.join(' ')} }`)\n }\n\n return styles.join('\\n')\n}\n","import { getDocument } from '@ocavue/utils'\n\nexport function injectStyle(container: HTMLElement, styleText: string): void {\n if (!styleText) {\n return\n }\n const document = getDocument(container)\n const style = document.createElement('style')\n style.textContent = styleText\n container.appendChild(style)\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,iBAAoC,SAAY,YAAY,OAAoB;CAC9F,MAAM,gBAAgB,QAAQ,UAAU,KAAK;AAE7C,QAAO,CAAC,eADM,eAAe,SAAS,eAAe,UAAU,CAClC;;;;;;AAO/B,SAAgB,aAAgC,SAAY,YAAY,OAAoB;CAC1F,MAAM,gBAAgB,QAAQ,WAAW;AAEzC,QAAO,CAAC,eADM,WAAW,SAAS,eAAe,UAAU,CAC9B;;AAG/B,SAAS,eAAe,QAAiB,QAAiB,WAA4B;CACpF,MAAM,UAAU,CAAC,OAAO;CACxB,MAAM,UAAU,CAAC,OAAO;CACxB,MAAMA,SAAmB,EAAE;AAE3B,QAAO,QAAQ,SAAS,KAAK,QAAQ,WAAW,QAAQ,QAAQ;EAC9D,MAAMC,WAAS,QAAQ,KAAK;EAC5B,MAAMC,WAAS,QAAQ,KAAK;AAE5B,MAAI,CAACD,YAAU,CAACC,SACd;EAGF,MAAM,QAAQ,WAAWD,UAAQC,UAAQ,UAAU;AACnD,MA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,eAAe,KAAK,SAAS,KAAK,IAAI,CAAC,IAAI;;AAG/E,QAAO,OAAO,KAAK,KAAK;;;;;AC1G1B,SAAgB,YAAY,WAAwB,WAAyB;AAC3E,KAAI,CAAC,UACH;CAGF,MAAM,QADW,YAAY,UAAU,CAChB,cAAc,QAAQ;AAC7C,OAAM,cAAc;AACpB,WAAU,YAAY,MAAM"}
@@ -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;;AAAsD,cAMzC,uBANyC,EAMhB,iBANgB,CAME,uBANF,CAAA;;;cCJhD,8BAA8B,uBAAuB;cAQrD,wBAAA,SAAiC,4BAAA;;;;;;cCR1B,6BAA6B;;;UCIzB,qBAAA;;;;;AHHjB;AAGA;;OAAsD,EAAA,MAAA;;;AAGrC,cGSJ,qBHT2B,EGSJ,gBHTI,CGSa,qBHTb,CAAA;AAG3B,UGYI,sBAAA,SAA+B,iBHZqC,CAAA;;AAA/C,cGezB,sBHfyB,EGeD,iBHfC,CGeiB,sBHfjB,CAAA;;;cIVhC,6BAA6B,uBAAuB;cAQpD,uBAAA,SAAgC,2BAAA;;;;;;iBCKtB,mBAAA,UACL;;;GACQ,aAAa,uBAAuB;;;UCRtC,qBAAA,SAA8B,KAAK;;;;ANNpD;AAGA;;QAAsD,EMU5C,MNV4C,GAAA,IAAA;;AAAD,cMaxC,qBNbwC,EMajB,gBNbiB,CMaA,qBNbA,CAAA;AAGpC,UMeA,sBAAA,SAA+B,aNfR,CAAA,CAGxC;AAAqF,cMcxE,sBNdwE,EMchD,iBNdgD,CMc9B,sBNd8B,CAAA;;;cOV/E,6BAA6B,uBAAuB;cAQpD,uBAAA,SAAgC,2BAAA;;;;;;iBCsBtB,mBAAA,UACL;;;GACQ,aAAa,uBAAuB;;;UCzBtC,wBAAA,SAAiC;;;;ATNlD;AAGA;;QAAsD,ESU5C,MTV4C,GAAA,IAAA;;;AAGtD;AAGA;;OAAwD,ESW/C,MTX+C,GAAA,IAAA;;;;;;ECVlD,SAAA,EQ4BO,sBRrBX,CAAA,WAAA,CAAA;EAAA;;;;AAPwD;UQmChD;;;APnCV;UOwCU;;;ANpCV;EAYa,KAAA,EM6BJ,sBNzBR,CAAA,OAAA,CAAA;EAAA;;;EAJmD,WAAA,EMkCrC,sBNlCqC,CAAA,aAAA,CAAA;EAMnC;AAGjB;;UAAuD,EM8B3C,sBN9B2C,CAAA,UAAA,CAAA;;;;mBMmCpC;;AL9D6G;AAS9H,cK4DW,wBL5DX,EK4DqC,gBL5DrC,CK4DsD,wBL5DtD,CAAA;AAPwD,UKgFzC,yBAAA,SAAkC,uBLhFO,CAAA;;;AAAD;cKoF3C;;;AJvEd;EAAmC,WAAA,EI4EpB,WJ5EoB,CAAA,MAAA,CAAA;;;AAExB,cI8EE,yBJ9EF,EI8E6B,iBJ9E7B,CI8E+C,yBJ9E/C,CAAA;;;cKfL,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","../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,sBLhBkB,EKgBM,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,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"}
@@ -1,6 +1,6 @@
1
- import { getStateWithDefaults } from "./get-default-state-CIEy7xrl.js";
2
- import { useEditorExtension } from "./use-editor-extension-Cc7ZG7uj.js";
3
- import { getSafeEditorView } from "./get-safe-editor-view-DENm4avv.js";
1
+ import { t as getStateWithDefaults } from "./get-default-state-BzBimBWi.js";
2
+ import { t as useEditorExtension } from "./use-editor-extension-B2WuUfnd.js";
3
+ import { t as getSafeEditorView } from "./get-safe-editor-view-Dt9Amrcn.js";
4
4
  import { createComputed, createContext, createSignal, defineCustomElement, registerCustomElement, useAnimationFrame, useAttribute, useEffect, useEventListener } from "@aria-ui/core";
5
5
  import { listboxProps, useListbox, useListboxEmpty, useListboxItem } from "@aria-ui/listbox/elements";
6
6
  import { listboxEvents, listboxItemEvents, listboxProps as listboxProps$1 } from "@aria-ui/listbox";
@@ -221,8 +221,7 @@ function useAutocompleteExtension(host, editor, regex, reference, query, onDismi
221
221
  const editorValue = editor.get();
222
222
  const regexValue = regex.get();
223
223
  if (!editorValue || !regexValue) return;
224
- const rule = createAutocompleteRule(editorValue, regexValue, reference, query, onDismiss, onSubmit);
225
- const extension = defineAutocomplete(rule);
224
+ const extension = defineAutocomplete(createAutocompleteRule(editorValue, regexValue, reference, query, onDismiss, onSubmit));
226
225
  return editorValue.use(extension);
227
226
  });
228
227
  }
@@ -254,8 +253,7 @@ function createKeymapHandler(handler, enabled) {
254
253
  };
255
254
  }
256
255
  function useEscapeKeydown(host, editor, handler) {
257
- const extension = withPriority(defineKeymap({ Escape: handler }), Priority.highest);
258
- useEditorExtension(host, editor, extension);
256
+ useEditorExtension(host, editor, withPriority(defineKeymap({ Escape: handler }), Priority.highest));
259
257
  }
260
258
 
261
259
  //#endregion
@@ -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,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,g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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('.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,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,eAAe,GAAG;GAE5C;AAEF,kBAAiB,SAAS,gBAAgB,UAAU;AAElD,QAAM,gBAAgB;GACtB;;;;;;ACfJ,MAAaC,wBAAiE,EAC5E,OAAO,EACL,SAAS,IACV,EACF;;AAKD,MAAaC,yBAAoE;;;;ACzBjF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,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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AA0B,kBAAkB;;;cC3EnD,+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,7 +1,7 @@
1
- import { useEditorExtension } from "./use-editor-extension-Cc7ZG7uj.js";
2
- import { getSafeEditorView } from "./get-safe-editor-view-DENm4avv.js";
3
- import { assignStyles, useScrolling } from "./use-scrolling-BNfsQs3S.js";
4
- import { deepCloneElement, injectStyle } from "./inject-style-BJQNFufI.js";
1
+ import { t as useEditorExtension } from "./use-editor-extension-B2WuUfnd.js";
2
+ import { t as getSafeEditorView } from "./get-safe-editor-view-Dt9Amrcn.js";
3
+ import { n as assignStyles, t as useScrolling } from "./use-scrolling-BOvyjDvH.js";
4
+ import { r as deepCloneElement, t as injectStyle } from "./inject-style-Dm6W58W3.js";
5
5
  import { createComputed, createContext, createSignal, defineCustomElement, registerCustomElement, useAttribute, useEffect, useEventListener } from "@aria-ui/core";
6
6
  import { defineDOMEventHandler, insertDefaultBlock, union } from "@prosekit/core";
7
7
  import { overlayPositionerEvents, overlayPositionerProps, useOverlayPositionerState } from "@aria-ui/overlay/elements";
@@ -265,8 +265,18 @@ function defineElementHoverHandler(handler) {
265
265
  pos
266
266
  });
267
267
  };
268
+ let lastX = -1;
269
+ let lastY = -1;
270
+ let lastTime = -1;
268
271
  const handlePointerEvent = (view, event) => {
269
272
  const { x, y } = event;
273
+ if (lastX === x && lastY === y) {
274
+ const now = Date.now();
275
+ if (now - lastTime < 100) return;
276
+ lastTime = now;
277
+ }
278
+ lastX = x;
279
+ lastY = y;
270
280
  const block = findBlockByCoords(view, x, y);
271
281
  if (!block) {
272
282
  handler(null, null);
@@ -282,15 +292,13 @@ function defineElementHoverHandler(handler) {
282
292
  if ($pos.depth > 0 && $pos.index($pos.depth) === 0) {
283
293
  const parentPos = $pos.before($pos.depth);
284
294
  const parentNode = $pos.parent;
285
- const parentElement = view.nodeDOM(parentPos);
286
- handleElement(parentNode, parentPos, element, parentElement);
295
+ handleElement(parentNode, parentPos, element, view.nodeDOM(parentPos));
287
296
  } else handleElement(node, pos, element);
288
297
  };
289
- return union(defineDOMEventHandler("pointermove", throttle(handlePointerEvent, 200)), defineDOMEventHandler("pointerout", handlePointerEvent), defineDOMEventHandler("keypress", () => handler(null, null)));
298
+ return union(defineDOMEventHandler("pointermove", throttle(handlePointerEvent, 200)), defineDOMEventHandler("pointerenter", handlePointerEvent), defineDOMEventHandler("pointerout", handlePointerEvent), defineDOMEventHandler("keypress", () => handler(null, null)));
290
299
  }
291
300
  function findBlockByCoords(view, x, y) {
292
- const rect = getClientRect(view.dom);
293
- if (!isWithinRect(rect, x, y)) return;
301
+ if (!isWithinRect(getClientRect(view.dom), x, y)) return;
294
302
  let parent = view.state.doc;
295
303
  let pos = -1;
296
304
  while (parent) {
@@ -308,8 +316,7 @@ function findBlockByCoords(view, x, y) {
308
316
  let hi = children.length - 1;
309
317
  while (lo <= hi) {
310
318
  const i = hi - (hi - lo >> 1);
311
- const childDOM = view.nodeDOM(positions[i]);
312
- const childRect = getNodeRect(childDOM);
319
+ const childRect = getNodeRect(view.nodeDOM(positions[i]));
313
320
  if (!childRect) {
314
321
  console.warn(`[prosekit] Unable to get rect at position: ${positions[i]}`);
315
322
  return;
@@ -390,10 +397,9 @@ function findFirstLineRectInElement(element) {
390
397
  const paddingTop = style && Number.parseInt(style.paddingTop, 10) || 0;
391
398
  const borderTop = style && Number.parseInt(style.borderTopWidth, 10) || 0;
392
399
  const top = rect.top + paddingTop + borderTop;
393
- const bottom = top + lineHeight;
394
400
  return {
395
401
  top,
396
- bottom,
402
+ bottom: top + lineHeight,
397
403
  left,
398
404
  right
399
405
  };
@@ -441,23 +447,21 @@ function useBlockHandlePopover(host, { state, emit }) {
441
447
  useHoverExtension(host, editor, (referenceValue, hoverState) => {
442
448
  reference.set(referenceValue);
443
449
  context.set(hoverState);
444
- const stateChangeDetails = hoverState ? {
450
+ emit("stateChange", hoverState ? {
445
451
  node: hoverState.node,
446
452
  pos: hoverState.pos
447
- } : null;
448
- emit("stateChange", stateChangeDetails);
453
+ } : null);
449
454
  });
450
455
  useAttribute(host, "data-state", () => open.get() ? "open" : "closed");
451
456
  usePresence(host, open);
452
457
  }
453
458
  function useHoverExtension(host, editor, handler) {
454
459
  let prevHoverState = null;
455
- const extension = defineElementHoverHandler((reference, hoverState) => {
460
+ useEditorExtension(host, editor, defineElementHoverHandler((reference, hoverState) => {
456
461
  if (isHoverStateEqual(prevHoverState, hoverState)) return;
457
462
  prevHoverState = hoverState;
458
463
  handler(reference, hoverState);
459
- });
460
- useEditorExtension(host, editor, extension);
464
+ }));
461
465
  }
462
466
  function isHoverStateEqual(a, b) {
463
467
  if (!a && !b) return true;
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-web-block-handle.js","names":["blockPopoverContext: Context<BlockPopoverContext>","draggingContext: Context<boolean>","blockHandleAddProps: PropDeclarations<BlockHandleAddProps>","blockHandleAddEvents: EventDeclarations<BlockHandleAddEvents>","BlockHandleAddElementBase: BaseElementConstructor<BlockHandleAddProps>","blockHandleDraggableProps: PropDeclarations<BlockHandleDraggableProps>","blockHandleDraggableEvents: EventDeclarations<BlockHandleDraggableEvents>","BlockHandleDraggableElementBase: BaseElementConstructor<BlockHandleDraggableProps>","parent: ProseMirrorNode | undefined","children: ProseMirrorNode[]","positions: number[]","prevHoverState: HoverState | null","blockHandlePopoverProps: PropDeclarations<BlockHandlePopoverProps>","blockHandlePopoverEvents: EventDeclarations<BlockHandlePopoverEvents>","BlockHandlePopoverElementBase: BaseElementConstructor<BlockHandlePopoverProps>"],"sources":["../src/components/block-handle/context.ts","../src/components/block-handle/block-handle-add/setup.ts","../src/components/block-handle/block-handle-add/types.ts","../src/components/block-handle/block-handle-add/element.gen.ts","../src/utils/get-box-element.ts","../src/utils/get-client-rect.ts","../src/utils/max-z-index.ts","../src/components/block-handle/block-handle-draggable/set-drag-preview.ts","../src/components/block-handle/block-handle-draggable/setup.ts","../src/components/block-handle/block-handle-draggable/types.ts","../src/components/block-handle/block-handle-draggable/element.gen.ts","../src/utils/throttle.ts","../src/components/block-handle/block-handle-popover/pointer-move.ts","../src/components/block-handle/block-handle-popover/setup.ts","../src/components/block-handle/block-handle-popover/types.ts","../src/components/block-handle/block-handle-popover/element.gen.ts"],"sourcesContent":["import {\n createContext,\n type Context,\n} from '@aria-ui/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport interface HoverState {\n node: ProseMirrorNode\n pos: number\n}\n\n/**\n * @internal\n */\nexport type BlockPopoverContext = HoverState | null\n\n/**\n * @internal\n */\nexport const blockPopoverContext: Context<BlockPopoverContext> = createContext(\n 'prosekit-block-popover-context',\n null,\n)\n\n/**\n * @internal\n */\nexport const draggingContext: Context<boolean> = createContext(\n 'prosekit-block-handle-dragging-context',\n false,\n)\n","import {\n useEventListener,\n type ConnectableElement,\n type SignalState,\n} from '@aria-ui/core'\nimport { insertDefaultBlock } from '@prosekit/core'\n\nimport { blockPopoverContext } from '../context'\n\nimport type { BlockHandleAddProps } from './types'\n\n/**\n * @internal\n */\nexport function useBlockHandleAdd(\n host: ConnectableElement,\n { state }: { state: SignalState<BlockHandleAddProps> },\n): void {\n const context = blockPopoverContext.consume(host)\n\n useEventListener(host, 'pointerdown', (event) => {\n event.preventDefault()\n\n const editor = state.editor.get()\n const hoverState = context.get()\n if (!editor || !hoverState) {\n return\n }\n\n const { node, pos } = hoverState\n editor.exec(insertDefaultBlock({ pos: pos + node.nodeSize }))\n editor.focus()\n\n // Hide the drag handle\n context.set(null)\n })\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nexport interface BlockHandleAddProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const blockHandleAddProps: PropDeclarations<BlockHandleAddProps> = {\n editor: { default: null },\n}\n\n/** @internal */\nexport interface BlockHandleAddEvents {}\n\n/** @internal */\nexport const blockHandleAddEvents: EventDeclarations<BlockHandleAddEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useBlockHandleAdd } from \"./setup\"\nimport { blockHandleAddEvents, blockHandleAddProps, type BlockHandleAddEvents, type BlockHandleAddProps } from \"./types\"\n\nconst BlockHandleAddElementBase: BaseElementConstructor<BlockHandleAddProps> = defineCustomElement<\n BlockHandleAddProps,\n BlockHandleAddEvents\n>({\n props: blockHandleAddProps,\n events: blockHandleAddEvents,\n setup: useBlockHandleAdd,\n})\nclass BlockHandleAddElement extends BlockHandleAddElementBase {}\n\nregisterCustomElement('prosekit-block-handle-add', BlockHandleAddElement)\n \nexport { BlockHandleAddElement }\n","/**\n * Returns the element that has a box.\n */\nexport function getBoxElement(element: Element): Element | null | undefined {\n const window = element.ownerDocument.defaultView\n if (!window) {\n return\n }\n\n const style = window.getComputedStyle(element)\n const display = style.display\n\n if (display === 'contents' && element.childElementCount === 1) {\n return element.firstElementChild\n } else if (display === 'none') {\n return\n }\n\n return element\n}\n","/**\n * Similar to `element.getBoundingClientRect`, but handles `display: contents` elements.\n */\nexport function getClientRect(element: Element): {\n top: number\n right: number\n bottom: number\n left: number\n} {\n const rect = element.getBoundingClientRect()\n if (rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0) {\n // Suspiciously rect, probably an element with `display: contents`, in\n // which case `element.getClientRects()` will return an empty array.\n if (element.getClientRects().length === 0) {\n const children = Array.from(element.children)\n const rects = children.map(child => getClientRect(child))\n if (rects.length === 0) {\n return rect\n }\n if (rects.length === 1) {\n return rects[0]\n }\n let { top, bottom, left, right } = rects[0]\n for (let i = 1; i < rects.length; i++) {\n const r = rects[i]\n if (r.top < top) top = r.top\n if (r.bottom > bottom) bottom = r.bottom\n if (r.left < left) left = r.left\n if (r.right > right) right = r.right\n }\n return { top, bottom, left, right }\n }\n }\n return rect\n}\n","// Maximum possible z-index\n// https://stackoverflow.com/questions/491052/minimum-and-maximum-value-of-z-index\nexport const maxZIndex = '2147483647'\n","import { assignStyles } from '../../../utils/assign-styles'\nimport { deepCloneElement } from '../../../utils/clone-element'\nimport { getClientRect } from '../../../utils/get-client-rect'\nimport { injectStyle } from '../../../utils/inject-style'\nimport { maxZIndex } from '../../../utils/max-z-index'\n\n/**\n * Sets a drag preview image for the given element and ensures the preview position\n * relative to the pointer is correct.\n *\n * This function does the following:\n *\n * - Creates a temporary container element.\n * - Puts the container at the end of the document body.\n * - Sets event's drag image.\n * - Removes the container from the document body after the next frame.\n */\nexport function setDragPreview(event: DragEvent, element: HTMLElement): void {\n const { top, bottom, left, right } = getClientRect(element)\n const width = right - left\n const height = bottom - top\n const elementX = left\n const elementY = top\n\n const { clientX, clientY } = event\n\n const document = element.ownerDocument\n\n const container = document.createElement('div')\n\n // If outsideX is positive, the point is at the left side of the element.\n const outsideX = Math.round(elementX - clientX)\n // If outsideY is positive, the point is above the element.\n const outsideY = Math.round(elementY - clientY)\n\n const borderX = Math.max(outsideX, 0)\n const borderY = Math.max(outsideY, 0)\n assignStyles(container, {\n // Ensuring we don't cause reflow when adding the element to the page using\n // `position:fixed` rather than `position:absolute` so we are positioned on\n // the current viewport. `position:fixed` also creates a new stacking\n // context, so we don't need to do that here.\n // https://github.com/atlassian/pragmatic-drag-and-drop/blob/56276552/packages/core/src/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.ts#L60\n position: 'fixed',\n\n // The element is positioned off-screen to avoid capturing the content of\n // the page on Safari when the dragging element has a transparent background\n // on Safari. See https://github.com/prosekit/prosekit/issues/1153 for more\n // details.\n top: '-1000vh',\n left: '-1000vw',\n\n // The element should not be interactive.\n pointerEvents: 'none',\n\n zIndex: maxZIndex,\n\n // Only reliable cross browser technique found to push a drag preview away\n // from the cursor is to use transparent borders on the container.\n // https://github.com/atlassian/pragmatic-drag-and-drop/blob/56276552/packages/core/src/public-utils/element/custom-native-drag-preview/pointer-outside-of-preview.ts#L13-L18\n borderLeft: `${borderX}px solid transparent`,\n borderTop: `${borderY}px solid transparent`,\n\n boxSizing: 'border-box',\n width: `${width + borderX}px`,\n height: `${height + borderY}px`,\n })\n\n const [clonedElement, styleText] = deepCloneElement(element, true)\n\n // A hardcoded opacity.\n clonedElement.style.setProperty('opacity', '0.5', 'important')\n // The bounding client rect doesn't include the margin, so we need to remove\n // the margin too from the cloned element so that it can fit the container.\n clonedElement.style.setProperty('margin', '0', 'important')\n // Hide the outline of the cloned element.\n clonedElement.style.setProperty('outline-color', 'transparent', 'important')\n\n document.body.appendChild(container)\n container.appendChild(clonedElement)\n injectStyle(container, styleText)\n\n event.dataTransfer?.setDragImage(container, Math.max(-outsideX, 0), Math.max(-outsideY, 0))\n\n requestAnimationFrame(() => {\n container.remove()\n })\n}\n","import {\n useAttribute,\n useEffect,\n useEventListener,\n type ConnectableElement,\n type ReadonlySignal,\n type SignalState,\n} from '@aria-ui/core'\nimport { isHTMLElement } from '@ocavue/utils'\nimport type { Editor } from '@prosekit/core'\nimport type { ViewDragging } from '@prosekit/extensions/drop-indicator'\nimport {\n Fragment,\n Slice,\n} from '@prosekit/pm/model'\nimport { NodeSelection } from '@prosekit/pm/state'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { getBoxElement } from '../../../utils/get-box-element'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport {\n blockPopoverContext,\n draggingContext,\n type BlockPopoverContext,\n type HoverState,\n} from '../context'\n\nimport { setDragPreview } from './set-drag-preview'\nimport type { BlockHandleDraggableProps } from './types'\n\n/**\n * @internal\n */\nexport function useBlockHandleDraggable(\n host: ConnectableElement,\n { state }: { state: SignalState<BlockHandleDraggableProps> },\n): void {\n const context = blockPopoverContext.consume(host)\n const dragging = draggingContext.consume(host)\n\n useEffect(host, () => {\n host.draggable = true\n })\n\n usePointerDownHandler(host, context, state.editor)\n\n useEventListener(host, 'dragstart', (event) => {\n dragging.set(true)\n\n const view = getSafeEditorView(state.editor.get())\n const hoverState = context.get()\n\n if (view && hoverState) {\n view.dom.classList.add('prosekit-dragging')\n createDraggingPreview(view, hoverState, event)\n setViewDragging(view, hoverState)\n }\n })\n\n useEventListener(host, 'dragend', () => {\n dragging.set(false)\n\n const view = getSafeEditorView(state.editor.get())\n if (view) {\n view.dom.classList.remove('prosekit-dragging')\n }\n })\n\n useAttribute(host, 'data-dragging', () => (dragging.get() ? '' : undefined))\n}\n\nfunction usePointerDownHandler(\n host: ConnectableElement,\n context: ReadonlySignal<BlockPopoverContext>,\n editor: ReadonlySignal<Editor | null>,\n) {\n useEventListener(host, 'pointerdown', () => {\n const { pos } = context.get() ?? {}\n const { view } = editor.get() ?? {}\n\n if (pos == null || view == null) {\n return\n }\n\n view.dispatch(\n view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos)),\n )\n\n // Clicking the handle will blur the editor, so we need to focus it again.\n // We cannot call `event.preventDefault()` here to prevent the blur\n // because it will prevent the drag event from firing.\n requestAnimationFrame(() => {\n view.focus()\n })\n })\n}\n\nfunction createDraggingPreview(view: EditorView, hoverState: HoverState, event: DragEvent): void {\n if (!event.dataTransfer) {\n return\n }\n\n const { pos } = hoverState\n\n const element = view.nodeDOM(pos)\n if (!element || !isHTMLElement(element)) {\n return\n }\n\n const boxElement = getBoxElement(element)\n if (!boxElement || !isHTMLElement(boxElement)) {\n return\n }\n\n event.dataTransfer.clearData()\n event.dataTransfer.setData('text/html', boxElement.outerHTML)\n event.dataTransfer.effectAllowed = 'copyMove'\n setDragPreview(event, boxElement)\n\n return\n}\n\nfunction setViewDragging(view: EditorView, hoverState: HoverState): void {\n const { node, pos } = hoverState\n\n const dragging: ViewDragging = {\n slice: new Slice(Fragment.from(node), 0, 0),\n move: true,\n node: NodeSelection.create(view.state.doc, pos),\n }\n\n view.dragging = dragging\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nexport interface BlockHandleDraggableProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const blockHandleDraggableProps: PropDeclarations<BlockHandleDraggableProps> = {\n editor: { default: null },\n}\n\n/** @internal */\nexport interface BlockHandleDraggableEvents {}\n\n/** @internal */\nexport const blockHandleDraggableEvents: EventDeclarations<BlockHandleDraggableEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useBlockHandleDraggable } from \"./setup\"\nimport { blockHandleDraggableEvents, blockHandleDraggableProps, type BlockHandleDraggableEvents, type BlockHandleDraggableProps } from \"./types\"\n\nconst BlockHandleDraggableElementBase: BaseElementConstructor<BlockHandleDraggableProps> = defineCustomElement<\n BlockHandleDraggableProps,\n BlockHandleDraggableEvents\n>({\n props: blockHandleDraggableProps,\n events: blockHandleDraggableEvents,\n setup: useBlockHandleDraggable,\n})\nclass BlockHandleDraggableElement extends BlockHandleDraggableElementBase {}\n\nregisterCustomElement('prosekit-block-handle-draggable', BlockHandleDraggableElement)\n \nexport { BlockHandleDraggableElement }\n","/**\n * @internal\n */\nexport function throttle<Args extends any[]>(\n callback: (...args: Args) => void,\n wait: number,\n): (...args: Args) => void {\n let lastTime = 0\n\n return (...args: Args) => {\n const now = Date.now()\n if (now - lastTime >= wait) {\n callback(...args)\n lastTime = now\n }\n }\n}\n","import type { VirtualElement } from '@floating-ui/dom'\nimport {\n isElement,\n isHTMLElement,\n isTextNode,\n} from '@ocavue/utils'\nimport {\n defineDOMEventHandler,\n union,\n type PlainExtension,\n} from '@prosekit/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { getClientRect } from '../../../utils/get-client-rect'\nimport { throttle } from '../../../utils/throttle'\nimport type { HoverState } from '../context'\n\nexport type ElementHoverHandler = (\n reference: VirtualElement | null,\n hoverState: HoverState | null,\n) => void\n\nexport function defineElementHoverHandler(handler: ElementHoverHandler): PlainExtension {\n const handleElement = (\n node: ProseMirrorNode,\n pos: number,\n element: HTMLElement,\n parentElement?: Node | null,\n ) => {\n const reference: VirtualElement = {\n contextElement: element,\n\n getBoundingClientRect: () => {\n const rect = findFirstLineRect(parentElement, element)\n return rect ? fulfillRect(rect) : fallbackRect\n },\n }\n\n handler(reference, { node, pos })\n }\n\n const handlePointerEvent = (view: EditorView, event: PointerEvent) => {\n const { x, y } = event\n const block = findBlockByCoords(view, x, y)\n if (!block) {\n handler(null, null)\n return\n }\n\n const { node, pos } = block\n const element = view.nodeDOM(pos)\n if (!element || !isHTMLElement(element)) {\n handler(null, null)\n return\n }\n\n // If `node` is the first child of another non-doc block node, for example a\n // list node or a blockquote node, we want to put the block handle agains\n // the parent node.\n const $pos = view.state.doc.resolve(pos)\n if ($pos.depth > 0 && $pos.index($pos.depth) === 0) {\n const parentPos = $pos.before($pos.depth)\n const parentNode = $pos.parent\n const parentElement = view.nodeDOM(parentPos)\n handleElement(parentNode, parentPos, element, parentElement)\n } else {\n handleElement(node, pos, element)\n }\n }\n\n return union(\n defineDOMEventHandler('pointermove', throttle(handlePointerEvent, 200)),\n defineDOMEventHandler('pointerout', handlePointerEvent),\n defineDOMEventHandler('keypress', () => handler(null, null)),\n )\n}\n\nfunction findBlockByCoords(view: EditorView, x: number, y: number): { node: ProseMirrorNode; pos: number } | undefined {\n const rect = getClientRect(view.dom)\n if (!isWithinRect(rect, x, y)) {\n return\n }\n\n let parent: ProseMirrorNode | undefined = view.state.doc\n let pos = -1\n\n while (parent) {\n if (parent.isBlock && (parent.isTextblock || parent.isAtom || parent.type.spec.isolating)) {\n return { node: parent, pos }\n }\n\n // Collect all children and their positions\n const children: ProseMirrorNode[] = []\n const positions: number[] = []\n parent.forEach((child, offset) => {\n children.push(child)\n positions.push(offset + pos + 1)\n })\n\n let lo = 0\n let hi = children.length - 1\n\n while (lo <= hi) {\n const i = hi - ((hi - lo) >> 1)\n const childDOM = view.nodeDOM(positions[i])\n const childRect = getNodeRect(childDOM)\n if (!childRect) {\n console.warn(`[prosekit] Unable to get rect at position: ${positions[i]}`)\n return\n }\n if (childRect.top > y) {\n hi = i - 1\n } else if (childRect.bottom < y) {\n lo = i + 1\n } else {\n lo = i\n break\n }\n }\n\n if (lo > hi) {\n return\n }\n\n parent = children[lo]\n pos = positions[lo]\n }\n}\n\nfunction getNodeRect(node: Node | null | undefined): Rect | undefined {\n if (node && isElement(node) && node.isConnected) {\n return getClientRect(node)\n }\n}\n\nfunction isWithinRect(rect: Rect, x: number, y: number) {\n return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom\n}\n\ninterface Rect {\n top: number\n right: number\n bottom: number\n left: number\n}\n\nfunction findFirstLineRect(outer?: Node | null, inner?: Node | null): Rect | undefined {\n if (outer && !outer.isConnected) {\n return\n }\n if (inner && !inner.isConnected) {\n return\n }\n\n if (outer && inner) {\n const outerRect = findOuterRect(outer)\n const innerRect = findFirstLineRectInNode(inner)\n if (outerRect && innerRect) {\n const { top, bottom } = innerRect\n const { left, right } = outerRect\n return { top, bottom, left, right }\n } else {\n return outerRect || innerRect\n }\n } else if (outer) {\n return findFirstLineRectInNode(outer)\n } else if (inner) {\n return findFirstLineRectInNode(inner)\n }\n}\n\nfunction findOuterRect(node: Node): Rect | undefined {\n if (!isElement(node)) {\n return\n }\n\n const rect = getClientRect(node)\n const style = node.ownerDocument.defaultView?.getComputedStyle(node)\n const marginLeft = style && Number.parseInt(style.marginLeft, 10) || 0\n const marginRight = style && Number.parseInt(style.marginRight, 10) || 0\n const left = rect.left - marginLeft\n const right = rect.right + marginRight\n\n return { top: rect.top, bottom: rect.bottom, left, right }\n}\n\nfunction findFirstLineRectInNode(node: Node): Rect | undefined {\n if (isElement(node)) {\n return findFirstLineRectInElement(node)\n } else if (isTextNode(node)) {\n return findFirstLineRectInTextNode(node)\n }\n}\n\nfunction findFirstLineRectInTextNode(node: Text): Rect | undefined {\n const ownerDocument = node.ownerDocument\n if (!ownerDocument) {\n return\n }\n const range = ownerDocument.createRange()\n range.setStart(node, 0)\n range.setEnd(node, 0)\n const rects = range.getClientRects()\n return rects[0]\n}\n\nfunction findFirstLineRectInElement(element: Element): Rect | undefined {\n if (element.nodeName === 'BR') {\n return element.getBoundingClientRect()\n }\n\n const rect = getClientRect(element)\n const style = element.ownerDocument.defaultView?.getComputedStyle(element)\n const marginLeft = style && Number.parseInt(style.marginLeft, 10) || 0\n const marginRight = style && Number.parseInt(style.marginRight, 10) || 0\n const left = rect.left - marginLeft\n const right = rect.right + marginRight\n\n const lineHeight = style && Number.parseInt(style.lineHeight, 10) || 24\n const paddingTop = style && Number.parseInt(style.paddingTop, 10) || 0\n const borderTop = style && Number.parseInt(style.borderTopWidth, 10) || 0\n const top = rect.top + paddingTop + borderTop\n const bottom = top + lineHeight\n\n return { top, bottom, left, right }\n}\n\nfunction fulfillRect({ top, right, bottom, left }: Rect) {\n return { top, right, bottom, left, width: right - left, height: bottom - top, x: left, y: top }\n}\n\n// A fallback rect that is far away from the screen. It should not be used through.\nconst fallbackRect = Object.freeze({\n top: -9999,\n right: -9999,\n bottom: -9999,\n left: -9999,\n width: 0,\n height: 0,\n x: -9999,\n y: -9999,\n})\n","import {\n createComputed,\n createSignal,\n useAttribute,\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 { VirtualElement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nimport { useEditorExtension } from '../../../hooks/use-editor-extension'\nimport { useScrolling } from '../../../hooks/use-scrolling'\nimport {\n blockPopoverContext,\n draggingContext,\n type BlockPopoverContext,\n type HoverState,\n} from '../context'\n\nimport {\n defineElementHoverHandler,\n type ElementHoverHandler,\n} from './pointer-move'\nimport type {\n BlockHandlePopoverEvents,\n BlockHandlePopoverProps,\n} from './types'\n\n/**\n * @internal\n */\nexport function useBlockHandlePopover(\n host: ConnectableElement,\n { state, emit }: SetupOptions<BlockHandlePopoverProps, BlockHandlePopoverEvents>,\n): void {\n const { editor, ...overlayState } = state\n const reference = createSignal<VirtualElement | null>(null)\n useOverlayPositionerState(host, overlayState, { reference })\n\n const context = createSignal<BlockPopoverContext>(null)\n blockPopoverContext.provide(host, context)\n\n const dragging = createSignal(false)\n draggingContext.provide(host, dragging)\n\n const scrolling = useScrolling(host)\n const open = createComputed(() => {\n return !!context.get() && !scrolling.get()\n })\n\n useHoverExtension(host, editor, (referenceValue, hoverState) => {\n reference.set(referenceValue)\n context.set(hoverState)\n const stateChangeDetails = hoverState ? { node: hoverState.node, pos: hoverState.pos } : null\n emit('stateChange', stateChangeDetails)\n })\n\n useAttribute(host, 'data-state', () => (open.get() ? 'open' : 'closed'))\n usePresence(host, open)\n}\n\nfunction useHoverExtension(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: ElementHoverHandler,\n) {\n let prevHoverState: HoverState | null = null\n\n const extension = defineElementHoverHandler((reference, hoverState) => {\n if (isHoverStateEqual(prevHoverState, hoverState)) {\n return\n }\n\n prevHoverState = hoverState\n handler(reference, hoverState)\n })\n\n useEditorExtension(host, editor, extension)\n}\n\nfunction isHoverStateEqual(a: HoverState | null, b: HoverState | null) {\n if (!a && !b) return true\n if (!a || !b) return false\n return a.pos === b.pos && a.node.eq(b.node)\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 { Placement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\n\nexport interface BlockHandlePopoverProps 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 block.\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 blockHandlePopoverProps: PropDeclarations<BlockHandlePopoverProps> = {\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\nexport interface BlockHandlePopoverEvents extends OverlayPositionerEvents {\n /**\n * Fired when the hovered block changes.\n */\n stateChange: CustomEvent<{ node: ProseMirrorNode; pos: number } | null>\n}\n\n/** @internal */\nexport const blockHandlePopoverEvents: EventDeclarations<BlockHandlePopoverEvents> = {\n ...overlayPositionerEvents,\n stateChange: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useBlockHandlePopover } from \"./setup\"\nimport { blockHandlePopoverEvents, blockHandlePopoverProps, type BlockHandlePopoverEvents, type BlockHandlePopoverProps } from \"./types\"\n\nconst BlockHandlePopoverElementBase: BaseElementConstructor<BlockHandlePopoverProps> = defineCustomElement<\n BlockHandlePopoverProps,\n BlockHandlePopoverEvents\n>({\n props: blockHandlePopoverProps,\n events: blockHandlePopoverEvents,\n setup: useBlockHandlePopover,\n})\nclass BlockHandlePopoverElement extends BlockHandlePopoverElementBase {}\n\nregisterCustomElement('prosekit-block-handle-popover', BlockHandlePopoverElement)\n \nexport { BlockHandlePopoverElement }\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,MAAaA,sBAAoD,cAC/D,kCACA,KACD;;;;AAKD,MAAaC,kBAAoC,cAC/C,0CACA,MACD;;;;;;;ACnBD,SAAgB,kBACd,MACA,EAAE,SACI;CACN,MAAM,UAAU,oBAAoB,QAAQ,KAAK;AAEjD,kBAAiB,MAAM,gBAAgB,UAAU;AAC/C,QAAM,gBAAgB;EAEtB,MAAM,SAAS,MAAM,OAAO,KAAK;EACjC,MAAM,aAAa,QAAQ,KAAK;AAChC,MAAI,CAAC,UAAU,CAAC,WACd;EAGF,MAAM,EAAE,MAAM,QAAQ;AACtB,SAAO,KAAK,mBAAmB,EAAE,KAAK,MAAM,KAAK,UAAU,CAAC,CAAC;AAC7D,SAAO,OAAO;AAGd,UAAQ,IAAI,KAAK;GACjB;;;;;;AClBJ,MAAaC,sBAA6D,EACxE,QAAQ,EAAE,SAAS,MAAM,EAC1B;;AAMD,MAAaC,uBAAgE,EAAE;;;;ACpB/E,MAAMC,4BAAyE,oBAG7E;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,wBAAN,cAAoC,0BAA0B;AAE9D,sBAAsB,6BAA6B,sBAAsB;;;;;;;ACZzE,SAAgB,cAAc,SAA8C;CAC1E,MAAM,SAAS,QAAQ,cAAc;AACrC,KAAI,CAAC,OACH;CAIF,MAAM,UADQ,OAAO,iBAAiB,QAAQ,CACxB;AAEtB,KAAI,YAAY,cAAc,QAAQ,sBAAsB,EAC1D,QAAO,QAAQ;UACN,YAAY,OACrB;AAGF,QAAO;;;;;;;;ACfT,SAAgB,cAAc,SAK5B;CACA,MAAM,OAAO,QAAQ,uBAAuB;A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AAK,GAAG,SAAS,SAAU;AACxE,aAAY,MAAM,KAAK;;AAGzB,SAAS,kBACP,MACA,QACA,SACA;CACA,IAAIC,iBAAoC;CAExC,MAAM,YAAY,2BAA2B,WAAW,eAAe;AACrE,MAAI,kBAAkB,gBAAgB,WAAW,CAC/C;AAGF,mBAAiB;AACjB,UAAQ,WAAW,WAAW;GAC9B;AAEF,oBAAmB,MAAM,QAAQ,UAAU;;AAG7C,SAAS,kBAAkB,GAAsB,GAAsB;AACrE,KAAI,CAAC,KAAK,CAAC,EAAG,QAAO;AACrB,KAAI,CAAC,KAAK,CAAC,EAAG,QAAO;AACrB,QAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK;;;;;;AC5B7C,MAAaC,0BAAqE;CAChF,GAAG;CACH,QAAQ,EAAE,SAAS,MAAM;CACzB,WAAW,EAAE,SAAS,QAAQ;CAI9B,OAAO,EAAE,SAAS,OAAO;CAEzB,MAAM,EAAE,SAAS,OAAO;CACxB,OAAO,EAAE,SAAS,OAAO;CACzB,MAAM,EAAE,SAAS,MAAM;CACxB;;AAUD,MAAaC,2BAAwE;CACnF,GAAG;CACH,aAAa,EAAE;CAChB;;;;AC9ED,MAAMC,gCAAiF,oBAGrF;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,4BAAN,cAAwC,8BAA8B;AAEtE,sBAAsB,iCAAiC,0BAA0B"}
1
+ {"version":3,"file":"prosekit-web-block-handle.js","names":["blockPopoverContext: Context<BlockPopoverContext>","draggingContext: Context<boolean>","blockHandleAddProps: PropDeclarations<BlockHandleAddProps>","blockHandleAddEvents: EventDeclarations<BlockHandleAddEvents>","BlockHandleAddElementBase: BaseElementConstructor<BlockHandleAddProps>","blockHandleDraggableProps: PropDeclarations<BlockHandleDraggableProps>","blockHandleDraggableEvents: EventDeclarations<BlockHandleDraggableEvents>","BlockHandleDraggableElementBase: BaseElementConstructor<BlockHandleDraggableProps>","parent: ProseMirrorNode | undefined","children: ProseMirrorNode[]","positions: number[]","prevHoverState: HoverState | null","blockHandlePopoverProps: PropDeclarations<BlockHandlePopoverProps>","blockHandlePopoverEvents: EventDeclarations<BlockHandlePopoverEvents>","BlockHandlePopoverElementBase: BaseElementConstructor<BlockHandlePopoverProps>"],"sources":["../src/components/block-handle/context.ts","../src/components/block-handle/block-handle-add/setup.ts","../src/components/block-handle/block-handle-add/types.ts","../src/components/block-handle/block-handle-add/element.gen.ts","../src/utils/get-box-element.ts","../src/utils/get-client-rect.ts","../src/utils/max-z-index.ts","../src/components/block-handle/block-handle-draggable/set-drag-preview.ts","../src/components/block-handle/block-handle-draggable/setup.ts","../src/components/block-handle/block-handle-draggable/types.ts","../src/components/block-handle/block-handle-draggable/element.gen.ts","../src/utils/throttle.ts","../src/components/block-handle/block-handle-popover/pointer-move.ts","../src/components/block-handle/block-handle-popover/setup.ts","../src/components/block-handle/block-handle-popover/types.ts","../src/components/block-handle/block-handle-popover/element.gen.ts"],"sourcesContent":["import {\n createContext,\n type Context,\n} from '@aria-ui/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport interface HoverState {\n node: ProseMirrorNode\n pos: number\n}\n\n/**\n * @internal\n */\nexport type BlockPopoverContext = HoverState | null\n\n/**\n * @internal\n */\nexport const blockPopoverContext: Context<BlockPopoverContext> = createContext(\n 'prosekit-block-popover-context',\n null,\n)\n\n/**\n * @internal\n */\nexport const draggingContext: Context<boolean> = createContext(\n 'prosekit-block-handle-dragging-context',\n false,\n)\n","import {\n useEventListener,\n type ConnectableElement,\n type SignalState,\n} from '@aria-ui/core'\nimport { insertDefaultBlock } from '@prosekit/core'\n\nimport { blockPopoverContext } from '../context'\n\nimport type { BlockHandleAddProps } from './types'\n\n/**\n * @internal\n */\nexport function useBlockHandleAdd(\n host: ConnectableElement,\n { state }: { state: SignalState<BlockHandleAddProps> },\n): void {\n const context = blockPopoverContext.consume(host)\n\n useEventListener(host, 'pointerdown', (event) => {\n event.preventDefault()\n\n const editor = state.editor.get()\n const hoverState = context.get()\n if (!editor || !hoverState) {\n return\n }\n\n const { node, pos } = hoverState\n editor.exec(insertDefaultBlock({ pos: pos + node.nodeSize }))\n editor.focus()\n\n // Hide the drag handle\n context.set(null)\n })\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nexport interface BlockHandleAddProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const blockHandleAddProps: PropDeclarations<BlockHandleAddProps> = {\n editor: { default: null },\n}\n\n/** @internal */\nexport interface BlockHandleAddEvents {}\n\n/** @internal */\nexport const blockHandleAddEvents: EventDeclarations<BlockHandleAddEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useBlockHandleAdd } from \"./setup\"\nimport { blockHandleAddEvents, blockHandleAddProps, type BlockHandleAddEvents, type BlockHandleAddProps } from \"./types\"\n\nconst BlockHandleAddElementBase: BaseElementConstructor<BlockHandleAddProps> = defineCustomElement<\n BlockHandleAddProps,\n BlockHandleAddEvents\n>({\n props: blockHandleAddProps,\n events: blockHandleAddEvents,\n setup: useBlockHandleAdd,\n})\nclass BlockHandleAddElement extends BlockHandleAddElementBase {}\n\nregisterCustomElement('prosekit-block-handle-add', BlockHandleAddElement)\n \nexport { BlockHandleAddElement }\n","/**\n * Returns the element that has a box.\n */\nexport function getBoxElement(element: Element): Element | null | undefined {\n const window = element.ownerDocument.defaultView\n if (!window) {\n return\n }\n\n const style = window.getComputedStyle(element)\n const display = style.display\n\n if (display === 'contents' && element.childElementCount === 1) {\n return element.firstElementChild\n } else if (display === 'none') {\n return\n }\n\n return element\n}\n","/**\n * Similar to `element.getBoundingClientRect`, but handles `display: contents` elements.\n */\nexport function getClientRect(element: Element): {\n top: number\n right: number\n bottom: number\n left: number\n} {\n const rect = element.getBoundingClientRect()\n if (rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0) {\n // Suspiciously rect, probably an element with `display: contents`, in\n // which case `element.getClientRects()` will return an empty array.\n if (element.getClientRects().length === 0) {\n const children = Array.from(element.children)\n const rects = children.map(child => getClientRect(child))\n if (rects.length === 0) {\n return rect\n }\n if (rects.length === 1) {\n return rects[0]\n }\n let { top, bottom, left, right } = rects[0]\n for (let i = 1; i < rects.length; i++) {\n const r = rects[i]\n if (r.top < top) top = r.top\n if (r.bottom > bottom) bottom = r.bottom\n if (r.left < left) left = r.left\n if (r.right > right) right = r.right\n }\n return { top, bottom, left, right }\n }\n }\n return rect\n}\n","// Maximum possible z-index\n// https://stackoverflow.com/questions/491052/minimum-and-maximum-value-of-z-index\nexport const maxZIndex = '2147483647'\n","import { assignStyles } from '../../../utils/assign-styles'\nimport { deepCloneElement } from '../../../utils/clone-element'\nimport { getClientRect } from '../../../utils/get-client-rect'\nimport { injectStyle } from '../../../utils/inject-style'\nimport { maxZIndex } from '../../../utils/max-z-index'\n\n/**\n * Sets a drag preview image for the given element and ensures the preview position\n * relative to the pointer is correct.\n *\n * This function does the following:\n *\n * - Creates a temporary container element.\n * - Puts the container at the end of the document body.\n * - Sets event's drag image.\n * - Removes the container from the document body after the next frame.\n */\nexport function setDragPreview(event: DragEvent, element: HTMLElement): void {\n const { top, bottom, left, right } = getClientRect(element)\n const width = right - left\n const height = bottom - top\n const elementX = left\n const elementY = top\n\n const { clientX, clientY } = event\n\n const document = element.ownerDocument\n\n const container = document.createElement('div')\n\n // If outsideX is positive, the point is at the left side of the element.\n const outsideX = Math.round(elementX - clientX)\n // If outsideY is positive, the point is above the element.\n const outsideY = Math.round(elementY - clientY)\n\n const borderX = Math.max(outsideX, 0)\n const borderY = Math.max(outsideY, 0)\n assignStyles(container, {\n // Ensuring we don't cause reflow when adding the element to the page using\n // `position:fixed` rather than `position:absolute` so we are positioned on\n // the current viewport. `position:fixed` also creates a new stacking\n // context, so we don't need to do that here.\n // https://github.com/atlassian/pragmatic-drag-and-drop/blob/56276552/packages/core/src/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.ts#L60\n position: 'fixed',\n\n // The element is positioned off-screen to avoid capturing the content of\n // the page on Safari when the dragging element has a transparent background\n // on Safari. See https://github.com/prosekit/prosekit/issues/1153 for more\n // details.\n top: '-1000vh',\n left: '-1000vw',\n\n // The element should not be interactive.\n pointerEvents: 'none',\n\n zIndex: maxZIndex,\n\n // Only reliable cross browser technique found to push a drag preview away\n // from the cursor is to use transparent borders on the container.\n // https://github.com/atlassian/pragmatic-drag-and-drop/blob/56276552/packages/core/src/public-utils/element/custom-native-drag-preview/pointer-outside-of-preview.ts#L13-L18\n borderLeft: `${borderX}px solid transparent`,\n borderTop: `${borderY}px solid transparent`,\n\n boxSizing: 'border-box',\n width: `${width + borderX}px`,\n height: `${height + borderY}px`,\n })\n\n const [clonedElement, styleText] = deepCloneElement(element, true)\n\n // A hardcoded opacity.\n clonedElement.style.setProperty('opacity', '0.5', 'important')\n // The bounding client rect doesn't include the margin, so we need to remove\n // the margin too from the cloned element so that it can fit the container.\n clonedElement.style.setProperty('margin', '0', 'important')\n // Hide the outline of the cloned element.\n clonedElement.style.setProperty('outline-color', 'transparent', 'important')\n\n document.body.appendChild(container)\n container.appendChild(clonedElement)\n injectStyle(container, styleText)\n\n event.dataTransfer?.setDragImage(container, Math.max(-outsideX, 0), Math.max(-outsideY, 0))\n\n requestAnimationFrame(() => {\n container.remove()\n })\n}\n","import {\n useAttribute,\n useEffect,\n useEventListener,\n type ConnectableElement,\n type ReadonlySignal,\n type SignalState,\n} from '@aria-ui/core'\nimport { isHTMLElement } from '@ocavue/utils'\nimport type { Editor } from '@prosekit/core'\nimport type { ViewDragging } from '@prosekit/extensions/drop-indicator'\nimport {\n Fragment,\n Slice,\n} from '@prosekit/pm/model'\nimport { NodeSelection } from '@prosekit/pm/state'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { getBoxElement } from '../../../utils/get-box-element'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view'\nimport {\n blockPopoverContext,\n draggingContext,\n type BlockPopoverContext,\n type HoverState,\n} from '../context'\n\nimport { setDragPreview } from './set-drag-preview'\nimport type { BlockHandleDraggableProps } from './types'\n\n/**\n * @internal\n */\nexport function useBlockHandleDraggable(\n host: ConnectableElement,\n { state }: { state: SignalState<BlockHandleDraggableProps> },\n): void {\n const context = blockPopoverContext.consume(host)\n const dragging = draggingContext.consume(host)\n\n useEffect(host, () => {\n host.draggable = true\n })\n\n usePointerDownHandler(host, context, state.editor)\n\n useEventListener(host, 'dragstart', (event) => {\n dragging.set(true)\n\n const view = getSafeEditorView(state.editor.get())\n const hoverState = context.get()\n\n if (view && hoverState) {\n view.dom.classList.add('prosekit-dragging')\n createDraggingPreview(view, hoverState, event)\n setViewDragging(view, hoverState)\n }\n })\n\n useEventListener(host, 'dragend', () => {\n dragging.set(false)\n\n const view = getSafeEditorView(state.editor.get())\n if (view) {\n view.dom.classList.remove('prosekit-dragging')\n }\n })\n\n useAttribute(host, 'data-dragging', () => (dragging.get() ? '' : undefined))\n}\n\nfunction usePointerDownHandler(\n host: ConnectableElement,\n context: ReadonlySignal<BlockPopoverContext>,\n editor: ReadonlySignal<Editor | null>,\n) {\n useEventListener(host, 'pointerdown', () => {\n const { pos } = context.get() ?? {}\n const { view } = editor.get() ?? {}\n\n if (pos == null || view == null) {\n return\n }\n\n view.dispatch(\n view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos)),\n )\n\n // Clicking the handle will blur the editor, so we need to focus it again.\n // We cannot call `event.preventDefault()` here to prevent the blur\n // because it will prevent the drag event from firing.\n requestAnimationFrame(() => {\n view.focus()\n })\n })\n}\n\nfunction createDraggingPreview(view: EditorView, hoverState: HoverState, event: DragEvent): void {\n if (!event.dataTransfer) {\n return\n }\n\n const { pos } = hoverState\n\n const element = view.nodeDOM(pos)\n if (!element || !isHTMLElement(element)) {\n return\n }\n\n const boxElement = getBoxElement(element)\n if (!boxElement || !isHTMLElement(boxElement)) {\n return\n }\n\n event.dataTransfer.clearData()\n event.dataTransfer.setData('text/html', boxElement.outerHTML)\n event.dataTransfer.effectAllowed = 'copyMove'\n setDragPreview(event, boxElement)\n\n return\n}\n\nfunction setViewDragging(view: EditorView, hoverState: HoverState): void {\n const { node, pos } = hoverState\n\n const dragging: ViewDragging = {\n slice: new Slice(Fragment.from(node), 0, 0),\n move: true,\n node: NodeSelection.create(view.state.doc, pos),\n }\n\n view.dragging = dragging\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nexport interface BlockHandleDraggableProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const blockHandleDraggableProps: PropDeclarations<BlockHandleDraggableProps> = {\n editor: { default: null },\n}\n\n/** @internal */\nexport interface BlockHandleDraggableEvents {}\n\n/** @internal */\nexport const blockHandleDraggableEvents: EventDeclarations<BlockHandleDraggableEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useBlockHandleDraggable } from \"./setup\"\nimport { blockHandleDraggableEvents, blockHandleDraggableProps, type BlockHandleDraggableEvents, type BlockHandleDraggableProps } from \"./types\"\n\nconst BlockHandleDraggableElementBase: BaseElementConstructor<BlockHandleDraggableProps> = defineCustomElement<\n BlockHandleDraggableProps,\n BlockHandleDraggableEvents\n>({\n props: blockHandleDraggableProps,\n events: blockHandleDraggableEvents,\n setup: useBlockHandleDraggable,\n})\nclass BlockHandleDraggableElement extends BlockHandleDraggableElementBase {}\n\nregisterCustomElement('prosekit-block-handle-draggable', BlockHandleDraggableElement)\n \nexport { BlockHandleDraggableElement }\n","/**\n * @internal\n */\nexport function throttle<Args extends any[]>(\n callback: (...args: Args) => void,\n wait: number,\n): (...args: Args) => void {\n let lastTime = 0\n\n return (...args: Args) => {\n const now = Date.now()\n if (now - lastTime >= wait) {\n callback(...args)\n lastTime = now\n }\n }\n}\n","import type { VirtualElement } from '@floating-ui/dom'\nimport {\n isElement,\n isHTMLElement,\n isTextNode,\n} from '@ocavue/utils'\nimport {\n defineDOMEventHandler,\n union,\n type PlainExtension,\n} from '@prosekit/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { getClientRect } from '../../../utils/get-client-rect'\nimport { throttle } from '../../../utils/throttle'\nimport type { HoverState } from '../context'\n\nexport type ElementHoverHandler = (\n reference: VirtualElement | null,\n hoverState: HoverState | null,\n) => void\n\nexport function defineElementHoverHandler(handler: ElementHoverHandler): PlainExtension {\n const handleElement = (\n node: ProseMirrorNode,\n pos: number,\n element: HTMLElement,\n parentElement?: Node | null,\n ) => {\n const reference: VirtualElement = {\n contextElement: element,\n\n getBoundingClientRect: () => {\n const rect = findFirstLineRect(parentElement, element)\n return rect ? fulfillRect(rect) : fallbackRect\n },\n }\n\n handler(reference, { node, pos })\n }\n\n let lastX = -1\n let lastY = -1\n let lastTime = -1\n\n const handlePointerEvent = (view: EditorView, event: PointerEvent) => {\n const { x, y } = event\n\n // Simple performance optimization. If the pointer is not moving, we don't\n // want to recalculate the block handle position within a short period of\n // time window.\n if (lastX === x && lastY === y) {\n const now = Date.now()\n if (now - lastTime < 100) {\n return\n }\n lastTime = now\n }\n lastX = x\n lastY = y\n\n const block = findBlockByCoords(view, x, y)\n if (!block) {\n handler(null, null)\n return\n }\n\n const { node, pos } = block\n const element = view.nodeDOM(pos)\n if (!element || !isHTMLElement(element)) {\n handler(null, null)\n return\n }\n\n // If `node` is the first child of another non-doc block node, for example a\n // list node or a blockquote node, we want to put the block handle agains\n // the parent node.\n const $pos = view.state.doc.resolve(pos)\n if ($pos.depth > 0 && $pos.index($pos.depth) === 0) {\n const parentPos = $pos.before($pos.depth)\n const parentNode = $pos.parent\n const parentElement = view.nodeDOM(parentPos)\n handleElement(parentNode, parentPos, element, parentElement)\n } else {\n handleElement(node, pos, element)\n }\n }\n\n return union(\n defineDOMEventHandler('pointermove', throttle(handlePointerEvent, 200)),\n defineDOMEventHandler('pointerenter', handlePointerEvent),\n defineDOMEventHandler('pointerout', handlePointerEvent),\n defineDOMEventHandler('keypress', () => handler(null, null)),\n )\n}\n\nfunction findBlockByCoords(view: EditorView, x: number, y: number): { node: ProseMirrorNode; pos: number } | undefined {\n const rect = getClientRect(view.dom)\n if (!isWithinRect(rect, x, y)) {\n return\n }\n\n let parent: ProseMirrorNode | undefined = view.state.doc\n let pos = -1\n\n while (parent) {\n if (parent.isBlock && (parent.isTextblock || parent.isAtom || parent.type.spec.isolating)) {\n return { node: parent, pos }\n }\n\n // Collect all children and their positions\n const children: ProseMirrorNode[] = []\n const positions: number[] = []\n parent.forEach((child, offset) => {\n children.push(child)\n positions.push(offset + pos + 1)\n })\n\n let lo = 0\n let hi = children.length - 1\n\n while (lo <= hi) {\n const i = hi - ((hi - lo) >> 1)\n const childDOM = view.nodeDOM(positions[i])\n const childRect = getNodeRect(childDOM)\n if (!childRect) {\n console.warn(`[prosekit] Unable to get rect at position: ${positions[i]}`)\n return\n }\n if (childRect.top > y) {\n hi = i - 1\n } else if (childRect.bottom < y) {\n lo = i + 1\n } else {\n lo = i\n break\n }\n }\n\n if (lo > hi) {\n return\n }\n\n parent = children[lo]\n pos = positions[lo]\n }\n}\n\nfunction getNodeRect(node: Node | null | undefined): Rect | undefined {\n if (node && isElement(node) && node.isConnected) {\n return getClientRect(node)\n }\n}\n\nfunction isWithinRect(rect: Rect, x: number, y: number) {\n return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom\n}\n\ninterface Rect {\n top: number\n right: number\n bottom: number\n left: number\n}\n\nfunction findFirstLineRect(outer?: Node | null, inner?: Node | null): Rect | undefined {\n if (outer && !outer.isConnected) {\n return\n }\n if (inner && !inner.isConnected) {\n return\n }\n\n if (outer && inner) {\n const outerRect = findOuterRect(outer)\n const innerRect = findFirstLineRectInNode(inner)\n if (outerRect && innerRect) {\n const { top, bottom } = innerRect\n const { left, right } = outerRect\n return { top, bottom, left, right }\n } else {\n return outerRect || innerRect\n }\n } else if (outer) {\n return findFirstLineRectInNode(outer)\n } else if (inner) {\n return findFirstLineRectInNode(inner)\n }\n}\n\nfunction findOuterRect(node: Node): Rect | undefined {\n if (!isElement(node)) {\n return\n }\n\n const rect = getClientRect(node)\n const style = node.ownerDocument.defaultView?.getComputedStyle(node)\n const marginLeft = style && Number.parseInt(style.marginLeft, 10) || 0\n const marginRight = style && Number.parseInt(style.marginRight, 10) || 0\n const left = rect.left - marginLeft\n const right = rect.right + marginRight\n\n return { top: rect.top, bottom: rect.bottom, left, right }\n}\n\nfunction findFirstLineRectInNode(node: Node): Rect | undefined {\n if (isElement(node)) {\n return findFirstLineRectInElement(node)\n } else if (isTextNode(node)) {\n return findFirstLineRectInTextNode(node)\n }\n}\n\nfunction findFirstLineRectInTextNode(node: Text): Rect | undefined {\n const ownerDocument = node.ownerDocument\n if (!ownerDocument) {\n return\n }\n const range = ownerDocument.createRange()\n range.setStart(node, 0)\n range.setEnd(node, 0)\n const rects = range.getClientRects()\n return rects[0]\n}\n\nfunction findFirstLineRectInElement(element: Element): Rect | undefined {\n if (element.nodeName === 'BR') {\n return element.getBoundingClientRect()\n }\n\n const rect = getClientRect(element)\n const style = element.ownerDocument.defaultView?.getComputedStyle(element)\n const marginLeft = style && Number.parseInt(style.marginLeft, 10) || 0\n const marginRight = style && Number.parseInt(style.marginRight, 10) || 0\n const left = rect.left - marginLeft\n const right = rect.right + marginRight\n\n const lineHeight = style && Number.parseInt(style.lineHeight, 10) || 24\n const paddingTop = style && Number.parseInt(style.paddingTop, 10) || 0\n const borderTop = style && Number.parseInt(style.borderTopWidth, 10) || 0\n const top = rect.top + paddingTop + borderTop\n const bottom = top + lineHeight\n\n return { top, bottom, left, right }\n}\n\nfunction fulfillRect({ top, right, bottom, left }: Rect) {\n return { top, right, bottom, left, width: right - left, height: bottom - top, x: left, y: top }\n}\n\n// A fallback rect that is far away from the screen. It should not be used through.\nconst fallbackRect = Object.freeze({\n top: -9999,\n right: -9999,\n bottom: -9999,\n left: -9999,\n width: 0,\n height: 0,\n x: -9999,\n y: -9999,\n})\n","import {\n createComputed,\n createSignal,\n useAttribute,\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 { VirtualElement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nimport { useEditorExtension } from '../../../hooks/use-editor-extension'\nimport { useScrolling } from '../../../hooks/use-scrolling'\nimport {\n blockPopoverContext,\n draggingContext,\n type BlockPopoverContext,\n type HoverState,\n} from '../context'\n\nimport {\n defineElementHoverHandler,\n type ElementHoverHandler,\n} from './pointer-move'\nimport type {\n BlockHandlePopoverEvents,\n BlockHandlePopoverProps,\n} from './types'\n\n/**\n * @internal\n */\nexport function useBlockHandlePopover(\n host: ConnectableElement,\n { state, emit }: SetupOptions<BlockHandlePopoverProps, BlockHandlePopoverEvents>,\n): void {\n const { editor, ...overlayState } = state\n const reference = createSignal<VirtualElement | null>(null)\n useOverlayPositionerState(host, overlayState, { reference })\n\n const context = createSignal<BlockPopoverContext>(null)\n blockPopoverContext.provide(host, context)\n\n const dragging = createSignal(false)\n draggingContext.provide(host, dragging)\n\n const scrolling = useScrolling(host)\n const open = createComputed(() => {\n return !!context.get() && !scrolling.get()\n })\n\n useHoverExtension(host, editor, (referenceValue, hoverState) => {\n reference.set(referenceValue)\n context.set(hoverState)\n const stateChangeDetails = hoverState ? { node: hoverState.node, pos: hoverState.pos } : null\n emit('stateChange', stateChangeDetails)\n })\n\n useAttribute(host, 'data-state', () => (open.get() ? 'open' : 'closed'))\n usePresence(host, open)\n}\n\nfunction useHoverExtension(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: ElementHoverHandler,\n) {\n let prevHoverState: HoverState | null = null\n\n const extension = defineElementHoverHandler((reference, hoverState) => {\n if (isHoverStateEqual(prevHoverState, hoverState)) {\n return\n }\n\n prevHoverState = hoverState\n handler(reference, hoverState)\n })\n\n useEditorExtension(host, editor, extension)\n}\n\nfunction isHoverStateEqual(a: HoverState | null, b: HoverState | null) {\n if (!a && !b) return true\n if (!a || !b) return false\n return a.pos === b.pos && a.node.eq(b.node)\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 { Placement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\n\nexport interface BlockHandlePopoverProps 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 block.\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 blockHandlePopoverProps: PropDeclarations<BlockHandlePopoverProps> = {\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\nexport interface BlockHandlePopoverEvents extends OverlayPositionerEvents {\n /**\n * Fired when the hovered block changes.\n */\n stateChange: CustomEvent<{ node: ProseMirrorNode; pos: number } | null>\n}\n\n/** @internal */\nexport const blockHandlePopoverEvents: EventDeclarations<BlockHandlePopoverEvents> = {\n ...overlayPositionerEvents,\n stateChange: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useBlockHandlePopover } from \"./setup\"\nimport { blockHandlePopoverEvents, blockHandlePopoverProps, type BlockHandlePopoverEvents, type BlockHandlePopoverProps } from \"./types\"\n\nconst BlockHandlePopoverElementBase: BaseElementConstructor<BlockHandlePopoverProps> = defineCustomElement<\n BlockHandlePopoverProps,\n BlockHandlePopoverEvents\n>({\n props: blockHandlePopoverProps,\n events: blockHandlePopoverEvents,\n setup: useBlockHandlePopover,\n})\nclass BlockHandlePopoverElement extends BlockHandlePopoverElementBase {}\n\nregisterCustomElement('prosekit-block-handle-popover', BlockHandlePopoverElement)\n \nexport { BlockHandlePopoverElement }\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,MAAaA,sBAAoD,cAC/D,kCACA,KACD;;;;AAKD,MAAaC,kBAAoC,cAC/C,0CACA,MACD;;;;;;;ACnBD,SAAgB,kBACd,MACA,EAAE,SACI;CACN,MAAM,UAAU,oBAAoB,QAAQ,KAAK;AAEjD,kBAAiB,MAAM,gBAAgB,UAAU;AAC/C,QAAM,gBAAgB;EAEtB,MAAM,SAAS,MAAM,OAAO,KAAK;EACjC,MAAM,aAAa,QAAQ,KAAK;AAChC,MAAI,CAAC,UAAU,CAAC,WACd;EAGF,MAAM,EAAE,MAAM,QAAQ;AACtB,SAAO,KAAK,mBAAmB,EAAE,KAAK,MAAM,KAAK,UAAU,CAAC,CAAC;AAC7D,SAAO,OAAO;AAGd,UAAQ,IAAI,KAAK;GACjB;;;;;;AClBJ,MAAaC,sBAA6D,EACxE,QAAQ,EAAE,SAAS,MAAM,EAC1B;;AAMD,MAAaC,uBAAgE,EAAE;;;;ACpB/E,MAAMC,4BAAyE,oBAG7E;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,wBAAN,cAAoC,0BAA0B;AAE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;CACR,OAAO;CACR,CAAC;AACF,IAAM,4BAAN,cAAwC,8BAA8B;AAEtE,sBAAsB,iCAAiC,0BAA0B"}
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-web-drop-indicator.d.ts","names":[],"sources":["../src/components/drop-indicator/drop-indicator/types.ts","../src/components/drop-indicator/drop-indicator/element.gen.ts","../src/components/drop-indicator/drop-indicator/setup.ts"],"sourcesContent":[],"mappings":";;;;UAMiB,kBAAA;;AAAjB;AAkBA;;;;EAAiD,MAAA,EAXvC,MAWuC,GAAA,IAAA;EAKhC;AAIjB;;;;EAAmD,KAAA,EAAA,MAAA;;;cATtC,oBAAoB,iBAAiB;ACnB5C,UDwBW,mBAAA,CCjBf;;AAP8B,cD4BnB,mBC5BmB,ED4BE,iBC5BF,CD4BoB,mBC5BpB,CAAA;;;cAA1B,0BAA0B,uBAAuB;cAQjD,oBAAA,SAA6B,wBAAA;;;;;ADPnC;AAkBa,iBECG,gBAAA,CFEd,IAAA,EEDM,kBFCN,EAAA;EAAA;AAAA,CAAA,EEAW,YFAX,CEAwB,kBFAxB,EEA4C,mBFA5C,CAAA,CAAA,EAAA,IAAA"}
1
+ {"version":3,"file":"prosekit-web-drop-indicator.d.ts","names":[],"sources":["../src/components/drop-indicator/drop-indicator/types.ts","../src/components/drop-indicator/drop-indicator/element.gen.ts","../src/components/drop-indicator/drop-indicator/setup.ts"],"sourcesContent":[],"mappings":";;;;UAMiB,kBAAA;;AAAjB;AAkBA;AAKA;AAIA;;UApBU;;ACV0G;AAE9D;;;;ACoBtD;;AAEI,cFHS,kBEGT,EFH6B,gBEG7B,CFH8C,kBEG9C,CAAA;AAAsB,UFET,mBAAA,CEFS;;AAAD,cFMZ,mBENY,EFMS,iBENT,CFM2B,mBEN3B,CAAA;;;cDtBnB,0BAA0B,uBAAuB;cAQjD,oBAAA,SAA6B,wBAAA;;;;;ADPnC;AAkBa,iBECG,gBAAA,CFDkC,IAAA,EEE1C,kBFFyB,EAAA;EAAA;AAAgB,CAAA,EEGpC,YFHoC,CEGvB,kBFHuB,EEGH,mBFHG,CAAA,CAAA,EAAA,IAAA"}