@prosekit/web 0.8.0-beta.3 → 0.8.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/get-safe-editor-view.js +0 -2
- package/dist/get-safe-editor-view.js.map +1 -1
- package/dist/prosekit-web-autocomplete.d.ts +47 -19
- package/dist/prosekit-web-autocomplete.d.ts.map +1 -1
- package/dist/prosekit-web-autocomplete.js +49 -28
- package/dist/prosekit-web-autocomplete.js.map +1 -1
- package/dist/prosekit-web-block-handle.d.ts +43 -16
- package/dist/prosekit-web-block-handle.d.ts.map +1 -1
- package/dist/prosekit-web-block-handle.js +45 -35
- package/dist/prosekit-web-block-handle.js.map +1 -1
- package/dist/prosekit-web-drop-indicator.d.ts +3 -4
- package/dist/prosekit-web-drop-indicator.d.ts.map +1 -1
- package/dist/prosekit-web-drop-indicator.js +3 -3
- package/dist/prosekit-web-drop-indicator.js.map +1 -1
- package/dist/prosekit-web-inline-popover.d.ts +31 -10
- package/dist/prosekit-web-inline-popover.d.ts.map +1 -1
- package/dist/prosekit-web-inline-popover.js +32 -20
- package/dist/prosekit-web-inline-popover.js.map +1 -1
- package/dist/prosekit-web-menu.d.ts +121 -5
- package/dist/prosekit-web-menu.d.ts.map +1 -1
- package/dist/prosekit-web-menu.js +115 -10
- package/dist/prosekit-web-menu.js.map +1 -1
- package/dist/prosekit-web-popover.d.ts +64 -5
- package/dist/prosekit-web-popover.d.ts.map +1 -1
- package/dist/prosekit-web-popover.js +60 -7
- package/dist/prosekit-web-popover.js.map +1 -1
- package/dist/prosekit-web-resizable.d.ts +14 -7
- package/dist/prosekit-web-resizable.d.ts.map +1 -1
- package/dist/prosekit-web-resizable.js +14 -12
- package/dist/prosekit-web-resizable.js.map +1 -1
- package/dist/prosekit-web-table-handle.d.ts +73 -36
- package/dist/prosekit-web-table-handle.d.ts.map +1 -1
- package/dist/prosekit-web-table-handle.js +75 -66
- package/dist/prosekit-web-table-handle.js.map +1 -1
- package/dist/prosekit-web-tooltip.d.ts +61 -5
- package/dist/prosekit-web-tooltip.d.ts.map +1 -1
- package/dist/prosekit-web-tooltip.js +58 -7
- package/dist/prosekit-web-tooltip.js.map +1 -1
- package/dist/prosekit-web.d.ts +0 -3
- package/dist/prosekit-web.d.ts.map +1 -1
- package/dist/prosekit-web.js +0 -2
- package/dist/prosekit-web.js.map +1 -1
- package/dist/use-editor-extension.js +0 -2
- package/dist/use-editor-extension.js.map +1 -1
- package/dist/use-scrolling.js +11 -21
- package/dist/use-scrolling.js.map +1 -1
- package/package.json +8 -8
- package/src/components/autocomplete/autocomplete-empty.ts +3 -4
- package/src/components/autocomplete/autocomplete-item.ts +12 -2
- package/src/components/autocomplete/autocomplete-popup.ts +11 -1
- package/src/components/autocomplete/autocomplete-positioner.ts +17 -1
- package/src/components/autocomplete/autocomplete-root.ts +6 -2
- package/src/components/block-handle/block-handle-add.ts +4 -2
- package/src/components/block-handle/block-handle-draggable.ts +10 -3
- package/src/components/block-handle/block-handle-popup.ts +9 -1
- package/src/components/block-handle/block-handle-positioner.ts +17 -1
- package/src/components/block-handle/block-handle-root.ts +5 -1
- package/src/components/drop-indicator/drop-indicator.ts +3 -1
- package/src/components/inline-popover/inline-popover-popup.ts +9 -1
- package/src/components/inline-popover/inline-popover-positioner.ts +17 -1
- package/src/components/inline-popover/inline-popover-root.ts +5 -1
- package/src/components/menu/index.ts +140 -43
- package/src/components/popover/index.ts +76 -23
- package/src/components/resizable/resizable-handle.ts +3 -1
- package/src/components/resizable/resizable-root.ts +11 -1
- package/src/components/table-handle/table-handle-column-menu-root.ts +3 -1
- package/src/components/table-handle/table-handle-column-menu-trigger.ts +4 -2
- package/src/components/table-handle/table-handle-column-popup.ts +9 -1
- package/src/components/table-handle/table-handle-column-positioner.ts +17 -1
- package/src/components/table-handle/table-handle-drag-preview.ts +3 -1
- package/src/components/table-handle/table-handle-drop-indicator.ts +3 -1
- package/src/components/table-handle/table-handle-root.ts +3 -1
- package/src/components/table-handle/table-handle-row-menu-root.ts +3 -1
- package/src/components/table-handle/table-handle-row-menu-trigger.ts +4 -2
- package/src/components/table-handle/table-handle-row-popup.ts +9 -1
- package/src/components/table-handle/table-handle-row-positioner.ts +17 -1
- package/src/components/tooltip/index.ts +73 -22
- package/src/hooks/use-scrolling.ts +16 -14
|
@@ -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":"
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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":"
|
|
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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E;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"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as useEditorExtension } from "./use-editor-extension.js";
|
|
2
2
|
import { t as getSafeEditorView } from "./get-safe-editor-view.js";
|
|
3
|
-
import { createContext, createSignal, defineCustomElement, defineProps, onMount, registerCustomElement, useEffect
|
|
3
|
+
import { createContext, createSignal, defineCustomElement, defineProps, onMount, registerCustomElement, useEffect } from "@aria-ui/core";
|
|
4
4
|
import { SelectEvent, ValueChangeEvent, ValuesChangeEvent, defaultItemFilter, setupListboxEmpty, setupListboxItem, setupListboxRoot } from "@aria-ui/elements/listbox";
|
|
5
|
+
import { useEventListener } from "@aria-ui/utils";
|
|
5
6
|
import { OpenChangeEvent, OverlayPopupPropsDeclaration, OverlayPositionerPropsDeclaration, createOverlayStore, setupOverlayPopup, setupOverlayPositioner } from "@aria-ui/elements/overlay";
|
|
6
7
|
import { defineDOMEventHandler, defineKeymap, withPriority } from "@prosekit/core";
|
|
7
8
|
import { AutocompleteRule, defineAutocomplete } from "@prosekit/extensions/autocomplete";
|
|
8
|
-
//#region src/components/autocomplete/autocomplete-empty.ts
|
|
9
9
|
/** @internal */
|
|
10
10
|
const AutocompleteEmptyPropsDeclaration = /* @__PURE__ */ defineProps({});
|
|
11
11
|
/**
|
|
@@ -16,20 +16,18 @@ function setupAutocompleteEmpty(host, props) {
|
|
|
16
16
|
}
|
|
17
17
|
const AutocompleteEmptyElementBase = defineCustomElement(setupAutocompleteEmpty, AutocompleteEmptyPropsDeclaration);
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* `<prosekit-autocomplete-empty>` custom element.
|
|
20
|
+
*
|
|
21
|
+
* Properties: {@link AutocompleteEmptyProps}
|
|
20
22
|
*/
|
|
21
23
|
var AutocompleteEmptyElement = class extends AutocompleteEmptyElementBase {};
|
|
22
24
|
/** @internal */
|
|
23
25
|
function registerAutocompleteEmptyElement() {
|
|
24
26
|
registerCustomElement("prosekit-autocomplete-empty", AutocompleteEmptyElement);
|
|
25
27
|
}
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/utils/prevent-default.ts
|
|
28
28
|
function preventDefault(event) {
|
|
29
29
|
event.preventDefault();
|
|
30
30
|
}
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/components/autocomplete/autocomplete-item.ts
|
|
33
31
|
/** @internal */
|
|
34
32
|
const AutocompleteItemPropsDeclaration = /* @__PURE__ */ defineProps({
|
|
35
33
|
value: {
|
|
@@ -53,15 +51,23 @@ function setupAutocompleteItem(host, props) {
|
|
|
53
51
|
}
|
|
54
52
|
const AutocompleteItemElementBase = defineCustomElement(setupAutocompleteItem, AutocompleteItemPropsDeclaration);
|
|
55
53
|
/**
|
|
56
|
-
*
|
|
54
|
+
* `<prosekit-autocomplete-item>` custom element.
|
|
55
|
+
*
|
|
56
|
+
* Properties: {@link AutocompleteItemProps}
|
|
57
|
+
*
|
|
58
|
+
* Events: {@link AutocompleteItemEvents}
|
|
59
|
+
*
|
|
60
|
+
* Data attributes:
|
|
61
|
+
*
|
|
62
|
+
* | Attribute | Description |
|
|
63
|
+
* | --- | --- |
|
|
64
|
+
* | `data-highlighted` | Present when the item is the currently highlighted option |
|
|
57
65
|
*/
|
|
58
66
|
var AutocompleteItemElement = class extends AutocompleteItemElementBase {};
|
|
59
67
|
/** @internal */
|
|
60
68
|
function registerAutocompleteItemElement() {
|
|
61
69
|
registerCustomElement("prosekit-autocomplete-item", AutocompleteItemElement);
|
|
62
70
|
}
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/utils/lazy-signal.ts
|
|
65
71
|
function createLazySignal(getRemote, fallback) {
|
|
66
72
|
return {
|
|
67
73
|
get: () => {
|
|
@@ -74,21 +80,15 @@ function createLazySignal(getRemote, fallback) {
|
|
|
74
80
|
}
|
|
75
81
|
};
|
|
76
82
|
}
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/utils/use-no-focus.ts
|
|
79
83
|
function useNoFocus(host) {
|
|
80
84
|
onMount(host, () => {
|
|
81
85
|
host.tabIndex = -1;
|
|
82
86
|
});
|
|
83
87
|
}
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/components/autocomplete/context.ts
|
|
86
88
|
/**
|
|
87
89
|
* @internal
|
|
88
90
|
*/
|
|
89
91
|
const autocompleteStoreContext = createContext("prosekit-autocomplete-store");
|
|
90
|
-
//#endregion
|
|
91
|
-
//#region src/components/autocomplete/autocomplete-popup.ts
|
|
92
92
|
/** @internal */
|
|
93
93
|
const AutocompletePopupPropsDeclaration = /* @__PURE__ */ defineProps(OverlayPopupPropsDeclaration);
|
|
94
94
|
/** @internal */
|
|
@@ -122,15 +122,23 @@ function createPopupListboxProps(filter, query, eventTarget, disabled) {
|
|
|
122
122
|
}
|
|
123
123
|
const AutocompletePopupElementBase = defineCustomElement(setupAutocompletePopup, AutocompletePopupPropsDeclaration);
|
|
124
124
|
/**
|
|
125
|
-
*
|
|
125
|
+
* `<prosekit-autocomplete-popup>` custom element.
|
|
126
|
+
*
|
|
127
|
+
* Properties: {@link AutocompletePopupProps}
|
|
128
|
+
*
|
|
129
|
+
* Events: {@link AutocompletePopupEvents}
|
|
130
|
+
*
|
|
131
|
+
* Data attributes:
|
|
132
|
+
*
|
|
133
|
+
* | Attribute | Description |
|
|
134
|
+
* | --- | --- |
|
|
135
|
+
* | `data-state` | `"open"` when the autocomplete is visible, `"closed"` otherwise |
|
|
126
136
|
*/
|
|
127
137
|
var AutocompletePopupElement = class extends AutocompletePopupElementBase {};
|
|
128
138
|
/** @internal */
|
|
129
139
|
function registerAutocompletePopupElement() {
|
|
130
140
|
registerCustomElement("prosekit-autocomplete-popup", AutocompletePopupElement);
|
|
131
141
|
}
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/components/autocomplete/autocomplete-positioner.ts
|
|
134
142
|
const defaultBoundary = typeof document !== "undefined" && document.querySelector("body") || "clippingAncestors";
|
|
135
143
|
/** @internal */
|
|
136
144
|
const AutocompletePositionerPropsDeclaration = /* @__PURE__ */ defineProps({
|
|
@@ -179,15 +187,29 @@ function setupAutocompletePositioner(host, props) {
|
|
|
179
187
|
}
|
|
180
188
|
const AutocompletePositionerElementBase = defineCustomElement(setupAutocompletePositioner, AutocompletePositionerPropsDeclaration);
|
|
181
189
|
/**
|
|
182
|
-
*
|
|
190
|
+
* `<prosekit-autocomplete-positioner>` custom element.
|
|
191
|
+
*
|
|
192
|
+
* Properties: {@link AutocompletePositionerProps}
|
|
193
|
+
*
|
|
194
|
+
* Data attributes:
|
|
195
|
+
*
|
|
196
|
+
* | Attribute | Description |
|
|
197
|
+
* | --- | --- |
|
|
198
|
+
* | `data-state` | `"open"` when the autocomplete is visible, `"closed"` otherwise |
|
|
199
|
+
* | `data-side` | The side of the anchor element the positioner is on |
|
|
200
|
+
* | `data-align` | The alignment of the positioner relative to the anchor element |
|
|
201
|
+
*
|
|
202
|
+
* CSS variables:
|
|
203
|
+
*
|
|
204
|
+
* | Variable | Description |
|
|
205
|
+
* | --- | --- |
|
|
206
|
+
* | `--transform-origin` | The coordinates that this element is anchored to. Useful for scale animations. |
|
|
183
207
|
*/
|
|
184
208
|
var AutocompletePositionerElement = class extends AutocompletePositionerElementBase {};
|
|
185
209
|
/** @internal */
|
|
186
210
|
function registerAutocompletePositionerElement() {
|
|
187
211
|
registerCustomElement("prosekit-autocomplete-positioner", AutocompletePositionerElement);
|
|
188
212
|
}
|
|
189
|
-
//#endregion
|
|
190
|
-
//#region src/utils/event.ts
|
|
191
213
|
function cloneKeyboardEvent(source) {
|
|
192
214
|
return new KeyboardEvent(source.type, {
|
|
193
215
|
code: source.code,
|
|
@@ -211,13 +233,9 @@ var KeyboardEventTarget = class extends EventTarget {
|
|
|
211
233
|
return result;
|
|
212
234
|
}
|
|
213
235
|
};
|
|
214
|
-
//#endregion
|
|
215
|
-
//#region src/components/autocomplete/helpers.ts
|
|
216
236
|
function defaultQueryBuilder(match) {
|
|
217
237
|
return match[0].toLowerCase().replaceAll(/[!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]/g, "").replaceAll(/\s\s+/g, " ").trim();
|
|
218
238
|
}
|
|
219
|
-
//#endregion
|
|
220
|
-
//#region src/components/autocomplete/autocomplete-root.ts
|
|
221
239
|
/** @internal */
|
|
222
240
|
const AutocompleteRootPropsDeclaration = /* @__PURE__ */ defineProps({
|
|
223
241
|
editor: {
|
|
@@ -341,14 +359,17 @@ function useEscapeKeydown(host, getEditor, handler) {
|
|
|
341
359
|
}
|
|
342
360
|
const AutocompleteRootElementBase = defineCustomElement(setupAutocompleteRoot, AutocompleteRootPropsDeclaration);
|
|
343
361
|
/**
|
|
344
|
-
*
|
|
362
|
+
* `<prosekit-autocomplete-root>` custom element.
|
|
363
|
+
*
|
|
364
|
+
* Properties: {@link AutocompleteRootProps}
|
|
365
|
+
*
|
|
366
|
+
* Events: {@link AutocompleteRootEvents}
|
|
345
367
|
*/
|
|
346
368
|
var AutocompleteRootElement = class extends AutocompleteRootElementBase {};
|
|
347
369
|
/** @internal */
|
|
348
370
|
function registerAutocompleteRootElement() {
|
|
349
371
|
registerCustomElement("prosekit-autocomplete-root", AutocompleteRootElement);
|
|
350
372
|
}
|
|
351
|
-
//#endregion
|
|
352
373
|
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
374
|
|
|
354
375
|
//# 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,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,mBADL,uBAAuB,QAAQ,OAAO,KAAK,CACd;AAC1C,SAAO,OAAO,IAAI,UAAU;GAC5B;;AAGJ,SAAS,uBACP,QACA,OACA,MACA;CACA,MAAM,EAAE,WAAW,UAAU,UAAU,sBAAsB;CAE7D,MAAM,eAA6B,YAAY;EAE7C,MAAM,OADO,kBAAkB,OAAO,EACnB,IAAI,cAAc,+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 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'\nimport { useEventListener } from '@aria-ui/utils'\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 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 { useEventListener } from '@aria-ui/utils'\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,8B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B,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;;;;;;;;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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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","../src/components/block-handle/block-handle-positioner.ts","../src/components/block-handle/block-handle-root.ts"],"mappings":"
|
|
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,UC7CC,yBAAA;;;;ADXjB;;;ECkBE,MAAA,EAAQ,MAAA;AAAA;ADPV;AAAA,cCWa,oCAAA,EAAsC,gBAAA,CAAiB,yBAAA;;;;iBASpD,yBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,yBAAA;AAAA,cAgGT,+BAAA,EAAiC,sBAAA,CAAuB,yBAAA;;;;;;;;;;;;cAgBjD,2BAAA,SAAoC,+BAAA;ADxGhD;AAAA,iBC2Ge,mCAAA,CAAA;;;;UCnJC,qBAAA,SAA8B,iBAAA;;cAGlC,gCAAA,EAAkC,gBAAA,CAAiB,qBAAA;;iBAGhD,qBAAA,CACd,IAAA,EAAM,WAAA,EACN,MAAA,EAAQ,KAAA,CAAM,qBAAA;AAAA,cAMV,2BAAA,EAA6B,sBAAA,CAAuB,qBAAA;;;;;AFG1D;;;;;;;cEaa,uBAAA,SAAgC,2BAAA;;iBAG7B,+BAAA,CAAA;;;;UC/BC,0BAAA,SAAmC,IAAA,CAAK,sBAAA;EHHrB;;;;AAWpC;EGFE,SAAA,EAAW,SAAA;;;;AHSb;;;EGDE,KAAA;EHGa;;;;EGGb,IAAA;EHJA;;;;EGUA,KAAA;EHTiC;AAqBlC;;;EGNC,IAAA;AAAA;AHkBF;AAAA,cGda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