@prosekit/web 0.1.5 → 0.1.7
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/prosekit-web-autocomplete.js +25 -17
- package/package.json +11 -11
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useEditorExtension
|
|
3
|
+
} from "./chunk-VJEVDINM.js";
|
|
1
4
|
import {
|
|
2
5
|
defineCustomElement
|
|
3
6
|
} from "./chunk-LCDA7GFP.js";
|
|
@@ -138,6 +141,9 @@ function useAutocompleteList(element, props) {
|
|
|
138
141
|
};
|
|
139
142
|
}
|
|
140
143
|
});
|
|
144
|
+
useEffect2(element, () => {
|
|
145
|
+
element.tabIndex = -1;
|
|
146
|
+
});
|
|
141
147
|
return { editor, filter };
|
|
142
148
|
}
|
|
143
149
|
function useKeyboardHandler(element, open, editor) {
|
|
@@ -208,10 +214,16 @@ import {
|
|
|
208
214
|
createComputed,
|
|
209
215
|
createSignal as createSignal3,
|
|
210
216
|
mapSignals,
|
|
217
|
+
useAnimationFrame,
|
|
211
218
|
useEffect as useEffect4
|
|
212
219
|
} from "@aria-ui/core";
|
|
213
220
|
import { useOverlayPositionerState } from "@aria-ui/overlay";
|
|
214
221
|
import { usePresence } from "@aria-ui/presence";
|
|
222
|
+
import {
|
|
223
|
+
Priority as Priority2,
|
|
224
|
+
defineKeymap,
|
|
225
|
+
withPriority as withPriority2
|
|
226
|
+
} from "@prosekit/core";
|
|
215
227
|
import {
|
|
216
228
|
AutocompleteRule,
|
|
217
229
|
defineAutocomplete
|
|
@@ -253,7 +265,7 @@ function useAutocompletePopoverState(host, state) {
|
|
|
253
265
|
queryContext.provide(host, query);
|
|
254
266
|
onSubmitContext.provide(host, onSubmit);
|
|
255
267
|
openContext.provide(host, presence);
|
|
256
|
-
useEscapeKeydown(host, createKeymapHandler(onDismiss, presence));
|
|
268
|
+
useEscapeKeydown(host, editor, createKeymapHandler(onDismiss, presence));
|
|
257
269
|
useAutocompleteExtension(
|
|
258
270
|
host,
|
|
259
271
|
editor,
|
|
@@ -273,10 +285,15 @@ function useAutocompletePopoverState(host, state) {
|
|
|
273
285
|
(_a = state.onQueryChange.peek()) == null ? void 0 : _a(queryValue);
|
|
274
286
|
}
|
|
275
287
|
});
|
|
276
|
-
|
|
277
|
-
var _a;
|
|
288
|
+
useAnimationFrame(host, () => {
|
|
278
289
|
const presenceValue = presence.value;
|
|
279
|
-
|
|
290
|
+
const onOpenChangeValue = state.onOpenChange.peek();
|
|
291
|
+
if (!onOpenChangeValue) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
return () => {
|
|
295
|
+
onOpenChangeValue(presenceValue);
|
|
296
|
+
};
|
|
280
297
|
});
|
|
281
298
|
}
|
|
282
299
|
function useAutocompleteExtension(host, editor, regex, reference, query, onDismiss, onSubmit) {
|
|
@@ -332,19 +349,10 @@ function createKeymapHandler(handler, enabled) {
|
|
|
332
349
|
return true;
|
|
333
350
|
};
|
|
334
351
|
}
|
|
335
|
-
function useEscapeKeydown(host, handler) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
if (handler()) {
|
|
342
|
-
event.preventDefault();
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
346
|
-
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
347
|
-
});
|
|
352
|
+
function useEscapeKeydown(host, editor, handler) {
|
|
353
|
+
const keymap = { Escape: handler };
|
|
354
|
+
const extension = withPriority2(defineKeymap(keymap), Priority2.highest);
|
|
355
|
+
return useEditorExtension(host, editor, extension);
|
|
348
356
|
}
|
|
349
357
|
|
|
350
358
|
// src/components/autocomplete/autocomplete-popover/element.gen.ts
|
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.7",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "ocavue",
|
|
@@ -68,21 +68,21 @@
|
|
|
68
68
|
"@aria-ui/collection": "^0.0.3",
|
|
69
69
|
"@aria-ui/core": "^0.0.14",
|
|
70
70
|
"@aria-ui/listbox": "^0.0.13",
|
|
71
|
-
"@aria-ui/overlay": "^0.0.
|
|
72
|
-
"@aria-ui/popover": "^0.0.
|
|
71
|
+
"@aria-ui/overlay": "^0.0.15",
|
|
72
|
+
"@aria-ui/popover": "^0.0.14",
|
|
73
73
|
"@aria-ui/presence": "^0.0.9",
|
|
74
|
-
"@aria-ui/tooltip": "^0.0.
|
|
75
|
-
"@floating-ui/dom": "^1.6.
|
|
76
|
-
"@prosekit/core": "^0.
|
|
77
|
-
"@prosekit/extensions": "^0.
|
|
78
|
-
"@prosekit/pm": "^0.1.
|
|
79
|
-
"@zag-js/dom-query": "^0.
|
|
74
|
+
"@aria-ui/tooltip": "^0.0.16",
|
|
75
|
+
"@floating-ui/dom": "^1.6.5",
|
|
76
|
+
"@prosekit/core": "^0.5.1",
|
|
77
|
+
"@prosekit/extensions": "^0.5.0",
|
|
78
|
+
"@prosekit/pm": "^0.1.4",
|
|
79
|
+
"@zag-js/dom-query": "^0.50.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@prosekit/dev": "*",
|
|
83
82
|
"tsup": "^8.0.2",
|
|
84
83
|
"typescript": "^5.4.5",
|
|
85
|
-
"vitest": "^1.6.0"
|
|
84
|
+
"vitest": "^1.6.0",
|
|
85
|
+
"@prosekit/dev": "0.0.0"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"build:tsup": "tsup",
|