@prosekit/preact 0.7.0-beta.0 → 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.
Files changed (117) hide show
  1. package/dist/prosekit-preact-autocomplete.d.ts +226 -18
  2. package/dist/prosekit-preact-autocomplete.d.ts.map +1 -1
  3. package/dist/prosekit-preact-autocomplete.js +218 -9
  4. package/dist/prosekit-preact-autocomplete.js.map +1 -1
  5. package/dist/prosekit-preact-block-handle.d.ts +210 -14
  6. package/dist/prosekit-preact-block-handle.d.ts.map +1 -1
  7. package/dist/prosekit-preact-block-handle.js +184 -7
  8. package/dist/prosekit-preact-block-handle.js.map +1 -1
  9. package/dist/prosekit-preact-drop-indicator.d.ts +27 -6
  10. package/dist/prosekit-preact-drop-indicator.d.ts.map +1 -1
  11. package/dist/prosekit-preact-drop-indicator.js +38 -3
  12. package/dist/prosekit-preact-drop-indicator.js.map +1 -1
  13. package/dist/prosekit-preact-inline-popover.d.ts +204 -8
  14. package/dist/prosekit-preact-inline-popover.d.ts.map +1 -1
  15. package/dist/prosekit-preact-inline-popover.js +130 -5
  16. package/dist/prosekit-preact-inline-popover.js.map +1 -1
  17. package/dist/prosekit-preact-menu.d.ts +288 -0
  18. package/dist/prosekit-preact-menu.d.ts.map +1 -0
  19. package/dist/prosekit-preact-menu.js +274 -0
  20. package/dist/prosekit-preact-menu.js.map +1 -0
  21. package/dist/prosekit-preact-popover.d.ts +227 -14
  22. package/dist/prosekit-preact-popover.d.ts.map +1 -1
  23. package/dist/prosekit-preact-popover.js +170 -7
  24. package/dist/prosekit-preact-popover.js.map +1 -1
  25. package/dist/prosekit-preact-resizable.d.ts +56 -12
  26. package/dist/prosekit-preact-resizable.d.ts.map +1 -1
  27. package/dist/prosekit-preact-resizable.js +80 -7
  28. package/dist/prosekit-preact-resizable.js.map +1 -1
  29. package/dist/prosekit-preact-table-handle.d.ts +447 -38
  30. package/dist/prosekit-preact-table-handle.d.ts.map +1 -1
  31. package/dist/prosekit-preact-table-handle.js +381 -19
  32. package/dist/prosekit-preact-table-handle.js.map +1 -1
  33. package/dist/prosekit-preact-tooltip.d.ts +211 -14
  34. package/dist/prosekit-preact-tooltip.d.ts.map +1 -1
  35. package/dist/prosekit-preact-tooltip.js +157 -7
  36. package/dist/prosekit-preact-tooltip.js.map +1 -1
  37. package/package.json +27 -16
  38. package/src/components/autocomplete/autocomplete-empty.gen.ts +41 -31
  39. package/src/components/autocomplete/autocomplete-item.gen.ts +84 -31
  40. package/src/components/autocomplete/autocomplete-popup.gen.ts +80 -0
  41. package/src/components/autocomplete/autocomplete-positioner.gen.ts +153 -0
  42. package/src/components/autocomplete/autocomplete-root.gen.ts +109 -0
  43. package/src/components/autocomplete/index.gen.ts +12 -4
  44. package/src/components/autocomplete/index.ts +27 -0
  45. package/src/components/block-handle/block-handle-add.gen.ts +59 -31
  46. package/src/components/block-handle/block-handle-draggable.gen.ts +59 -31
  47. package/src/components/block-handle/block-handle-popup.gen.ts +44 -0
  48. package/src/components/block-handle/block-handle-positioner.gen.ts +171 -0
  49. package/src/components/block-handle/block-handle-root.gen.ts +84 -0
  50. package/src/components/block-handle/index.gen.ts +13 -3
  51. package/src/components/block-handle/index.ts +27 -0
  52. package/src/components/drop-indicator/drop-indicator.gen.ts +65 -31
  53. package/src/components/drop-indicator/index.gen.ts +5 -1
  54. package/src/components/drop-indicator/index.ts +14 -0
  55. package/src/components/inline-popover/index.gen.ts +11 -1
  56. package/src/components/inline-popover/index.ts +22 -0
  57. package/src/components/inline-popover/inline-popover-popup.gen.ts +44 -0
  58. package/src/components/inline-popover/inline-popover-positioner.gen.ts +177 -0
  59. package/src/components/inline-popover/inline-popover-root.gen.ts +108 -0
  60. package/src/components/menu/index.gen.ts +19 -0
  61. package/src/components/menu/index.ts +37 -0
  62. package/src/components/menu/menu-item.gen.ts +91 -0
  63. package/src/components/menu/menu-popup.gen.ts +58 -0
  64. package/src/components/menu/menu-positioner.gen.ts +178 -0
  65. package/src/components/menu/menu-root.gen.ts +88 -0
  66. package/src/components/menu/menu-submenu-root.gen.ts +44 -0
  67. package/src/components/menu/menu-submenu-trigger.gen.ts +44 -0
  68. package/src/components/menu/menu-trigger.gen.ts +79 -0
  69. package/src/components/popover/index.gen.ts +11 -3
  70. package/src/components/popover/index.ts +24 -0
  71. package/src/components/popover/popover-popup.gen.ts +44 -0
  72. package/src/components/popover/popover-positioner.gen.ts +178 -0
  73. package/src/components/popover/popover-root.gen.ts +92 -31
  74. package/src/components/popover/popover-trigger.gen.ts +92 -31
  75. package/src/components/resizable/index.gen.ts +8 -2
  76. package/src/components/resizable/index.ts +20 -0
  77. package/src/components/resizable/resizable-handle.gen.ts +54 -31
  78. package/src/components/resizable/resizable-root.gen.ts +90 -31
  79. package/src/components/table-handle/index.gen.ts +17 -9
  80. package/src/components/table-handle/index.ts +58 -0
  81. package/src/components/table-handle/table-handle-column-menu-root.gen.ts +66 -0
  82. package/src/components/table-handle/table-handle-column-menu-trigger.gen.ts +60 -0
  83. package/src/components/table-handle/table-handle-column-popup.gen.ts +44 -0
  84. package/src/components/table-handle/table-handle-column-positioner.gen.ts +201 -0
  85. package/src/components/table-handle/table-handle-drag-preview.gen.ts +57 -31
  86. package/src/components/table-handle/table-handle-drop-indicator.gen.ts +57 -31
  87. package/src/components/table-handle/table-handle-root.gen.ts +59 -31
  88. package/src/components/table-handle/table-handle-row-menu-root.gen.ts +66 -0
  89. package/src/components/table-handle/table-handle-row-menu-trigger.gen.ts +60 -0
  90. package/src/components/table-handle/table-handle-row-popup.gen.ts +44 -0
  91. package/src/components/table-handle/table-handle-row-positioner.gen.ts +201 -0
  92. package/src/components/tooltip/index.gen.ts +11 -3
  93. package/src/components/tooltip/index.ts +24 -0
  94. package/src/components/tooltip/tooltip-popup.gen.ts +44 -0
  95. package/src/components/tooltip/tooltip-positioner.gen.ts +178 -0
  96. package/src/components/tooltip/tooltip-root.gen.ts +85 -31
  97. package/src/components/tooltip/tooltip-trigger.gen.ts +63 -31
  98. package/src/extensions/preact-node-view.spec.ts +151 -0
  99. package/dist/create-component.js +0 -95
  100. package/dist/create-component.js.map +0 -1
  101. package/dist/create-props.d.ts +0 -6
  102. package/dist/create-props.d.ts.map +0 -1
  103. package/src/components/autocomplete/autocomplete-list.gen.ts +0 -34
  104. package/src/components/autocomplete/autocomplete-popover.gen.ts +0 -34
  105. package/src/components/block-handle/block-handle-popover.gen.ts +0 -34
  106. package/src/components/create-component.ts +0 -123
  107. package/src/components/create-props.ts +0 -13
  108. package/src/components/inline-popover/inline-popover.gen.ts +0 -34
  109. package/src/components/merge-refs.ts +0 -35
  110. package/src/components/popover/popover-content.gen.ts +0 -34
  111. package/src/components/table-handle/table-handle-column-root.gen.ts +0 -34
  112. package/src/components/table-handle/table-handle-column-trigger.gen.ts +0 -34
  113. package/src/components/table-handle/table-handle-popover-content.gen.ts +0 -34
  114. package/src/components/table-handle/table-handle-popover-item.gen.ts +0 -34
  115. package/src/components/table-handle/table-handle-row-root.gen.ts +0 -34
  116. package/src/components/table-handle/table-handle-row-trigger.gen.ts +0 -34
  117. package/src/components/tooltip/tooltip-content.gen.ts +0 -34
