@prosekit/preact 0.7.0-beta.1 → 0.7.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,6 +42,13 @@ interface InlinePopoverPositionerProps extends HTMLAttributes<InlinePopoverPosit
42
42
  * @default true
43
43
  */
44
44
  hide?: InlinePopoverPositionerProps$1['hide'];
45
+ /**
46
+ * Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
47
+ * to place the floating element on top of other page content.
48
+ *
49
+ * @default false
50
+ */
51
+ hoist?: InlinePopoverPositionerProps$1['hoist'];
45
52
  /**
46
53
  * Whether the floating element can overlap the reference element to keep it
47
54
  * in view.
@@ -76,13 +83,6 @@ interface InlinePopoverPositionerProps extends HTMLAttributes<InlinePopoverPosit
76
83
  * @default true
77
84
  */
78
85
  autoUpdate?: InlinePopoverPositionerProps$1['autoUpdate'];
79
- /**
80
- * Whether to use the browser Popover API to place the floating element on
81
- * top of other page content.
82
- *
83
- * @default true
84
- */
85
- hoist?: InlinePopoverPositionerProps$1['hoist'];
86
86
  /**
87
87
  * Whether to flip the `placement` in order to keep it in view when the
88
88
  * preferred placement(s) will overflow the clipping boundary. You can also
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-preact-inline-popover.d.ts","names":[],"sources":["../src/components/inline-popover/inline-popover-popup.gen.ts","../src/components/inline-popover/inline-popover-positioner.gen.ts","../src/components/inline-popover/inline-popover-root.gen.ts"],"mappings":";;;;;;;;;AA2CA;UA7BiB,uBAAA,SAAgC,cAAA,CAAe,yBAAA;;;;;;cA6BnD,kBAAA,EAAoB,yBAAA,CAA0B,uBAAA,GAA0B,aAAA,CAAc,yBAAA;;;;;;;AAAnG;UC7BiB,4BAAA,SAAqC,cAAA,CAAe,8BAAA;;;;;;EAMnE,SAAA,GAAY,8BAAA;EDuB4C;;;;;ECjBxD,MAAA,GAAS,8BAAA;EDiBiH;;;;AC7B5H;;EAmBE,IAAA,GAAO,8BAAA;EAnB4D;;;;;;EA0BnE,OAAA,GAAU,8BAAA;EAmBC;;;;;;EAZX,MAAA,GAAS,8BAAA;EA+DI;;;;;EAzDb,eAAA,GAAkB,8BAAA;EAvCgD;;;;;EA6ClE,QAAA,GAAW,8BAAA;EAjCX;;;;;;;EAyCA,UAAA,GAAa,8BAAA;EAdb;;;;;;EAqBA,KAAA,GAAQ,8BAAA;EAAA;;;;;;;;EASR,IAAA,GAAO,8BAAA;EA2BP;;;;;EArBA,KAAA,GAAQ,8BAAA;EA2CR;;;;;;EApCA,WAAA,GAAc,8BAAA;EAgF4L;;;;;;EAzE1M,SAAA,GAAY,8BAAA;EAyEiD;;;;;;EAlE7D,UAAA,GAAa,8BAAA;;;;AC9Ff;;;EDqGE,QAAA,GAAW,8BAAA;EC9FF;;;;;;EDqGT,YAAA,GAAe,8BAAA;EC5G6C;;;;;;;EDoH5D,cAAA,GAAiB,8BAAA;EC/FjB;;;;;;;EDuGA,WAAA,GAAc,8BAAA;AAAA;;;ACnChB;;;cDuEa,uBAAA,EAAyB,yBAAA,CAA0B,4BAAA,GAA+B,aAAA,CAAc,8BAAA;;;;;;;ADrI7G;UE3BiB,sBAAA,SAA+B,cAAA,CAAe,wBAAA;;;;;;;EAO7D,MAAA,GAAS,wBAAA;EFoBsB;;;;;;EEb/B,WAAA,GAAc,wBAAA;;;ADhBhB;;;;ECuBE,eAAA,GAAkB,wBAAA;EDXT;;;;ECgBT,IAAA,GAAO,wBAAA;EDiBI;;;;ECZX,QAAA,GAAW,wBAAA;EDiDG;EC/Cd,YAAA,IAAgB,KAAA,EAAO,uBAAA;AAAA;;;;;;cAwDZ,iBAAA,EAAmB,yBAAA,CAA0B,sBAAA,GAAyB,aAAA,CAAc,wBAAA"}
1
+ {"version":3,"file":"prosekit-preact-inline-popover.d.ts","names":[],"sources":["../src/components/inline-popover/inline-popover-popup.gen.ts","../src/components/inline-popover/inline-popover-positioner.gen.ts","../src/components/inline-popover/inline-popover-root.gen.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A;EDkBW;;;;ECblB,QAAA,GAAW,wBAAA;EDiDG;EC/Cd,YAAA,IAAgB,KAAA,EAAO,uBAAA;AAAA;;;;;;cAwDZ,iBAAA,EAAmB,yBAAA,CAA0B,sBAAA,GAAyB,aAAA,CAAc,wBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-preact-inline-popover.js","names":[],"sources":["../src/components/inline-popover/inline-popover-popup.gen.ts","../src/components/inline-popover/inline-popover-positioner.gen.ts","../src/components/inline-popover/inline-popover-root.gen.ts"],"sourcesContent":["/**\n * This file is auto-generated by the \"@aria-ui/cli\" tool. Do not edit this file directly.\n */\n\nimport { registerInlinePopoverPopupElement, type InlinePopoverPopupElement } from '@prosekit/web/inline-popover';\nimport { createElement, type HTMLAttributes, type Ref } from 'preact';\nimport { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';\nimport { useCallback, useRef } from 'preact/hooks';\n\n/**\n * Props for the {@link InlinePopoverPopup} Preact component.\n *\n * @public\n */\nexport interface InlinePopoverPopupProps extends HTMLAttributes<InlinePopoverPopupElement> {}\n\nfunction InlinePopoverPopupComponent(props: InlinePopoverPopupProps, forwardedRef: Ref<InlinePopoverPopupElement>) {\n registerInlinePopoverPopupElement();\n\n const elementRef = useRef<InlinePopoverPopupElement>(null);\n\n const { ...restProps } = props;\n\n const mergedRef = useCallback(\n (element: InlinePopoverPopupElement | null) => {\n elementRef.current = element;\n if (typeof forwardedRef === 'function') {\n forwardedRef(element);\n } else if (forwardedRef) {\n forwardedRef.current = element;\n }\n },\n [forwardedRef],\n );\n\n return createElement('prosekit-inline-popover-popup', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });\n}\n\n/**\n * A Preact component that renders an `prosekit-inline-popover-popup` custom element.\n *\n * @public\n */\nexport const InlinePopoverPopup: ForwardRefExoticComponent<InlinePopoverPopupProps & RefAttributes<InlinePopoverPopupElement>> = /* @__PURE__ */ forwardRef(InlinePopoverPopupComponent);\n","/**\n * This file is auto-generated by the \"@aria-ui/cli\" tool. Do not edit this file directly.\n */\n\nimport { registerInlinePopoverPositionerElement, type InlinePopoverPositionerElement, type InlinePopoverPositionerProps as InlinePopoverPositionerElementProps } from '@prosekit/web/inline-popover';\nimport { createElement, type HTMLAttributes, type Ref } from 'preact';\nimport { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';\nimport { useCallback, useRef, useLayoutEffect } from 'preact/hooks';\n\n/**\n * Props for the {@link InlinePopoverPositioner} Preact component.\n *\n * @public\n */\nexport interface InlinePopoverPositionerProps extends HTMLAttributes<InlinePopoverPositionerElement> {\n /**\n * The initial placement of the floating element\n *\n * @default \"top\"\n */\n placement?: InlinePopoverPositionerElementProps['placement'];\n /**\n * The distance between the reference and floating element.\n *\n * @default 12\n */\n offset?: InlinePopoverPositionerElementProps['offset'];\n /**\n * Whether to hide the floating element when the reference element or the\n * floating element is fully clipped.\n *\n * @default true\n */\n hide?: InlinePopoverPositionerElementProps['hide'];\n /**\n * Whether the floating element can overlap the reference element to keep it\n * in view.\n *\n * @default true\n */\n overlap?: InlinePopoverPositionerElementProps['overlap'];\n /**\n * Whether to improve positioning for inline reference elements that span over\n * multiple lines.\n *\n * @default true\n */\n inline?: InlinePopoverPositionerElementProps['inline'];\n /**\n * Describes the virtual padding around the boundary to check for overflow.\n *\n * @default 8\n */\n overflowPadding?: InlinePopoverPositionerElementProps['overflowPadding'];\n /**\n * The strategy to use for positioning\n *\n * @default \"absolute\"\n */\n strategy?: InlinePopoverPositionerElementProps['strategy'];\n /**\n * Options to activate auto-update listeners\n *\n * @see https://floating-ui.com/docs/autoUpdate\n *\n * @default true\n */\n autoUpdate?: InlinePopoverPositionerElementProps['autoUpdate'];\n /**\n * Whether to use the browser Popover API to place the floating element on\n * top of other page content.\n *\n * @default true\n */\n hoist?: InlinePopoverPositionerElementProps['hoist'];\n /**\n * Whether to flip the `placement` in order to keep it in view when the\n * preferred placement(s) will overflow the clipping boundary. You can also\n * provide an array of placements to try sequentially if the preferred\n * `placement` does not fit.\n *\n * @default true\n */\n flip?: InlinePopoverPositionerElementProps['flip'];\n /**\n * Whether the floating element should shift to keep it in view.\n *\n * @default true\n */\n shift?: InlinePopoverPositionerElementProps['shift'];\n /**\n * Whether to constrain the floating element's width and height to not exceed\n * the viewport.\n *\n * @default false\n */\n fitViewport?: InlinePopoverPositionerElementProps['fitViewport'];\n /**\n * Whether to constrain the floating element's width so that it matches the\n * reference element.\n *\n * @default false\n */\n sameWidth?: InlinePopoverPositionerElementProps['sameWidth'];\n /**\n * Whether to constrain the floating element's height so that it matches the\n * reference element.\n *\n * @default false\n */\n sameHeight?: InlinePopoverPositionerElementProps['sameHeight'];\n /**\n * Describes the clipping element(s) or area that overflow will be checked relative to.\n * Please see https://floating-ui.com/docs/detectoverflow#boundary for more information.\n *\n * @default 'clippingAncestors'\n */\n boundary?: InlinePopoverPositionerElementProps['boundary'];\n /**\n * Describes the root boundary that the element will be checked for overflow relative to.\n * Please see https://floating-ui.com/docs/detectoverflow#rootboundary for more information.\n *\n * @default 'viewport'\n */\n rootBoundary?: InlinePopoverPositionerElementProps['rootBoundary'];\n /**\n * The element that will be used to check for overflow. Please see\n * https://floating-ui.com/docs/detectoverflow#elementcontext for more\n * information.\n *\n * @default 'floating'\n */\n elementContext?: InlinePopoverPositionerElementProps['elementContext'];\n /**\n * Whether to check the alternate elementContext's boundary. Please see\n * https://floating-ui.com/docs/detectoverflow#altboundary for more\n * information.\n *\n * @default false\n */\n altBoundary?: InlinePopoverPositionerElementProps['altBoundary'];\n}\n\nfunction InlinePopoverPositionerComponent(props: InlinePopoverPositionerProps, forwardedRef: Ref<InlinePopoverPositionerElement>) {\n registerInlinePopoverPositionerElement();\n\n const elementRef = useRef<InlinePopoverPositionerElement>(null);\n\n const { altBoundary: p0, autoUpdate: p1, boundary: p2, elementContext: p3, fitViewport: p4, flip: p5, hide: p6, hoist: p7, inline: p8, offset: p9, overflowPadding: p10, overlap: p11, placement: p12, rootBoundary: p13, sameHeight: p14, sameWidth: p15, shift: p16, strategy: p17, ...restProps } = props;\n\n useLayoutEffect(() => {\n const element = elementRef.current as Record<string, unknown> | null;\n if (!element) return;\n Object.assign(element, { altBoundary: p0, autoUpdate: p1, boundary: p2, elementContext: p3, fitViewport: p4, flip: p5, hide: p6, hoist: p7, inline: p8, offset: p9, overflowPadding: p10, overlap: p11, placement: p12, rootBoundary: p13, sameHeight: p14, sameWidth: p15, shift: p16, strategy: p17 });\n });\n\n const mergedRef = useCallback(\n (element: InlinePopoverPositionerElement | null) => {\n elementRef.current = element;\n if (typeof forwardedRef === 'function') {\n forwardedRef(element);\n } else if (forwardedRef) {\n forwardedRef.current = element;\n }\n },\n [forwardedRef],\n );\n\n return createElement('prosekit-inline-popover-positioner', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });\n}\n\n/**\n * A Preact component that renders an `prosekit-inline-popover-positioner` custom element.\n *\n * @public\n */\nexport const InlinePopoverPositioner: ForwardRefExoticComponent<InlinePopoverPositionerProps & RefAttributes<InlinePopoverPositionerElement>> = /* @__PURE__ */ forwardRef(InlinePopoverPositionerComponent);\n","/**\n * This file is auto-generated by the \"@aria-ui/cli\" tool. Do not edit this file directly.\n */\n\nimport { registerInlinePopoverRootElement, type InlinePopoverRootElement, type InlinePopoverRootProps as InlinePopoverRootElementProps, type InlinePopoverRootEvents } from '@prosekit/web/inline-popover';\nimport { createElement, type HTMLAttributes, type Ref } from 'preact';\nimport { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';\nimport { useCallback, useRef, useLayoutEffect } from 'preact/hooks';\n\nimport { useEditorContext } from '../../contexts/editor-context.ts';\n\n/**\n * Props for the {@link InlinePopoverRoot} Preact component.\n *\n * @public\n */\nexport interface InlinePopoverRootProps extends HTMLAttributes<InlinePopoverRootElement> {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor?: InlinePopoverRootElementProps['editor'];\n /**\n * Whether the popover is open by default when some inline content is\n * selected.\n *\n * @default true\n */\n defaultOpen?: InlinePopoverRootElementProps['defaultOpen'];\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?: InlinePopoverRootElementProps['dismissOnEscape'];\n /**\n * Whether the overlay is currently open.\n * @default null\n */\n open?: InlinePopoverRootElementProps['open'];\n /**\n * Whether the component should ignore user interaction.\n * @default false\n */\n disabled?: InlinePopoverRootElementProps['disabled'];\n /** */\n onOpenChange?: (event: InlinePopoverRootEvents['openChange']) => void;\n}\n\nfunction InlinePopoverRootComponent(props: InlinePopoverRootProps, forwardedRef: Ref<InlinePopoverRootElement>) {\n registerInlinePopoverRootElement();\n\n const elementRef = useRef<InlinePopoverRootElement>(null);\n const handlersRef = useRef<Array<((event: Event) => void) | undefined>>([]);\n\n const p3Fallback = useEditorContext();\n\n const { defaultOpen: p0, disabled: p1, dismissOnEscape: p2, editor: p3, open: p4, onOpenChange: e0, ...restProps } = props;\n\n useLayoutEffect(() => {\n const element = elementRef.current as Record<string, unknown> | null;\n if (!element) return;\n Object.assign(element, { defaultOpen: p0, disabled: p1, dismissOnEscape: p2, editor: p3 ?? p3Fallback, open: p4 });\n handlersRef.current = [e0] as Array<((event: Event) => void) | undefined>;\n });\n\n useLayoutEffect(() => {\n const element = elementRef.current;\n if (!element) return;\n const ac = new AbortController();\n for (const [index, eventName] of ['openChange'].entries()) {\n element.addEventListener(\n eventName,\n (event: Event) => {\n handlersRef.current[index]?.(event);\n },\n { signal: ac.signal },\n );\n }\n return () => ac.abort();\n }, []);\n\n const mergedRef = useCallback(\n (element: InlinePopoverRootElement | null) => {\n elementRef.current = element;\n if (typeof forwardedRef === 'function') {\n forwardedRef(element);\n } else if (forwardedRef) {\n forwardedRef.current = element;\n }\n },\n [forwardedRef],\n );\n\n return createElement('prosekit-inline-popover-root', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });\n}\n\n/**\n * A Preact component that renders an `prosekit-inline-popover-root` custom element.\n *\n * @public\n */\nexport const InlinePopoverRoot: ForwardRefExoticComponent<InlinePopoverRootProps & RefAttributes<InlinePopoverRootElement>> = /* @__PURE__ */ forwardRef(InlinePopoverRootComponent);\n\nexport type { InlinePopoverRootEvents };\n"],"mappings":";;;;;;;;;AAgBA,SAAS,4BAA4B,OAAgC,cAA8C;AACjH,oCAAmC;CAEnC,MAAM,aAAa,OAAkC,KAAK;CAE1D,MAAM,EAAE,GAAG,cAAc;CAEzB,MAAM,YAAY,aACf,YAA8C;AAC7C,aAAW,UAAU;AACrB,MAAI,OAAO,iBAAiB,WAC1B,cAAa,QAAQ;WACZ,aACT,cAAa,UAAU;IAG3B,CAAC,aAAa,CACf;AAED,QAAO,cAAc,iCAAiC;EAAE,GAAG;EAAW,KAAK;EAAW,0BAA0B;EAAM,CAAC;;;;;;;AAQzH,MAAa,qBAAoI,2BAAW,4BAA4B;;;;;;ACoGxL,SAAS,iCAAiC,OAAqC,cAAmD;AAChI,yCAAwC;CAExC,MAAM,aAAa,OAAuC,KAAK;CAE/D,MAAM,EAAE,aAAa,IAAI,YAAY,IAAI,UAAU,IAAI,gBAAgB,IAAI,aAAa,IAAI,MAAM,IAAI,MAAM,IAAI,OAAO,IAAI,QAAQ,IAAI,QAAQ,IAAI,iBAAiB,KAAK,SAAS,KAAK,WAAW,KAAK,cAAc,KAAK,YAAY,KAAK,WAAW,KAAK,OAAO,KAAK,UAAU,KAAK,GAAG,cAAc;AAEvS,uBAAsB;EACpB,MAAM,UAAU,WAAW;AAC3B,MAAI,CAAC,QAAS;AACd,SAAO,OAAO,SAAS;GAAE,aAAa;GAAI,YAAY;GAAI,UAAU;GAAI,gBAAgB;GAAI,aAAa;GAAI,MAAM;GAAI,MAAM;GAAI,OAAO;GAAI,QAAQ;GAAI,QAAQ;GAAI,iBAAiB;GAAK,SAAS;GAAK,WAAW;GAAK,cAAc;GAAK,YAAY;GAAK,WAAW;GAAK,OAAO;GAAK,UAAU;GAAK,CAAC;GACxS;CAEF,MAAM,YAAY,aACf,YAAmD;AACl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Aa,oBAAiI,2BAAW,2BAA2B"}
1
+ {"version":3,"file":"prosekit-preact-inline-popover.js","names":[],"sources":["../src/components/inline-popover/inline-popover-popup.gen.ts","../src/components/inline-popover/inline-popover-positioner.gen.ts","../src/components/inline-popover/inline-popover-root.gen.ts"],"sourcesContent":["/**\n * This file is auto-generated by the \"@aria-ui/cli\" tool. Do not edit this file directly.\n */\n\nimport { registerInlinePopoverPopupElement, type InlinePopoverPopupElement } from '@prosekit/web/inline-popover';\nimport { createElement, type HTMLAttributes, type Ref } from 'preact';\nimport { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';\nimport { useCallback, useRef } from 'preact/hooks';\n\n/**\n * Props for the {@link InlinePopoverPopup} Preact component.\n *\n * @public\n */\nexport interface InlinePopoverPopupProps extends HTMLAttributes<InlinePopoverPopupElement> {}\n\nfunction InlinePopoverPopupComponent(props: InlinePopoverPopupProps, forwardedRef: Ref<InlinePopoverPopupElement>) {\n registerInlinePopoverPopupElement();\n\n const elementRef = useRef<InlinePopoverPopupElement>(null);\n\n const { ...restProps } = props;\n\n const mergedRef = useCallback(\n (element: InlinePopoverPopupElement | null) => {\n elementRef.current = element;\n if (typeof forwardedRef === 'function') {\n forwardedRef(element);\n } else if (forwardedRef) {\n forwardedRef.current = element;\n }\n },\n [forwardedRef],\n );\n\n return createElement('prosekit-inline-popover-popup', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });\n}\n\n/**\n * A Preact component that renders an `prosekit-inline-popover-popup` custom element.\n *\n * @public\n */\nexport const InlinePopoverPopup: ForwardRefExoticComponent<InlinePopoverPopupProps & RefAttributes<InlinePopoverPopupElement>> = /* @__PURE__ */ forwardRef(InlinePopoverPopupComponent);\n","/**\n * This file is auto-generated by the \"@aria-ui/cli\" tool. Do not edit this file directly.\n */\n\nimport { registerInlinePopoverPositionerElement, type InlinePopoverPositionerElement, type InlinePopoverPositionerProps as InlinePopoverPositionerElementProps } from '@prosekit/web/inline-popover';\nimport { createElement, type HTMLAttributes, type Ref } from 'preact';\nimport { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';\nimport { useCallback, useRef, useLayoutEffect } from 'preact/hooks';\n\n/**\n * Props for the {@link InlinePopoverPositioner} Preact component.\n *\n * @public\n */\nexport interface InlinePopoverPositionerProps extends HTMLAttributes<InlinePopoverPositionerElement> {\n /**\n * The initial placement of the floating element\n *\n * @default \"top\"\n */\n placement?: InlinePopoverPositionerElementProps['placement'];\n /**\n * The distance between the reference and floating element.\n *\n * @default 12\n */\n offset?: InlinePopoverPositionerElementProps['offset'];\n /**\n * Whether to hide the floating element when the reference element or the\n * floating element is fully clipped.\n *\n * @default true\n */\n hide?: InlinePopoverPositionerElementProps['hide'];\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?: InlinePopoverPositionerElementProps['hoist'];\n /**\n * Whether the floating element can overlap the reference element to keep it\n * in view.\n *\n * @default true\n */\n overlap?: InlinePopoverPositionerElementProps['overlap'];\n /**\n * Whether to improve positioning for inline reference elements that span over\n * multiple lines.\n *\n * @default true\n */\n inline?: InlinePopoverPositionerElementProps['inline'];\n /**\n * Describes the virtual padding around the boundary to check for overflow.\n *\n * @default 8\n */\n overflowPadding?: InlinePopoverPositionerElementProps['overflowPadding'];\n /**\n * The strategy to use for positioning\n *\n * @default \"absolute\"\n */\n strategy?: InlinePopoverPositionerElementProps['strategy'];\n /**\n * Options to activate auto-update listeners\n *\n * @see https://floating-ui.com/docs/autoUpdate\n *\n * @default true\n */\n autoUpdate?: InlinePopoverPositionerElementProps['autoUpdate'];\n /**\n * Whether to flip the `placement` in order to keep it in view when the\n * preferred placement(s) will overflow the clipping boundary. You can also\n * provide an array of placements to try sequentially if the preferred\n * `placement` does not fit.\n *\n * @default true\n */\n flip?: InlinePopoverPositionerElementProps['flip'];\n /**\n * Whether the floating element should shift to keep it in view.\n *\n * @default true\n */\n shift?: InlinePopoverPositionerElementProps['shift'];\n /**\n * Whether to constrain the floating element's width and height to not exceed\n * the viewport.\n *\n * @default false\n */\n fitViewport?: InlinePopoverPositionerElementProps['fitViewport'];\n /**\n * Whether to constrain the floating element's width so that it matches the\n * reference element.\n *\n * @default false\n */\n sameWidth?: InlinePopoverPositionerElementProps['sameWidth'];\n /**\n * Whether to constrain the floating element's height so that it matches the\n * reference element.\n *\n * @default false\n */\n sameHeight?: InlinePopoverPositionerElementProps['sameHeight'];\n /**\n * Describes the clipping element(s) or area that overflow will be checked relative to.\n * Please see https://floating-ui.com/docs/detectoverflow#boundary for more information.\n *\n * @default 'clippingAncestors'\n */\n boundary?: InlinePopoverPositionerElementProps['boundary'];\n /**\n * Describes the root boundary that the element will be checked for overflow relative to.\n * Please see https://floating-ui.com/docs/detectoverflow#rootboundary for more information.\n *\n * @default 'viewport'\n */\n rootBoundary?: InlinePopoverPositionerElementProps['rootBoundary'];\n /**\n * The element that will be used to check for overflow. Please see\n * https://floating-ui.com/docs/detectoverflow#elementcontext for more\n * information.\n *\n * @default 'floating'\n */\n elementContext?: InlinePopoverPositionerElementProps['elementContext'];\n /**\n * Whether to check the alternate elementContext's boundary. Please see\n * https://floating-ui.com/docs/detectoverflow#altboundary for more\n * information.\n *\n * @default false\n */\n altBoundary?: InlinePopoverPositionerElementProps['altBoundary'];\n}\n\nfunction InlinePopoverPositionerComponent(props: InlinePopoverPositionerProps, forwardedRef: Ref<InlinePopoverPositionerElement>) {\n registerInlinePopoverPositionerElement();\n\n const elementRef = useRef<InlinePopoverPositionerElement>(null);\n\n const { altBoundary: p0, autoUpdate: p1, boundary: p2, elementContext: p3, fitViewport: p4, flip: p5, hide: p6, hoist: p7, inline: p8, offset: p9, overflowPadding: p10, overlap: p11, placement: p12, rootBoundary: p13, sameHeight: p14, sameWidth: p15, shift: p16, strategy: p17, ...restProps } = props;\n\n useLayoutEffect(() => {\n const element = elementRef.current as Record<string, unknown> | null;\n if (!element) return;\n Object.assign(element, { altBoundary: p0, autoUpdate: p1, boundary: p2, elementContext: p3, fitViewport: p4, flip: p5, hide: p6, hoist: p7, inline: p8, offset: p9, overflowPadding: p10, overlap: p11, placement: p12, rootBoundary: p13, sameHeight: p14, sameWidth: p15, shift: p16, strategy: p17 });\n });\n\n const mergedRef = useCallback(\n (element: InlinePopoverPositionerElement | null) => {\n elementRef.current = element;\n if (typeof forwardedRef === 'function') {\n forwardedRef(element);\n } else if (forwardedRef) {\n forwardedRef.current = element;\n }\n },\n [forwardedRef],\n );\n\n return createElement('prosekit-inline-popover-positioner', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });\n}\n\n/**\n * A Preact component that renders an `prosekit-inline-popover-positioner` custom element.\n *\n * @public\n */\nexport const InlinePopoverPositioner: ForwardRefExoticComponent<InlinePopoverPositionerProps & RefAttributes<InlinePopoverPositionerElement>> = /* @__PURE__ */ forwardRef(InlinePopoverPositionerComponent);\n","/**\n * This file is auto-generated by the \"@aria-ui/cli\" tool. Do not edit this file directly.\n */\n\nimport { registerInlinePopoverRootElement, type InlinePopoverRootElement, type InlinePopoverRootProps as InlinePopoverRootElementProps, type InlinePopoverRootEvents } from '@prosekit/web/inline-popover';\nimport { createElement, type HTMLAttributes, type Ref } from 'preact';\nimport { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';\nimport { useCallback, useRef, useLayoutEffect } from 'preact/hooks';\n\nimport { useEditorContext } from '../../contexts/editor-context.ts';\n\n/**\n * Props for the {@link InlinePopoverRoot} Preact component.\n *\n * @public\n */\nexport interface InlinePopoverRootProps extends HTMLAttributes<InlinePopoverRootElement> {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor?: InlinePopoverRootElementProps['editor'];\n /**\n * Whether the popover is open by default when some inline content is\n * selected.\n *\n * @default true\n */\n defaultOpen?: InlinePopoverRootElementProps['defaultOpen'];\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?: InlinePopoverRootElementProps['dismissOnEscape'];\n /**\n * Whether the overlay is currently open.\n * @default null\n */\n open?: InlinePopoverRootElementProps['open'];\n /**\n * Whether the component should ignore user interaction.\n * @default false\n */\n disabled?: InlinePopoverRootElementProps['disabled'];\n /** */\n onOpenChange?: (event: InlinePopoverRootEvents['openChange']) => void;\n}\n\nfunction InlinePopoverRootComponent(props: InlinePopoverRootProps, forwardedRef: Ref<InlinePopoverRootElement>) {\n registerInlinePopoverRootElement();\n\n const elementRef = useRef<InlinePopoverRootElement>(null);\n const handlersRef = useRef<Array<((event: Event) => void) | undefined>>([]);\n\n const p3Fallback = useEditorContext();\n\n const { defaultOpen: p0, disabled: p1, dismissOnEscape: p2, editor: p3, open: p4, onOpenChange: e0, ...restProps } = props;\n\n useLayoutEffect(() => {\n const element = elementRef.current as Record<string, unknown> | null;\n if (!element) return;\n Object.assign(element, { defaultOpen: p0, disabled: p1, dismissOnEscape: p2, editor: p3 ?? p3Fallback, open: p4 });\n handlersRef.current = [e0] as Array<((event: Event) => void) | undefined>;\n });\n\n useLayoutEffect(() => {\n const element = elementRef.current;\n if (!element) return;\n const ac = new AbortController();\n for (const [index, eventName] of ['openChange'].entries()) {\n element.addEventListener(\n eventName,\n (event: Event) => {\n handlersRef.current[index]?.(event);\n },\n { signal: ac.signal },\n );\n }\n return () => ac.abort();\n }, []);\n\n const mergedRef = useCallback(\n (element: InlinePopoverRootElement | null) => {\n elementRef.current = element;\n if (typeof forwardedRef === 'function') {\n forwardedRef(element);\n } else if (forwardedRef) {\n forwardedRef.current = element;\n }\n },\n [forwardedRef],\n );\n\n return createElement('prosekit-inline-popover-root', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });\n}\n\n/**\n * A Preact component that renders an `prosekit-inline-popover-root` custom element.\n *\n * @public\n */\nexport const InlinePopoverRoot: ForwardRefExoticComponent<InlinePopoverRootProps & RefAttributes<InlinePopoverRootElement>> = /* @__PURE__ */ forwardRef(InlinePopoverRootComponent);\n\nexport type { InlinePopover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0.7.0-beta.1",
4
+ "version": "0.7.0-beta.2",
5
5
  "private": false,
6
6
  "description": "Preact components and utilities for ProseKit",
7
7
  "author": {
@@ -76,7 +76,7 @@
76
76
  "@prosemirror-adapter/preact": "^0.5.3",
77
77
  "@prosekit/core": "^0.12.0-beta.0",
78
78
  "@prosekit/pm": "^0.1.15",
79
- "@prosekit/web": "^0.8.0-beta.1"
79
+ "@prosekit/web": "^0.8.0-beta.2"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "preact": ">= 10.11.0"
@@ -93,8 +93,8 @@
93
93
  "vitest": "^4.1.4",
94
94
  "vitest-browser-preact": "^1.0.0",
95
95
  "@prosekit/config-ts": "0.0.0",
96
- "@prosekit/config-tsdown": "0.0.0",
97
96
  "@prosekit/config-vitest": "0.0.0",
97
+ "@prosekit/config-tsdown": "0.0.0",
98
98
  "@prosekit/testing": "0.0.0"
99
99
  },
100
100
  "publishConfig": {
@@ -32,6 +32,13 @@ export interface InlinePopoverPositionerProps extends HTMLAttributes<InlinePopov
32
32
  * @default true
33
33
  */
34
34
  hide?: InlinePopoverPositionerElementProps['hide'];
35
+ /**
36
+ * Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
37
+ * to place the floating element on top of other page content.
38
+ *
39
+ * @default false
40
+ */
41
+ hoist?: InlinePopoverPositionerElementProps['hoist'];
35
42
  /**
36
43
  * Whether the floating element can overlap the reference element to keep it
37
44
  * in view.
@@ -66,13 +73,6 @@ export interface InlinePopoverPositionerProps extends HTMLAttributes<InlinePopov
66
73
  * @default true
67
74
  */
68
75
  autoUpdate?: InlinePopoverPositionerElementProps['autoUpdate'];
69
- /**
70
- * Whether to use the browser Popover API to place the floating element on
71
- * top of other page content.
72
- *
73
- * @default true
74
- */
75
- hoist?: InlinePopoverPositionerElementProps['hoist'];
76
76
  /**
77
77
  * Whether to flip the `placement` in order to keep it in view when the
78
78
  * preferred placement(s) will overflow the clipping boundary. You can also