@prosekit/web 0.1.2 → 0.1.3
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.
|
@@ -658,6 +658,8 @@ export declare function useEditorFocusChangeEvent(host: ConnectableElement, edit
|
|
|
658
658
|
*/
|
|
659
659
|
export declare function useEditorUpdateEvent(host: ConnectableElement, editor: ReadonlySignal<Editor | null>, handler: UpdateHandler): void;
|
|
660
660
|
|
|
661
|
+
export declare function useFirstRendering(host: ConnectableElement): ReadonlySignal<boolean>;
|
|
662
|
+
|
|
661
663
|
export declare function useInlinePopover(host: ConnectableElement, props?: Partial<InlinePopoverProps>): SignalState<Readonly<InlinePopoverProps>>;
|
|
662
664
|
|
|
663
665
|
export { usePopoverContent }
|
|
@@ -131,6 +131,7 @@ function useAutocompleteList(element, props) {
|
|
|
131
131
|
useEffect2(element, () => {
|
|
132
132
|
if (!open.value) {
|
|
133
133
|
listboxValue.value = "";
|
|
134
|
+
query.value = "";
|
|
134
135
|
}
|
|
135
136
|
});
|
|
136
137
|
useEffect2(element, () => {
|
|
@@ -227,9 +228,9 @@ var defaultAutocompletePopoverProps = Object.freeze({
|
|
|
227
228
|
import {
|
|
228
229
|
assignProps as assignProps2,
|
|
229
230
|
createComputed,
|
|
230
|
-
createSignal as
|
|
231
|
+
createSignal as createSignal3,
|
|
231
232
|
mapSignals,
|
|
232
|
-
useEffect as
|
|
233
|
+
useEffect as useEffect4
|
|
233
234
|
} from "@aria-ui/core";
|
|
234
235
|
import { useOverlayPositionerState } from "@aria-ui/overlay";
|
|
235
236
|
import { usePresence } from "@aria-ui/presence";
|
|
@@ -238,6 +239,21 @@ import {
|
|
|
238
239
|
defineAutocomplete
|
|
239
240
|
} from "@prosekit/extensions/autocomplete";
|
|
240
241
|
|
|
242
|
+
// src/hooks/use-first-rendering.ts
|
|
243
|
+
import {
|
|
244
|
+
createSignal as createSignal2,
|
|
245
|
+
useEffect as useEffect3
|
|
246
|
+
} from "@aria-ui/core";
|
|
247
|
+
function useFirstRendering(host) {
|
|
248
|
+
const firstRendering = createSignal2(true);
|
|
249
|
+
useEffect3(host, () => {
|
|
250
|
+
requestAnimationFrame(() => {
|
|
251
|
+
firstRendering.value = false;
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
return firstRendering;
|
|
255
|
+
}
|
|
256
|
+
|
|
241
257
|
// src/components/autocomplete/autocomplete-popover/helpers.ts
|
|
242
258
|
function defaultQueryBuilder(match) {
|
|
243
259
|
return match[0].toLowerCase().replace(/[!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]/g, "").replace(/\s\s+/g, " ").trim();
|
|
@@ -251,10 +267,10 @@ function useAutocompletePopover(host, props) {
|
|
|
251
267
|
}
|
|
252
268
|
function useAutocompletePopoverState(host, state) {
|
|
253
269
|
const { editor, regex, ...overlayState } = state;
|
|
254
|
-
const reference =
|
|
255
|
-
const query =
|
|
256
|
-
const onDismiss =
|
|
257
|
-
const onSubmit =
|
|
270
|
+
const reference = createSignal3(null);
|
|
271
|
+
const query = createSignal3("");
|
|
272
|
+
const onDismiss = createSignal3(null);
|
|
273
|
+
const onSubmit = createSignal3(null);
|
|
258
274
|
const presence = createComputed(() => !!reference.value);
|
|
259
275
|
queryContext.provide(host, query);
|
|
260
276
|
onSubmitContext.provide(host, onSubmit);
|
|
@@ -271,21 +287,22 @@ function useAutocompletePopoverState(host, state) {
|
|
|
271
287
|
);
|
|
272
288
|
useOverlayPositionerState(host, overlayState, { reference });
|
|
273
289
|
usePresence(host, presence);
|
|
274
|
-
|
|
290
|
+
const firstRendering = useFirstRendering(host);
|
|
291
|
+
useEffect4(host, () => {
|
|
275
292
|
var _a;
|
|
276
293
|
const queryValue = query.value;
|
|
277
|
-
if (
|
|
294
|
+
if (!firstRendering.peek()) {
|
|
278
295
|
(_a = state.onQueryChange.peek()) == null ? void 0 : _a(queryValue);
|
|
279
296
|
}
|
|
280
297
|
});
|
|
281
|
-
|
|
298
|
+
useEffect4(host, () => {
|
|
282
299
|
var _a;
|
|
283
300
|
const presenceValue = presence.value;
|
|
284
301
|
(_a = state.onOpenChange.peek()) == null ? void 0 : _a(presenceValue);
|
|
285
302
|
});
|
|
286
303
|
}
|
|
287
304
|
function useAutocompleteExtension(host, editor, regex, reference, query, onDismiss, onSubmit) {
|
|
288
|
-
|
|
305
|
+
useEffect4(host, () => {
|
|
289
306
|
const editorValue = editor.value;
|
|
290
307
|
const regexValue = regex.value;
|
|
291
308
|
if (!editorValue || !regexValue) {
|
|
@@ -338,7 +355,7 @@ function createKeymapHandler(handler, enabled) {
|
|
|
338
355
|
};
|
|
339
356
|
}
|
|
340
357
|
function useEscapeKeydown(host, handler) {
|
|
341
|
-
|
|
358
|
+
useEffect4(host, () => {
|
|
342
359
|
const handleKeyDown = (event) => {
|
|
343
360
|
if (event.key !== "Escape") {
|
|
344
361
|
return;
|
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.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "ocavue",
|
|
@@ -74,15 +74,15 @@
|
|
|
74
74
|
"@aria-ui/tooltip": "^0.0.13",
|
|
75
75
|
"@floating-ui/dom": "^1.6.3",
|
|
76
76
|
"@prosekit/core": "^0.4.0",
|
|
77
|
-
"@prosekit/extensions": "^0.4.
|
|
77
|
+
"@prosekit/extensions": "^0.4.6",
|
|
78
78
|
"@prosekit/pm": "^0.1.2",
|
|
79
|
-
"@zag-js/dom-query": "^0.
|
|
79
|
+
"@zag-js/dom-query": "^0.48.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@prosekit/dev": "*",
|
|
83
83
|
"tsup": "^8.0.2",
|
|
84
84
|
"typescript": "^5.4.5",
|
|
85
|
-
"vitest": "^1.5.
|
|
85
|
+
"vitest": "^1.5.2"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"build:tsup": "tsup",
|