@prosekit/web 0.8.0-beta.3 → 0.8.0-beta.4

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 (77) hide show
  1. package/dist/get-safe-editor-view.js +0 -2
  2. package/dist/get-safe-editor-view.js.map +1 -1
  3. package/dist/prosekit-web-autocomplete.d.ts +47 -19
  4. package/dist/prosekit-web-autocomplete.d.ts.map +1 -1
  5. package/dist/prosekit-web-autocomplete.js +47 -27
  6. package/dist/prosekit-web-autocomplete.js.map +1 -1
  7. package/dist/prosekit-web-block-handle.d.ts +43 -16
  8. package/dist/prosekit-web-block-handle.d.ts.map +1 -1
  9. package/dist/prosekit-web-block-handle.js +43 -33
  10. package/dist/prosekit-web-block-handle.js.map +1 -1
  11. package/dist/prosekit-web-drop-indicator.d.ts +3 -4
  12. package/dist/prosekit-web-drop-indicator.d.ts.map +1 -1
  13. package/dist/prosekit-web-drop-indicator.js +3 -3
  14. package/dist/prosekit-web-drop-indicator.js.map +1 -1
  15. package/dist/prosekit-web-inline-popover.d.ts +31 -10
  16. package/dist/prosekit-web-inline-popover.d.ts.map +1 -1
  17. package/dist/prosekit-web-inline-popover.js +31 -19
  18. package/dist/prosekit-web-inline-popover.js.map +1 -1
  19. package/dist/prosekit-web-menu.d.ts +121 -5
  20. package/dist/prosekit-web-menu.d.ts.map +1 -1
  21. package/dist/prosekit-web-menu.js +115 -10
  22. package/dist/prosekit-web-menu.js.map +1 -1
  23. package/dist/prosekit-web-popover.d.ts +64 -5
  24. package/dist/prosekit-web-popover.d.ts.map +1 -1
  25. package/dist/prosekit-web-popover.js +60 -7
  26. package/dist/prosekit-web-popover.js.map +1 -1
  27. package/dist/prosekit-web-resizable.d.ts +14 -7
  28. package/dist/prosekit-web-resizable.d.ts.map +1 -1
  29. package/dist/prosekit-web-resizable.js +14 -12
  30. package/dist/prosekit-web-resizable.js.map +1 -1
  31. package/dist/prosekit-web-table-handle.d.ts +73 -36
  32. package/dist/prosekit-web-table-handle.d.ts.map +1 -1
  33. package/dist/prosekit-web-table-handle.js +73 -65
  34. package/dist/prosekit-web-table-handle.js.map +1 -1
  35. package/dist/prosekit-web-tooltip.d.ts +61 -5
  36. package/dist/prosekit-web-tooltip.d.ts.map +1 -1
  37. package/dist/prosekit-web-tooltip.js +58 -7
  38. package/dist/prosekit-web-tooltip.js.map +1 -1
  39. package/dist/prosekit-web.d.ts +0 -3
  40. package/dist/prosekit-web.d.ts.map +1 -1
  41. package/dist/prosekit-web.js +0 -2
  42. package/dist/prosekit-web.js.map +1 -1
  43. package/dist/use-editor-extension.js +0 -2
  44. package/dist/use-editor-extension.js.map +1 -1
  45. package/dist/use-scrolling.js +0 -4
  46. package/dist/use-scrolling.js.map +1 -1
  47. package/package.json +7 -7
  48. package/src/components/autocomplete/autocomplete-empty.ts +3 -4
  49. package/src/components/autocomplete/autocomplete-item.ts +11 -1
  50. package/src/components/autocomplete/autocomplete-popup.ts +11 -1
  51. package/src/components/autocomplete/autocomplete-positioner.ts +17 -1
  52. package/src/components/autocomplete/autocomplete-root.ts +5 -1
  53. package/src/components/block-handle/block-handle-add.ts +3 -1
  54. package/src/components/block-handle/block-handle-draggable.ts +9 -1
  55. package/src/components/block-handle/block-handle-popup.ts +9 -1
  56. package/src/components/block-handle/block-handle-positioner.ts +17 -1
  57. package/src/components/block-handle/block-handle-root.ts +5 -1
  58. package/src/components/drop-indicator/drop-indicator.ts +3 -1
  59. package/src/components/inline-popover/inline-popover-popup.ts +9 -1
  60. package/src/components/inline-popover/inline-popover-positioner.ts +17 -1
  61. package/src/components/inline-popover/inline-popover-root.ts +5 -1
  62. package/src/components/menu/index.ts +140 -43
  63. package/src/components/popover/index.ts +76 -23
  64. package/src/components/resizable/resizable-handle.ts +3 -1
  65. package/src/components/resizable/resizable-root.ts +11 -1
  66. package/src/components/table-handle/table-handle-column-menu-root.ts +3 -1
  67. package/src/components/table-handle/table-handle-column-menu-trigger.ts +3 -1
  68. package/src/components/table-handle/table-handle-column-popup.ts +9 -1
  69. package/src/components/table-handle/table-handle-column-positioner.ts +17 -1
  70. package/src/components/table-handle/table-handle-drag-preview.ts +3 -1
  71. package/src/components/table-handle/table-handle-drop-indicator.ts +3 -1
  72. package/src/components/table-handle/table-handle-root.ts +3 -1
  73. package/src/components/table-handle/table-handle-row-menu-root.ts +3 -1
  74. package/src/components/table-handle/table-handle-row-menu-trigger.ts +3 -1
  75. package/src/components/table-handle/table-handle-row-popup.ts +9 -1
  76. package/src/components/table-handle/table-handle-row-positioner.ts +17 -1
  77. package/src/components/tooltip/index.ts +73 -22
@@ -1,4 +1,3 @@
1
- //#region src/utils/get-safe-editor-view.ts
2
1
  /**
3
2
  * @internal
4
3
  */
@@ -6,7 +5,6 @@ function getSafeEditorView(editor) {
6
5
  if (!editor || !editor.mounted) return;
7
6
  return editor.view;
8
7
  }
9
- //#endregion
10
8
  export { getSafeEditorView as t };
11
9
 
12
10
  //# sourceMappingURL=get-safe-editor-view.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-safe-editor-view.js","names":[],"sources":["../src/utils/get-safe-editor-view.ts"],"sourcesContent":["import type { Editor } from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\n/**\n * @internal\n */\nexport function getSafeEditorView(editor?: Editor | null): EditorView | undefined {\n if (!editor || !editor.mounted) return\n return editor.view\n}\n"],"mappings":";;;;AAMA,SAAgB,kBAAkB,QAAgD;AAChF,KAAI,CAAC,UAAU,CAAC,OAAO,QAAS;AAChC,QAAO,OAAO"}
1
+ {"version":3,"file":"get-safe-editor-view.js","names":[],"sources":["../src/utils/get-safe-editor-view.ts"],"sourcesContent":["import type { Editor } from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\n/**\n * @internal\n */\nexport function getSafeEditorView(editor?: Editor | null): EditorView | undefined {\n if (!editor || !editor.mounted) return\n return editor.view\n}\n"],"mappings":";;;AAMA,SAAgB,kBAAkB,QAAgD;AAChF,KAAI,CAAC,UAAU,CAAC,OAAO,QAAS;AAChC,QAAO,OAAO"}
@@ -2,11 +2,6 @@ import { HostElement, HostElementConstructor, PropsDeclaration, State } from "@a
2
2
  import { ItemFilter, ListboxEmptyProps, ListboxItemEvents, ListboxItemProps, ListboxRootEvents, SelectEvent, ValueChangeEvent, ValuesChangeEvent } from "@aria-ui/elements/listbox";
3
3
  import { OpenChangeEvent, OverlayPopupProps, OverlayPositionerProps } from "@aria-ui/elements/overlay";
4
4
  import { Editor } from "@prosekit/core";
5
-
6
- //#region src/components/autocomplete/autocomplete-empty.d.ts
7
- /**
8
- * @internal
9
- */
10
5
  interface AutocompleteEmptyProps extends ListboxEmptyProps {}
11
6
  /** @internal */
12
7
  declare const AutocompleteEmptyPropsDeclaration: PropsDeclaration<AutocompleteEmptyProps>;
@@ -16,13 +11,13 @@ declare const AutocompleteEmptyPropsDeclaration: PropsDeclaration<AutocompleteEm
16
11
  declare function setupAutocompleteEmpty(host: HostElement, props: State<AutocompleteEmptyProps>): void;
17
12
  declare const AutocompleteEmptyElementBase: HostElementConstructor<AutocompleteEmptyProps>;
18
13
  /**
19
- * @public
14
+ * `<prosekit-autocomplete-empty>` custom element.
15
+ *
16
+ * Properties: {@link AutocompleteEmptyProps}
20
17
  */
21
18
  declare class AutocompleteEmptyElement extends AutocompleteEmptyElementBase {}
22
19
  /** @internal */
23
20
  declare function registerAutocompleteEmptyElement(): void;
