@prosekit/web 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,6 +10,7 @@ import { Editor } from '@prosekit/core';
|
|
|
10
10
|
import type { EditorView } from '@prosekit/pm/view';
|
|
11
11
|
import { Extension } from '@prosekit/core';
|
|
12
12
|
import { FocusChangeHandler } from '@prosekit/core';
|
|
13
|
+
import { ListboxProps } from '@aria-ui/listbox';
|
|
13
14
|
import { Options } from 'tsup';
|
|
14
15
|
import type { OverlayPositionerProps } from '@aria-ui/overlay';
|
|
15
16
|
import type { Placement } from '@floating-ui/dom';
|
|
@@ -84,7 +85,7 @@ declare interface AutocompleteListElement extends AutocompleteListProps {
|
|
|
84
85
|
export { AutocompleteListElement }
|
|
85
86
|
export { AutocompleteListElement as AutocompleteListElement_alias_1 }
|
|
86
87
|
|
|
87
|
-
declare interface AutocompleteListProps {
|
|
88
|
+
declare interface AutocompleteListProps extends Pick<ListboxProps, 'filter'> {
|
|
88
89
|
editor: Editor | null;
|
|
89
90
|
}
|
|
90
91
|
export { AutocompleteListProps }
|
|
@@ -108,11 +109,19 @@ declare interface AutocompletePopoverProps extends OverlayPositionerProps {
|
|
|
108
109
|
*/
|
|
109
110
|
editor: Editor | null;
|
|
110
111
|
/**
|
|
111
|
-
* The regular expression to match the text to autocomplete.
|
|
112
|
+
* The regular expression to match the query text to autocomplete.
|
|
112
113
|
*
|
|
113
114
|
* @default null
|
|
114
115
|
*/
|
|
115
116
|
regex: RegExp | null;
|
|
117
|
+
/**
|
|
118
|
+
* A callback that is called when the query changes.
|
|
119
|
+
*/
|
|
120
|
+
onQueryChange: ((query: string) => void) | null;
|
|
121
|
+
/**
|
|
122
|
+
* A callback that is called when the open state changes.
|
|
123
|
+
*/
|
|
124
|
+
onOpenChange: ((open: boolean) => void) | null;
|
|
116
125
|
/**
|
|
117
126
|
* The placement of the popover, relative to the text cursor.
|
|
118
127
|
*
|
|
@@ -239,6 +248,10 @@ export { defaultAutocompleteItemProps }
|
|
|
239
248
|
export { defaultAutocompleteItemProps as defaultAutocompleteItemProps_alias_1 }
|
|
240
249
|
|
|
241
250
|
declare const defaultAutocompleteListProps: {
|
|
251
|
+
filter: (options: {
|
|
252
|
+
query: string;
|
|
253
|
+
value: string;
|
|
254
|
+
}) => boolean;
|
|
242
255
|
editor: null;
|
|
243
256
|
};
|
|
244
257
|
export { defaultAutocompleteListProps }
|
|
@@ -247,6 +260,8 @@ export { defaultAutocompleteListProps as defaultAutocompleteListProps_alias_1 }
|
|
|
247
260
|
declare const defaultAutocompletePopoverProps: Readonly<{
|
|
248
261
|
editor: null;
|
|
249
262
|
regex: null;
|
|
263
|
+
onQueryChange: null;
|
|
264
|
+
onOpenChange: null;
|
|
250
265
|
placement: "bottom-start";
|
|
251
266
|
offset: 4;
|
|
252
267
|
inline: true;
|
|
@@ -83,7 +83,10 @@ defineCustomElement("prosekit-autocomplete-item", AutocompleteItemElement);
|
|
|
83
83
|
import { BaseElement as BaseElement3 } from "@aria-ui/core";
|
|
84
84
|
|
|
85
85
|
// src/components/autocomplete/autocomplete-list/props.ts
|
|
86
|
+
import { defaultListboxProps } from "@aria-ui/listbox";
|
|
87
|
+
var defaultFilter = defaultListboxProps.filter;
|
|
86
88
|
var defaultAutocompleteListProps = {
|
|
89
|
+
filter: defaultFilter,
|
|
87
90
|
editor: null
|
|
88
91
|
};
|
|
89
92
|
|
|
@@ -207,6 +210,8 @@ var defaultAutocompletePopoverProps = Object.freeze({
|
|
|
207
210
|
...defaultOverlayPositionerProps,
|
|
208
211
|
editor: null,
|
|
209
212
|
regex: null,
|
|
213
|
+
onQueryChange: null,
|
|
214
|
+
onOpenChange: null,
|
|
210
215
|
placement: "bottom-start",
|
|
211
216
|
offset: 4,
|
|
212
217
|
inline: true,
|
|
@@ -264,6 +269,18 @@ function useAutocompletePopoverState(host, state) {
|
|
|
264
269
|
);
|
|
265
270
|
useOverlayPositionerState(host, overlayState, { reference });
|
|
266
271
|
usePresence(host, presence);
|
|
272
|
+
useEffect3(host, () => {
|
|
273
|
+
var _a;
|
|
274
|
+
const queryValue = query.value;
|
|
275
|
+
if (presence.peek()) {
|
|
276
|
+
(_a = state.onQueryChange.peek()) == null ? void 0 : _a(queryValue);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
useEffect3(host, () => {
|
|
280
|
+
var _a;
|
|
281
|
+
const presenceValue = presence.value;
|
|
282
|
+
(_a = state.onOpenChange.peek()) == null ? void 0 : _a(presenceValue);
|
|
283
|
+
});
|
|
267
284
|
}
|
|
268
285
|
function useAutocompleteExtension(host, editor, regex, reference, query, onDismiss, onSubmit) {
|
|
269
286
|
useEffect3(host, () => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosekit/web",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "ocavue",
|
|
@@ -65,8 +65,9 @@
|
|
|
65
65
|
"dist"
|
|
66
66
|
],
|
|
67
67
|
"dependencies": {
|
|
68
|
+
"@aria-ui/collection": "^0.0.3",
|
|
68
69
|
"@aria-ui/core": "^0.0.12",
|
|
69
|
-
"@aria-ui/listbox": "^0.0.
|
|
70
|
+
"@aria-ui/listbox": "^0.0.11",
|
|
70
71
|
"@aria-ui/overlay": "^0.0.12",
|
|
71
72
|
"@aria-ui/popover": "^0.0.11",
|
|
72
73
|
"@aria-ui/presence": "^0.0.7",
|