@prosekit/web 0.8.0-beta.0 → 0.8.0-beta.1

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 (207) hide show
  1. package/dist/prosekit-web-autocomplete.d.ts +112 -90
  2. package/dist/prosekit-web-autocomplete.d.ts.map +1 -1
  3. package/dist/prosekit-web-autocomplete.js +292 -217
  4. package/dist/prosekit-web-autocomplete.js.map +1 -1
  5. package/dist/prosekit-web-block-handle.d.ts +95 -62
  6. package/dist/prosekit-web-block-handle.d.ts.map +1 -1
  7. package/dist/prosekit-web-block-handle.js +219 -114
  8. package/dist/prosekit-web-block-handle.js.map +1 -1
  9. package/dist/prosekit-web-drop-indicator.d.ts +13 -15
  10. package/dist/prosekit-web-drop-indicator.d.ts.map +1 -1
  11. package/dist/prosekit-web-drop-indicator.js +34 -30
  12. package/dist/prosekit-web-drop-indicator.js.map +1 -1
  13. package/dist/prosekit-web-inline-popover.d.ts +88 -54
  14. package/dist/prosekit-web-inline-popover.d.ts.map +1 -1
  15. package/dist/prosekit-web-inline-popover.js +129 -79
  16. package/dist/prosekit-web-inline-popover.js.map +1 -1
  17. package/dist/prosekit-web-menu.d.ts +13 -0
  18. package/dist/prosekit-web-menu.d.ts.map +1 -0
  19. package/dist/prosekit-web-menu.js +53 -0
  20. package/dist/prosekit-web-menu.js.map +1 -0
  21. package/dist/prosekit-web-popover.d.ts +7 -26
  22. package/dist/prosekit-web-popover.d.ts.map +1 -1
  23. package/dist/prosekit-web-popover.js +31 -29
  24. package/dist/prosekit-web-popover.js.map +1 -1
  25. package/dist/prosekit-web-resizable.d.ts +92 -51
  26. package/dist/prosekit-web-resizable.d.ts.map +1 -1
  27. package/dist/prosekit-web-resizable.js +139 -131
  28. package/dist/prosekit-web-resizable.js.map +1 -1
  29. package/dist/prosekit-web-table-handle.d.ts +166 -199
  30. package/dist/prosekit-web-table-handle.d.ts.map +1 -1
  31. package/dist/prosekit-web-table-handle.js +495 -496
  32. package/dist/prosekit-web-table-handle.js.map +1 -1
  33. package/dist/prosekit-web-tooltip.d.ts +7 -26
  34. package/dist/prosekit-web-tooltip.d.ts.map +1 -1
  35. package/dist/prosekit-web-tooltip.js +31 -29
  36. package/dist/prosekit-web-tooltip.js.map +1 -1
  37. package/dist/use-editor-extension.js +2 -2
  38. package/dist/use-editor-extension.js.map +1 -1
  39. package/dist/use-scrolling.js +17 -8
  40. package/dist/use-scrolling.js.map +1 -1
  41. package/package.json +28 -23
  42. package/src/components/autocomplete/autocomplete-empty.ts +45 -0
  43. package/src/components/autocomplete/autocomplete-item.ts +65 -0
  44. package/src/components/autocomplete/autocomplete-popup.ts +95 -0
  45. package/src/components/autocomplete/autocomplete-positioner.ts +98 -0
  46. package/src/components/autocomplete/autocomplete-root.ts +280 -0
  47. package/src/components/autocomplete/context.ts +16 -14
  48. package/src/components/autocomplete/index.ts +65 -0
  49. package/src/components/block-handle/block-handle-add.ts +71 -0
  50. package/src/components/block-handle/block-handle-draggable.ts +158 -0
  51. package/src/components/block-handle/block-handle-popup.ts +43 -0
  52. package/src/components/block-handle/block-handle-positioner.ts +89 -0
  53. package/src/components/block-handle/block-handle-root.ts +116 -0
  54. package/src/components/block-handle/context.ts +9 -18
  55. package/src/components/block-handle/hover-state.ts +16 -0
  56. package/src/components/block-handle/index.ts +59 -0
  57. package/src/components/block-handle/{block-handle-popover/pointer-move.ts → pointer-move.ts} +8 -7
  58. package/src/components/block-handle/{block-handle-draggable/set-drag-preview.ts → set-drag-preview.ts} +4 -4
  59. package/src/components/block-handle/use-hover-extension.ts +65 -0
  60. package/src/components/drop-indicator/drop-indicator.ts +128 -0
  61. package/src/components/drop-indicator/index.ts +18 -0
  62. package/src/components/inline-popover/index.ts +41 -0
  63. package/src/components/inline-popover/inline-popover-popup.ts +52 -0
  64. package/src/components/inline-popover/inline-popover-positioner.ts +98 -0
  65. package/src/components/inline-popover/inline-popover-root.ts +122 -0
  66. package/src/components/inline-popover/store.ts +6 -0
  67. package/src/components/menu/index.ts +92 -0
  68. package/src/components/popover/index.ts +53 -0
  69. package/src/components/resizable/{resizable-handle/calc-resize.ts → calc-resize.ts} +1 -1
  70. package/src/components/resizable/context.ts +3 -6
  71. package/src/components/resizable/index.ts +32 -0
  72. package/src/components/resizable/resizable-handle.ts +134 -0
  73. package/src/components/resizable/resizable-root.ts +184 -0
  74. package/src/components/table-handle/dnd.ts +16 -27
  75. package/src/components/table-handle/index.ts +125 -0
  76. package/src/components/table-handle/{table-handle-drag-preview/render-preview.ts → render-preview.ts} +5 -5
  77. package/src/components/table-handle/shared.ts +61 -0
  78. package/src/components/table-handle/store.ts +117 -0
  79. package/src/components/table-handle/table-handle-column-menu-root.ts +51 -0
  80. package/src/components/table-handle/table-handle-column-menu-trigger.ts +107 -0
  81. package/src/components/table-handle/table-handle-column-popup.ts +44 -0
  82. package/src/components/table-handle/table-handle-column-positioner.ts +67 -0
  83. package/src/components/table-handle/table-handle-drag-preview.ts +169 -0
  84. package/src/components/table-handle/table-handle-drop-indicator.ts +166 -0
  85. package/src/components/table-handle/table-handle-root.ts +103 -0
  86. package/src/components/table-handle/table-handle-row-menu-root.ts +51 -0
  87. package/src/components/table-handle/table-handle-row-menu-trigger.ts +107 -0
  88. package/src/components/table-handle/table-handle-row-popup.ts +42 -0
  89. package/src/components/table-handle/table-handle-row-positioner.ts +67 -0
  90. package/src/components/table-handle/use-drop.ts +74 -0
  91. package/src/components/table-handle/{hooks/use-empty-image.ts → use-empty-image.ts} +2 -3
  92. package/src/components/table-handle/utils.ts +0 -11
  93. package/src/components/tooltip/index.ts +52 -0
  94. package/src/hooks/use-editor-extension.ts +4 -4
  95. package/src/hooks/use-editor-focus-event.ts +4 -4
  96. package/src/hooks/use-editor-typing.ts +12 -16
  97. package/src/hooks/use-editor-update-event.ts +4 -4
  98. package/src/hooks/use-keymap.ts +4 -4
  99. package/src/hooks/use-scrolling.ts +11 -10
  100. package/src/hooks/use-selecting.ts +8 -15
  101. package/src/utils/event.ts +28 -0
  102. package/src/utils/lazy-signal.spec.ts +68 -0
  103. package/src/utils/lazy-signal.ts +17 -0
  104. package/src/utils/prefers-reduced-motion.ts +6 -0
  105. package/src/utils/prevent-default.ts +3 -0
  106. package/src/utils/use-html-element-at.ts +17 -0
  107. package/src/utils/use-no-focus.ts +7 -0
  108. package/dist/get-default-state.js +0 -11
  109. package/dist/get-default-state.js.map +0 -1
  110. package/src/components/autocomplete/autocomplete-empty/element.gen.ts +0 -18
  111. package/src/components/autocomplete/autocomplete-empty/setup.ts +0 -6
  112. package/src/components/autocomplete/autocomplete-empty/types.ts +0 -13
  113. package/src/components/autocomplete/autocomplete-item/element.gen.ts +0 -18
  114. package/src/components/autocomplete/autocomplete-item/setup.ts +0 -30
  115. package/src/components/autocomplete/autocomplete-item/types.ts +0 -25
  116. package/src/components/autocomplete/autocomplete-list/element.gen.ts +0 -18
  117. package/src/components/autocomplete/autocomplete-list/setup.ts +0 -125
  118. package/src/components/autocomplete/autocomplete-list/types.ts +0 -22
  119. package/src/components/autocomplete/autocomplete-popover/element.gen.ts +0 -18
  120. package/src/components/autocomplete/autocomplete-popover/setup.ts +0 -169
  121. package/src/components/autocomplete/autocomplete-popover/types.ts +0 -100
  122. package/src/components/autocomplete/index.gen.ts +0 -17
  123. package/src/components/block-handle/block-handle-add/element.gen.ts +0 -18
  124. package/src/components/block-handle/block-handle-add/setup.ts +0 -33
  125. package/src/components/block-handle/block-handle-add/types.ts +0 -23
  126. package/src/components/block-handle/block-handle-draggable/element.gen.ts +0 -18
  127. package/src/components/block-handle/block-handle-draggable/setup.ts +0 -113
  128. package/src/components/block-handle/block-handle-draggable/types.ts +0 -23
  129. package/src/components/block-handle/block-handle-popover/element.gen.ts +0 -18
  130. package/src/components/block-handle/block-handle-popover/setup.ts +0 -68
  131. package/src/components/block-handle/block-handle-popover/types.ts +0 -81
  132. package/src/components/block-handle/index.gen.ts +0 -13
  133. package/src/components/drop-indicator/drop-indicator/element.gen.ts +0 -18
  134. package/src/components/drop-indicator/drop-indicator/setup.ts +0 -75
  135. package/src/components/drop-indicator/drop-indicator/types.ts +0 -31
  136. package/src/components/drop-indicator/index.gen.ts +0 -5
  137. package/src/components/inline-popover/index.gen.ts +0 -5
  138. package/src/components/inline-popover/inline-popover/element.gen.ts +0 -18
  139. package/src/components/inline-popover/inline-popover/setup.ts +0 -111
  140. package/src/components/inline-popover/inline-popover/types.ts +0 -112
  141. package/src/components/popover/index.gen.ts +0 -13
  142. package/src/components/popover/popover-content/element.gen.ts +0 -18
  143. package/src/components/popover/popover-content/setup.ts +0 -1
  144. package/src/components/popover/popover-content/types.ts +0 -6
  145. package/src/components/popover/popover-root/element.gen.ts +0 -18
  146. package/src/components/popover/popover-root/setup.ts +0 -1
  147. package/src/components/popover/popover-root/types.ts +0 -6
  148. package/src/components/popover/popover-trigger/element.gen.ts +0 -18
  149. package/src/components/popover/popover-trigger/setup.ts +0 -1
  150. package/src/components/popover/popover-trigger/types.ts +0 -6
  151. package/src/components/resizable/index.gen.ts +0 -9
  152. package/src/components/resizable/resizable-handle/element.gen.ts +0 -18
  153. package/src/components/resizable/resizable-handle/setup.ts +0 -106
  154. package/src/components/resizable/resizable-handle/types.ts +0 -29
  155. package/src/components/resizable/resizable-root/element.gen.ts +0 -18
  156. package/src/components/resizable/resizable-root/setup.ts +0 -84
  157. package/src/components/resizable/resizable-root/types.ts +0 -59
  158. package/src/components/table-handle/context.ts +0 -43
  159. package/src/components/table-handle/hooks/use-drop.ts +0 -85
  160. package/src/components/table-handle/index.gen.ts +0 -37
  161. package/src/components/table-handle/table-handle-column-root/element.gen.ts +0 -18
  162. package/src/components/table-handle/table-handle-column-root/setup.ts +0 -60
  163. package/src/components/table-handle/table-handle-column-root/types.ts +0 -73
  164. package/src/components/table-handle/table-handle-column-trigger/element.gen.ts +0 -18
  165. package/src/components/table-handle/table-handle-column-trigger/setup.ts +0 -64
  166. package/src/components/table-handle/table-handle-column-trigger/types.ts +0 -20
  167. package/src/components/table-handle/table-handle-drag-preview/element.gen.ts +0 -18
  168. package/src/components/table-handle/table-handle-drag-preview/setup.ts +0 -57
  169. package/src/components/table-handle/table-handle-drag-preview/types.ts +0 -14
  170. package/src/components/table-handle/table-handle-drag-preview/updater.ts +0 -90
  171. package/src/components/table-handle/table-handle-drop-indicator/element.gen.ts +0 -18
  172. package/src/components/table-handle/table-handle-drop-indicator/setup.ts +0 -52
  173. package/src/components/table-handle/table-handle-drop-indicator/types.ts +0 -15
  174. package/src/components/table-handle/table-handle-drop-indicator/updater.ts +0 -96
  175. package/src/components/table-handle/table-handle-popover-content/element.gen.ts +0 -18
  176. package/src/components/table-handle/table-handle-popover-content/setup.ts +0 -83
  177. package/src/components/table-handle/table-handle-popover-content/types.ts +0 -32
  178. package/src/components/table-handle/table-handle-popover-item/element.gen.ts +0 -18
  179. package/src/components/table-handle/table-handle-popover-item/setup.ts +0 -17
  180. package/src/components/table-handle/table-handle-popover-item/types.ts +0 -16
  181. package/src/components/table-handle/table-handle-root/element.gen.ts +0 -18
  182. package/src/components/table-handle/table-handle-root/setup.ts +0 -86
  183. package/src/components/table-handle/table-handle-root/types.ts +0 -23
  184. package/src/components/table-handle/table-handle-row-root/element.gen.ts +0 -18
  185. package/src/components/table-handle/table-handle-row-root/setup.ts +0 -70
  186. package/src/components/table-handle/table-handle-row-root/types.ts +0 -68
  187. package/src/components/table-handle/table-handle-row-trigger/element.gen.ts +0 -18
  188. package/src/components/table-handle/table-handle-row-trigger/setup.ts +0 -63
  189. package/src/components/table-handle/table-handle-row-trigger/types.ts +0 -23
  190. package/src/components/tooltip/index.gen.ts +0 -13
  191. package/src/components/tooltip/tooltip-content/element.gen.ts +0 -18
  192. package/src/components/tooltip/tooltip-content/setup.ts +0 -1
  193. package/src/components/tooltip/tooltip-content/types.ts +0 -6
  194. package/src/components/tooltip/tooltip-root/element.gen.ts +0 -18
  195. package/src/components/tooltip/tooltip-root/setup.ts +0 -1
  196. package/src/components/tooltip/tooltip-root/types.ts +0 -6
  197. package/src/components/tooltip/tooltip-trigger/element.gen.ts +0 -18
  198. package/src/components/tooltip/tooltip-trigger/setup.ts +0 -1
  199. package/src/components/tooltip/tooltip-trigger/types.ts +0 -6
  200. package/src/hooks/use-first-rendering.ts +0 -15
  201. package/src/utils/get-default-state.spec.ts +0 -42
  202. package/src/utils/get-default-state.ts +0 -18
  203. /package/src/components/autocomplete/{autocomplete-popover/helpers.spec.ts → helpers.spec.ts} +0 -0
  204. /package/src/components/autocomplete/{autocomplete-popover/helpers.ts → helpers.ts} +0 -0
  205. /package/src/components/inline-popover/{inline-popover/virtual-selection-element.ts → virtual-selection-element.ts} +0 -0
  206. /package/src/components/resizable/{resizable-handle/calc-resize.spec.ts → calc-resize.spec.ts} +0 -0
  207. /package/src/components/table-handle/{table-handle-drop-indicator/calc-drag-over.ts → calc-drag-over.ts} +0 -0