@@ -1,34 +1,62 @@
1
- import {
2
- type BlockHandleDraggableElement,
3
- type BlockHandleDraggableProps as Props,
4
- type BlockHandleDraggableEvents as Events,
5
- blockHandleDraggableProps,
6
- blockHandleDraggableEvents,
7
- } from '@prosekit/web/block-handle'
8
- import type {
9
- ForwardRefExoticComponent,
10
- HTMLAttributes,
11
- RefAttributes,
12
- } from 'preact/compat'
13
-
14
- import { createComponent } from '../create-component.ts'
15
- import type { CreateProps } from '../create-props.ts'
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ import { registerBlockHandleDraggableElement, type BlockHandleDraggableElement, type BlockHandleDraggableProps as BlockHandleDraggableElementProps } from '@prosekit/web/block-handle';
6
+ import { createElement, type HTMLAttributes, type Ref } from 'preact';
7
+ import { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';
8
+ import { useCallback, useRef, useLayoutEffect } from 'preact/hooks';
9
+
10
+ import { useEditorContext } from '../../contexts/editor-context.ts';
11
+
12
+ /**
13
+ * Props for the {@link BlockHandleDraggable} Preact component.
14
+ *
15
+ * @public
16
+ */
17
+ export interface BlockHandleDraggableProps extends HTMLAttributes<BlockHandleDraggableElement> {
18
+ /**
19
+ * The ProseKit editor instance.
20
+ *
21
+ * @default null
22
+ * @hidden
23
+ */
24
+ editor?: BlockHandleDraggableElementProps['editor'];
25
+ }
26
+
27
+ function BlockHandleDraggableComponent(props: BlockHandleDraggableProps, forwardedRef: Ref<BlockHandleDraggableElement>) {
28
+ registerBlockHandleDraggableElement();
29
+
30
+ const elementRef = useRef<BlockHandleDraggableElement>(null);
31
+
32
+ const p0Fallback = useEditorContext();
33
+
34
+ const { editor: p0, ...restProps } = props;
35
+
36
+ useLayoutEffect(() => {
37
+ const element = elementRef.current as Record<string, unknown> | null;
38
+ if (!element) return;
39
+ Object.assign(element, { editor: p0 ?? p0Fallback });
40
+ });
41
+
42
+ const mergedRef = useCallback(
43
+ (element: BlockHandleDraggableElement | null) => {
44
+ elementRef.current = element;
45
+ if (typeof forwardedRef === 'function') {
46
+ forwardedRef(element);
47
+ } else if (forwardedRef) {
48
+ forwardedRef.current = element;
49
+ }
50
+ },
51
+ [forwardedRef],
52
+ );
53
+
54
+ return createElement('prosekit-block-handle-draggable', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });
55
+ }
16
56
 
