@prosekit/web 0.7.8 → 0.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{get-default-state-Bqluw34o.js → get-default-state-BzBimBWi.js} +1 -1
- package/dist/get-default-state-BzBimBWi.js.map +1 -0
- package/dist/{get-safe-editor-view-DJlcheeV.js → get-safe-editor-view-Dt9Amrcn.js} +1 -1
- package/dist/{get-safe-editor-view-DJlcheeV.js.map → get-safe-editor-view-Dt9Amrcn.js.map} +1 -1
- package/dist/{inject-style-DYQXx-cE.js → inject-style-BaFaVQvj.js} +7 -7
- package/dist/inject-style-BaFaVQvj.js.map +1 -0
- package/dist/prosekit-web-autocomplete.d.ts.map +1 -1
- package/dist/prosekit-web-autocomplete.js +3 -3
- package/dist/prosekit-web-autocomplete.js.map +1 -1
- package/dist/prosekit-web-block-handle.d.ts.map +1 -1
- package/dist/prosekit-web-block-handle.js +4 -4
- package/dist/prosekit-web-block-handle.js.map +1 -1
- package/dist/prosekit-web-drop-indicator.d.ts.map +1 -1
- package/dist/prosekit-web-drop-indicator.js +2 -2
- package/dist/prosekit-web-drop-indicator.js.map +1 -1
- package/dist/prosekit-web-inline-popover.d.ts.map +1 -1
- package/dist/prosekit-web-inline-popover.js +1 -1
- package/dist/prosekit-web-inline-popover.js.map +1 -1
- package/dist/prosekit-web-popover.d.ts.map +1 -1
- package/dist/prosekit-web-popover.js.map +1 -1
- package/dist/prosekit-web-resizable.d.ts.map +1 -1
- package/dist/prosekit-web-resizable.js.map +1 -1
- package/dist/prosekit-web-table-handle.d.ts.map +1 -1
- package/dist/prosekit-web-table-handle.js +25 -25
- package/dist/prosekit-web-table-handle.js.map +1 -1
- package/dist/prosekit-web-tooltip.d.ts.map +1 -1
- package/dist/prosekit-web-tooltip.js.map +1 -1
- package/dist/prosekit-web.d.ts +80 -1
- package/dist/prosekit-web.d.ts.map +1 -0
- package/dist/prosekit-web.js +95 -1
- package/dist/prosekit-web.js.map +1 -0
- package/dist/{use-editor-extension-B_5BbYvf.js → use-editor-extension-B2WuUfnd.js} +1 -1
- package/dist/use-editor-extension-B2WuUfnd.js.map +1 -0
- package/dist/{use-scrolling-BjI3cuLt.js → use-scrolling-BjVzAkiZ.js} +3 -1
- package/dist/use-scrolling-BjVzAkiZ.js.map +1 -0
- package/package.json +10 -10
- package/src/components/autocomplete/autocomplete-empty/types.ts +1 -4
- package/src/components/autocomplete/autocomplete-item/setup.ts +2 -10
- package/src/components/autocomplete/autocomplete-item/types.ts +2 -8
- package/src/components/autocomplete/autocomplete-list/setup.ts +5 -21
- package/src/components/autocomplete/autocomplete-list/types.ts +2 -10
- package/src/components/autocomplete/autocomplete-popover/helpers.spec.ts +1 -5
- package/src/components/autocomplete/autocomplete-popover/setup.ts +4 -20
- package/src/components/autocomplete/autocomplete-popover/types.ts +1 -4
- package/src/components/autocomplete/context.ts +1 -4
- package/src/components/block-handle/block-handle-add/setup.ts +1 -5
- package/src/components/block-handle/block-handle-add/types.ts +1 -4
- package/src/components/block-handle/block-handle-draggable/setup.ts +3 -18
- package/src/components/block-handle/block-handle-draggable/types.ts +1 -4
- package/src/components/block-handle/block-handle-popover/pointer-move.ts +2 -10
- package/src/components/block-handle/block-handle-popover/setup.ts +4 -22
- package/src/components/block-handle/block-handle-popover/types.ts +1 -4
- package/src/components/block-handle/context.ts +1 -4
- package/src/components/drop-indicator/drop-indicator/setup.ts +3 -15
- package/src/components/drop-indicator/drop-indicator/types.ts +1 -4
- package/src/components/inline-popover/inline-popover/setup.ts +1 -4
- package/src/components/inline-popover/inline-popover/types.ts +1 -4
- package/src/components/inline-popover/inline-popover/virtual-selection-element.ts +1 -5
- package/src/components/popover/popover-content/types.ts +2 -8
- package/src/components/popover/popover-root/types.ts +2 -8
- package/src/components/popover/popover-trigger/types.ts +2 -8
- package/src/components/resizable/context.ts +1 -4
- package/src/components/resizable/resizable-handle/calc-resize.spec.ts +1 -4
- package/src/components/resizable/resizable-handle/setup.ts +2 -15
- package/src/components/resizable/resizable-handle/types.ts +1 -4
- package/src/components/resizable/resizable-root/setup.ts +4 -20
- package/src/components/resizable/resizable-root/types.ts +1 -4
- package/src/components/table-handle/context.ts +2 -8
- package/src/components/table-handle/dnd.ts +11 -17
- package/src/components/table-handle/hooks/use-drop.ts +2 -11
- package/src/components/table-handle/table-handle-column-root/setup.ts +2 -13
- package/src/components/table-handle/table-handle-column-root/types.ts +1 -4
- package/src/components/table-handle/table-handle-column-trigger/setup.ts +3 -14
- package/src/components/table-handle/table-handle-column-trigger/types.ts +1 -4
- package/src/components/table-handle/table-handle-drag-preview/render-preview.ts +2 -5
- package/src/components/table-handle/table-handle-drag-preview/setup.ts +3 -13
- package/src/components/table-handle/table-handle-drag-preview/types.ts +1 -4
- package/src/components/table-handle/table-handle-drag-preview/updater.ts +3 -14
- package/src/components/table-handle/table-handle-drop-indicator/setup.ts +6 -10
- package/src/components/table-handle/table-handle-drop-indicator/types.ts +1 -4
- package/src/components/table-handle/table-handle-drop-indicator/updater.ts +5 -19
- package/src/components/table-handle/table-handle-popover-content/setup.ts +2 -9
- package/src/components/table-handle/table-handle-popover-content/types.ts +2 -10
- package/src/components/table-handle/table-handle-popover-item/setup.ts +2 -8
- package/src/components/table-handle/table-handle-popover-item/types.ts +2 -10
- package/src/components/table-handle/table-handle-root/setup.ts +2 -9
- package/src/components/table-handle/table-handle-root/types.ts +1 -4
- package/src/components/table-handle/table-handle-row-root/setup.ts +2 -9
- package/src/components/table-handle/table-handle-row-root/types.ts +2 -9
- package/src/components/table-handle/table-handle-row-trigger/setup.ts +3 -14
- package/src/components/table-handle/table-handle-row-trigger/types.ts +1 -4
- package/src/components/table-handle/utils.ts +1 -4
- package/src/components/tooltip/tooltip-content/types.ts +2 -8
- package/src/components/tooltip/tooltip-root/types.ts +2 -8
- package/src/components/tooltip/tooltip-trigger/types.ts +2 -8
- package/src/hooks/use-editor-extension.ts +2 -9
- package/src/hooks/use-editor-focus-event.ts +2 -9
- package/src/hooks/use-editor-typing.ts +2 -10
- package/src/hooks/use-editor-update-event.ts +2 -9
- package/src/hooks/use-first-rendering.ts +1 -6
- package/src/hooks/use-keymap.ts +2 -9
- package/src/hooks/use-scrolling.ts +3 -6
- package/src/hooks/use-selecting.ts +1 -5
- package/src/index.ts +1 -1
- package/src/queue-extension.ts +93 -0
- package/src/utils/get-default-state.spec.ts +2 -10
- package/src/utils/get-default-state.ts +1 -5
- package/dist/get-default-state-Bqluw34o.js.map +0 -1
- package/dist/inject-style-DYQXx-cE.js.map +0 -1
- package/dist/use-editor-extension-B_5BbYvf.js.map +0 -1
- package/dist/use-scrolling-BjI3cuLt.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-default-state-BzBimBWi.js","names":[],"sources":["../src/utils/get-default-state.ts"],"sourcesContent":["import { createSignal, type PropDeclarations, type SignalState } 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":";;;AAEA,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-safe-editor-view-
|
|
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"}
|
|
@@ -22,13 +22,13 @@ function deepCopyStyles(source, target, important) {
|
|
|
22
22
|
const targets = [target];
|
|
23
23
|
const styles = [];
|
|
24
24
|
while (sources.length > 0 && sources.length === targets.length) {
|
|
25
|
-
const source
|
|
26
|
-
const target
|
|
27
|
-
if (!source
|
|
28
|
-
const style = copyStyles(source
|
|
25
|
+
const source = sources.pop();
|
|
26
|
+
const target = targets.pop();
|
|
27
|
+
if (!source || !target) break;
|
|
28
|
+
const style = copyStyles(source, target, important);
|
|
29
29
|
if (style) styles.push(style);
|
|
30
|
-
sources.push(...source
|
|
31
|
-
targets.push(...target
|
|
30
|
+
sources.push(...source.children);
|
|
31
|
+
targets.push(...target.children);
|
|
32
32
|
}
|
|
33
33
|
return styles.join("\n");
|
|
34
34
|
}
|
|
@@ -73,4 +73,4 @@ function injectStyle(container, styleText) {
|
|
|
73
73
|
|
|
74
74
|
//#endregion
|
|
75
75
|
export { cloneElement as n, deepCloneElement as r, injectStyle as t };
|
|
76
|
-
//# sourceMappingURL=inject-style-
|
|
76
|
+
//# sourceMappingURL=inject-style-BaFaVQvj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-style-BaFaVQvj.js","names":[],"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,MAAM,SAAmB,EAAE;AAE3B,QAAO,QAAQ,SAAS,KAAK,QAAQ,WAAW,QAAQ,QAAQ;EAC9D,MAAM,SAAS,QAAQ,KAAK;EAC5B,MAAM,SAAS,QAAQ,KAAK;AAE5B,MAAI,CAAC,UAAU,CAAC,OACd;EAGF,MAAM,QAAQ,WAAW,QAAQ,QAAQ,UAAU;AACnD,MAAI,MACF,QAAO,KAAK,MAAM;AAGpB,UAAQ,KAAK,GAAG,OAAO,SAAS;AAChC,UAAQ,KAAK,GAAG,OAAO,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,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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"],"
|
|
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"],"mappings":";;;;;;;;UAGiB,sBAAA;;cAGJ,sBAAA,EAAwB,gBAAA,CAAiB,sBAAA;;UAGrC,uBAAA;;cAGJ,uBAAA,EAAyB,iBAAA,CAAkB,uBAAA;;;cCPlD,4BAAA,EAA8B,sBAAA,CAAuB,sBAAA;AAAA,cAQrD,wBAAA,SAAiC,4BAAA;;;;;;cCR1B,oBAAA,SAA6B,eAAA;;;UCFzB,qBAAA;;;;;AHAjB;;;EGQE,KAAA;AAAA;AHLF;AAAA,cGSa,qBAAA,EAAuB,gBAAA,CAAiB,qBAAA;AAAA,UAMpC,sBAAA,SAA+B,iB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AA,EAAgC,sBAAA,CAAuB,wBAAA;AAAA,cAQvD,0BAAA,SAAmC,8BAAA;;;;;;iBCczB,sBAAA,CACd,IAAA,EAAM,kBAAA;EAEJ,KAAA;EACA;AAAA,GACC,YAAA,CAAa,wBAAA,EAA0B,yBAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as getStateWithDefaults } from "./get-default-state-
|
|
2
|
-
import { t as useEditorExtension } from "./use-editor-extension-
|
|
3
|
-
import { t as getSafeEditorView } from "./get-safe-editor-view-
|
|
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";
|
|
@@ -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('.prosekit-autocomplete-match')\n\n if (span) {\n reference.set(span)\n }\n\n query.set(defaultQueryBuilder(options.match))\n onDismiss.set(options.ignoreMatch)\n onSubmit.set(options.deleteMatch)\n }\n\n const handleLeave = () => {\n reference.set(null)\n query.set('')\n }\n\n return new AutocompleteRule({\n regex,\n onEnter: handleEnter,\n onLeave: handleLeave,\n })\n}\n\nfunction createKeymapHandler(\n handler: ReadonlySignal<VoidFunction | null>,\n enabled: ReadonlySignal<boolean>,\n) {\n return (): boolean => {\n if (!enabled.get()) {\n return false\n }\n\n const fn = handler.peek()\n if (!fn) return false\n fn()\n return true\n }\n}\n\nfunction useEscapeKeydown(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: () => boolean,\n): void {\n const keymap = { Escape: handler }\n const extension = withPriority(defineKeymap(keymap), Priority.highest)\n useEditorExtension(host, editor, extension)\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n overlayPositionerEvents,\n overlayPositionerProps,\n type OverlayPositionerEvents,\n type OverlayPositionerProps,\n} from '@aria-ui/overlay/elements'\nimport type { Editor } from '@prosekit/core'\n\nexport interface AutocompletePopoverProps extends OverlayPositionerProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * The regular expression to match the query text to autocomplete.\n *\n * @default null\n */\n regex: RegExp | null\n\n /**\n * The placement of the popover, relative to the text cursor.\n *\n * @default \"bottom-start\"\n */\n placement: OverlayPositionerProps['placement']\n\n /**\n * The distance between the popover and the hovered block.\n *\n * @default 4\n */\n offset: OverlayPositionerProps['offset']\n\n /**\n * @default true\n */\n inline: OverlayPositionerProps['inline']\n\n /**\n * @default true\n */\n hoist: OverlayPositionerProps['hoist']\n\n /**\n * @default true\n */\n fitViewport: OverlayPositionerProps['fitViewport']\n\n /**\n * @default \"The body element\"\n */\n boundary: OverlayPositionerProps['boundary']\n\n /**\n * @default 8\n */\n overflowPadding: OverlayPositionerProps['overflowPadding']\n}\n\nconst body = typeof document !== 'undefined' && document.querySelector('body')\nconst defaultBoundary = body || 'clippingAncestors'\n\n/** @internal */\nexport const autocompletePopoverProps: PropDeclarations<AutocompletePopoverProps> = {\n ...overlayPositionerProps,\n editor: { default: null },\n regex: { default: null },\n placement: { default: 'bottom-start' },\n offset: { default: 4 },\n inline: { default: true },\n hoist: { default: true },\n fitViewport: { default: true },\n boundary: { default: defaultBoundary },\n overflowPadding: { default: 8 },\n}\n\nexport interface AutocompletePopoverEvents extends OverlayPositionerEvents {\n /**\n * Fired when the open state changes.\n */\n openChange: CustomEvent<boolean>\n\n /**\n * Fired when the query changes.\n */\n queryChange: CustomEvent<string>\n}\n\n/** @internal */\nexport const autocompletePopoverEvents: EventDeclarations<AutocompletePopoverEvents> = {\n ...overlayPositionerEvents,\n openChange: {},\n queryChange: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useAutocompletePopover } from \"./setup\"\nimport { autocompletePopoverEvents, autocompletePopoverProps, type AutocompletePopoverEvents, type AutocompletePopoverProps } from \"./types\"\n\nconst AutocompletePopoverElementBase: BaseElementConstructor<AutocompletePopoverProps> = defineCustomElement<\n AutocompletePopoverProps,\n AutocompletePopoverEvents\n>({\n props: autocompletePopoverProps,\n events: autocompletePopoverEvents,\n setup: useAutocompletePopover,\n})\nclass AutocompletePopoverElement extends AutocompletePopoverElementBase {}\n\nregisterCustomElement('prosekit-autocomplete-popover', AutocompletePopoverElement)\n \nexport { AutocompletePopoverElement }\n"],"mappings":";;;;;;;;;;;;;;;AAKA,MAAaA,uBAA+C;;;;;ACI5D,MAAaC,yBAAmE,EAAE;;AAMlF,MAAaC,0BAAsE,EAAE;;;;ACV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AS,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
|
+
{"version":3,"file":"prosekit-web-autocomplete.js","names":["listboxProps"],"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 { EventDeclarations, PropDeclarations } 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 { createContext, type Context } 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 { useEffect, useEventListener, type ConnectableElement, type SetupOptions } from '@aria-ui/core'\nimport { useListboxItem } from '@aria-ui/listbox/elements'\n\nimport { openContext } from '../context'\n\nimport type { AutocompleteItemEvents, AutocompleteItemProps } 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 { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport { listboxItemEvents, type ListboxItemEvents } 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 { listboxProps, useListbox, type ListboxProps } from '@aria-ui/listbox/elements'\nimport { defineDOMEventHandler, Priority, withPriority, type Editor } from '@prosekit/core'\n\nimport { getStateWithDefaults } from '../../../utils/get-default-state'\nimport { onSubmitContext, openContext, queryContext } from '../context'\n\nimport type { AutocompleteListEvents, AutocompleteListProps } 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 { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport { listboxEvents, listboxProps, type ListboxEvents, type ListboxProps } 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 { createSignal, useEffect, type ConnectableElement, type ReadonlySignal } 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 { defineKeymap, Priority, withPriority, type Editor } from '@prosekit/core'\nimport { AutocompleteRule, defineAutocomplete, type MatchHandler } 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 { onSubmitContext, openContext, queryContext } from '../context'\n\nimport { defaultQueryBuilder } from './helpers'\nimport type { AutocompletePopoverEvents, AutocompletePopoverProps } from './types'\n\n/**\n * @internal\n */\nexport function useAutocompletePopover(\n host: ConnectableElement,\n {\n state,\n emit,\n }: SetupOptions<AutocompletePopoverProps, AutocompletePopoverEvents>,\n): void {\n const { editor, regex, ...overlayState } = state\n\n const reference = createSignal<Element | null>(null)\n const query = createSignal<string>('')\n const onDismiss = createSignal<VoidFunction | null>(null)\n const onSubmit = createSignal<VoidFunction | null>(null)\n const presence = createComputed(() => !!reference.get())\n\n queryContext.provide(host, query)\n onSubmitContext.provide(host, onSubmit)\n openContext.provide(host, presence)\n\n useEscapeKeydown(host, editor, createKeymapHandler(onDismiss, presence))\n\n useAutocompleteExtension(\n host,\n editor,\n regex,\n reference,\n query,\n onDismiss,\n onSubmit,\n )\n\n useOverlayPositionerState(host, overlayState, { reference })\n\n useAttribute(host, 'data-state', () => (presence.get() ? 'open' : 'closed'))\n usePresence(host, presence)\n\n const firstRendering = useFirstRendering(host)\n\n useEffect(host, () => {\n const queryValue = query.get()\n\n if (!firstRendering.peek()) {\n emit('queryChange', queryValue)\n }\n })\n\n useAnimationFrame(host, () => {\n const presenceValue = presence.get()\n return () => {\n emit('openChange', presenceValue)\n }\n })\n}\n\nfunction useAutocompleteExtension(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n regex: ReadonlySignal<RegExp | null>,\n reference: Signal<Element | null>,\n query: Signal<string>,\n onDismiss: Signal<VoidFunction | null>,\n onSubmit: Signal<VoidFunction | null>,\n) {\n useEffect(host, () => {\n const editorValue = editor.get()\n const regexValue = regex.get()\n\n if (!editorValue || !regexValue) {\n return\n }\n\n const rule = createAutocompleteRule(\n editorValue,\n regexValue,\n reference,\n query,\n onDismiss,\n onSubmit,\n )\n const extension = defineAutocomplete(rule)\n return editorValue.use(extension)\n })\n}\n\nfunction createAutocompleteRule(\n editor: Editor,\n regex: RegExp,\n reference: Signal<Element | null>,\n query: Signal<string>,\n onDismiss: Signal<VoidFunction | null>,\n onSubmit: Signal<VoidFunction | null>,\n) {\n const handleEnter: MatchHandler = (options) => {\n const view = getSafeEditorView(editor)\n const span = view?.dom.querySelector('.prosekit-autocomplete-match')\n\n if (span) {\n reference.set(span)\n }\n\n query.set(defaultQueryBuilder(options.match))\n onDismiss.set(options.ignoreMatch)\n onSubmit.set(options.deleteMatch)\n }\n\n const handleLeave = () => {\n reference.set(null)\n query.set('')\n }\n\n return new AutocompleteRule({\n regex,\n onEnter: handleEnter,\n onLeave: handleLeave,\n })\n}\n\nfunction createKeymapHandler(\n handler: ReadonlySignal<VoidFunction | null>,\n enabled: ReadonlySignal<boolean>,\n) {\n return (): boolean => {\n if (!enabled.get()) {\n return false\n }\n\n const fn = handler.peek()\n if (!fn) return false\n fn()\n return true\n }\n}\n\nfunction useEscapeKeydown(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: () => boolean,\n): void {\n const keymap = { Escape: handler }\n const extension = withPriority(defineKeymap(keymap), Priority.highest)\n useEditorExtension(host, editor, extension)\n}\n","import type { EventDeclarations, PropDeclarations } 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,MAAa,uBAA+C;;;;;ACC5D,MAAa,yBAA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,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,MAAa,4BAA0E;CACrF,GAAG;CACH,YAAY,EAAE;CACd,aAAa,EAAE;CAChB;;;;AC9FD,MAAM,iCAAmF,oBAGvF;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,6BAAN,cAAyC,+BAA+B;AAExE,sBAAsB,iCAAiC,2BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-block-handle.d.ts","names":[],"sources":["../src/components/block-handle/block-handle-add/types.ts","../src/components/block-handle/block-handle-add/element.gen.ts","../src/components/block-handle/block-handle-add/setup.ts","../src/components/block-handle/block-handle-draggable/types.ts","../src/components/block-handle/block-handle-draggable/element.gen.ts","../src/components/block-handle/block-handle-draggable/setup.ts","../src/components/block-handle/block-handle-popover/types.ts","../src/components/block-handle/block-handle-popover/element.gen.ts","../src/components/block-handle/block-handle-popover/setup.ts"],"
|
|
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"],"mappings":";;;;;;;UAGiB,mBAAA;;;;;AAAjB;;EAOE,MAAA,EAAQ,MAAA;AAAA;;cAIG,mBAAA,EAAqB,gBAAA,CAAiB,mBAAA;;UAKlC,oBAAA;;cAGJ,oBAAA,EAAsB,iBAAA,CAAkB,oBAAA;;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as getSafeEditorView } from "./get-safe-editor-view-
|
|
3
|
-
import { n as assignStyles, t as useScrolling } from "./use-scrolling-
|
|
4
|
-
import { r as deepCloneElement, t as injectStyle } from "./inject-style-
|
|
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-BjVzAkiZ.js";
|
|
4
|
+
import { r as deepCloneElement, t as injectStyle } from "./inject-style-BaFaVQvj.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";
|
|
@@ -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 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;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;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AAU,IAAI,eAAe;AAC7B,UAAQ,IAAI,WAAW;AAEvB,OAAK,eADsB,aAAa;GAAE,MAAM,WAAW;GAAM,KAAK,WAAW;GAAK,GAAG,KAClD;GACvC;AAEF,cAAa,MAAM,oBAAqB,KAAK,KAAK,GAAG,SAAS,SAAU;AACxE,aAAY,MAAM,KAAK;;AAGzB,SAAS,kBACP,MACA,QACA,SACA;CACA,IAAIC,iBAAoC;AAWxC,oBAAmB,MAAM,QATP,2BAA2B,WAAW,eAAe;AACrE,MAAI,kBAAkB,gBAAgB,WAAW,CAC/C;AAGF,mBAAiB;AACjB,UAAQ,WAAW,WAAW;GAC9B,CAEyC;;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":[],"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 { createContext, type Context } 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 { useEventListener, type ConnectableElement, type SignalState } 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 { EventDeclarations, PropDeclarations } 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 { useAttribute, useEffect, useEventListener, type ConnectableElement, type ReadonlySignal, type SignalState } from '@aria-ui/core'\nimport { isHTMLElement } from '@ocavue/utils'\nimport type { Editor } from '@prosekit/core'\nimport type { ViewDragging } from '@prosekit/extensions/drop-indicator'\nimport { Fragment, Slice } 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 { blockPopoverContext, draggingContext, type BlockPopoverContext, type HoverState } 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 { EventDeclarations, PropDeclarations } 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 { isElement, isHTMLElement, isTextNode } from '@ocavue/utils'\nimport { defineDOMEventHandler, union, type PlainExtension } 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 { createComputed, createSignal, useAttribute, type ConnectableElement, type ReadonlySignal, type SetupOptions } 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 { blockPopoverContext, draggingContext, type BlockPopoverContext, type HoverState } from '../context'\n\nimport { defineElementHoverHandler, type ElementHoverHandler } from './pointer-move'\nimport type { BlockHandlePopoverEvents, BlockHandlePopoverProps } 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 { EventDeclarations, PropDeclarations } 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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;AAGzB,SAAS,kBACP,MACA,QACA,SACA;CACA,IAAI,iBAAoC;AAWxC,oBAAmB,MAAM,QATP,2BAA2B,WAAW,eAAe;AACrE,MAAI,kBAAkB,gBAAgB,WAAW,CAC/C;AAGF,mBAAiB;AACjB,UAAQ,WAAW,WAAW;GAC9B,CAEyC;;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;;;;;;ACb7C,MAAa,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,MAAa,2BAAwE;CACnF,GAAG;CACH,aAAa,EAAE;CAChB;;;;AC3ED,MAAM,gCAAiF,oBAGrF;CACA,OAAO;CACP,QAAQ;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"],"
|
|
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"],"mappings":";;;;UAGiB,kBAAA;;AAAjB;;;;;EAOE,MAAA,EAAQ,MAAA;EAOR;;;AAIF;;EAJE,KAAA;AAAA;;cAIW,kBAAA,EAAoB,gBAAA,CAAiB,kBAAA;AAAA,UAKjC,mBAAA;;cAIJ,mBAAA,EAAqB,iBAAA,CAAkB,mBAAA;;;cCzB9C,wBAAA,EAA0B,sBAAA,CAAuB,kBAAA;AAAA,cAQjD,oBAAA,SAA6B,wBAAA;;;;;ADVnC;iBEUgB,gBAAA,CACd,IAAA,EAAM,kBAAA;EACJ;AAAA,GAAS,YAAA,CAAa,kBAAA,EAAoB,mBAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as useEditorExtension } from "./use-editor-extension-
|
|
2
|
-
import { n as assignStyles, t as useScrolling } from "./use-scrolling-
|
|
1
|
+
import { t as useEditorExtension } from "./use-editor-extension-B2WuUfnd.js";
|
|
2
|
+
import { n as assignStyles, t as useScrolling } from "./use-scrolling-BjVzAkiZ.js";
|
|
3
3
|
import { createComputed, createSignal, defineCustomElement, registerCustomElement, useEffect } from "@aria-ui/core";
|
|
4
4
|
import { usePresence } from "@aria-ui/presence";
|
|
5
5
|
import { defineDropIndicator } from "@prosekit/extensions/drop-indicator";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-drop-indicator.js","names":[
|
|
1
|
+
{"version":3,"file":"prosekit-web-drop-indicator.js","names":[],"sources":["../src/components/drop-indicator/drop-indicator/setup.ts","../src/components/drop-indicator/drop-indicator/types.ts","../src/components/drop-indicator/drop-indicator/element.gen.ts"],"sourcesContent":["import { createComputed, createSignal, useEffect, type ConnectableElement, type SetupOptions } from '@aria-ui/core'\nimport { usePresence } from '@aria-ui/presence'\nimport { defineDropIndicator, type ShowHandlerOptions } from '@prosekit/extensions/drop-indicator'\n\nimport { useEditorExtension } from '../../../hooks/use-editor-extension'\nimport { useScrolling } from '../../../hooks/use-scrolling'\nimport { assignStyles } from '../../../utils/assign-styles'\n\nimport type { DropIndicatorEvents, DropIndicatorProps } from './types'\n\n/**\n * @internal\n */\nexport function useDropIndicator(\n host: ConnectableElement,\n { state }: SetupOptions<DropIndicatorProps, DropIndicatorEvents>,\n): void {\n type DropIndicatorContext = ShowHandlerOptions | null\n const context = createSignal<DropIndicatorContext>(null)\n\n const extension = defineDropIndicator({\n onShow: (options) => context.set(options),\n onHide: () => context.set(null),\n })\n\n useEditorExtension(host, state.editor, extension)\n\n const line = createComputed(() => context.get()?.line)\n const scrolling = useScrolling(host)\n const presence = createComputed(() => {\n return !!context.get() && !scrolling.get()\n })\n usePresence(host, presence)\n\n useEffect(\n host,\n () => {\n const lineValue = line.get()\n const lineWidth = state.width.get()\n\n if (!lineValue) return\n\n const { p1: { x: x1, y: y1 }, p2: { x: x2, y: y2 } } = lineValue\n const horizontal = y1 === y2\n\n let width: number\n let height: number\n let top: number = y1\n let left: number = x1\n\n if (horizontal) {\n width = x2 - x1\n height = lineWidth\n top -= lineWidth / 2\n } else {\n width = lineWidth\n height = y2 - y1\n left -= lineWidth / 2\n }\n\n top = Math.round(top)\n left = Math.round(left)\n\n assignStyles(host, {\n position: 'fixed',\n pointerEvents: 'none',\n width: `${width}px`,\n height: `${height}px`,\n transform: `translate(${left}px, ${top}px)`,\n left: '0px',\n top: '0px',\n })\n },\n )\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nexport interface DropIndicatorProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * The line width in pixels.\n *\n * @default 2\n */\n width: number\n}\n\n/** @internal */\nexport const dropIndicatorProps: PropDeclarations<DropIndicatorProps> = Object.freeze({\n editor: { default: null },\n width: { default: 2 },\n})\n\nexport interface DropIndicatorEvents {\n}\n\n/** @internal */\nexport const dropIndicatorEvents: EventDeclarations<DropIndicatorEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useDropIndicator } from \"./setup\"\nimport { dropIndicatorEvents, dropIndicatorProps, type DropIndicatorEvents, type DropIndicatorProps } from \"./types\"\n\nconst DropIndicatorElementBase: BaseElementConstructor<DropIndicatorProps> = defineCustomElement<\n DropIndicatorProps,\n DropIndicatorEvents\n>({\n props: dropIndicatorProps,\n events: dropIndicatorEvents,\n setup: useDropIndicator,\n})\nclass DropIndicatorElement extends DropIndicatorElementBase {}\n\nregisterCustomElement('prosekit-drop-indicator', DropIndicatorElement)\n \nexport { DropIndicatorElement }\n"],"mappings":";;;;;;;;;;AAaA,SAAgB,iBACd,MACA,EAAE,SACI;CAEN,MAAM,UAAU,aAAmC,KAAK;CAExD,MAAM,YAAY,oBAAoB;EACpC,SAAS,YAAY,QAAQ,IAAI,QAAQ;EACzC,cAAc,QAAQ,IAAI,KAAK;EAChC,CAAC;AAEF,oBAAmB,MAAM,MAAM,QAAQ,UAAU;CAEjD,MAAM,OAAO,qBAAqB,QAAQ,KAAK,EAAE,KAAK;CACtD,MAAM,YAAY,aAAa,KAAK;AAIpC,aAAY,MAHK,qBAAqB;AACpC,SAAO,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,UAAU,KAAK;GAC1C,CACyB;AAE3B,WACE,YACM;EACJ,MAAM,YAAY,KAAK,KAAK;EAC5B,MAAM,YAAY,MAAM,MAAM,KAAK;AAEnC,MAAI,CAAC,UAAW;EAEhB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,MAAM,IAAI,EAAE,GAAG,IAAI,GAAG,SAAS;EACvD,MAAM,aAAa,OAAO;EAE1B,IAAI;EACJ,IAAI;EACJ,IAAI,MAAc;EAClB,IAAI,OAAe;AAEnB,MAAI,YAAY;AACd,WAAQ,KAAK;AACb,YAAS;AACT,UAAO,YAAY;SACd;AACL,WAAQ;AACR,YAAS,KAAK;AACd,WAAQ,YAAY;;AAGtB,QAAM,KAAK,MAAM,IAAI;AACrB,SAAO,KAAK,MAAM,KAAK;AAEvB,eAAa,MAAM;GACjB,UAAU;GACV,eAAe;GACf,OAAO,GAAG,MAAM;GAChB,QAAQ,GAAG,OAAO;GAClB,WAAW,aAAa,KAAK,MAAM,IAAI;GACvC,MAAM;GACN,KAAK;GACN,CAAC;GAEL;;;;;;ACpDH,MAAa,qBAA2D,OAAO,OAAO;CACpF,QAAQ,EAAE,SAAS,MAAM;CACzB,OAAO,EAAE,SAAS,GAAG;CACtB,CAAC;;AAMF,MAAa,sBAA8D,EAAE;;;;ACzB7E,MAAM,2BAAuE,oBAG3E;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,uBAAN,cAAmC,yBAAyB;AAE5D,sBAAsB,2BAA2B,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-inline-popover.d.ts","names":[],"sources":["../src/components/inline-popover/inline-popover/types.ts","../src/components/inline-popover/inline-popover/element.gen.ts","../src/components/inline-popover/inline-popover/setup.ts"],"
|
|
1
|
+
{"version":3,"file":"prosekit-web-inline-popover.d.ts","names":[],"sources":["../src/components/inline-popover/inline-popover/types.ts","../src/components/inline-popover/inline-popover/element.gen.ts","../src/components/inline-popover/inline-popover/setup.ts"],"mappings":";;;;;UASiB,kBAAA,SACf,IAAA,CACE,sBAAA;;AAFJ;;;;;EAYE,MAAA,EAAQ,MAAA;EAwCA;;;;;;;;;;EA5BR,WAAA;EAZQ;;;;;;;;EAsBR,IAAA;EAuBM;;;;;;EAfN,eAAA;EA8BuC;;AAIzC;EA7BE,SAAA,EAAW,sBAAA;;;;EAKX,MAAA,EAAQ,sBAAA;EAuC2B;;;EAlCnC,IAAA,EAAM,sBAAA;EAsCN;;;EAjCA,OAAA,EAAS,sBAAA;EAqCE;;;EAhCX,MAAA,EAAQ,sBAAA;EAgC6D;;;EA3BrE,eAAA,EAAiB,sBAAA;AAAA;;cAIN,kBAAA,EAAoB,gBAAA,CAAiB,kBAAA;AAAA,UAejC,mBAAA,SAA4B,uBAAA;EC/F4B;AAAA;;EDmGvE,UAAA,EAAY,WAAA;AAAA;;cAID,mBAAA,EAAqB,iBAAA,CAAkB,mBAAA;;;cCvG9C,wBAAA,EAA0B,sBAAA,CAAuB,kBAAA;AAAA,cAQjD,oBAAA,SAA6B,wBAAA;;;;;;iBCYnB,gBAAA,CACd,IAAA,EAAM,kBAAA;EACJ,KAAA;EAAO;AAAA,GAAQ,YAAA,CAAa,kBAAA,EAAoB,mBAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as useEditorExtension } from "./use-editor-extension-
|
|
1
|
+
import { t as useEditorExtension } from "./use-editor-extension-B2WuUfnd.js";
|
|
2
2
|
import { createComputed, createSignal, defineCustomElement, registerCustomElement, useAttribute, useEffect } from "@aria-ui/core";
|
|
3
3
|
import { containsInlineNode, defineFocusChangeHandler, defineKeymap, defineUpdateHandler, isInCodeBlock, isTextSelection } from "@prosekit/core";
|
|
4
4
|
import { useOverlayPositionerState } from "@aria-ui/overlay/elements";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-inline-popover.js","names":["prevSelection: Selection | undefined","inlinePopoverProps: PropDeclarations<InlinePopoverProps>","overlayPositionerProps","inlinePopoverEvents: EventDeclarations<InlinePopoverEvents>","overlayPositionerEvents","InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps>"],"sources":["../src/hooks/use-editor-focus-event.ts","../src/hooks/use-editor-update-event.ts","../src/hooks/use-keymap.ts","../src/components/inline-popover/inline-popover/virtual-selection-element.ts","../src/components/inline-popover/inline-popover/setup.ts","../src/components/inline-popover/inline-popover/types.ts","../src/components/inline-popover/inline-popover/element.gen.ts"],"sourcesContent":["import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineFocusChangeHandler,\n type Editor,\n type FocusChangeHandler,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\n/**\n * @internal\n */\nexport function useEditorFocusChangeEvent(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: FocusChangeHandler,\n): void {\n const extension = defineFocusChangeHandler(handler)\n useEditorExtension(host, editor, extension)\n}\n","import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineUpdateHandler,\n type Editor,\n type UpdateHandler,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\n/**\n * @internal\n */\nexport function useEditorUpdateEvent(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: UpdateHandler,\n): void {\n const extension = defineUpdateHandler(handler)\n useEditorExtension(host, editor, extension)\n}\n","import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineKeymap,\n type Editor,\n type Keymap,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\nexport function useKeymap(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n keymap: Keymap,\n): void {\n const extension = defineKeymap(keymap)\n useEditorExtension(host, editor, extension)\n}\n","import type { ReferenceElement } from '@floating-ui/dom'\nimport {\n containsInlineNode,\n isInCodeBlock,\n isTextSelection,\n} from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nexport function getVirtualSelectionElement(\n view: EditorView,\n): ReferenceElement | undefined {\n if (typeof window === 'undefined' || view.isDestroyed) {\n return\n }\n\n const selection = view.state.selection\n\n if (\n !selection.empty\n && !isInCodeBlock(selection)\n && isTextSelection(selection)\n && containsInlineNode(view.state.doc, selection.from, selection.to)\n ) {\n return getDomDecoration(view) || getInlineDecoration(view)\n }\n}\n\nfunction getDomDecoration(view: EditorView): ReferenceElement | undefined {\n const range = getDomRange(view)\n if (range) {\n // To get it work properly in Safari, we cannot return the range directly.\n // We have to return a contextElement.\n return {\n contextElement: view.dom,\n getBoundingClientRect: () => range.getBoundingClientRect(),\n getClientRects: () => range.getClientRects(),\n }\n }\n}\n\nfunction getDomRange(view: EditorView): Range | undefined {\n const win = view.dom.ownerDocument.defaultView\n const selection = win?.getSelection()\n if (!selection || selection.isCollapsed) {\n return\n }\n\n const range = typeof selection.rangeCount === 'number'\n && selection.rangeCount > 0\n && selection.getRangeAt(0)\n\n if (!range) {\n return\n }\n\n return range\n}\n\nfunction getInlineDecoration(view: EditorView): ReferenceElement | undefined {\n const match = view.dom.querySelectorAll('.prosekit-virtual-selection')\n\n if (match.length === 0) {\n return\n }\n if (match.length === 1) {\n return match[0]\n }\n\n const items = Array.from(match)\n return {\n contextElement: items[0],\n getBoundingClientRect: () => items[0].getBoundingClientRect(),\n getClientRects: () => items.map((item) => item.getBoundingClientRect()),\n }\n}\n","import {\n createComputed,\n createSignal,\n useAttribute,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { useOverlayPositionerState } from '@aria-ui/overlay/elements'\nimport { usePresence } from '@aria-ui/presence'\nimport type { ReferenceElement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\nimport type { Selection } from '@prosekit/pm/state'\n\nimport { useEditorFocusChangeEvent } from '../../../hooks/use-editor-focus-event'\nimport { useEditorUpdateEvent } from '../../../hooks/use-editor-update-event'\nimport { useKeymap } from '../../../hooks/use-keymap'\n\nimport type {\n InlinePopoverEvents,\n InlinePopoverProps,\n} from './types'\nimport { getVirtualSelectionElement } from './virtual-selection-element'\n\n/**\n * @internal\n */\nexport function useInlinePopover(\n host: ConnectableElement,\n { state, emit }: SetupOptions<InlinePopoverProps, InlinePopoverEvents>,\n): void {\n const { editor, defaultOpen, open, ...overlayState } = state\n\n const reference = useInlinePopoverReference(host, editor)\n const hasReference = createComputed(() => !!reference.get())\n\n useEffect(host, () => {\n const hasReferenceValue = hasReference.get()\n const defaultOpenValue = defaultOpen.peek()\n const openValue = open.peek()\n\n if (defaultOpenValue || openValue) {\n emit('openChange', hasReferenceValue)\n }\n })\n\n useEffect(host, () => {\n const hasReferenceValue = hasReference.get()\n const defaultOpenValue = defaultOpen.peek()\n\n if (hasReferenceValue && defaultOpenValue) {\n open.set(true)\n } else if (!hasReferenceValue) {\n open.set(false)\n }\n })\n\n useKeymap(host, editor, {\n Escape: () => {\n if (!state.dismissOnEscape.peek() || !open.peek()) {\n return false\n }\n open.set(false)\n emit('openChange', false)\n return true\n },\n })\n\n useOverlayPositionerState(host, overlayState, { reference })\n\n useAttribute(host, 'data-state', () => (open.get() ? 'open' : 'closed'))\n usePresence(host, open)\n}\n\nfunction useInlinePopoverReference(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n) {\n const reference = createSignal<ReferenceElement | null>(null)\n let editorFocused = false\n\n useEditorFocusChangeEvent(host, editor, (focus) => {\n editorFocused = focus\n })\n\n let prevSelection: Selection | undefined\n\n useEditorUpdateEvent(host, editor, (view) => {\n const isPopoverFocused = !editorFocused && host.contains(host.ownerDocument.activeElement)\n\n if (isPopoverFocused) {\n return\n }\n\n const { selection } = view.state\n const selectionUnchanged = prevSelection?.eq(selection)\n prevSelection = selection\n\n // Skip reference update if only the document content has changed, not the\n // selection itself.\n //\n // Example: If the user selects text and then applies mark bold using the\n // popover, the selection may widen, but we don't want to reposition the\n // popover.\n if (selectionUnchanged) {\n return\n }\n\n reference.set(getVirtualSelectionElement(view) || null)\n })\n\n return reference\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n overlayPositionerEvents,\n overlayPositionerProps,\n type OverlayPositionerEvents,\n type OverlayPositionerProps,\n} from '@aria-ui/overlay'\nimport type { Editor } from '@prosekit/core'\n\nexport interface InlinePopoverProps extends\n Omit<\n OverlayPositionerProps,\n 'placement' | 'offset' | 'hide' | 'overlap' | 'inline' | 'overflowPadding'\n >\n{\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * Whether the popover is open by default when some inline content is\n * selected.\n *\n * When `defaultOpen` is true, the popover will open or close based on the\n * inline selection. When `defaultOpen` is false, the popover will never be\n * opened unless the `open` prop is true.\n *\n * @default true\n */\n defaultOpen: boolean\n\n /**\n * Whether the popover is open.\n *\n * Notice that the popover will be always hidden if the inline selection is\n * empty.\n *\n * @default false\n */\n open: boolean\n\n /**\n * Whether the inline popover should be dismissed when the editor receives an\n * Escape key press.\n *\n * @default true\n */\n dismissOnEscape: boolean\n\n /**\n * @default \"top\"\n */\n placement: OverlayPositionerProps['placement']\n\n /**\n * @default 12\n */\n offset: OverlayPositionerProps['offset']\n\n /**\n * @default true\n */\n hide: OverlayPositionerProps['hide']\n\n /**\n * @default true\n */\n overlap: OverlayPositionerProps['overlap']\n\n /**\n * @default true\n */\n inline: OverlayPositionerProps['inline']\n\n /**\n * @default 8\n */\n overflowPadding: OverlayPositionerProps['overflowPadding']\n}\n\n/** @internal */\nexport const inlinePopoverProps: PropDeclarations<InlinePopoverProps> = Object.freeze({\n ...overlayPositionerProps,\n editor: { default: null },\n defaultOpen: { default: true },\n open: { default: false },\n dismissOnEscape: { default: true },\n\n placement: { default: 'top' },\n offset: { default: 12 },\n hide: { default: true },\n overlap: { default: true },\n inline: { default: true },\n overflowPadding: { default: 8 },\n})\n\nexport interface InlinePopoverEvents extends OverlayPositionerEvents {\n /**\n * Fired when the open state changes.\n */\n openChange: CustomEvent<boolean>\n}\n\n/** @internal */\nexport const inlinePopoverEvents: EventDeclarations<InlinePopoverEvents> = {\n ...overlayPositionerEvents,\n openChange: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useInlinePopover } from \"./setup\"\nimport { inlinePopoverEvents, inlinePopoverProps, type InlinePopoverEvents, type InlinePopoverProps } from \"./types\"\n\nconst InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps> = defineCustomElement<\n InlinePopoverProps,\n InlinePopoverEvents\n>({\n props: inlinePopoverProps,\n events: inlinePopoverEvents,\n setup: useInlinePopover,\n})\nclass InlinePopoverElement extends InlinePopoverElementBase {}\n\nregisterCustomElement('prosekit-inline-popover', InlinePopoverElement)\n \nexport { InlinePopoverElement }\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,0BACd,MACA,QACA,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ACvD;AAEF,QAAO;;;;;;ACxBT,MAAaC,qBAA2D,OAAO,OAAO;CACpF,GAAGC;CACH,QAAQ,EAAE,SAAS,MAAM;CACzB,aAAa,EAAE,SAAS,MAAM;CAC9B,MAAM,EAAE,SAAS,OAAO;CACxB,iBAAiB,EAAE,SAAS,MAAM;CAElC,WAAW,EAAE,SAAS,OAAO;CAC7B,QAAQ,EAAE,SAAS,IAAI;CACvB,MAAM,EAAE,SAAS,MAAM;CACvB,SAAS,EAAE,SAAS,MAAM;CAC1B,QAAQ,EAAE,SAAS,MAAM;CACzB,iBAAiB,EAAE,SAAS,GAAG;CAChC,CAAC;;AAUF,MAAaC,sBAA8D;CACzE,GAAGC;CACH,YAAY,EAAE;CACf;;;;AC7GD,MAAMC,2BAAuE,oBAG3E;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,uBAAN,cAAmC,yBAAyB;AAE5D,sBAAsB,2BAA2B,qBAAqB"}
|
|
1
|
+
{"version":3,"file":"prosekit-web-inline-popover.js","names":["overlayPositionerProps","overlayPositionerEvents"],"sources":["../src/hooks/use-editor-focus-event.ts","../src/hooks/use-editor-update-event.ts","../src/hooks/use-keymap.ts","../src/components/inline-popover/inline-popover/virtual-selection-element.ts","../src/components/inline-popover/inline-popover/setup.ts","../src/components/inline-popover/inline-popover/types.ts","../src/components/inline-popover/inline-popover/element.gen.ts"],"sourcesContent":["import type { ConnectableElement, ReadonlySignal } from '@aria-ui/core'\nimport { defineFocusChangeHandler, type Editor, type FocusChangeHandler } from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\n/**\n * @internal\n */\nexport function useEditorFocusChangeEvent(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: FocusChangeHandler,\n): void {\n const extension = defineFocusChangeHandler(handler)\n useEditorExtension(host, editor, extension)\n}\n","import type { ConnectableElement, ReadonlySignal } from '@aria-ui/core'\nimport { defineUpdateHandler, type Editor, type UpdateHandler } from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\n/**\n * @internal\n */\nexport function useEditorUpdateEvent(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: UpdateHandler,\n): void {\n const extension = defineUpdateHandler(handler)\n useEditorExtension(host, editor, extension)\n}\n","import type { ConnectableElement, ReadonlySignal } from '@aria-ui/core'\nimport { defineKeymap, type Editor, type Keymap } from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\nexport function useKeymap(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n keymap: Keymap,\n): void {\n const extension = defineKeymap(keymap)\n useEditorExtension(host, editor, extension)\n}\n","import type { ReferenceElement } from '@floating-ui/dom'\nimport { containsInlineNode, isInCodeBlock, isTextSelection } from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nexport function getVirtualSelectionElement(\n view: EditorView,\n): ReferenceElement | undefined {\n if (typeof window === 'undefined' || view.isDestroyed) {\n return\n }\n\n const selection = view.state.selection\n\n if (\n !selection.empty\n && !isInCodeBlock(selection)\n && isTextSelection(selection)\n && containsInlineNode(view.state.doc, selection.from, selection.to)\n ) {\n return getDomDecoration(view) || getInlineDecoration(view)\n }\n}\n\nfunction getDomDecoration(view: EditorView): ReferenceElement | undefined {\n const range = getDomRange(view)\n if (range) {\n // To get it work properly in Safari, we cannot return the range directly.\n // We have to return a contextElement.\n return {\n contextElement: view.dom,\n getBoundingClientRect: () => range.getBoundingClientRect(),\n getClientRects: () => range.getClientRects(),\n }\n }\n}\n\nfunction getDomRange(view: EditorView): Range | undefined {\n const win = view.dom.ownerDocument.defaultView\n const selection = win?.getSelection()\n if (!selection || selection.isCollapsed) {\n return\n }\n\n const range = typeof selection.rangeCount === 'number'\n && selection.rangeCount > 0\n && selection.getRangeAt(0)\n\n if (!range) {\n return\n }\n\n return range\n}\n\nfunction getInlineDecoration(view: EditorView): ReferenceElement | undefined {\n const match = view.dom.querySelectorAll('.prosekit-virtual-selection')\n\n if (match.length === 0) {\n return\n }\n if (match.length === 1) {\n return match[0]\n }\n\n const items = Array.from(match)\n return {\n contextElement: items[0],\n getBoundingClientRect: () => items[0].getBoundingClientRect(),\n getClientRects: () => items.map((item) => item.getBoundingClientRect()),\n }\n}\n","import {\n createComputed,\n createSignal,\n useAttribute,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { useOverlayPositionerState } from '@aria-ui/overlay/elements'\nimport { usePresence } from '@aria-ui/presence'\nimport type { ReferenceElement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\nimport type { Selection } from '@prosekit/pm/state'\n\nimport { useEditorFocusChangeEvent } from '../../../hooks/use-editor-focus-event'\nimport { useEditorUpdateEvent } from '../../../hooks/use-editor-update-event'\nimport { useKeymap } from '../../../hooks/use-keymap'\n\nimport type { InlinePopoverEvents, InlinePopoverProps } from './types'\nimport { getVirtualSelectionElement } from './virtual-selection-element'\n\n/**\n * @internal\n */\nexport function useInlinePopover(\n host: ConnectableElement,\n { state, emit }: SetupOptions<InlinePopoverProps, InlinePopoverEvents>,\n): void {\n const { editor, defaultOpen, open, ...overlayState } = state\n\n const reference = useInlinePopoverReference(host, editor)\n const hasReference = createComputed(() => !!reference.get())\n\n useEffect(host, () => {\n const hasReferenceValue = hasReference.get()\n const defaultOpenValue = defaultOpen.peek()\n const openValue = open.peek()\n\n if (defaultOpenValue || openValue) {\n emit('openChange', hasReferenceValue)\n }\n })\n\n useEffect(host, () => {\n const hasReferenceValue = hasReference.get()\n const defaultOpenValue = defaultOpen.peek()\n\n if (hasReferenceValue && defaultOpenValue) {\n open.set(true)\n } else if (!hasReferenceValue) {\n open.set(false)\n }\n })\n\n useKeymap(host, editor, {\n Escape: () => {\n if (!state.dismissOnEscape.peek() || !open.peek()) {\n return false\n }\n open.set(false)\n emit('openChange', false)\n return true\n },\n })\n\n useOverlayPositionerState(host, overlayState, { reference })\n\n useAttribute(host, 'data-state', () => (open.get() ? 'open' : 'closed'))\n usePresence(host, open)\n}\n\nfunction useInlinePopoverReference(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n) {\n const reference = createSignal<ReferenceElement | null>(null)\n let editorFocused = false\n\n useEditorFocusChangeEvent(host, editor, (focus) => {\n editorFocused = focus\n })\n\n let prevSelection: Selection | undefined\n\n useEditorUpdateEvent(host, editor, (view) => {\n const isPopoverFocused = !editorFocused && host.contains(host.ownerDocument.activeElement)\n\n if (isPopoverFocused) {\n return\n }\n\n const { selection } = view.state\n const selectionUnchanged = prevSelection?.eq(selection)\n prevSelection = selection\n\n // Skip reference update if only the document content has changed, not the\n // selection itself.\n //\n // Example: If the user selects text and then applies mark bold using the\n // popover, the selection may widen, but we don't want to reposition the\n // popover.\n if (selectionUnchanged) {\n return\n }\n\n reference.set(getVirtualSelectionElement(view) || null)\n })\n\n return reference\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport {\n overlayPositionerEvents,\n overlayPositionerProps,\n type OverlayPositionerEvents,\n type OverlayPositionerProps,\n} from '@aria-ui/overlay'\nimport type { Editor } from '@prosekit/core'\n\nexport interface InlinePopoverProps extends\n Omit<\n OverlayPositionerProps,\n 'placement' | 'offset' | 'hide' | 'overlap' | 'inline' | 'overflowPadding'\n >\n{\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * Whether the popover is open by default when some inline content is\n * selected.\n *\n * When `defaultOpen` is true, the popover will open or close based on the\n * inline selection. When `defaultOpen` is false, the popover will never be\n * opened unless the `open` prop is true.\n *\n * @default true\n */\n defaultOpen: boolean\n\n /**\n * Whether the popover is open.\n *\n * Notice that the popover will be always hidden if the inline selection is\n * empty.\n *\n * @default false\n */\n open: boolean\n\n /**\n * Whether the inline popover should be dismissed when the editor receives an\n * Escape key press.\n *\n * @default true\n */\n dismissOnEscape: boolean\n\n /**\n * @default \"top\"\n */\n placement: OverlayPositionerProps['placement']\n\n /**\n * @default 12\n */\n offset: OverlayPositionerProps['offset']\n\n /**\n * @default true\n */\n hide: OverlayPositionerProps['hide']\n\n /**\n * @default true\n */\n overlap: OverlayPositionerProps['overlap']\n\n /**\n * @default true\n */\n inline: OverlayPositionerProps['inline']\n\n /**\n * @default 8\n */\n overflowPadding: OverlayPositionerProps['overflowPadding']\n}\n\n/** @internal */\nexport const inlinePopoverProps: PropDeclarations<InlinePopoverProps> = Object.freeze({\n ...overlayPositionerProps,\n editor: { default: null },\n defaultOpen: { default: true },\n open: { default: false },\n dismissOnEscape: { default: true },\n\n placement: { default: 'top' },\n offset: { default: 12 },\n hide: { default: true },\n overlap: { default: true },\n inline: { default: true },\n overflowPadding: { default: 8 },\n})\n\nexport interface InlinePopoverEvents extends OverlayPositionerEvents {\n /**\n * Fired when the open state changes.\n */\n openChange: CustomEvent<boolean>\n}\n\n/** @internal */\nexport const inlinePopoverEvents: EventDeclarations<InlinePopoverEvents> = {\n ...overlayPositionerEvents,\n openChange: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useInlinePopover } from \"./setup\"\nimport { inlinePopoverEvents, inlinePopoverProps, type InlinePopoverEvents, type InlinePopoverProps } from \"./types\"\n\nconst InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps> = defineCustomElement<\n InlinePopoverProps,\n InlinePopoverEvents\n>({\n props: inlinePopoverProps,\n events: inlinePopoverEvents,\n setup: useInlinePopover,\n})\nclass InlinePopoverElement extends InlinePopoverElementBase {}\n\nregisterCustomElement('prosekit-inline-popover', InlinePopoverElement)\n \nexport { InlinePopoverElement }\n"],"mappings":";;;;;;;;;;;AAQA,SAAgB,0BACd,MACA,QACA,SACM;AAEN,oBAAmB,MAAM,QADP,yBAAyB,QAAQ,CACR;;;;;;;;ACN7C,SAAgB,qBACd,MACA,QACA,SACM;AAEN,oBAAmB,MAAM,QADP,oBAAoB,QAAQ,CACH;;;;;ACT7C,SAAgB,UACd,MACA,QACA,QACM;A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