@@ -1,7 +1,7 @@
1
- import { BaseElementConstructor, ConnectableElement, EventDeclarations, PropDeclarations, SetupOptions } from "@aria-ui/core";
1
+ import { HostElement, HostElementConstructor, PropsDeclaration, State } from "@aria-ui/core";
2
2
  import { Editor } from "@prosekit/core";
3
3
 
4
- //#region src/components/drop-indicator/drop-indicator/types.d.ts
4
+ //#region src/components/drop-indicator/drop-indicator.d.ts
5
5
  interface DropIndicatorProps {
6
6
  /**
7
7
  * The ProseKit editor instance.
@@ -18,22 +18,20 @@ interface DropIndicatorProps {
18
18
  width: number;
19
19
  }
20
20
  /** @internal */
21
- declare const dropIndicatorProps: PropDeclarations<DropIndicatorProps>;
22
- interface DropIndicatorEvents {}
23
- /** @internal */
24
- declare const dropIndicatorEvents: EventDeclarations<DropIndicatorEvents>;
25
- //#endregion
26
- //#region src/components/drop-indicator/drop-indicator/element.gen.d.ts
27
- declare const DropIndicatorElementBase: BaseElementConstructor<DropIndicatorProps>;
21
+ declare const DropIndicatorPropsDeclaration: PropsDeclaration<DropIndicatorProps>;
22
+ /**
23
+ * @internal
24
+ */
25
+ declare function setupDropIndicator(host: HostElement, props: State<DropIndicatorProps>): void;
26
+ declare const DropIndicatorElementBase: HostElementConstructor<DropIndicatorProps>;
27
+ /**
28
+ * @public
29
+ */
28
30
  declare class DropIndicatorElement extends DropIndicatorElementBase {}
29
- //#endregion
30
- //#region src/components/drop-indicator/drop-indicator/setup.d.ts
31
31
  /**
32
32
  * @internal
33
33
  */
34
- declare function useDropIndicator(host: ConnectableElement, {
35
- state
36
- }: SetupOptions<DropIndicatorProps, DropIndicatorEvents>): void;
34
+ declare function registerDropIndicatorElement(): void;
37
35
  //#endregion
38
- export { DropIndicatorElement, type DropIndicatorEvents, type DropIndicatorProps, dropIndicatorEvents, dropIndicatorProps, useDropIndicator };
36
+ export { DropIndicatorElement, type DropIndicatorProps, DropIndicatorPropsDeclaration, registerDropIndicatorElement, setupDropIndicator };
39
37
  //# sourceMappingURL=prosekit-web-drop-indicator.d.ts.map
@@ -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"],"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
+ {"version":3,"file":"prosekit-web-drop-indicator.d.ts","names":[],"sources":["../src/components/drop-indicator/drop-indicator.ts"],"mappings":";;;;UAoBiB,kBAAA;;AAAjB;;;;;EAOE,MAAA,EAAQ,MAAA;EAOR;;;AAIF;;EAJE,KAAA;AAAA;;cAIW,6BAAA,EAA+B,gBAAA,CAAiB,kBAAA;;;;iBAgB7C,kBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,kBAAA;AAAA,cAwDT,wBAAA,EAA0B,sBAAA,CAAuB,kBAAA;;;;cAQ1C,oBAAA,SAA6B,wBAAA;;;;iBAK1B,4BAAA,CAAA"}
@@ -1,27 +1,38 @@
1
1
  import { t as useEditorExtension } from "./use-editor-extension.js";
2
2
  import { n as assignStyles, t as useScrolling } from "./use-scrolling.js";
3
- import { createComputed, createSignal, defineCustomElement, registerCustomElement, useEffect } from "@aria-ui/core";
4
- import { usePresence } from "@aria-ui/presence";
3
+ import { computed, createSignal, defineCustomElement, defineProps, registerCustomElement, useEffect } from "@aria-ui/core";
4
+ import { usePresence } from "@aria-ui/utils";
5
5
  import { defineDropIndicator } from "@prosekit/extensions/drop-indicator";
6
- //#region src/components/drop-indicator/drop-indicator/setup.ts
6
+ //#region src/components/drop-indicator/drop-indicator.ts
7
+ /** @internal */
8
+ const DropIndicatorPropsDeclaration = /* @__PURE__ */ defineProps({
9
+ editor: {
10
+ default: null,
11
+ attribute: false,
12
+ type: "json"
13
+ },
14
+ width: {
15
+ default: 2,
16
+ attribute: "width",
17
+ type: "number"
18
+ }
19
+ });
7
20
  /**
8
21
  * @internal
9
22
  */
10
- function useDropIndicator(host, { state }) {
23
+ function setupDropIndicator(host, props) {
11
24
  const context = createSignal(null);
12
25
  const extension = defineDropIndicator({
13
26
  onShow: (options) => context.set(options),
14
27
  onHide: () => context.set(null)
15
28
  });
16
- useEditorExtension(host, state.editor, extension);
17
- const line = createComputed(() => context.get()?.line);
18
- const scrolling = useScrolling(host);
19
- usePresence(host, createComputed(() => {
20
- return !!context.get() && !scrolling.get();
21
- }));
29
+ useEditorExtension(host, props.editor.get, extension);
30
+ const getLine = computed(() => context.get()?.line);
31
+ const getScrolling = useScrolling(host);
32
+ usePresence(host, computed(() => !!context.get() && !getScrolling()));
22
33
  useEffect(host, () => {
23
- const lineValue = line.get();
24
- const lineWidth = state.width.get();
34
+ const lineValue = getLine();
35
+ const lineWidth = props.width.get();
25
36
  if (!lineValue) return;
26
37
  const { p1: { x: x1, y: y1 }, p2: { x: x2, y: y2 } } = lineValue;
27
38
  const horizontal = y1 === y2;
@@ -51,25 +62,18 @@ function useDropIndicator(host, { state }) {
51
62
  });
52
63
  });
53
64
  }
54
- //#endregion
55
- //#region src/components/drop-indicator/drop-indicator/types.ts
56
- /** @internal */
57
- const dropIndicatorProps = Object.freeze({
58
- editor: { default: null },
59
- width: { default: 2 }
60
- });
61
- /** @internal */
62
- const dropIndicatorEvents = {};
63
- //#endregion
64
- //#region src/components/drop-indicator/drop-indicator/element.gen.ts
65
- const DropIndicatorElementBase = defineCustomElement({
66
- props: dropIndicatorProps,
67
- events: dropIndicatorEvents,
68
- setup: useDropIndicator
69
- });
65
+ const DropIndicatorElementBase = defineCustomElement(setupDropIndicator, DropIndicatorPropsDeclaration);
66
+ /**
67
+ * @public
68
+ */
70
69
  var DropIndicatorElement = class extends DropIndicatorElementBase {};
71
- registerCustomElement("prosekit-drop-indicator", DropIndicatorElement);
70
+ /**
71
+ * @internal
72
+ */
73
+ function registerDropIndicatorElement() {
74
+ registerCustomElement("prosekit-drop-indicator", DropIndicatorElement);
75
+ }
72
76
  //#endregion
73
- export { DropIndicatorElement, dropIndicatorEvents, dropIndicatorProps, useDropIndicator };
77
+ export { DropIndicatorElement, DropIndicatorPropsDeclaration, registerDropIndicatorElement, setupDropIndicator };
74
78
 
75
79
  //# sourceMappingURL=prosekit-web-drop-indicator.js.map
@@ -1 +1 @@
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.ts'\nimport { useScrolling } from '../../../hooks/use-scrolling.ts'\nimport { assignStyles } from '../../../utils/assign-styles.ts'\n\nimport type { DropIndicatorEvents, DropIndicatorProps } from './types.ts'\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.ts\"\nimport { dropIndicatorEvents, dropIndicatorProps, type DropIndicatorEvents, type DropIndicatorProps } from \"./types.ts\"\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
+ {"version":3,"file":"prosekit-web-drop-indicator.js","names":[],"sources":["../src/components/drop-indicator/drop-indicator.ts"],"sourcesContent":["import {\n computed,\n createSignal,\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEffect,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { usePresence } from '@aria-ui/utils'\nimport type { Editor } from '@prosekit/core'\nimport { defineDropIndicator, type ShowHandlerOptions } from '@prosekit/extensions/drop-indicator'\n\nimport { useEditorExtension } from '../../hooks/use-editor-extension.ts'\nimport { useScrolling } from '../../hooks/use-scrolling.ts'\nimport { assignStyles } from '../../utils/assign-styles.ts'\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 DropIndicatorPropsDeclaration: PropsDeclaration<DropIndicatorProps> = /* @__PURE__ */ defineProps<DropIndicatorProps>({\n editor: {\n default: null,\n attribute: false,\n type: 'json',\n },\n width: {\n default: 2,\n attribute: 'width',\n type: 'number',\n },\n})\n\n/**\n * @internal\n */\nexport function setupDropIndicator(\n host: HostElement,\n props: State<DropIndicatorProps>,\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, props.editor.get, extension)\n\n const getLine = computed(() => context.get()?.line)\n const getScrolling = useScrolling(host)\n const getPresence = computed(() => !!context.get() && !getScrolling())\n usePresence(host, getPresence)\n\n useEffect(host, () => {\n const lineValue = getLine()\n const lineWidth = props.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\nconst DropIndicatorElementBase: HostElementConstructor<DropIndicatorProps> = defineCustomElement(\n setupDropIndicator,\n DropIndicatorPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class DropIndicatorElement extends DropIndicatorElementBase {}\n\n/**\n * @internal\n */\nexport function registerDropIndicatorElement(): void {\n registerCustomElement('prosekit-drop-indicator', DropIndicatorElement)\n}\n"],"mappings":";;;;;;;AAsCA,MAAa,gCAAsF,4BAAgC;CACjI,QAAQ;EACN,SAAS;EACT,WAAW;EACX,MAAM;EACP;CACD,OAAO;EACL,SAAS;EACT,WAAW;EACX,MAAM;EACP;CACF,CAAC;;;;AAKF,SAAgB,mBACd,MACA,OACM;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,OAAO,KAAK,UAAU;CAErD,MAAM,UAAU,eAAe,QAAQ,KAAK,EAAE,KAAK;CACnD,MAAM,eAAe,aAAa,KAAK;AAEvC,aAAY,MADQ,eAAe,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,cAAc,CAAC,CACxC;AAE9B,WAAU,YAAY;EACpB,MAAM,YAAY,SAAS;EAC3B,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;GACF;;AAGJ,MAAM,2BAAuE,oBAC3E,oBACA,8BACD;;;;AAKD,IAAa,uBAAb,cAA0C,yBAAyB;;;;AAKnE,SAAgB,+BAAqC;AACnD,uBAAsB,2BAA2B,qBAAqB"}
@@ -1,91 +1,125 @@
1
- import { BaseElementConstructor, ConnectableElement, EventDeclarations, PropDeclarations, SetupOptions } from "@aria-ui/core";
1
+ import { HostElement, HostElementConstructor, PropsDeclaration, State } from "@aria-ui/core";
2
+ import { OpenChangeEvent, OpenChangeEvent as OpenChangeEvent$1, OverlayPopupProps, OverlayPositionerProps, OverlayRootProps } from "@aria-ui/elements/overlay";
2
3
  import { Editor } from "@prosekit/core";
3
- import { OverlayPositionerEvents, OverlayPositionerProps } from "@aria-ui/overlay";
4
4
 
5
- //#region src/components/inline-popover/inline-popover/types.d.ts
6
- interface InlinePopoverProps extends Omit<OverlayPositionerProps, 'placement' | 'offset' | 'hide' | 'overlap' | 'inline' | 'overflowPadding'> {
7
- /**
8
- * The ProseKit editor instance.
9
- *
10
- * @default null
11
- * @hidden
12
- */
13
- editor: Editor | null;
14
- /**
15
- * Whether the popover is open by default when some inline content is
16
- * selected.
17
- *
18
- * When `defaultOpen` is true, the popover will open or close based on the
19
- * inline selection. When `defaultOpen` is false, the popover will never be
20
- * opened unless the `open` prop is true.
21
- *
22
- * @default true
23
- */
24
- defaultOpen: boolean;
25
- /**
26
- * Whether the popover is open.
27
- *
28
- * Notice that the popover will be always hidden if the inline selection is
29
- * empty.
30
- *
31
- * @default false
32
- */
33
- open: boolean;
5
+ //#region src/components/inline-popover/inline-popover-popup.d.ts
6
+ /**
7
+ * @public
8
+ */
9
+ interface InlinePopoverPopupProps extends OverlayPopupProps {}
10
+ /** @internal */
11
+ declare const InlinePopoverPopupPropsDeclaration: PropsDeclaration<InlinePopoverPopupProps>;
12
+ /** @internal */
13
+ declare function setupInlinePopoverPopup(host: HostElement, _props: State<InlinePopoverPopupProps>): void;
14
+ declare const InlinePopoverPopupElementBase: HostElementConstructor<InlinePopoverPopupProps>;
15
+ /**
16
+ * @public
17
+ */
18
+ declare class InlinePopoverPopupElement extends InlinePopoverPopupElementBase {}
19
+ /** @internal */
20
+ declare function registerInlinePopoverPopupElement(): void;
21
+ //#endregion
22
+ //#region src/components/inline-popover/inline-popover-positioner.d.ts
23
+ /**
24
+ * @public
25
+ */
26
+ interface InlinePopoverPositionerProps extends OverlayPositionerProps {
34
27
  /**
35
- * Whether the inline popover should be dismissed when the editor receives an
36
- * Escape key press.
28
+ * The initial placement of the floating element
37
29
  *
38
- * @default true
39
- */
40
- dismissOnEscape: boolean;
41
- /**
42
30
  * @default "top"
43
31
  */
44
32
  placement: OverlayPositionerProps['placement'];
45
33
  /**
34
+ * The distance between the reference and floating element.
35
+ *
46
36
  * @default 12
47
37
  */
48
38
  offset: OverlayPositionerProps['offset'];
49
39
  /**
40
+ * Whether to hide the floating element when the reference element or the
41
+ * floating element is fully clipped.
42
+ *
50
43
  * @default true
51
44
  */
52
45
  hide: OverlayPositionerProps['hide'];
53
46
  /**
47
+ * Whether the floating element can overlap the reference element to keep it
48
+ * in view.
49
+ *
54
50
  * @default true
55
51
  */
56
52
  overlap: OverlayPositionerProps['overlap'];
57
53
  /**
54
+ * Whether to improve positioning for inline reference elements that span over
55
+ * multiple lines.
56
+ *
58
57
  * @default true
59
58
  */
60
59
  inline: OverlayPositionerProps['inline'];
61
60
  /**
61
+ * Describes the virtual padding around the boundary to check for overflow.
62
+ *
62
63
  * @default 8
63
64
  */
64
65
  overflowPadding: OverlayPositionerProps['overflowPadding'];
65
66
  }
66
67
  /** @internal */
67
- declare const inlinePopoverProps: PropDeclarations<InlinePopoverProps>;
68
- interface InlinePopoverEvents extends OverlayPositionerEvents {
68
+ declare const InlinePopoverPositionerPropsDeclaration: PropsDeclaration<InlinePopoverPositionerProps>;
69
+ /** @internal */
70
+ declare function setupInlinePopoverPositioner(host: HostElement, props: State<InlinePopoverPositionerProps>): void;
71
+ declare const InlinePopoverPositionerElementBase: HostElementConstructor<InlinePopoverPositionerProps>;
72
+ /**
73
+ * @public
74
+ */
75
+ declare class InlinePopoverPositionerElement extends InlinePopoverPositionerElementBase {}
76
+ /** @internal */
77
+ declare function registerInlinePopoverPositionerElement(): void;
78
+ //#endregion
79
+ //#region src/components/inline-popover/inline-popover-root.d.ts
80
+ /**
81
+ * @public
82
+ */
83
+ interface InlinePopoverRootProps extends OverlayRootProps {
84
+ /**
85
+ * The ProseKit editor instance.
86
+ *
87
+ * @default null
88
+ * @hidden
89
+ */
90
+ editor: Editor | null;
91
+ /**
92
+ * Whether the popover is open by default when some inline content is
93
+ * selected.
94
+ *
95
+ * @default true
96
+ */
97
+ defaultOpen: boolean;
69
98
  /**
70
- * Fired when the open state changes.
99
+ * Whether the inline popover should be dismissed when the editor receives an
100
+ * Escape key press.
101
+ *
102
+ * @default true
71
103
  */
72
- openChange: CustomEvent<boolean>;
104
+ dismissOnEscape: boolean;
73
105
  }
74
106
  /** @internal */
75
- declare const inlinePopoverEvents: EventDeclarations<InlinePopoverEvents>;
76
- //#endregion
77
- //#region src/components/inline-popover/inline-popover/element.gen.d.ts
78
- declare const InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps>;
79
- declare class InlinePopoverElement extends InlinePopoverElementBase {}
80
- //#endregion
81
- //#region src/components/inline-popover/inline-popover/setup.d.ts
107
+ declare const InlinePopoverRootPropsDeclaration: PropsDeclaration<InlinePopoverRootProps>;
82
108
  /**
83
- * @internal
109
+ * @public
84
110
  */
85
- declare function useInlinePopover(host: ConnectableElement, {
86
- state,
87
- emit
88
- }: SetupOptions<InlinePopoverProps, InlinePopoverEvents>): void;
111
+ interface InlinePopoverRootEvents {
112
+ openChange: OpenChangeEvent$1;
113
+ }
114
+ /** @internal */
115
+ declare function setupInlinePopoverRoot(host: HostElement, props: State<InlinePopoverRootProps>): void;
116
+ declare const InlinePopoverRootElementBase: HostElementConstructor<InlinePopoverRootProps>;
117
+ /**
118
+ * @public
119
+ */
120
+ declare class InlinePopoverRootElement extends InlinePopoverRootElementBase {}
121
+ /** @internal */
122
+ declare function registerInlinePopoverRootElement(): void;
89
123
  //#endregion
90
- export { InlinePopoverElement, type InlinePopoverEvents, type InlinePopoverProps, inlinePopoverEvents, inlinePopoverProps, useInlinePopover };
124
+ export { InlinePopoverPopupElement, type InlinePopoverPopupProps, InlinePopoverPopupPropsDeclaration, InlinePopoverPositionerElement, type InlinePopoverPositionerProps, InlinePopoverPositionerPropsDeclaration, InlinePopoverRootElement, type InlinePopoverRootEvents, type InlinePopoverRootProps, InlinePopoverRootPropsDeclaration, OpenChangeEvent, registerInlinePopoverPopupElement, registerInlinePopoverPositionerElement, registerInlinePopoverRootElement, setupInlinePopoverPopup, setupInlinePopoverPositioner, setupInlinePopoverRoot };
91
125
  //# sourceMappingURL=prosekit-web-inline-popover.d.ts.map
@@ -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"],"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
+ {"version":3,"file":"prosekit-web-inline-popover.d.ts","names":[],"sources":["../src/components/inline-popover/inline-popover-popup.ts","../src/components/inline-popover/inline-popover-positioner.ts","../src/components/inline-popover/inline-popover-root.ts"],"mappings":";;;;;;;;UAkBiB,uBAAA,SAAgC,iBAAA;;cAGpC,kCAAA,EAAoC,gBAAA,CAAiB,uBAAA;;iBAGlD,uBAAA,CACd,IAAA,EAAM,WAAA,EACN,MAAA,EAAQ,KAAA,CAAM,uBAAA;AAAA,cAYV,6BAAA,EAA+B,sBAAA,CAAuB,uBAAA;;;;cAQ/C,yBAAA,SAAkC,6BAAA;;iBAG/B,iCAAA,CAAA;;;;;;UCjCC,4BAAA,SAAqC,sBAAA;EDEb;;;;AAGzC;ECCE,SAAA,EAAW,sBAAA;;;;ADEb;;ECKE,MAAA,EAAQ,sBAAA;EDJF;;;;;;ECYN,IAAA,EAAM,sBAAA;EDXE;;;;;AAUT;ECSC,OAAA,EAAS,sBAAA;;;;ADCX;;;ECOE,MAAA,EAAQ,sBAAA;EDPkE;AAG5E;;;;ECWE,eAAA,EAAiB,sBAAA;AAAA;;cAIN,uCAAA,EAAyC,gBAAA,CAAiB,4BAAA;AAhDvE;AAAA,iBA6DgB,4BAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,4BAAA;AAAA,cAKT,kCAAA,EAAoC,sBAAA,CAAuB,4BAAA;;;;cAQpD,8BAAA,SAAuC,kCAAA;;iBAGpC,sCAAA,CAAA;;;;AD7EhB;;UEMiB,sBAAA,SAA+B,gBAAA;EFNC;;AAGjD;;;;EEUE,MAAA,EAAQ,MAAA;EFPM;;;;;;EEed,WAAA;EFba;;;;;;EEqBb,eAAA;AAAA;AFXD;AAAA,cEeY,iCAAA,EAAmC,gBAAA,CAAiB,sBAAA;;;;UAYhD,uBAAA;EACf,UAAA,EAAY,iBAAA;AAAA;;iBAIE,sBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,sBAAA;AAAA,cAsCT,4BAAA,EAA8B,sBAAA,CAAuB,sBAAA;;;;cAQ9C,wBAAA,SAAiC,4BAAA;;iBAG9B,gCAAA,CAAA"}
@@ -1,31 +1,104 @@
1
1
  import { t as useEditorExtension } from "./use-editor-extension.js";
2
- import { createComputed, createSignal, defineCustomElement, registerCustomElement, useAttribute, useEffect } from "@aria-ui/core";
2
+ import { computed, createContext, defineCustomElement, defineProps, onMount, registerCustomElement } from "@aria-ui/core";
3
+ import { OpenChangeEvent, OverlayPopupPropsDeclaration, OverlayPositionerPropsDeclaration, OverlayRootPropsDeclaration, setupOverlayPopup, setupOverlayPositioner, useOverlayStore } from "@aria-ui/elements/overlay";
3
4
  import { containsInlineNode, defineFocusChangeHandler, defineKeymap, defineUpdateHandler, isInCodeBlock, isTextSelection } from "@prosekit/core";
4
- import { useOverlayPositionerState } from "@aria-ui/overlay/elements";
5
- import { usePresence } from "@aria-ui/presence";
6
- import { overlayPositionerEvents as overlayPositionerEvents$1, overlayPositionerProps as overlayPositionerProps$1 } from "@aria-ui/overlay";
5
+ import { usePresence } from "@aria-ui/utils";
6
+ //#region src/components/inline-popover/store.ts
7
+ const InlinePopoverStoreContext = createContext("prosekit-inline-popover-store");
8
+ //#endregion
9
+ //#region src/components/inline-popover/inline-popover-popup.ts
10
+ /** @internal */
11
+ const InlinePopoverPopupPropsDeclaration = OverlayPopupPropsDeclaration;
12
+ /** @internal */
13
+ function setupInlinePopoverPopup(host, _props) {
14
+ const getStore = InlinePopoverStoreContext.consume(host);
15
+ setupOverlayPopup(host, getStore);
16
+ usePresence(host, computed(() => getStore()?.getIsOpen() ?? false));
17
+ onMount(host, () => {
18
+ host.role = "dialog";
19
+ });
20
+ }
21
+ const InlinePopoverPopupElementBase = defineCustomElement(setupInlinePopoverPopup, InlinePopoverPopupPropsDeclaration);
22
+ /**
23
+ * @public
24
+ */
25
+ var InlinePopoverPopupElement = class extends InlinePopoverPopupElementBase {};
26
+ /** @internal */
27
+ function registerInlinePopoverPopupElement() {
28
+ registerCustomElement("prosekit-inline-popover-popup", InlinePopoverPopupElement);
29
+ }
30
+ //#endregion
31
+ //#region src/components/inline-popover/inline-popover-positioner.ts
32
+ /** @internal */
33
+ const InlinePopoverPositionerPropsDeclaration = /* @__PURE__ */ defineProps({
34
+ ...OverlayPositionerPropsDeclaration,
35
+ placement: {
36
+ default: "top",
37
+ attribute: "placement",
38
+ type: "string"
39
+ },
40
+ offset: {
41
+ default: 12,
42
+ attribute: false,
43
+ type: "json"
44
+ },
45
+ hide: {
46
+ default: true,
47
+ attribute: "hide",
48
+ type: "boolean"
49
+ },
50
+ overlap: {
51
+ default: true,
52
+ attribute: "overlap",
53
+ type: "boolean"
54
+ },
55
+ inline: {
56
+ default: true,
57
+ attribute: "inline",
58
+ type: "boolean"
59
+ },
60
+ overflowPadding: {
61
+ default: 8,
62
+ attribute: "overflow-padding",
63
+ type: "number"
64
+ }
65
+ });
66
+ /** @internal */
67
+ function setupInlinePopoverPositioner(host, props) {
68
+ setupOverlayPositioner(host, props, InlinePopoverStoreContext.consume(host));
69
+ }
70
+ const InlinePopoverPositionerElementBase = defineCustomElement(setupInlinePopoverPositioner, InlinePopoverPositionerPropsDeclaration);
71
+ /**
72
+ * @public
73
+ */
74
+ var InlinePopoverPositionerElement = class extends InlinePopoverPositionerElementBase {};
75
+ /** @internal */
76
+ function registerInlinePopoverPositionerElement() {
77
+ registerCustomElement("prosekit-inline-popover-positioner", InlinePopoverPositionerElement);
78
+ }
79
+ //#endregion
7
80
  //#region src/hooks/use-editor-focus-event.ts
8
81
  /**
9
82
  * @internal
10
83
  */
11
- function useEditorFocusChangeEvent(host, editor, handler) {
12
- useEditorExtension(host, editor, defineFocusChangeHandler(handler));
84
+ function useEditorFocusChangeEvent(host, getEditor, handler) {
85
+ useEditorExtension(host, getEditor, defineFocusChangeHandler(handler));
13
86
  }
14
87
  //#endregion
15
88
  //#region src/hooks/use-editor-update-event.ts
16
89
  /**
17
90
  * @internal
18
91
  */
19
- function useEditorUpdateEvent(host, editor, handler) {
20
- useEditorExtension(host, editor, defineUpdateHandler(handler));
92
+ function useEditorUpdateEvent(host, getEditor, handler) {
93
+ useEditorExtension(host, getEditor, defineUpdateHandler(handler));
21
94
  }
22
95
  //#endregion
23
96
  //#region src/hooks/use-keymap.ts
24
- function useKeymap(host, editor, keymap) {
25
- useEditorExtension(host, editor, defineKeymap(keymap));
97
+ function useKeymap(host, getEditor, keymap) {
98
+ useEditorExtension(host, getEditor, defineKeymap(keymap));
26
99
  }
27
100
  //#endregion
28
- //#region src/components/inline-popover/inline-popover/virtual-selection-element.ts
101
+ //#region src/components/inline-popover/virtual-selection-element.ts
29
102
  function getVirtualSelectionElement(view) {
30
103
  if (typeof window === "undefined" || view.isDestroyed) return;
31
104
  const selection = view.state.selection;
@@ -58,84 +131,61 @@ function getInlineDecoration(view) {
58
131
  };
59
132
  }
60
133
  //#endregion
61
- //#region src/components/inline-popover/inline-popover/setup.ts
62
- /**
63
- * @internal
64
- */
65
- function useInlinePopover(host, { state, emit }) {
66
- const { editor, defaultOpen, open, ...overlayState } = state;
67
- const reference = useInlinePopoverReference(host, editor);
68
- const hasReference = createComputed(() => !!reference.get());
69
- useEffect(host, () => {
70
- const hasReferenceValue = hasReference.get();
71
- const defaultOpenValue = defaultOpen.peek();
72
- const openValue = open.peek();
73
- if (defaultOpenValue || openValue) emit("openChange", hasReferenceValue);
74
- });
75
- useEffect(host, () => {
76
- const hasReferenceValue = hasReference.get();
77
- const defaultOpenValue = defaultOpen.peek();
78
- if (hasReferenceValue && defaultOpenValue) open.set(true);
79
- else if (!hasReferenceValue) open.set(false);
80
- });
81
- useKeymap(host, editor, { Escape: () => {
82
- if (!state.dismissOnEscape.peek() || !open.peek()) return false;
83
- open.set(false);
84
- emit("openChange", false);
85
- return true;
86
- } });
87
- useOverlayPositionerState(host, overlayState, { reference });
88
- useAttribute(host, "data-state", () => open.get() ? "open" : "closed");
89
- usePresence(host, open);
90
- }
91
- function useInlinePopoverReference(host, editor) {
92
- const reference = createSignal(null);
134
+ //#region src/components/inline-popover/inline-popover-root.ts
135
+ /** @internal */
136
+ const InlinePopoverRootPropsDeclaration = /* @__PURE__ */ defineProps({
137
+ ...OverlayRootPropsDeclaration,
138
+ editor: {
139
+ default: null,
140
+ attribute: false,
141
+ type: "json"
142
+ },
143
+ defaultOpen: {
144
+ default: true,
145
+ attribute: "default-open",
146
+ type: "boolean"
147
+ },
148
+ dismissOnEscape: {
149
+ default: true,
150
+ attribute: "dismiss-on-escape",
151
+ type: "boolean"
152
+ }
153
+ });
154
+ /** @internal */
155
+ function setupInlinePopoverRoot(host, props) {
156
+ const store = useOverlayStore(host, props);
157
+ InlinePopoverStoreContext.provide(host, store);
93
158
  let editorFocused = false;
94
- useEditorFocusChangeEvent(host, editor, (focus) => {
159
+ useEditorFocusChangeEvent(host, props.editor.get, (focus) => {
95
160
  editorFocused = focus;
96
161
  });
97
162
  let prevSelection;
98
- useEditorUpdateEvent(host, editor, (view) => {
163
+ useEditorUpdateEvent(host, props.editor.get, (view) => {
99
164
  if (!editorFocused && host.contains(host.ownerDocument.activeElement)) return;
100
165
  const { selection } = view.state;
101
- const selectionUnchanged = prevSelection?.eq(selection);
166
+ if (prevSelection?.eq(selection)) return;
102
167
  prevSelection = selection;
103
- if (selectionUnchanged) return;
104
- reference.set(getVirtualSelectionElement(view) || null);
168
+ const reference = getVirtualSelectionElement(view);
169
+ store.setAnchorElement(reference);
170
+ if (reference && props.defaultOpen.get()) store.requestOpenChange(true);
171
+ else if (!reference) store.requestOpenChange(false);
105
172
  });
106
- return reference;
173
+ useKeymap(host, props.editor.get, { Escape: () => {
174
+ if (!props.dismissOnEscape.get() || !store.getIsOpen()) return false;
175
+ store.requestOpenChange(false);
176
+ return true;
177
+ } });
107
178
  }
108
- //#endregion
109
- //#region src/components/inline-popover/inline-popover/types.ts
110
- /** @internal */
111
- const inlinePopoverProps = Object.freeze({
112
- ...overlayPositionerProps$1,
113
- editor: { default: null },
114
- defaultOpen: { default: true },
115
- open: { default: false },
116
- dismissOnEscape: { default: true },
117
- placement: { default: "top" },
118
- offset: { default: 12 },
119
- hide: { default: true },
120
- overlap: { default: true },
121
- inline: { default: true },
122
- overflowPadding: { default: 8 }
123
- });
179
+ const InlinePopoverRootElementBase = defineCustomElement(setupInlinePopoverRoot, InlinePopoverRootPropsDeclaration);
180
+ /**
181
+ * @public
182
+ */
183
+ var InlinePopoverRootElement = class extends InlinePopoverRootElementBase {};
124
184
  /** @internal */
125
- const inlinePopoverEvents = {
126
- ...overlayPositionerEvents$1,
127
- openChange: {}
128
- };
129
- //#endregion
130
- //#region src/components/inline-popover/inline-popover/element.gen.ts
131
- const InlinePopoverElementBase = defineCustomElement({
132
- props: inlinePopoverProps,
133
- events: inlinePopoverEvents,
134
- setup: useInlinePopover
135
- });
136
- var InlinePopoverElement = class extends InlinePopoverElementBase {};
137
- registerCustomElement("prosekit-inline-popover", InlinePopoverElement);
185
+ function registerInlinePopoverRootElement() {
186
+ registerCustomElement("prosekit-inline-popover-root", InlinePopoverRootElement);
187
+ }
138
188
  //#endregion
139
- export { InlinePopoverElement, inlinePopoverEvents, inlinePopoverProps, useInlinePopover };
189
+ export { InlinePopoverPopupElement, InlinePopoverPopupPropsDeclaration, InlinePopoverPositionerElement, InlinePopoverPositionerPropsDeclaration, InlinePopoverRootElement, InlinePopoverRootPropsDeclaration, OpenChangeEvent, registerInlinePopoverPopupElement, registerInlinePopoverPositionerElement, registerInlinePopoverRootElement, setupInlinePopoverPopup, setupInlinePopoverPositioner, setupInlinePopoverRoot };
140
190
 
141
191
  //# sourceMappingURL=prosekit-web-inline-popover.js.map