17
57
  /**
18
- * Props for the {@link BlockHandleDraggable} component.
58
+ * A Preact component that renders an `prosekit-block-handle-draggable` custom element.
59
+ *
60
+ * @public
19
61
  */
20
- export interface BlockHandleDraggableProps extends Partial<CreateProps<Props, Events>> {}
21
-
22
- export const BlockHandleDraggable: ForwardRefExoticComponent<
23
- Partial<BlockHandleDraggableProps> &
24
- RefAttributes<BlockHandleDraggableElement> &
25
- HTMLAttributes<BlockHandleDraggableElement>
26
- > = createComponent<
27
- BlockHandleDraggableProps,
28
- BlockHandleDraggableElement
29
- >(
30
- 'prosekit-block-handle-draggable',
31
- 'BlockHandleDraggable',
32
- Object.keys(blockHandleDraggableProps),
33
- Object.keys(blockHandleDraggableEvents),
34
- )
62
+ export const BlockHandleDraggable: ForwardRefExoticComponent<BlockHandleDraggableProps & RefAttributes<BlockHandleDraggableElement>> = /* @__PURE__ */ forwardRef(BlockHandleDraggableComponent);
@@ -0,0 +1,44 @@
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ import { registerBlockHandlePopupElement, type BlockHandlePopupElement } from '@prosekit/web/block-handle';
6
+ import { createElement, type HTMLAttributes, type Ref } from 'preact';
7
+ import { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';
8
+ import { useCallback, useRef } from 'preact/hooks';
9
+
10
+ /**
11
+ * Props for the {@link BlockHandlePopup} Preact component.
12
+ *
13
+ * @public
14
+ */
15
+ export interface BlockHandlePopupProps extends HTMLAttributes<BlockHandlePopupElement> {}
16
+
17
+ function BlockHandlePopupComponent(props: BlockHandlePopupProps, forwardedRef: Ref<BlockHandlePopupElement>) {
18
+ registerBlockHandlePopupElement();
19
+
20
+ const elementRef = useRef<BlockHandlePopupElement>(null);
21
+
22
+ const { ...restProps } = props;
23
+
24
+ const mergedRef = useCallback(
25
+ (element: BlockHandlePopupElement | null) => {
26
+ elementRef.current = element;
27
+ if (typeof forwardedRef === 'function') {
28
+ forwardedRef(element);
29
+ } else if (forwardedRef) {
30
+ forwardedRef.current = element;
31
+ }
32
+ },
33
+ [forwardedRef],
34
+ );
35
+
36
+ return createElement('prosekit-block-handle-popup', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });
37
+ }
38
+
39
+ /**
40
+ * A Preact component that renders an `prosekit-block-handle-popup` custom element.
41
+ *
42
+ * @public
43
+ */
44
+ export const BlockHandlePopup: ForwardRefExoticComponent<BlockHandlePopupProps & RefAttributes<BlockHandlePopupElement>> = /* @__PURE__ */ forwardRef(BlockHandlePopupComponent);
@@ -0,0 +1,171 @@
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ import { registerBlockHandlePositionerElement, type BlockHandlePositionerElement, type BlockHandlePositionerProps as BlockHandlePositionerElementProps } from '@prosekit/web/block-handle';
6
+ import { createElement, type HTMLAttributes, type Ref } from 'preact';
7
+ import { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';
8
+ import { useCallback, useRef, useLayoutEffect } from 'preact/hooks';
9
+
10
+ /**
11
+ * Props for the {@link BlockHandlePositioner} Preact component.
12
+ *
13
+ * @public
14
+ */
15
+ export interface BlockHandlePositionerProps extends HTMLAttributes<BlockHandlePositionerElement> {
16
+ /**
17
+ * The placement of the popover, relative to the hovered block.
18
+ *
19
+ * @default "left"
20
+ */
21
+ placement?: BlockHandlePositionerElementProps['placement'];
22
+ /**
23
+ * Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
24
+ * to place the floating element on top of other page content.
25
+ *
26
+ * @default false
27
+ */
28
+ hoist?: BlockHandlePositionerElementProps['hoist'];
29
+ /**
30
+ * @default false
31
+ * @hidden
32
+ */
33
+ flip?: BlockHandlePositionerElementProps['flip'];
34
+ /**
35
+ * @default false
36
+ * @hidden
37
+ */
38
+ shift?: BlockHandlePositionerElementProps['shift'];
39
+ /**
40
+ * @default true
41
+ * @hidden
42
+ */
43
+ hide?: BlockHandlePositionerElementProps['hide'];
44
+ /**
45
+ * The strategy to use for positioning
46
+ *
47
+ * @default "absolute"
48
+ */
49
+ strategy?: BlockHandlePositionerElementProps['strategy'];
50
+ /**
51
+ * Options to activate auto-update listeners
52
+ *
53
+ * @see https://floating-ui.com/docs/autoUpdate
54
+ *
55
+ * @default true
56
+ */
57
+ autoUpdate?: BlockHandlePositionerElementProps['autoUpdate'];
58
+ /**
59
+ * The distance between the reference and floating element.
60
+ *
61
+ * @default 6
62
+ */
63
+ offset?: BlockHandlePositionerElementProps['offset'];
64
+ /**
65
+ * Whether the floating element can overlap the reference element to keep it
66
+ * in view.
67
+ *
68
+ * @default false
69
+ */
70
+ overlap?: BlockHandlePositionerElementProps['overlap'];
71
+ /**
72
+ * Whether to constrain the floating element's width and height to not exceed
73
+ * the viewport.
74
+ *
75
+ * @default false
76
+ */
77
+ fitViewport?: BlockHandlePositionerElementProps['fitViewport'];
78
+ /**
79
+ * Whether to constrain the floating element's width so that it matches the
80
+ * reference element.
81
+ *
82
+ * @default false
83
+ */
84
+ sameWidth?: BlockHandlePositionerElementProps['sameWidth'];
85
+ /**
86
+ * Whether to constrain the floating element's height so that it matches the
87
+ * reference element.
88
+ *
89
+ * @default false
90
+ */
91
+ sameHeight?: BlockHandlePositionerElementProps['sameHeight'];
92
+ /**
93
+ * Whether to improve positioning for inline reference elements that span over
94
+ * multiple lines.
95
+ *
96
+ * @default false
97
+ */
98
+ inline?: BlockHandlePositionerElementProps['inline'];
99
+ /**
100
+ * Describes the clipping element(s) or area that overflow will be checked relative to.
101
+ * Please see https://floating-ui.com/docs/detectoverflow#boundary for more information.
102
+ *
103
+ * @default 'clippingAncestors'
104
+ */
105
+ boundary?: BlockHandlePositionerElementProps['boundary'];
106
+ /**
107
+ * Describes the root boundary that the element will be checked for overflow relative to.
108
+ * Please see https://floating-ui.com/docs/detectoverflow#rootboundary for more information.
109
+ *
110
+ * @default 'viewport'
111
+ */
112
+ rootBoundary?: BlockHandlePositionerElementProps['rootBoundary'];
113
+ /**
114
+ * Describes the virtual padding around the boundary to check for overflow.
115
+ * Please see https://floating-ui.com/docs/detectoverflow#padding for more information.
116
+ *
117
+ * @default 4
118
+ */
119
+ overflowPadding?: BlockHandlePositionerElementProps['overflowPadding'];
120
+ /**
121
+ * The element that will be used to check for overflow. Please see
122
+ * https://floating-ui.com/docs/detectoverflow#elementcontext for more
123
+ * information.
124
+ *
125
+ * @default 'floating'
126
+ */
127
+ elementContext?: BlockHandlePositionerElementProps['elementContext'];
128
+ /**
129
+ * Whether to check the alternate elementContext's boundary. Please see
130
+ * https://floating-ui.com/docs/detectoverflow#altboundary for more
131
+ * information.
132
+ *
133
+ * @default false
134
+ */
135
+ altBoundary?: BlockHandlePositionerElementProps['altBoundary'];
136
+ }
137
+
138
+ function BlockHandlePositionerComponent(props: BlockHandlePositionerProps, forwardedRef: Ref<BlockHandlePositionerElement>) {
139
+ registerBlockHandlePositionerElement();
140
+
141
+ const elementRef = useRef<BlockHandlePositionerElement>(null);
142
+
143
+ 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;
144
+
145
+ useLayoutEffect(() => {
146
+ const element = elementRef.current as Record<string, unknown> | null;
147
+ if (!element) return;
148
+ 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 });
149
+ });
150
+
151
+ const mergedRef = useCallback(
152
+ (element: BlockHandlePositionerElement | null) => {
153
+ elementRef.current = element;
154
+ if (typeof forwardedRef === 'function') {
155
+ forwardedRef(element);
156
+ } else if (forwardedRef) {
157
+ forwardedRef.current = element;
158
+ }
159
+ },
160
+ [forwardedRef],
161
+ );
162
+
163
+ return createElement('prosekit-block-handle-positioner', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });
164
+ }
165
+
166
+ /**
167
+ * A Preact component that renders an `prosekit-block-handle-positioner` custom element.
168
+ *
169
+ * @public
170
+ */
171
+ export const BlockHandlePositioner: ForwardRefExoticComponent<BlockHandlePositionerProps & RefAttributes<BlockHandlePositionerElement>> = /* @__PURE__ */ forwardRef(BlockHandlePositionerComponent);
@@ -0,0 +1,84 @@
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ import { registerBlockHandleRootElement, type BlockHandleRootElement, type BlockHandleRootProps as BlockHandleRootElementProps, type BlockHandleRootEvents } from '@prosekit/web/block-handle';
6
+ import { createElement, type HTMLAttributes, type Ref } from 'preact';
7
+ import { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';
8
+ import { useCallback, useRef, useLayoutEffect } from 'preact/hooks';
9
+
10
+ import { useEditorContext } from '../../contexts/editor-context.ts';
11
+
12
+ /**
13
+ * Props for the {@link BlockHandleRoot} Preact component.
14
+ *
15
+ * @public
16
+ */
17
+ export interface BlockHandleRootProps extends HTMLAttributes<BlockHandleRootElement> {
18
+ /**
19
+ * The ProseKit editor instance.
20
+ *
21
+ * @default null
22
+ * @hidden
23
+ */
24
+ editor?: BlockHandleRootElementProps['editor'];
25
+ /** Fired when the hovered block changes. */
26
+ onStateChange?: (event: BlockHandleRootEvents['stateChange']) => void;
27
+ }
28
+
29
+ function BlockHandleRootComponent(props: BlockHandleRootProps, forwardedRef: Ref<BlockHandleRootElement>) {
30
+ registerBlockHandleRootElement();
31
+
32
+ const elementRef = useRef<BlockHandleRootElement>(null);
33
+ const handlersRef = useRef<Array<((event: Event) => void) | undefined>>([]);
34
+
35
+ const p0Fallback = useEditorContext();
36
+
37
+ const { editor: p0, onStateChange: e0, ...restProps } = props;
38
+
39
+ useLayoutEffect(() => {
40
+ const element = elementRef.current as Record<string, unknown> | null;
41
+ if (!element) return;
42
+ Object.assign(element, { editor: p0 ?? p0Fallback });
43
+ handlersRef.current = [e0] as Array<((event: Event) => void) | undefined>;
44
+ });
45
+
46
+ useLayoutEffect(() => {
47
+ const element = elementRef.current;
48
+ if (!element) return;
49
+ const ac = new AbortController();
50
+ for (const [index, eventName] of ['stateChange'].entries()) {
51
+ element.addEventListener(
52
+ eventName,
53
+ (event: Event) => {
54
+ handlersRef.current[index]?.(event);
55
+ },
56
+ { signal: ac.signal },
57
+ );
58
+ }
59
+ return () => ac.abort();
60
+ }, []);
61
+
62
+ const mergedRef = useCallback(
63
+ (element: BlockHandleRootElement | null) => {
64
+ elementRef.current = element;
65
+ if (typeof forwardedRef === 'function') {
66
+ forwardedRef(element);
67
+ } else if (forwardedRef) {
68
+ forwardedRef.current = element;
69
+ }
70
+ },
71
+ [forwardedRef],
72
+ );
73
+
74
+ return createElement('prosekit-block-handle-root', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });
75
+ }
76
+
77
+ /**
78
+ * A Preact component that renders an `prosekit-block-handle-root` custom element.
79
+ *
80
+ * @public
81
+ */
82
+ export const BlockHandleRoot: ForwardRefExoticComponent<BlockHandleRootProps & RefAttributes<BlockHandleRootElement>> = /* @__PURE__ */ forwardRef(BlockHandleRootComponent);
83
+
84
+ export type { BlockHandleRootEvents };
@@ -1,5 +1,15 @@
1
- export { BlockHandleAdd, type BlockHandleAddProps } from './block-handle-add.gen.ts'
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
2
4
 