24
- //#endregion
25
- //#region src/components/autocomplete/autocomplete-item.d.ts
26
21
  interface AutocompleteItemProps extends ListboxItemProps {
27
22
  /**
28
23
  * The value of the item, which will be matched against the query.
@@ -42,13 +37,21 @@ interface AutocompleteItemEvents extends ListboxItemEvents {}
42
37
  declare function setupAutocompleteItem(host: HostElement, props: State<AutocompleteItemProps>): void;
43
38
  declare const AutocompleteItemElementBase: HostElementConstructor<AutocompleteItemProps>;
44
39
  /**
45
- * @public
40
+ * `<prosekit-autocomplete-item>` custom element.
41
+ *
42
+ * Properties: {@link AutocompleteItemProps}
43
+ *
44
+ * Events: {@link AutocompleteItemEvents}
45
+ *
46
+ * Data attributes:
47
+ *
48
+ * | Attribute | Description |
49
+ * | --- | --- |
50
+ * | `data-highlighted` | Present when the item is the currently highlighted option |
46
51
  */
47
52
  declare class AutocompleteItemElement extends AutocompleteItemElementBase {}
48
53
  /** @internal */
49
54
  declare function registerAutocompleteItemElement(): void;
50
- //#endregion
51
- //#region src/components/autocomplete/autocomplete-popup.d.ts
52
55
  /**
53
56
  * @public
54
57
  */
@@ -63,13 +66,21 @@ declare const AutocompletePopupPropsDeclaration: PropsDeclaration<AutocompletePo
63
66
  declare function setupAutocompletePopup(host: HostElement, _props: State<AutocompletePopupProps>): void;
64
67
  declare const AutocompletePopupElementBase: HostElementConstructor<AutocompletePopupProps>;
65
68
  /**
66
- * @public
69
+ * `<prosekit-autocomplete-popup>` custom element.
70
+ *
71
+ * Properties: {@link AutocompletePopupProps}
72
+ *
73
+ * Events: {@link AutocompletePopupEvents}
74
+ *
75
+ * Data attributes:
76
+ *
77
+ * | Attribute | Description |
78
+ * | --- | --- |
79
+ * | `data-state` | `"open"` when the autocomplete is visible, `"closed"` otherwise |
67
80
  */
68
81
  declare class AutocompletePopupElement extends AutocompletePopupElementBase {}
69
82
  /** @internal */
70
83
  declare function registerAutocompletePopupElement(): void;
71
- //#endregion
72
- //#region src/components/autocomplete/autocomplete-positioner.d.ts
73
84
  /**
74
85
  * @public
75
86
  */
@@ -113,13 +124,27 @@ declare const AutocompletePositionerPropsDeclaration: PropsDeclaration<Autocompl
113
124
  declare function setupAutocompletePositioner(host: HostElement, props: State<AutocompletePositionerProps>): void;
114
125
  declare const AutocompletePositionerElementBase: HostElementConstructor<AutocompletePositionerProps>;
115
126
  /**
116
- * @public
127
+ * `<prosekit-autocomplete-positioner>` custom element.
128
+ *
129
+ * Properties: {@link AutocompletePositionerProps}
130
+ *
131
+ * Data attributes:
132
+ *
133
+ * | Attribute | Description |
134
+ * | --- | --- |
135
+ * | `data-state` | `"open"` when the autocomplete is visible, `"closed"` otherwise |
136
+ * | `data-side` | The side of the anchor element the positioner is on |
137
+ * | `data-align` | The alignment of the positioner relative to the anchor element |
138
+ *
139
+ * CSS variables:
140
+ *
141
+ * | Variable | Description |
142
+ * | --- | --- |
143
+ * | `--transform-origin` | The coordinates that this element is anchored to. Useful for scale animations. |
117
144
  */
118
145
  declare class AutocompletePositionerElement extends AutocompletePositionerElementBase {}
119
146
  /** @internal */
120
147
  declare function registerAutocompletePositionerElement(): void;
121
- //#endregion
122
- //#region src/components/autocomplete/autocomplete-root.d.ts
123
148
  interface AutocompleteRootProps {
124
149
  /**
125
150
  * The ProseKit editor instance.
@@ -173,11 +198,14 @@ interface AutocompleteRootEvents extends ListboxRootEvents {
173
198
  declare function setupAutocompleteRoot(host: HostElement, props: State<AutocompleteRootProps>): void;
174
199
  declare const AutocompleteRootElementBase: HostElementConstructor<AutocompleteRootProps>;
175
200
  /**
176
- * @public
201
+ * `<prosekit-autocomplete-root>` custom element.
202
+ *
203
+ * Properties: {@link AutocompleteRootProps}
204
+ *
205
+ * Events: {@link AutocompleteRootEvents}
177
206
  */
178
207
  declare class AutocompleteRootElement extends AutocompleteRootElementBase {}
179
208
  /** @internal */
180
209
  declare function registerAutocompleteRootElement(): void;
181
- //#endregion
182
210
  export { AutocompleteEmptyElement, type AutocompleteEmptyProps, AutocompleteEmptyPropsDeclaration, AutocompleteItemElement, type AutocompleteItemEvents, type AutocompleteItemProps, AutocompleteItemPropsDeclaration, AutocompletePopupElement, type AutocompletePopupEvents, type AutocompletePopupProps, AutocompletePopupPropsDeclaration, AutocompletePositionerElement, type AutocompletePositionerProps, AutocompletePositionerPropsDeclaration, AutocompleteRootElement, type AutocompleteRootEvents, type AutocompleteRootProps, AutocompleteRootPropsDeclaration, OpenChangeEvent, QueryChangeEvent, SelectEvent, ValueChangeEvent, ValuesChangeEvent, registerAutocompleteEmptyElement, registerAutocompleteItemElement, registerAutocompletePopupElement, registerAutocompletePositionerElement, registerAutocompleteRootElement, setupAutocompleteEmpty, setupAutocompleteItem, setupAutocompletePopup, setupAutocompletePositioner, setupAutocompleteRoot };
183
211
  //# sourceMappingURL=prosekit-web-autocomplete.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-web-autocomplete.d.ts","names":[],"sources":["../src/components/autocomplete/autocomplete-empty.ts","../src/components/autocomplete/autocomplete-item.ts","../src/components/autocomplete/autocomplete-popup.ts","../src/components/autocomplete/autocomplete-positioner.ts","../src/components/autocomplete/autocomplete-root.ts"],"mappings":";;;;;;;;;UAciB,sBAAA,SAA+B,iBAAA;;cAGnC,iCAAA,EAAmC,gBAAA,CAAiB,sBAAA;;;AAAjE;iBAOgB,sBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,sBAAA;AAAA,cAKT,4BAAA,EAA8B,sBAAA,CAAuB,sBAAA;;;AAP3D;cAea,wBAAA,SAAiC,4BAAA;;iBAG9B,gCAAA,CAAA;;;UC1BC,qBAAA,SAA8B,gBAAA;;;ADF/C;;;;;ECUE,KAAA;AAAA;;cAIW,gCAAA,EAAkC,gBAAA,CAAiB,qBAAA;AAAA,UAO/C,sBAAA,SAA+B,iBAAA;;;;iBAKhC,qBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,qBAAA;AAAA,cAST,2BAAA,EAA6B,sBAAA,CAAuB,qBAAA;;;;cAQ7C,uBAAA,SAAgC,2BAAA;;iBAG7B,+BAAA,CAAA;;;;;;UClCC,sBAAA,SAA+B,iBAAA;;;;UAK/B,uBAAA,SAAgC,iBAAA;;cAGpC,iCAAA,EAAmC,gBAAA,CAAiB,sBAAA;;iBAKjD,sBAAA,CACd,IAAA,EAAM,WAAA,EACN,MAAA,EAAQ,KAAA,CAAM,sBAAA;AAAA,cAsCV,4BAAA,EAA8B,sBAAA,CAAuB,sBAAA;;;;cAQ9C,wBAAA,SAAiC,4BAAA;;iBAG9B,gCAAA,CAAA;;;;;;UCzEC,2BAAA,SAAoC,sBAAA;EHLpC;;;;;EGWf,SAAA,EAAW,sBAAA;EHNR;;;;AAKL;EGQE,MAAA,EAAQ,sBAAA;;;;EAKR,MAAA,EAAQ,sBAAA;EHXI;;;EGgBZ,KAAA,EAAO,sBAAA;EHhBA;;;EGqBP,WAAA,EAAa,sBAAA;EHrBuB;AAGrC;;EGuBC,QAAA,EAAU,sBAAA;EHrBwB;;AAQpC;EGkBE,eAAA,EAAiB,sBAAA;AAAA;;cAIN,sCAAA,EAAwC,gBAAA,CAAiB,2BAAA;AHnBtE;AAAA,iBGiCgB,2BAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,2BAAA;AAAA,cAOT,iCAAA,EAAmC,sBAAA,CAAuB,2BAAA;;;;cAQnD,6BAAA,SAAsC,iCAAA;AF5EnD;AAAA,iBE+EgB,qCAAA,CAAA;;;UCpEC,qBAAA;EJbA;;;;;AAGjB;EIiBE,MAAA,EAAQ,MAAA;;;;AJVV;;EIiBE,KAAA,EAAO,MAAA;EJhBD;;;;;;EIwBN,MAAA,EAAQ,UAAA;AAAA;;cAIG,gCAAA,EAAkC,gBAAA,CAAiB,qBAAA;;;AJxB/D;cImCY,gBAAA,SAAyB,KAAA;;;;WAI3B,MAAA;cAEG,KAAA;AAAA;;;AJ5Bd;UIqCiB,sBAAA,SAA+B,iBAAA;;;;EAI9C,UAAA,EAAY,eAAA;;;AHnEd;EGwEE,WAAA,EAAa,gBAAA;AAAA;;;AH5Df;iBG8EgB,qBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,qBAAA;AAAA,cA8JT,2BAAA,EAA6B,sBAAA,CAAuB,qBAAA;;;AHvO1D;cG+Oa,uBAAA,SAAgC,2BAAA;;iBAG7B,+BAAA,CAAA"}
1
+ {"version":3,"file":"prosekit-web-autocomplete.d.ts","names":[],"sources":["../src/components/autocomplete/autocomplete-empty.ts","../src/components/autocomplete/autocomplete-item.ts","../src/components/autocomplete/autocomplete-pop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EAAa,sBAAA;EHnBT;;;EGwBJ,QAAA,EAAU,sBAAA;EHxBqE;AAUjF;;EGmBE,eAAA,EAAiB,sBAAA;AAAA;;cAIN,sCAAA,EAAwC,gBAAA,CAAiB,2BAAA;;iBActD,2BAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,2BAAA;AAAA,cAOT,iCAAA,EAAmC,sBAAA,CAAuB,2BAAA;;;AFpEhE;;;;;AAYA;;;;;AAOA;;;;;AAKA;;cEoEa,6BAAA,SAAsC,iCAAA;;iBAGnC,qCAAA,CAAA;AAAA,UCpFC,qBAAA;EJhBuB;;;;AAGxC;;EIoBE,MAAA,EAAQ,MAAA;EJpBsC;;AAOhD;;;EIoBE,KAAA,EAAO,MAAA;EJlBM;;;;;;EI0Bb,MAAA,EAAQ,UAAA;AAAA;;cAIG,gCAAA,EAAkC,gBAAA,CAAiB,qBAAA;;AJ3B/D;;cIsCY,gBAAA,SAAyB,KAAA;EJpCF;;AAUpC;EAVoC,SIwCzB,MAAA;cAEG,KAAA;AAAA;;AJ7Bd;;UIsCiB,sBAAA,SAA+B,iBAAA;EJtCA;;;EI0C9C,UAAA,EAAY,eAAA;EHnEyB;;;EGwErC,WAAA,EAAa,gBAAA;AAAA;;;;iBAkBC,qBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,qBAAA;AAAA,cA8JT,2BAAA,EAA6B,sBAAA,CAAuB,qBAAA;;;;;AHlO1D;;;cG8Oa,uBAAA,SAAgC,2BAAA;;iBAG7B,+BAAA,CAAA"}
@@ -5,7 +5,6 @@ import { SelectEvent, ValueChangeEvent, ValuesChangeEvent, defaultItemFilter, se
5
5
  import { OpenChangeEvent, OverlayPopupPropsDeclaration, OverlayPositionerPropsDeclaration, createOverlayStore, setupOverlayPopup, setupOverlayPositioner } from "@aria-ui/elements/overlay";
6
6
  import { defineDOMEventHandler, defineKeymap, withPriority } from "@prosekit/core";
7
7
  import { AutocompleteRule, defineAutocomplete } from "@prosekit/extensions/autocomplete";
8
- //#region src/components/autocomplete/autocomplete-empty.ts
9
8
  /** @internal */
10
9
  const AutocompleteEmptyPropsDeclaration = /* @__PURE__ */ defineProps({});
11
10
  /**
@@ -16,20 +15,18 @@ function setupAutocompleteEmpty(host, props) {
16
15
  }
17
16
  const AutocompleteEmptyElementBase = defineCustomElement(setupAutocompleteEmpty, AutocompleteEmptyPropsDeclaration);
18
17
  /**
19
- * @public
18
+ * `<prosekit-autocomplete-empty>` custom element.
19
+ *
20
+ * Properties: {@link AutocompleteEmptyProps}
20
21
  */
21
22
  var AutocompleteEmptyElement = class extends AutocompleteEmptyElementBase {};
22
23
  /** @internal */
23
24
  function registerAutocompleteEmptyElement() {
24
25
  registerCustomElement("prosekit-autocomplete-empty", AutocompleteEmptyElement);
25
26
  }
26
- //#endregion
27
- //#region src/utils/prevent-default.ts
28
27
  function preventDefault(event) {
29
28
  event.preventDefault();
30
29
  }
31
- //#endregion
32
- //#region src/components/autocomplete/autocomplete-item.ts
33
30
  /** @internal */
34
31
  const AutocompleteItemPropsDeclaration = /* @__PURE__ */ defineProps({
35
32
  value: {
@@ -53,15 +50,23 @@ function setupAutocompleteItem(host, props) {
53
50
  }
54
51
  const AutocompleteItemElementBase = defineCustomElement(setupAutocompleteItem, AutocompleteItemPropsDeclaration);
55
52
  /**
56
- * @public
53
+ * `<prosekit-autocomplete-item>` custom element.
54
+ *
55
+ * Properties: {@link AutocompleteItemProps}
56
+ *
57
+ * Events: {@link AutocompleteItemEvents}
58
+ *
59
+ * Data attributes:
60
+ *
61
+ * | Attribute | Description |
62
+ * | --- | --- |
63
+ * | `data-highlighted` | Present when the item is the currently highlighted option |
57
64
  */
58
65
  var AutocompleteItemElement = class extends AutocompleteItemElementBase {};
59
66
  /** @internal */
60
67
  function registerAutocompleteItemElement() {
61
68
  registerCustomElement("prosekit-autocomplete-item", AutocompleteItemElement);
62
69
  }
63
- //#endregion
64
- //#region src/utils/lazy-signal.ts
65
70
  function createLazySignal(getRemote, fallback) {
66
71
  return {
67
72
  get: () => {
@@ -74,21 +79,15 @@ function createLazySignal(getRemote, fallback) {
74
79
  }
75
80
  };
76
81
  }
77
- //#endregion
78
- //#region src/utils/use-no-focus.ts
79
82
  function useNoFocus(host) {
80
83
  onMount(host, () => {
81
84
  host.tabIndex = -1;
82
85
  });
83
86
  }
84
- //#endregion
85
- //#region src/components/autocomplete/context.ts
86
87
  /**
87
88
  * @internal
88
89
  */
89
90
  const autocompleteStoreContext = createContext("prosekit-autocomplete-store");
90
- //#endregion
91
- //#region src/components/autocomplete/autocomplete-popup.ts
92
91
  /** @internal */
93
92
  const AutocompletePopupPropsDeclaration = /* @__PURE__ */ defineProps(OverlayPopupPropsDeclaration);
94
93
  /** @internal */
@@ -122,15 +121,23 @@ function createPopupListboxProps(filter, query, eventTarget, disabled) {
122
121
  }
123
122
  const AutocompletePopupElementBase = defineCustomElement(setupAutocompletePopup, AutocompletePopupPropsDeclaration);
124
123
  /**
125
- * @public
124
+ * `<prosekit-autocomplete-popup>` custom element.
125
+ *
126
+ * Properties: {@link AutocompletePopupProps}
127
+ *
128
+ * Events: {@link AutocompletePopupEvents}
129
+ *
130
+ * Data attributes:
131
+ *
132
+ * | Attribute | Description |
133
+ * | --- | --- |
134
+ * | `data-state` | `"open"` when the autocomplete is visible, `"closed"` otherwise |
126
135
  */
127
136
  var AutocompletePopupElement = class extends AutocompletePopupElementBase {};
128
137
  /** @internal */
129
138
  function registerAutocompletePopupElement() {
130
139
  registerCustomElement("prosekit-autocomplete-popup", AutocompletePopupElement);
131
140
  }
132
- //#endregion
133
- //#region src/components/autocomplete/autocomplete-positioner.ts
134
141
  const defaultBoundary = typeof document !== "undefined" && document.querySelector("body") || "clippingAncestors";
135
142
  /** @internal */
136
143
  const AutocompletePositionerPropsDeclaration = /* @__PURE__ */ defineProps({
@@ -179,15 +186,29 @@ function setupAutocompletePositioner(host, props) {
179
186
  }
180
187
  const AutocompletePositionerElementBase = defineCustomElement(setupAutocompletePositioner, AutocompletePositionerPropsDeclaration);
181
188
  /**
182
- * @public
189
+ * `<prosekit-autocomplete-positioner>` custom element.
190
+ *
191
+ * Properties: {@link AutocompletePositionerProps}
192
+ *
193
+ * Data attributes:
194
+ *
195
+ * | Attribute | Description |
196
+ * | --- | --- |
197
+ * | `data-state` | `"open"` when the autocomplete is visible, `"closed"` otherwise |
198
+ * | `data-side` | The side of the anchor element the positioner is on |
199
+ * | `data-align` | The alignment of the positioner relative to the anchor element |
200
+ *
201
+ * CSS variables:
202
+ *
203
+ * | Variable | Description |
204
+ * | --- | --- |
205
+ * | `--transform-origin` | The coordinates that this element is anchored to. Useful for scale animations. |
183
206
  */
184
207
  var AutocompletePositionerElement = class extends AutocompletePositionerElementBase {};
185
208
  /** @internal */
186
209
  function registerAutocompletePositionerElement() {
187
210
  registerCustomElement("prosekit-autocomplete-positioner", AutocompletePositionerElement);
188
211
  }
189
- //#endregion
190
- //#region src/utils/event.ts
191
212
  function cloneKeyboardEvent(source) {
192
213
  return new KeyboardEvent(source.type, {
193
214
  code: source.code,
@@ -211,13 +232,9 @@ var KeyboardEventTarget = class extends EventTarget {
211
232
  return result;
212
233
  }
213
234
  };
214
- //#endregion
215
- //#region src/components/autocomplete/helpers.ts
216
235
  function defaultQueryBuilder(match) {
217
236
  return match[0].toLowerCase().replaceAll(/[!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]/g, "").replaceAll(/\s\s+/g, " ").trim();
218
237
  }
219
- //#endregion
220
- //#region src/components/autocomplete/autocomplete-root.ts
221
238
  /** @internal */
222
239
  const AutocompleteRootPropsDeclaration = /* @__PURE__ */ defineProps({
223
240
  editor: {
@@ -341,14 +358,17 @@ function useEscapeKeydown(host, getEditor, handler) {
341
358
  }
342
359
  const AutocompleteRootElementBase = defineCustomElement(setupAutocompleteRoot, AutocompleteRootPropsDeclaration);
343
360
  /**
344
- * @public
361
+ * `<prosekit-autocomplete-root>` custom element.
362
+ *
363
+ * Properties: {@link AutocompleteRootProps}
364
+ *
365
+ * Events: {@link AutocompleteRootEvents}
345
366
  */
346
367
  var AutocompleteRootElement = class extends AutocompleteRootElementBase {};
347
368
  /** @internal */
348
369
  function registerAutocompleteRootElement() {
349
370
  registerCustomElement("prosekit-autocomplete-root", AutocompleteRootElement);
350
371
  }
351
- //#endregion
352
372
  export { AutocompleteEmptyElement, AutocompleteEmptyPropsDeclaration, AutocompleteItemElement, AutocompleteItemPropsDeclaration, AutocompletePopupElement, AutocompletePopupPropsDeclaration, AutocompletePositionerElement, AutocompletePositionerPropsDeclaration, AutocompleteRootElement, AutocompleteRootPropsDeclaration, OpenChangeEvent, QueryChangeEvent, SelectEvent, ValueChangeEvent, ValuesChangeEvent, registerAutocompleteEmptyElement, registerAutocompleteItemElement, registerAutocompletePopupElement, registerAutocompletePositionerElement, registerAutocompleteRootElement, setupAutocompleteEmpty, setupAutocompleteItem, setupAutocompletePopup, setupAutocompletePositioner, setupAutocompleteRoot };
353
373
 
354
374
  //# sourceMappingURL=prosekit-web-autocomplete.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-web-autocomplete.js","names":[],"sources":["../src/components/autocomplete/autocomplete-empty.ts","../src/utils/prevent-default.ts","../src/components/autocomplete/autocomplete-item.ts","../src/utils/lazy-signal.ts","../src/utils/use-no-focus.ts","../src/components/autocomplete/context.ts","../src/components/autocomplete/autocomplete-popup.ts","../src/components/autocomplete/autocomplete-positioner.ts","../src/utils/event.ts","../src/components/autocomplete/helpers.ts","../src/components/autocomplete/autocomplete-root.ts"],"sourcesContent":["import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { setupListboxEmpty, type ListboxEmptyProps } from '@aria-ui/elements/listbox'\n\n/**\n * @internal\n */\nexport interface AutocompleteEmptyProps extends ListboxEmptyProps {}\n\n/** @internal */\nexport const AutocompleteEmptyPropsDeclaration: PropsDeclaration<AutocompleteEmptyProps> = /* @__PURE__ */ defineProps<\n AutocompleteEmptyProps\n>({})\n\n/**\n * @internal\n */\nexport function setupAutocompleteEmpty(\n host: HostElement,\n props: State<AutocompleteEmptyProps>,\n): void {\n setupListboxEmpty(host, props)\n}\n\nconst AutocompleteEmptyElementBase: HostElementConstructor<AutocompleteEmptyProps> = defineCustomElement(\n setupAutocompleteEmpty,\n AutocompleteEmptyPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class AutocompleteEmptyElement extends AutocompleteEmptyElementBase {}\n\n/** @internal */\nexport function registerAutocompleteEmptyElement(): void {\n registerCustomElement('prosekit-autocomplete-empty', AutocompleteEmptyElement)\n}\n","export function preventDefault(event: Event): void {\n event.preventDefault()\n}\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEventListener,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { SelectEvent, setupListboxItem, type ListboxItemEvents, type ListboxItemProps } from '@aria-ui/elements/listbox'\n\nimport { preventDefault } from '../../utils/prevent-default.ts'\n\nexport { SelectEvent }\n\nexport interface AutocompleteItemProps extends ListboxItemProps {\n /**\n * The value of the item, which will be matched against the query.\n *\n * If not provided, the value is the item's text content.\n *\n * @default \"\"\n */\n value: string\n}\n\n/** @internal */\nexport const AutocompleteItemPropsDeclaration: PropsDeclaration<AutocompleteItemProps> = /* @__PURE__ */ defineProps<AutocompleteItemProps>(\n {\n value: { default: '', attribute: 'value', type: 'string' },\n disabled: { default: false, attribute: 'disabled', type: 'boolean' },\n },\n)\n\nexport interface AutocompleteItemEvents extends ListboxItemEvents {}\n\n/**\n * @internal\n */\nexport function setupAutocompleteItem(\n host: HostElement,\n props: State<AutocompleteItemProps>,\n): void {\n setupListboxItem(host, props)\n\n // Prevent the editor from losing focus\n useEventListener(host, 'pointerdown', preventDefault)\n useEventListener(host, 'mousedown', preventDefault)\n}\n\nconst AutocompleteItemElementBase: HostElementConstructor<AutocompleteItemProps> = defineCustomElement(\n setupAutocompleteItem,\n AutocompleteItemPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class AutocompleteItemElement extends AutocompleteItemElementBase {}\n\n/** @internal */\nexport function registerAutocompleteItemElement(): void {\n registerCustomElement('prosekit-autocomplete-item', AutocompleteItemElement)\n}\n","import type { Signal } from '@aria-ui/core'\n\nexport function createLazySignal<T>(\n getRemote: () => Signal<T> | undefined,\n fallback: T,\n): Signal<T> {\n return {\n get: (): T => {\n const remote = getRemote()\n return remote ? remote.get() : fallback\n },\n set: (value: T): void => {\n const remote = getRemote()\n if (remote) remote.set(value)\n },\n }\n}\n","import { onMount, type HostElement } from '@aria-ui/core'\n\nexport function useNoFocus(host: HostElement): void {\n onMount(host, () => {\n host.tabIndex = -1\n })\n}\n","import { createContext, type Context, type Signal } from '@aria-ui/core'\nimport type { ItemFilter } from '@aria-ui/elements/listbox'\nimport type { OverlayStore } from '@aria-ui/elements/overlay'\n\n/**\n * @internal\n */\nexport interface AutocompleteStore {\n overlayStore: OverlayStore\n query: Signal<string>\n eventTarget: Signal<EventTarget | null>\n filter: Signal<ItemFilter | null>\n}\n\n/**\n * @internal\n */\nexport const autocompleteStoreContext: Context<AutocompleteStore> = createContext<AutocompleteStore>('prosekit-autocomplete-store')\n","import {\n createSignal,\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type Signal,\n type State,\n} from '@aria-ui/core'\nimport {\n defaultItemFilter,\n setupListboxRoot,\n type ItemFilter,\n type ListboxRootEvents,\n type ListboxRootProps,\n} from '@aria-ui/elements/listbox'\nimport { OverlayPopupPropsDeclaration, setupOverlayPopup, type OverlayPopupProps } from '@aria-ui/elements/overlay'\n\nimport { createLazySignal } from '../../utils/lazy-signal.ts'\nimport { useNoFocus } from '../../utils/use-no-focus.ts'\n\nimport { autocompleteStoreContext } from './context.ts'\n\n/**\n * @public\n */\nexport interface AutocompletePopupProps extends OverlayPopupProps {}\n\n/**\n * @public\n */\nexport interface AutocompletePopupEvents extends ListboxRootEvents {}\n\n/** @internal */\nexport const AutocompletePopupPropsDeclaration: PropsDeclaration<AutocompletePopupProps> = /* @__PURE__ */ defineProps<\n AutocompletePopupProps\n>(OverlayPopupPropsDeclaration)\n\n/** @internal */\nexport function setupAutocompletePopup(\n host: HostElement,\n _props: State<AutocompletePopupProps>,\n): void {\n const getStore = autocompleteStoreContext.consume(host)\n const getOverlayStore = () => getStore()?.overlayStore\n\n setupOverlayPopup(host, getOverlayStore)\n\n const query = createLazySignal<string>(() => getStore()?.query, ' ')\n const eventTarget = createLazySignal<EventTarget | null>(() => getStore()?.eventTarget, null)\n const filter = createLazySignal<ItemFilter | null>(() => getStore()?.filter, defaultItemFilter)\n const getDisabled = () => (!(getOverlayStore()?.getIsOpen?.()))\n const disabled: Signal<boolean> = { get: getDisabled, set: () => {} }\n const listboxProps = createPopupListboxProps(filter, query, eventTarget, disabled)\n\n setupListboxRoot(host, listboxProps)\n useNoFocus(host)\n}\n\nfunction createPopupListboxProps(\n filter: Signal<ItemFilter | null>,\n query: Signal<string>,\n eventTarget: Signal<EventTarget | null>,\n disabled: Signal<boolean>,\n): State<ListboxRootProps> {\n return {\n value: createSignal(''),\n values: createSignal<string[]>([]),\n multiple: createSignal(false),\n disabled,\n orientation: createSignal<'vertical' | 'horizontal'>('vertical'),\n loop: createSignal(false),\n autoHighlight: createSignal(true),\n query,\n eventTarget,\n filter,\n }\n}\n\nconst AutocompletePopupElementBase: HostElementConstructor<AutocompletePopupProps> = defineCustomElement(\n setupAutocompletePopup,\n AutocompletePopupPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class AutocompletePopupElement extends AutocompletePopupElementBase {}\n\n/** @internal */\nexport function registerAutocompletePopupElement(): void {\n registerCustomElement('prosekit-autocomplete-popup', AutocompletePopupElement)\n}\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { OverlayPositionerPropsDeclaration, setupOverlayPositioner, type OverlayPositionerProps } from '@aria-ui/elements/overlay'\n\nimport { autocompleteStoreContext } from './context.ts'\n\nconst body = typeof document !== 'undefined' && document.querySelector('body')\nconst defaultBoundary = body || 'clippingAncestors'\n\n/**\n * @public\n */\nexport interface AutocompletePositionerProps extends OverlayPositionerProps {\n /**\n * The placement of the popover, relative to the text cursor.\n *\n * @default \"bottom-start\"\n */\n placement: OverlayPositionerProps['placement']\n\n /**\n * The distance between the popover and the hovered block.\n *\n * @default 4\n */\n offset: OverlayPositionerProps['offset']\n\n /**\n * @default true\n */\n inline: OverlayPositionerProps['inline']\n\n /**\n * @default true\n */\n hoist: OverlayPositionerProps['hoist']\n\n /**\n * @default true\n */\n fitViewport: OverlayPositionerProps['fitViewport']\n\n /**\n * @default \"The body element\"\n */\n boundary: OverlayPositionerProps['boundary']\n\n /**\n * @default 8\n */\n overflowPadding: OverlayPositionerProps['overflowPadding']\n}\n\n/** @internal */\nexport const AutocompletePositionerPropsDeclaration: PropsDeclaration<AutocompletePositionerProps> = /* @__PURE__ */ defineProps<\n AutocompletePositionerProps\n>({\n ...OverlayPositionerPropsDeclaration,\n placement: { default: 'bottom-start', attribute: 'placement', type: 'string' },\n offset: { default: 4, attribute: false, type: 'json' },\n inline: { default: true, attribute: 'inline', type: 'boolean' },\n hoist: { default: true, attribute: 'hoist', type: 'boolean' },\n fitViewport: { default: true, attribute: 'fit-viewport', type: 'boolean' },\n boundary: { default: defaultBoundary, attribute: false, type: 'json' },\n overflowPadding: { default: 8, attribute: 'overflow-padding', type: 'number' },\n})\n\n/** @internal */\nexport function setupAutocompletePositioner(\n host: HostElement,\n props: State<AutocompletePositionerProps>,\n): void {\n const getStore = autocompleteStoreContext.consume(host)\n const getOverlayStore = () => getStore()?.overlayStore\n setupOverlayPositioner(host, props as unknown as State<OverlayPositionerProps>, getOverlayStore)\n}\n\nconst AutocompletePositionerElementBase: HostElementConstructor<AutocompletePositionerProps> = defineCustomElement(\n setupAutocompletePositioner,\n AutocompletePositionerPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class AutocompletePositionerElement extends AutocompletePositionerElementBase {}\n\n/** @internal */\nexport function registerAutocompletePositionerElement(): void {\n registerCustomElement('prosekit-autocomplete-positioner', AutocompletePositionerElement)\n}\n","function cloneKeyboardEvent(source: KeyboardEvent): KeyboardEvent {\n return new KeyboardEvent(source.type, {\n code: source.code,\n key: source.key,\n location: source.location,\n repeat: source.repeat,\n altKey: source.altKey,\n ctrlKey: source.ctrlKey,\n metaKey: source.metaKey,\n shiftKey: source.shiftKey,\n\n view: source.view,\n // internal bridge target; events don't need to bubble\"\n bubbles: false,\n cancelable: true,\n })\n}\n\nexport class KeyboardEventTarget extends EventTarget {\n override dispatchEvent(event: KeyboardEvent): boolean {\n const newEvent = cloneKeyboardEvent(event)\n const result: boolean = super.dispatchEvent(newEvent)\n if (newEvent.defaultPrevented) {\n event.preventDefault()\n }\n return result\n }\n}\n","export function defaultQueryBuilder(match: RegExpExecArray): string {\n return match[0]\n .toLowerCase()\n .replaceAll(/[!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~]/g, '')\n .replaceAll(/\\s\\s+/g, ' ')\n .trim()\n}\n","import {\n createSignal,\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEffect,\n useEventListener,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type Signal,\n type State,\n} from '@aria-ui/core'\nimport { defaultItemFilter, type ItemFilter, type ListboxRootEvents } from '@aria-ui/elements/listbox'\nimport { createOverlayStore, OpenChangeEvent, type OverlayStore } from '@aria-ui/elements/overlay'\nimport { defineDOMEventHandler, defineKeymap, withPriority, type Editor, type Extension, type Priority } from '@prosekit/core'\nimport { AutocompleteRule, defineAutocomplete, type MatchHandler } from '@prosekit/extensions/autocomplete'\n\nimport { useEditorExtension } from '../../hooks/use-editor-extension.ts'\nimport { KeyboardEventTarget } from '../../utils/event.ts'\nimport { getSafeEditorView } from '../../utils/get-safe-editor-view.ts'\n\nimport { autocompleteStoreContext, type AutocompleteStore } from './context.ts'\nimport { defaultQueryBuilder } from './helpers.ts'\n\nexport { OpenChangeEvent }\n\nexport interface AutocompleteRootProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * The regular expression to match the query text to autocomplete.\n *\n * @default null\n */\n regex: RegExp | null\n\n /**\n * The filter function to determine if an item should be shown in the\n * listbox.\n *\n * @default defaultItemFilter\n */\n filter: ItemFilter | null\n}\n\n/** @internal */\nexport const AutocompleteRootPropsDeclaration: PropsDeclaration<AutocompleteRootProps> = /* @__PURE__ */ defineProps<\n AutocompleteRootProps\n>({\n editor: { default: null, attribute: false, type: 'json' },\n regex: { default: null, attribute: false, type: 'json' },\n filter: { default: defaultItemFilter, attribute: false, type: 'json' },\n})\n\n/**\n * @public\n */\nexport class QueryChangeEvent extends Event {\n /**\n * The current query string.\n */\n readonly detail: string\n\n constructor(query: string) {\n super('queryChange', { bubbles: true })\n this.detail = query\n }\n}\n\n/**\n * @public\n */\nexport interface AutocompleteRootEvents extends ListboxRootEvents {\n /**\n * Fired when the open state changes.\n */\n openChange: OpenChangeEvent\n\n /**\n * Fired when the query changes.\n */\n queryChange: QueryChangeEvent\n}\n\ninterface RuleHandlers {\n submit?: VoidFunction\n dismiss?: VoidFunction\n}\n\ninterface AutocompleteRuleDeps {\n reference: Signal<Element | undefined>\n handlers: RuleHandlers\n setQuery: (next: string) => void\n requestOpenChange: (open: boolean) => void\n}\n\n/**\n * @internal\n */\nexport function setupAutocompleteRoot(\n host: HostElement,\n props: State<AutocompleteRootProps>,\n): void {\n const getEditor = props.editor.get\n\n const reference = createSignal<Element | undefined>(undefined)\n const open = createSignal(false)\n const query = createSignal('')\n const keyboardTarget = new KeyboardEventTarget()\n const eventTarget = createSignal<EventTarget | null>(keyboardTarget)\n const handlers: RuleHandlers = {}\n\n // Create overlay store for positioning. The open state is managed by the\n // overlay store via requestOpenChange(), which dispatches OpenChangeEvent and\n // updates the open signal.\n const overlayStore: OverlayStore = createOverlayStore(\n open.get,\n open.set,\n () => false,\n () => false,\n (event) => host.dispatchEvent(event),\n )\n\n useEffect(host, () => {\n overlayStore.setAnchorElement(reference.get())\n })\n\n const autocompleteStore: AutocompleteStore = {\n overlayStore,\n query,\n eventTarget,\n filter: props.filter,\n }\n\n autocompleteStoreContext.provide(host, autocompleteStore)\n\n useEventListener(host, 'valueChange', () => {\n handlers.submit?.()\n })\n\n useKeyboardBridge(host, getEditor, open.get, keyboardTarget)\n\n useEscapeKeydown(host, getEditor, () => {\n if (!open.get() || !handlers.dismiss) return false\n handlers.dismiss()\n return true\n })\n\n const setQuery = (next: string): void => {\n if (query.get() === next) return\n query.set(next)\n host.dispatchEvent(new QueryChangeEvent(next))\n }\n\n useAutocompleteExtension(host, getEditor, props.regex.get, {\n reference,\n handlers,\n setQuery,\n requestOpenChange: (open) => overlayStore.requestOpenChange(open),\n })\n}\n\nconst EVENT_KEYS = [\n 'ArrowDown',\n 'ArrowRight',\n 'ArrowUp',\n 'ArrowLeft',\n 'Home',\n 'End',\n 'Enter',\n] as const\n\nfunction useKeyboardBridge(\n host: HostElement,\n getEditor: () => Editor | null,\n getOpen: () => boolean,\n target: EventTarget,\n): void {\n const extension: Extension = defineDOMEventHandler('keydown', (view, event): boolean => {\n if (\n view.composing\n || event.defaultPrevented\n || !getOpen()\n || !EVENT_KEYS.includes(event.key as (typeof EVENT_KEYS)[number])\n ) {\n return false\n }\n target.dispatchEvent(event)\n return event.defaultPrevented\n })\n useEditorExtension(host, getEditor, withPriority(extension, 4 satisfies typeof Priority.highest))\n}\n\nfunction useAutocompleteExtension(\n host: HostElement,\n getEditor: () => Editor | null,\n getRegex: () => RegExp | null,\n deps: AutocompleteRuleDeps,\n) {\n useEffect(host, () => {\n const editor = getEditor()\n const regex = getRegex()\n\n if (!editor || !regex) {\n return\n }\n\n const rule = createAutocompleteRule(editor, regex, deps)\n const extension = defineAutocomplete(rule)\n return editor.use(extension)\n })\n}\n\nfunction createAutocompleteRule(\n editor: Editor,\n regex: RegExp,\n deps: AutocompleteRuleDeps,\n) {\n const { reference, handlers, setQuery, requestOpenChange } = deps\n\n const handleEnter: MatchHandler = (options) => {\n const view = getSafeEditorView(editor)\n const span = view?.dom.querySelector('.prosekit-autocomplete-match')\n\n if (span) {\n reference.set(span)\n }\n\n handlers.submit = options.deleteMatch\n handlers.dismiss = options.ignoreMatch\n setQuery(defaultQueryBuilder(options.match))\n requestOpenChange(true)\n }\n\n const handleLeave = () => {\n reference.set(undefined)\n setQuery('')\n handlers.submit = undefined\n handlers.dismiss = undefined\n requestOpenChange(false)\n }\n\n return new AutocompleteRule({\n regex,\n onEnter: handleEnter,\n onLeave: handleLeave,\n })\n}\n\nfunction useEscapeKeydown(\n host: HostElement,\n getEditor: () => Editor | null,\n handler: () => boolean,\n): void {\n const keymap = { Escape: handler }\n const extension = withPriority(defineKeymap(keymap), 4 satisfies typeof Priority.highest)\n useEditorExtension(host, getEditor, extension)\n}\n\nconst AutocompleteRootElementBase: HostElementConstructor<AutocompleteRootProps> = defineCustomElement(\n setupAutocompleteRoot,\n AutocompleteRootPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class AutocompleteRootElement extends AutocompleteRootElementBase {}\n\n/** @internal */\nexport function registerAutocompleteRootElement(): void {\n registerCustomElement('prosekit-autocomplete-root', AutocompleteRootElement)\n}\n"],"mappings":";;;;;;;;;AAiBA,MAAa,oCAA8F,4BAEzG,EAAE,CAAC;;;;AAKL,SAAgB,uBACd,MACA,OACM;AACN,mBAAkB,MAAM,MAAM;;AAGhC,MAAM,+BAA+E,oBACnF,wBACA,kCACD;;;;AAKD,IAAa,2BAAb,cAA8C,6BAA6B;;AAG3E,SAAgB,mCAAyC;AACvD,uBAAsB,+BAA+B,yBAAyB;;;;AC3ChF,SAAgB,eAAe,OAAoB;AACjD,OAAM,gBAAgB;;;;;AC2BxB,MAAa,mCAA4F,4BACvG;CACE,OAAO;EAAE,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,+BAA+B;AAEpE,MAAI,KACF,WAAU,IAAI,KAAK;AAGrB,WAAS,SAAS,QAAQ;AAC1B,WAAS,UAAU,QAAQ;AAC3B,WAAS,oBAAoB,QAAQ,MAAM,CAAC;AAC5C,oBAAkB,KAAK;;CAGzB,MAAM,oBAAoB;AACxB,YAAU,IAAI,KAAA,EAAU;AACxB,WAAS,GAAG;AACZ,WAAS,SAAS,KAAA;AAClB,WAAS,UAAU,KAAA;AACnB,oBAAkB,MAAM;;AAG1B,QAAO,IAAI,iBAAiB;EAC1B;EACA,SAAS;EACT,SAAS;EACV,CAAC;;AAGJ,SAAS,iBACP,MACA,WACA,SACM;AAGN,oBAAmB,MAAM,WADP,aAAa,aADhB,EAAE,QAAQ,SAAS,CACiB,EAAE,EAAoC,CAC3C;;AAGhD,MAAM,8BAA6E,oBACjF,uBACA,iCACD;;;;AAKD,IAAa,0BAAb,cAA6C,4BAA4B;;AAGzE,SAAgB,kCAAwC;AACtD,uBAAsB,8BAA8B,wBAAwB"}
1
+ {"version":3,"file":"prosekit-web-autocomplete.js","names":[],"sources":["../src/components/autocomplete/autocomplete-empty.ts","../src/utils/prevent-default.ts","../src/components/autocomplete/autocomplete-item.ts","../src/utils/lazy-signal.ts","../src/utils/use-no-focus.ts","../src/components/autocomplete/context.ts","../src/components/autocomplete/autocomplete-popup.ts","../src/components/autocomplete/autocomplete-positioner.ts","../src/utils/event.ts","../src/components/autocomplete/helpers.ts","../src/components/autocomplete/autocomplete-root.ts"],"sourcesContent":["import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { setupListboxEmpty, type ListboxEmptyProps } from '@aria-ui/elements/listbox'\n\nexport interface AutocompleteEmptyProps extends ListboxEmptyProps {}\n\n/** @internal */\nexport const AutocompleteEmptyPropsDeclaration: PropsDeclaration<AutocompleteEmptyProps> = /* @__PURE__ */ defineProps<\n AutocompleteEmptyProps\n>({})\n\n/**\n * @internal\n */\nexport function setupAutocompleteEmpty(\n host: HostElement,\n props: State<AutocompleteEmptyProps>,\n): void {\n setupListboxEmpty(host, props)\n}\n\nconst AutocompleteEmptyElementBase: HostElementConstructor<AutocompleteEmptyProps> = defineCustomElement(\n setupAutocompleteEmpty,\n AutocompleteEmptyPropsDeclaration,\n)\n\n/**\n * `<prosekit-autocomplete-empty>` custom element.\n *\n * Properties: {@link AutocompleteEmptyProps}\n */\nexport class AutocompleteEmptyElement extends AutocompleteEmptyElementBase {}\n\n/** @internal */\nexport function registerAutocompleteEmptyElement(): void {\n registerCustomElement('prosekit-autocomplete-empty', AutocompleteEmptyElement)\n}\n","export function preventDefault(event: Event): void {\n event.preventDefault()\n}\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEventListener,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { SelectEvent, setupListboxItem, type ListboxItemEvents, type ListboxItemProps } from '@aria-ui/elements/listbox'\n\nimport { preventDefault } from '../../utils/prevent-default.ts'\n\nexport { SelectEvent }\n\nexport interface AutocompleteItemProps extends ListboxItemProps {\n /**\n * The value of the item, which will be matched against the query.\n *\n * If not provided, the value is the item's text content.\n *\n * @default \"\"\n */\n value: string\n}\n\n/** @internal */\nexport const AutocompleteItemPropsDeclaration: PropsDeclaration<AutocompleteItemProps> = /* @__PURE__ */ defineProps<AutocompleteItemProps>(\n {\n value: { default: '', attribute: 'value', type: 'string' },\n disabled: { default: false, attribute: 'disabled', type: 'boolean' },\n },\n)\n\nexport interface AutocompleteItemEvents extends ListboxItemEvents {}\n\n/**\n * @internal\n */\nexport function setupAutocompleteItem(\n host: HostElement,\n props: State<AutocompleteItemProps>,\n): void {\n setupListboxItem(host, props)\n\n // Prevent the editor from losing focus\n useEventListener(host, 'pointerdown', preventDefault)\n useEventListener(host, 'mousedown', preventDefault)\n}\n\nconst AutocompleteItemElementBase: HostElementConstructor<AutocompleteItemProps> = defineCustomElement(\n setupAutocompleteItem,\n AutocompleteItemPropsDeclaration,\n)\n\n/**\n * `<prosekit-autocomplete-item>` custom element.\n *\n * Properties: {@link AutocompleteItemProps}\n *\n * Events: {@link AutocompleteItemEvents}\n *\n * Data attributes:\n *\n * | Attribute | Description |\n * | --- | --- |\n * | `data-highlighted` | Present when the item is the currently highlighted option |\n */\nexport class AutocompleteItemElement extends AutocompleteItemElementBase {}\n\n/** @internal */\nexport function registerAutocompleteItemElement(): void {\n registerCustomElement('prosekit-autocomplete-item', AutocompleteItemElement)\n}\n","import type { Signal } from '@aria-ui/core'\n\nexport function createLazySignal<T>(\n getRemote: () => Signal<T> | undefined,\n fallback: T,\n): Signal<T> {\n return {\n get: (): T => {\n const remote = getRemote()\n return remote ? remote.get() : fallback\n },\n set: (value: T): void => {\n const remote = getRemote()\n if (remote) remote.set(value)\n },\n }\n}\n","import { onMount, type HostElement } from '@aria-ui/core'\n\nexport function useNoFocus(host: HostElement): void {\n onMount(host, () => {\n host.tabIndex = -1\n })\n}\n","import { createContext, type Context, type Signal } from '@aria-ui/core'\nimport type { ItemFilter } from '@aria-ui/elements/listbox'\nimport type { OverlayStore } from '@aria-ui/elements/overlay'\n\n/**\n * @internal\n */\nexport interface AutocompleteStore {\n overlayStore: OverlayStore\n query: Signal<string>\n eventTarget: Signal<EventTarget | null>\n filter: Signal<ItemFilter | null>\n}\n\n/**\n * @internal\n */\nexport const autocompleteStoreContext: Context<AutocompleteStore> = createContext<AutocompleteStore>('prosekit-autocomplete-store')\n","import {\n createSignal,\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type Signal,\n type State,\n} from '@aria-ui/core'\nimport {\n defaultItemFilter,\n setupListboxRoot,\n type ItemFilter,\n type ListboxRootEvents,\n type ListboxRootProps,\n} from '@aria-ui/elements/listbox'\nimport { OverlayPopupPropsDeclaration, setupOverlayPopup, type OverlayPopupProps } from '@aria-ui/elements/overlay'\n\nimport { createLazySignal } from '../../utils/lazy-signal.ts'\nimport { useNoFocus } from '../../utils/use-no-focus.ts'\n\nimport { autocompleteStoreContext } from './context.ts'\n\n/**\n * @public\n */\nexport interface AutocompletePopupProps extends OverlayPopupProps {}\n\n/**\n * @public\n */\nexport interface AutocompletePopupEvents extends ListboxRootEvents {}\n\n/** @internal */\nexport const AutocompletePopupPropsDeclaration: PropsDeclaration<AutocompletePopupProps> = /* @__PURE__ */ defineProps<\n AutocompletePopupProps\n>(OverlayPopupPropsDeclaration)\n\n/** @internal */\nexport function setupAutocompletePopup(\n host: HostElement,\n _props: State<AutocompletePopupProps>,\n): void {\n const getStore = autocompleteStoreContext.consume(host)\n const getOverlayStore = () => getStore()?.overlayStore\n\n setupOverlayPopup(host, getOverlayStore)\n\n const query = createLazySignal<string>(() => getStore()?.query, ' ')\n const eventTarget = createLazySignal<EventTarget | null>(() => getStore()?.eventTarget, null)\n const filter = createLazySignal<ItemFilter | null>(() => getStore()?.filter, defaultItemFilter)\n const getDisabled = () => (!(getOverlayStore()?.getIsOpen?.()))\n const disabled: Signal<boolean> = { get: getDisabled, set: () => {} }\n const listboxProps = createPopupListboxProps(filter, query, eventTarget, disabled)\n\n setupListboxRoot(host, listboxProps)\n useNoFocus(host)\n}\n\nfunction createPopupListboxProps(\n filter: Signal<ItemFilter | null>,\n query: Signal<string>,\n eventTarget: Signal<EventTarget | null>,\n disabled: Signal<boolean>,\n): State<ListboxRootProps> {\n return {\n value: createSignal(''),\n values: createSignal<string[]>([]),\n multiple: createSignal(false),\n disabled,\n orientation: createSignal<'vertical' | 'horizontal'>('vertical'),\n loop: createSignal(false),\n autoHighlight: createSignal(true),\n query,\n eventTarget,\n filter,\n }\n}\n\nconst AutocompletePopupElementBase: HostElementConstructor<AutocompletePopupProps> = defineCustomElement(\n setupAutocompletePopup,\n AutocompletePopupPropsDeclaration,\n)\n\n/**\n * `<prosekit-autocomplete-popup>` custom element.\n *\n * Properties: {@link AutocompletePopupProps}\n *\n * Events: {@link AutocompletePopupEvents}\n *\n * Data attributes:\n *\n * | Attribute | Description |\n * | --- | --- |\n * | `data-state` | `\"open\"` when the autocomplete is visible, `\"closed\"` otherwise |\n */\nexport class AutocompletePopupElement extends AutocompletePopupElementBase {}\n\n/** @internal */\nexport function registerAutocompletePopupElement(): void {\n registerCustomElement('prosekit-autocomplete-popup', AutocompletePopupElement)\n}\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { OverlayPositionerPropsDeclaration, setupOverlayPositioner, type OverlayPositionerProps } from '@aria-ui/elements/overlay'\n\nimport { autocompleteStoreContext } from './context.ts'\n\nconst body = typeof document !== 'undefined' && document.querySelector('body')\nconst defaultBoundary = body || 'clippingAncestors'\n\n/**\n * @public\n */\nexport interface AutocompletePositionerProps extends OverlayPositionerProps {\n /**\n * The placement of the popover, relative to the text cursor.\n *\n * @default \"bottom-start\"\n */\n placement: OverlayPositionerProps['placement']\n\n /**\n * The distance between the popover and the hovered block.\n *\n * @default 4\n */\n offset: OverlayPositionerProps['offset']\n\n /**\n * @default true\n */\n inline: OverlayPositionerProps['inline']\n\n /**\n * @default true\n */\n hoist: OverlayPositionerProps['hoist']\n\n /**\n * @default true\n */\n fitViewport: OverlayPositionerProps['fitViewport']\n\n /**\n * @default \"The body element\"\n */\n boundary: OverlayPositionerProps['boundary']\n\n /**\n * @default 8\n */\n overflowPadding: OverlayPositionerProps['overflowPadding']\n}\n\n/** @internal */\nexport const AutocompletePositionerPropsDeclaration: PropsDeclaration<AutocompletePositionerProps> = /* @__PURE__ */ defineProps<\n AutocompletePositionerProps\n>({\n ...OverlayPositionerPropsDeclaration,\n placement: { default: 'bottom-start', attribute: 'placement', type: 'string' },\n offset: { default: 4, attribute: false, type: 'json' },\n inline: { default: true, attribute: 'inline', type: 'boolean' },\n hoist: { default: true, attribute: 'hoist', type: 'boolean' },\n fitViewport: { default: true, attribute: 'fit-viewport', type: 'boolean' },\n boundary: { default: defaultBoundary, attribute: false, type: 'json' },\n overflowPadding: { default: 8, attribute: 'overflow-padding', type: 'number' },\n})\n\n/** @internal */\nexport function setupAutocompletePositioner(\n host: HostElement,\n props: State<AutocompletePositionerProps>,\n): void {\n const getStore = autocompleteStoreContext.consume(host)\n const getOverlayStore = () => getStore()?.overlayStore\n setupOverlayPositioner(host, props as unknown as State<OverlayPositionerProps>, getOverlayStore)\n}\n\nconst AutocompletePositionerElementBase: HostElementConstructor<AutocompletePositionerProps> = defineCustomElement(\n setupAutocompletePositioner,\n AutocompletePositionerPropsDeclaration,\n)\n\n/**\n * `<prosekit-autocomplete-positioner>` custom element.\n *\n * Properties: {@link AutocompletePositionerProps}\n *\n * Data attributes:\n *\n * | Attribute | Description |\n * | --- | --- |\n * | `data-state` | `\"open\"` when the autocomplete is visible, `\"closed\"` otherwise |\n * | `data-side` | The side of the anchor element the positioner is on |\n * | `data-align` | The alignment of the positioner relative to the anchor element |\n *\n * CSS variables:\n *\n * | Variable | Description |\n * | --- | --- |\n * | `--transform-origin` | The coordinates that this element is anchored to. Useful for scale animations. |\n */\nexport class AutocompletePositionerElement extends AutocompletePositionerElementBase {}\n\n/** @internal */\nexport function registerAutocompletePositionerElement(): void {\n registerCustomElement('prosekit-autocomplete-positioner', AutocompletePositionerElement)\n}\n","function cloneKeyboardEvent(source: KeyboardEvent): KeyboardEvent {\n return new KeyboardEvent(source.type, {\n code: source.code,\n key: source.key,\n location: source.location,\n repeat: source.repeat,\n altKey: source.altKey,\n ctrlKey: source.ctrlKey,\n metaKey: source.metaKey,\n shiftKey: source.shiftKey,\n\n view: source.view,\n // internal bridge target; events don't need to bubble\"\n bubbles: false,\n cancelable: true,\n })\n}\n\nexport class KeyboardEventTarget extends EventTarget {\n override dispatchEvent(event: KeyboardEvent): boolean {\n const newEvent = cloneKeyboardEvent(event)\n const result: boolean = super.dispatchEvent(newEvent)\n if (newEvent.defaultPrevented) {\n event.preventDefault()\n }\n return result\n }\n}\n","export function defaultQueryBuilder(match: RegExpExecArray): string {\n return match[0]\n .toLowerCase()\n .replaceAll(/[!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~]/g, '')\n .replaceAll(/\\s\\s+/g, ' ')\n .trim()\n}\n","import {\n createSignal,\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEffect,\n useEventListener,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type Signal,\n type State,\n} from '@aria-ui/core'\nimport { defaultItemFilter, type ItemFilter, type ListboxRootEvents } from '@aria-ui/elements/listbox'\nimport { createOverlayStore, OpenChangeEvent, type OverlayStore } from '@aria-ui/elements/overlay'\nimport { defineDOMEventHandler, defineKeymap, withPriority, type Editor, type Extension, type Priority } from '@prosekit/core'\nimport { AutocompleteRule, defineAutocomplete, type MatchHandler } from '@prosekit/extensions/autocomplete'\n\nimport { useEditorExtension } from '../../hooks/use-editor-extension.ts'\nimport { KeyboardEventTarget } from '../../utils/event.ts'\nimport { getSafeEditorView } from '../../utils/get-safe-editor-view.ts'\n\nimport { autocompleteStoreContext, type AutocompleteStore } from './context.ts'\nimport { defaultQueryBuilder } from './helpers.ts'\n\nexport { OpenChangeEvent }\n\nexport interface AutocompleteRootProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * The regular expression to match the query text to autocomplete.\n *\n * @default null\n */\n regex: RegExp | null\n\n /**\n * The filter function to determine if an item should be shown in the\n * listbox.\n *\n * @default defaultItemFilter\n */\n filter: ItemFilter | null\n}\n\n/** @internal */\nexport const AutocompleteRootPropsDeclaration: PropsDeclaration<AutocompleteRootProps> = /* @__PURE__ */ defineProps<\n AutocompleteRootProps\n>({\n editor: { default: null, attribute: false, type: 'json' },\n regex: { default: null, attribute: false, type: 'json' },\n filter: { default: defaultItemFilter, attribute: false, type: 'json' },\n})\n\n/**\n * @public\n */\nexport class QueryChangeEvent extends Event {\n /**\n * The current query string.\n */\n readonly detail: string\n\n constructor(query: string) {\n super('queryChange', { bubbles: true })\n this.detail = query\n }\n}\n\n/**\n * @public\n */\nexport interface AutocompleteRootEvents extends ListboxRootEvents {\n /**\n * Fired when the open state changes.\n */\n openChange: OpenChangeEvent\n\n /**\n * Fired when the query changes.\n */\n queryChange: QueryChangeEvent\n}\n\ninterface RuleHandlers {\n submit?: VoidFunction\n dismiss?: VoidFunction\n}\n\ninterface AutocompleteRuleDeps {\n reference: Signal<Element | undefined>\n handlers: RuleHandlers\n setQuery: (next: string) => void\n requestOpenChange: (open: boolean) => void\n}\n\n/**\n * @internal\n */\nexport function setupAutocompleteRoot(\n host: HostElement,\n props: State<AutocompleteRootProps>,\n): void {\n const getEditor = props.editor.get\n\n const reference = createSignal<Element | undefined>(undefined)\n const open = createSignal(false)\n const query = createSignal('')\n const keyboardTarget = new KeyboardEventTarget()\n const eventTarget = createSignal<EventTarget | null>(keyboardTarget)\n const handlers: RuleHandlers = {}\n\n // Create overlay store for positioning. The open state is managed by the\n // overlay store via requestOpenChange(), which dispatches OpenChangeEvent and\n // updates the open signal.\n const overlayStore: OverlayStore = createOverlayStore(\n open.get,\n open.set,\n () => false,\n () => false,\n (event) => host.dispatchEvent(event),\n )\n\n useEffect(host, () => {\n overlayStore.setAnchorElement(reference.get())\n })\n\n const autocompleteStore: AutocompleteStore = {\n overlayStore,\n query,\n eventTarget,\n filter: props.filter,\n }\n\n autocompleteStoreContext.provide(host, autocompleteStore)\n\n useEventListener(host, 'valueChange', () => {\n handlers.submit?.()\n })\n\n useKeyboardBridge(host, getEditor, open.get, keyboardTarget)\n\n useEscapeKeydown(host, getEditor, () => {\n if (!open.get() || !handlers.dismiss) return false\n handlers.dismiss()\n return true\n })\n\n const setQuery = (next: string): void => {\n if (query.get() === next) return\n query.set(next)\n host.dispatchEvent(new QueryChangeEvent(next))\n }\n\n useAutocompleteExtension(host, getEditor, props.regex.get, {\n reference,\n handlers,\n setQuery,\n requestOpenChange: (open) => overlayStore.requestOpenChange(open),\n })\n}\n\nconst EVENT_KEYS = [\n 'ArrowDown',\n 'ArrowRight',\n 'ArrowUp',\n 'ArrowLeft',\n 'Home',\n 'End',\n 'Enter',\n] as const\n\nfunction useKeyboardBridge(\n host: HostElement,\n getEditor: () => Editor | null,\n getOpen: () => boolean,\n target: EventTarget,\n): void {\n const extension: Extension = defineDOMEventHandler('keydown', (view, event): boolean => {\n if (\n view.composing\n || event.defaultPrevented\n || !getOpen()\n || !EVENT_KEYS.includes(event.key as (typeof EVENT_KEYS)[number])\n ) {\n return false\n }\n target.dispatchEvent(event)\n return event.defaultPrevented\n })\n useEditorExtension(host, getEditor, withPriority(extension, 4 satisfies typeof Priority.highest))\n}\n\nfunction useAutocompleteExtension(\n host: HostElement,\n getEditor: () => Editor | null,\n getRegex: () => RegExp | null,\n deps: AutocompleteRuleDeps,\n) {\n useEffect(host, () => {\n const editor = getEditor()\n const regex = getRegex()\n\n if (!editor || !regex) {\n return\n }\n\n const rule = createAutocompleteRule(editor, regex, deps)\n const extension = defineAutocomplete(rule)\n return editor.use(extension)\n })\n}\n\nfunction createAutocompleteRule(\n editor: Editor,\n regex: RegExp,\n deps: AutocompleteRuleDeps,\n) {\n const { reference, handlers, setQuery, requestOpenChange } = deps\n\n const handleEnter: MatchHandler = (options) => {\n const view = getSafeEditorView(editor)\n const span = view?.dom.querySelector('.prosekit-autocomplete-match')\n\n if (span) {\n reference.set(span)\n }\n\n handlers.submit = options.deleteMatch\n handlers.dismiss = options.ignoreMatch\n setQuery(defaultQueryBuilder(options.match))\n requestOpenChange(true)\n }\n\n const handleLeave = () => {\n reference.set(undefined)\n setQuery('')\n handlers.submit = undefined\n handlers.dismiss = undefined\n requestOpenChange(false)\n }\n\n return new AutocompleteRule({\n regex,\n onEnter: handleEnter,\n onLeave: handleLeave,\n })\n}\n\nfunction useEscapeKeydown(\n host: HostElement,\n getEditor: () => Editor | null,\n handler: () => boolean,\n): void {\n const keymap = { Escape: handler }\n const extension = withPriority(defineKeymap(keymap), 4 satisfies typeof Priority.highest)\n useEditorExtension(host, getEditor, extension)\n}\n\nconst AutocompleteRootElementBase: HostElementConstructor<AutocompleteRootProps> = defineCustomElement(\n setupAutocompleteRoot,\n AutocompleteRootPropsDeclaration,\n)\n\n/**\n * `<prosekit-autocomplete-root>` custom element.\n *\n * Properties: {@link AutocompleteRootProps}\n *\n * Events: {@link AutocompleteRootEvents}\n */\nexport class AutocompleteRootElement extends AutocompleteRootElementBase {}\n\n/** @internal */\nexport function registerAutocompleteRootElement(): void {\n registerCustomElement('prosekit-autocomplete-root', AutocompleteRootElement)\n}\n"],"mappings":";;;;;;;;AAcA,MAAa,oCAA8F,4BAEzG,EAAE,CAAC;;;;AAKL,SAAgB,uBACd,MACA,OACM;AACN,mBAAkB,MAAM,MAAM;;AAGhC,MAAM,+BAA+E,oBACnF,wBACA,kCACD;;;;;;AAOD,IAAa,2BAAb,cAA8C,6BAA6B;;AAG3E,SAAgB,mCAAyC;AACvD,uBAAsB,+BAA+B,yBAAyB;;AC1ChF,SAAgB,eAAe,OAAoB;AACjD,OAAM,gBAAgB;;;AC2BxB,MAAa,mCAA4F,4BACvG;CACE,OAAO;EAAE,SAAS;EAAI,WAAW;EAAS,MAAM;EAAU;CAC1D,UAAU;EAAE,SAAS;EAAO,WAAW;EAAY,MAAM;EAAW;CACrE,CACF;;;;AAOD,SAAgB,sBACd,MACA,OACM;AACN,kBAAiB,MAAM,MAAM;AAG7B,kBAAiB,MAAM,eAAe,eAAe;AACrD,kBAAiB,MAAM,aAAa,eAAe;;AAGrD,MAAM,8BAA6E,oBACjF,uBACA,iCACD;;;;;;;;;;;;;;AAeD,IAAa,0BAAb,cAA6C,4BAA4B;;AAGzE,SAAgB,kCAAwC;AACtD,uBAAsB,8BAA8B,wBAAwB;;ACvE9E,SAAgB,iBACd,WACA,UACW;AACX,QAAO;EACL,WAAc;GACZ,MAAM,SAAS,WAAW;AAC1B,UAAO,SAAS,OAAO,KAAK,GAAG;;EAEjC,MAAM,UAAmB;GACvB,MA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,MAAM,8BAA6E,oBACjF,uBACA,iCACD;;;;;;;;AASD,IAAa,0BAAb,cAA6C,4BAA4B;;AAGzE,SAAgB,kCAAwC;AACtD,uBAAsB,8BAA8B,wBAAwB"}
@@ -3,8 +3,6 @@ import { OverlayPopupProps, OverlayPositionerProps } from "@aria-ui/elements/ove
3
3
  import { Editor } from "@prosekit/core";
4
4
  import { ProseMirrorNode } from "@prosekit/pm/model";
5
5
  import { Placement } from "@floating-ui/dom";
6
-
7
- //#region src/components/block-handle/block-handle-add.d.ts
8
6
  interface BlockHandleAddProps {
9
7
  /**
10
8
  * The ProseKit editor instance.
@@ -22,13 +20,13 @@ declare const BlockHandleAddPropsDeclaration: PropsDeclaration<BlockHandleAddPro
22
20
  declare function setupBlockHandleAdd(host: HostElement, props: State<BlockHandleAddProps>): void;
23
21
  declare const BlockHandleAddElementBase: HostElementConstructor<BlockHandleAddProps>;
24
22
  /**
25
- * @public
23
+ * `<prosekit-block-handle-add>` custom element.
24
+ *
25
+ * Properties: {@link BlockHandleAddProps}
26
26
  */
27
27
  declare class BlockHandleAddElement extends BlockHandleAddElementBase {}
28
28
  /** @internal */
29
29
  declare function registerBlockHandleAddElement(): void;
30
- //#endregion
31
- //#region src/components/block-handle/block-handle-draggable.d.ts
32
30
  interface BlockHandleDraggableProps {
33
31
  /**
34
32
  * The ProseKit editor instance.
@@ -46,13 +44,19 @@ declare const BlockHandleDraggablePropsDeclaration: PropsDeclaration<BlockHandle
46
44
  declare function setupBlockHandleDraggable(host: HostElement, props: State<BlockHandleDraggableProps>): void;
47
45
  declare const BlockHandleDraggableElementBase: HostElementConstructor<BlockHandleDraggableProps>;
48
46
  /**
49
- * @public
47
+ * `<prosekit-block-handle-draggable>` custom element.
48
+ *
49
+ * Properties: {@link BlockHandleDraggableProps}
50
+ *
51
+ * Data attributes:
52
+ *
53
+ * | Attribute | Description |
54
+ * | --- | --- |
55
+ * | `data-dragging` | Present when the element is being dragged |
50
56
  */
51
57
  declare class BlockHandleDraggableElement extends BlockHandleDraggableElementBase {}
52
58
  /** @internal */
53
59
  declare function registerBlockHandleDraggableElement(): void;
54
- //#endregion
55
- //#region src/components/block-handle/block-handle-popup.d.ts
56
60
  /**
57
61
  * @public
58
62
  */
@@ -63,13 +67,19 @@ declare const BlockHandlePopupPropsDeclaration: PropsDeclaration<BlockHandlePopu
63
67
  declare function setupBlockHandlePopup(host: HostElement, _props: State<BlockHandlePopupProps>): void;
64
68
  declare const BlockHandlePopupElementBase: HostElementConstructor<BlockHandlePopupProps>;
65
69
  /**
66
- * @public
70
+ * `<prosekit-block-handle-popup>` custom element.
71
+ *
72
+ * Properties: {@link BlockHandlePopupProps}
73
+ *
74
+ * Data attributes:
75
+ *
76
+ * | Attribute | Description |
77
+ * | --- | --- |
78
+ * | `data-state` | `"open"` when the block handle is visible, `"closed"` otherwise |
67
79
  */
68
80
  declare class BlockHandlePopupElement extends BlockHandlePopupElementBase {}
69
81
  /** @internal */
70
82
  declare function registerBlockHandlePopupElement(): void;
71
- //#endregion
72
- //#region src/components/block-handle/block-handle-positioner.d.ts
73
83
  /**
74
84
  * @public
75
85
  */
@@ -109,13 +119,27 @@ declare const BlockHandlePositionerPropsDeclaration: PropsDeclaration<BlockHandl
109
119
  declare function setupBlockHandlePositioner(host: HostElement, props: State<BlockHandlePositionerProps>): void;
110
120
  declare const BlockHandlePositionerElementBase: HostElementConstructor<BlockHandlePositionerProps>;
111
121
  /**
112
- * @public
122
+ * `<prosekit-block-handle-positioner>` custom element.
123
+ *
124
+ * Properties: {@link BlockHandlePositionerProps}
125
+ *
126
+ * Data attributes:
127
+ *
128
+ * | Attribute | Description |
129
+ * | --- | --- |
130
+ * | `data-state` | `"open"` when the block handle is visible, `"closed"` otherwise |
131
+ * | `data-side` | The side of the anchor element the positioner is on |
132
+ * | `data-align` | The alignment of the positioner relative to the anchor element |
133
+ *
134
+ * CSS variables:
135
+ *
136
+ * | Variable | Description |
137
+ * | --- | --- |
138
+ * | `--transform-origin` | The coordinates that this element is anchored to. Useful for scale animations. |
113
139
  */
114
140
  declare class BlockHandlePositionerElement extends BlockHandlePositionerElementBase {}
115
141
  /** @internal */
116
142
  declare function registerBlockHandlePositionerElement(): void;
117
- //#endregion
118
- //#region src/components/block-handle/block-handle-root.d.ts
119
143
  interface BlockHandleRootProps {
120
144
  /**
121
145
  * The ProseKit editor instance.
@@ -158,11 +182,14 @@ interface BlockHandleRootEvents {
158
182
  declare function setupBlockHandleRoot(host: HostElement, props: State<BlockHandleRootProps>): void;
159
183
  declare const BlockHandleRootElementBase: HostElementConstructor<BlockHandleRootProps>;
160
184
  /**
161
- * @public
185
+ * `<prosekit-block-handle-root>` custom element.
186
+ *
187
+ * Properties: {@link BlockHandleRootProps}
188
+ *
189
+ * Events: {@link BlockHandleRootEvents}
162
190
  */
163
191
  declare class BlockHandleRootElement extends BlockHandleRootElementBase {}
164
192
  /** @internal */
165
193
  declare function registerBlockHandleRootElement(): void;
166
- //#endregion
167
194
  export { BlockHandleAddElement, type BlockHandleAddProps, BlockHandleAddPropsDeclaration, BlockHandleDraggableElement, type BlockHandleDraggableProps, BlockHandleDraggablePropsDeclaration, BlockHandlePopupElement, type BlockHandlePopupProps, BlockHandlePopupPropsDeclaration, BlockHandlePositionerElement, type BlockHandlePositionerProps, BlockHandlePositionerPropsDeclaration, BlockHandleRootElement, type BlockHandleRootEvents, type BlockHandleRootProps, BlockHandleRootPropsDeclaration, BlockHandleStateChangeEvent, registerBlockHandleAddElement, registerBlockHandleDraggableElement, registerBlockHandlePopupElement, registerBlockHandlePositionerElement, registerBlockHandleRootElement, setupBlockHandleAdd, setupBlockHandleDraggable, setupBlockHandlePopup, setupBlockHandlePositioner, setupBlockHandleRoot };
168
195
  //# sourceMappingURL=prosekit-web-block-handle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-web-block-handle.d.ts","names":[],"sources":["../src/components/block-handle/block-handle-add.ts","../src/components/block-handle/block-handle-draggable.ts","../src/components/block-handle/block-handle-popup.ts","../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AM,0BAAA;AAAA,cAMT,gCAAA,EAAkC,sBAAA,CAAuB,0BAAA;;AHP/D;;cGea,4BAAA,SAAqC,gCAAA;;iBAGlC,oCAAA,CAAA;;;UChEC,oBAAA;;;;AJRjB;;;EIeE,MAAA,EAAQ,MAAA;AAAA;AJJV;AAAA,cIQa,+BAAA,EAAiC,gBAAA,CAAiB,oBAAA;;;;cASlD,2BAAA,SAAoC,KAAA;EJVd;;;EIcjC,MAAA;IAAU,IAAA,EAAM,eAAA;IAAiB,GAAA;EAAA;cACrB,KAAA;IAAS,IAAA,EAAM,eAAA;IAAiB,GAAA;EAAA;AAAA;;;AJQ7C;UICgB,qBAAA;;;;EAIf,WAAA,EAAa,2BAAA;AAAA;;;;iBAMC,oBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,oBAAA;AAAA,cAkCT,0BAAA,EAA4B,sBAAA,CAAuB,oBAAA;;;;cAQ5C,sBAAA,SAA+B,0BAAA;;iBAG5B,8BAAA,CAAA"}
1
+ {"version":3,"file":"prosekit-web-block-handle.d.ts","names":[],"sources":["../src/components/block-handle/block-handle-add.ts","../src/components/block-handle/block-handle-draggable.ts","../src/components/block-handle/block-handle-popup.ts","../src/components/block-handle/block-handle-positioner.ts","../src/components/block-handle/block-handle-root.ts"],"mappings":";;;;;UAciB,mBAAA;;;;AAAjB;;;EAOE,MAAA,EAAQ,MAAA;AAAA;AAIV;AAAA,cAAa,8BAAA,EAAgC,gBAAA,CAAiB,mBAAA;;;;iBAO9C,mBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,mBAAA;AAAA,cAuBT,yBAAA,EAA2B,sBAAA,CAAuB,mBAAA;;;;;;cAU3C,qBAAA,SAA8B,yBAAA;;iBAG3B,6BAAA,CAAA;AAAA,UC5CC,yBAAA;;;;ADZjB;;;ECmBE,MAAA,EAAQ,MAAA;AAAA;ADRV;AAAA,cCYa,oCAAA,EAAsC,gBAAA,CAAiB,y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