3
- export { BlockHandleDraggable, type BlockHandleDraggableProps } from './block-handle-draggable.gen.ts'
5
+ export { BlockHandleAdd, type BlockHandleAddProps } from './block-handle-add.gen.ts';
4
6
 
5
- export { BlockHandlePopover, type BlockHandlePopoverProps } from './block-handle-popover.gen.ts'
7
+ export { BlockHandleDraggable, type BlockHandleDraggableProps } from './block-handle-draggable.gen.ts';
8
+
9
+ export { BlockHandlePopup, type BlockHandlePopupProps } from './block-handle-popup.gen.ts';
10
+
11
+ export { BlockHandlePositioner, type BlockHandlePositionerProps } from './block-handle-positioner.gen.ts';
12
+
13
+ export { BlockHandleRoot, type BlockHandleRootProps, type BlockHandleRootEvents } from './block-handle-root.gen.ts';
14
+
15
+ export { BlockHandleStateChangeEvent } from '@prosekit/web/block-handle';
@@ -0,0 +1,27 @@
1
+ /**
2
+
3
+ @module
4
+
5
+ ## Anatomy
6
+
7
+ ```jsx
8
+ import {
9
+ BlockHandleAdd,
10
+ BlockHandleDraggable,
11
+ BlockHandlePopup,
12
+ BlockHandlePositioner,
13
+ BlockHandleRoot,
14
+ } from 'prosekit/preact/block-handle'
15
+
16
+ <BlockHandleRoot>
17
+ <BlockHandlePositioner>
18
+ <BlockHandlePopup>
19
+ <BlockHandleAdd>...</BlockHandleAdd>
20
+ <BlockHandleDraggable>...</BlockHandleDraggable>
21
+ </BlockHandlePopup>
22
+ </BlockHandlePositioner>
23
+ </BlockHandleRoot>
24
+ ```
25
+ */
26
+
27
+ export * from './index.gen.ts'
@@ -1,34 +1,68 @@
1
- import {
2
- type DropIndicatorElement,
3
- type DropIndicatorProps as Props,
4
- type DropIndicatorEvents as Events,
5
- dropIndicatorProps,
6
- dropIndicatorEvents,
7
- } from '@prosekit/web/drop-indicator'
8
- import type {
9
- ForwardRefExoticComponent,
10
- HTMLAttributes,
11
- RefAttributes,
12
- } from 'preact/compat'
13
-
14
- import { createComponent } from '../create-component.ts'
15
- import type { CreateProps } from '../create-props.ts'
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ import { registerDropIndicatorElement, type DropIndicatorElement, type DropIndicatorProps as DropIndicatorElementProps } from '@prosekit/web/drop-indicator';
6
+ import { createElement, type HTMLAttributes, type Ref } from 'preact';
7
+ import { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';
8
+ import { useCallback, useRef, useLayoutEffect } from 'preact/hooks';
9
+
10
+ import { useEditorContext } from '../../contexts/editor-context.ts';
11
+
12
+ /**
13
+ * Props for the {@link DropIndicator} Preact component.
14
+ *
15
+ * @public
16
+ */
17
+ export interface DropIndicatorProps extends HTMLAttributes<DropIndicatorElement> {
18
+ /**
19
+ * The ProseKit editor instance.
20
+ *
21
+ * @default null
22
+ * @hidden
23
+ */
24
+ editor?: DropIndicatorElementProps['editor'];
25
+ /**
26
+ * The line width in pixels.
27
+ *
28
+ * @default 2
29
+ */
30
+ width?: DropIndicatorElementProps['width'];
31
+ }
32
+
33
+ function DropIndicatorComponent(props: DropIndicatorProps, forwardedRef: Ref<DropIndicatorElement>) {
34
+ registerDropIndicatorElement();
35
+
36
+ const elementRef = useRef<DropIndicatorElement>(null);
37
+
38
+ const p0Fallback = useEditorContext();
39
+
40
+ const { editor: p0, width: p1, ...restProps } = props;
41
+
42
+ useLayoutEffect(() => {
43
+ const element = elementRef.current as Record<string, unknown> | null;
44
+ if (!element) return;
45
+ Object.assign(element, { editor: p0 ?? p0Fallback, width: p1 });
46
+ });
47
+
48
+ const mergedRef = useCallback(
49
+ (element: DropIndicatorElement | null) => {
50
+ elementRef.current = element;
51
+ if (typeof forwardedRef === 'function') {
52
+ forwardedRef(element);
53
+ } else if (forwardedRef) {
54
+ forwardedRef.current = element;
55
+ }
56
+ },
57
+ [forwardedRef],
58
+ );
59
+
60
+ return createElement('prosekit-drop-indicator', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });
61
+ }
16
62
 
17
63
  /**
18
- * Props for the {@link DropIndicator} component.
64
+ * A Preact component that renders an `prosekit-drop-indicator` custom element.
65
+ *
66
+ * @public
19
67
  */
20
- export interface DropIndicatorProps extends Partial<CreateProps<Props, Events>> {}
21
-
22
- export const DropIndicator: ForwardRefExoticComponent<
23
- Partial<DropIndicatorProps> &
24
- RefAttributes<DropIndicatorElement> &
25
- HTMLAttributes<DropIndicatorElement>
26
- > = createComponent<
27
- DropIndicatorProps,
28
- DropIndicatorElement
29
- >(
30
- 'prosekit-drop-indicator',
31
- 'DropIndicator',
32
- Object.keys(dropIndicatorProps),
33
- Object.keys(dropIndicatorEvents),
34
- )
68
+ export const DropIndicator: ForwardRefExoticComponent<DropIndicatorProps & RefAttributes<DropIndicatorElement>> = /* @__PURE__ */ forwardRef(DropIndicatorComponent);
@@ -1 +1,5 @@
1
- export { DropIndicator, type DropIndicatorProps } from './drop-indicator.gen.ts'
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ export { DropIndicator, type DropIndicatorProps } from './drop-indicator.gen.ts';
@@ -0,0 +1,14 @@
1
+ /**
2
+
3
+ @module
4
+
5
+ ## Anatomy
6
+
7
+ ```jsx
8
+ import { DropIndicator } from 'prosekit/preact/drop-indicator'
9
+
10
+ <DropIndicator />
11
+ ```
12
+ */
13
+
14
+ export * from './index.gen.ts'
@@ -1 +1,11 @@
1
- export { InlinePopover, type InlinePopoverProps } from './inline-popover.gen.ts'
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ export { InlinePopoverPopup, type InlinePopoverPopupProps } from './inline-popover-popup.gen.ts';
6
+
7
+ export { InlinePopoverPositioner, type InlinePopoverPositionerProps } from './inline-popover-positioner.gen.ts';
8
+
9
+ export { InlinePopoverRoot, type InlinePopoverRootProps, type InlinePopoverRootEvents } from './inline-popover-root.gen.ts';
10
+
11
+ export { OpenChangeEvent } from '@prosekit/web/inline-popover';
@@ -0,0 +1,22 @@
1
+ /**
2
+
3
+ @module
4
+
5
+ ## Anatomy
6
+
7
+ ```jsx
8
+ import {
9
+ InlinePopoverPopup,
10
+ InlinePopoverPositioner,
11
+ InlinePopoverRoot,
12
+ } from 'prosekit/preact/inline-popover'
13
+
14
+ <InlinePopoverRoot>
15
+ <InlinePopoverPositioner>
16
+ <InlinePopoverPopup>...</InlinePopoverPopup>
17
+ </InlinePopoverPositioner>
18
+ </InlinePopoverRoot>
19
+ ```
20
+ */
21
+
22
+ export * from './index.gen.ts'
@@ -0,0 +1,44 @@
1
+ /**
2
+ * This file is auto-generated by the "@aria-ui/cli" tool. Do not edit this file directly.
3
+ */
4
+
5
+ import { registerInlinePopoverPopupElement, type InlinePopoverPopupElement } from '@prosekit/web/inline-popover';
6
+ import { createElement, type HTMLAttributes, type Ref } from 'preact';
7
+ import { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'preact/compat';
8
+ import { useCallback, useRef } from 'preact/hooks';
9
+
10
+ /**
11
+ * Props for the {@link InlinePopoverPopup} Preact component.
12
+ *
13
+ * @public
14
+ */
15
+ export interface InlinePopoverPopupProps extends HTMLAttributes<InlinePopoverPopupElement> {}
16
+
17
+ function InlinePopoverPopupComponent(props: InlinePopoverPopupProps, forwardedRef: Ref<InlinePopoverPopupElement>) {
18
+ registerInlinePopoverPopupElement();
19
+
20
+ const elementRef = useRef<InlinePopoverPopupElement>(null);
21
+
22
+ const { ...restProps } = props;
23
+
24
+ const mergedRef = useCallback(
25
+ (element: InlinePopoverPopupElement | null) => {
26
+ elementRef.current = element;
27
+ if (typeof forwardedRef === 'function') {
28
+ forwardedRef(element);
29
+ } else if (forwardedRef) {
30
+ forwardedRef.current = element;
31
+ }
32
+ },
33
+ [forwardedRef],
34
+ );
35
+
36
+ return createElement('prosekit-inline-popover-popup', { ...restProps, ref: mergedRef, suppressHydrationWarning: true });
37
+ }
38
+
39
+ /**
40
+ * A Preact component that renders an `prosekit-inline-popover-popup` custom element.
41
+ *
42
+ * @public
43
+ */
44
+ export const InlinePopoverPopup: ForwardRefExoticComponent<InlinePopoverPopupProps & RefAttributes<InlinePopoverPopupElement>> = /* @__PURE__ */ forwardRef(InlinePopoverPopupComponent);