@prosekit/web 0.5.7 → 0.5.9
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-default-state-CIEy7xrl.js +11 -0
- package/dist/prosekit-web-autocomplete.d.ts +126 -20
- package/dist/prosekit-web-autocomplete.js +243 -349
- package/dist/prosekit-web-block-handle.d.ts +82 -15
- package/dist/prosekit-web-block-handle.js +422 -394
- package/dist/prosekit-web-inline-popover.d.ts +81 -5
- package/dist/prosekit-web-inline-popover.js +114 -155
- package/dist/prosekit-web-popover.d.ts +28 -15
- package/dist/prosekit-web-popover.js +31 -70
- package/dist/prosekit-web-resizable.d.ts +48 -10
- package/dist/prosekit-web-resizable.js +210 -238
- package/dist/prosekit-web-table-handle.d.ts +151 -35
- package/dist/prosekit-web-table-handle.js +364 -491
- package/dist/prosekit-web-tooltip.d.ts +28 -15
- package/dist/prosekit-web-tooltip.js +31 -70
- package/dist/prosekit-web.d.ts +1 -1
- package/dist/use-editor-extension-Cc7ZG7uj.js +11 -0
- package/package.json +29 -14
- package/dist/_tsup-dts-rollup.d.ts +0 -1100
- package/dist/chunk-WTW6FOH3.js +0 -13
- package/dist/chunk-ZGQ225UP.js +0 -17
|
@@ -1,386 +1,280 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
} from "
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
// src/components/autocomplete/autocomplete-empty/setup.ts
|
|
12
|
-
import { useListboxEmpty } from "@aria-ui/listbox/elements";
|
|
13
|
-
var useAutocompleteEmpty = useListboxEmpty;
|
|
1
|
+
import { getStateWithDefaults } from "./get-default-state-CIEy7xrl.js";
|
|
2
|
+
import { useEditorExtension } from "./use-editor-extension-Cc7ZG7uj.js";
|
|
3
|
+
import { createComputed, createContext, createSignal, defineCustomElement, registerCustomElement, useAnimationFrame, useAttribute, useEffect, useEventListener } from "@aria-ui/core";
|
|
4
|
+
import { listboxProps, useListbox, useListboxEmpty as useAutocompleteEmpty, useListboxItem } from "@aria-ui/listbox/elements";
|
|
5
|
+
import { listboxEvents, listboxItemEvents, listboxProps as listboxProps$1 } from "@aria-ui/listbox";
|
|
6
|
+
import { Priority, defineDOMEventHandler, defineKeymap, withPriority } from "@prosekit/core";
|
|
7
|
+
import { overlayPositionerEvents, overlayPositionerProps, useOverlayPositionerState } from "@aria-ui/overlay/elements";
|
|
8
|
+
import { usePresence } from "@aria-ui/presence";
|
|
9
|
+
import { AutocompleteRule, defineAutocomplete } from "@prosekit/extensions/autocomplete";
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
//#region src/components/autocomplete/autocomplete-empty/types.ts
|
|
12
|
+
/** @internal */
|
|
13
|
+
const autocompleteEmptyProps = {};
|
|
14
|
+
/** @internal */
|
|
15
|
+
const autocompleteEmptyEvents = {};
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/components/autocomplete/autocomplete-empty/element.gen.ts
|
|
19
|
+
const AutocompleteEmptyElementBase = defineCustomElement({
|
|
20
|
+
props: autocompleteEmptyProps,
|
|
21
|
+
events: autocompleteEmptyEvents,
|
|
22
|
+
setup: useAutocompleteEmpty
|
|
23
|
+
});
|
|
24
|
+
var AutocompleteEmptyElement = class extends AutocompleteEmptyElementBase {};
|
|
26
25
|
registerCustomElement("prosekit-autocomplete-empty", AutocompleteEmptyElement);
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/components/autocomplete/context.ts
|
|
29
|
+
const queryContext = createContext("prosekit/autocomplete-popover/query", "");
|
|
30
|
+
const onSubmitContext = createContext("prosekit/autocomplete-popover/onSubmit", null);
|
|
31
|
+
const openContext = createContext("prosekit/autocomplete-popover/open", false);
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
useEffect
|
|
34
|
-
} from "@aria-ui/core";
|
|
35
|
-
import { useListboxItem } from "@aria-ui/listbox/elements";
|
|
36
|
-
|
|
37
|
-
// src/components/autocomplete/context.ts
|
|
38
|
-
import { createContext } from "@aria-ui/core";
|
|
39
|
-
var queryContext = createContext(
|
|
40
|
-
"prosekit/autocomplete-popover/query",
|
|
41
|
-
""
|
|
42
|
-
);
|
|
43
|
-
var onSubmitContext = createContext(
|
|
44
|
-
"prosekit/autocomplete-popover/onSubmit",
|
|
45
|
-
null
|
|
46
|
-
);
|
|
47
|
-
var openContext = createContext(
|
|
48
|
-
"prosekit/autocomplete-popover/open",
|
|
49
|
-
false
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
// src/components/autocomplete/autocomplete-item/setup.ts
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/components/autocomplete/autocomplete-item/setup.ts
|
|
53
35
|
function useAutocompleteItem(element, { state, emit }) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
36
|
+
useListboxItem(element, {
|
|
37
|
+
state,
|
|
38
|
+
emit
|
|
39
|
+
});
|
|
40
|
+
const open = openContext.consume(element);
|
|
41
|
+
useEffect(element, () => {
|
|
42
|
+
if (!state.value.peek() && open.get()) state.value.set(element.textContent ?? "");
|
|
43
|
+
});
|
|
44
|
+
useEventListener(element, "pointerdown", (event) => {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
});
|
|
61
47
|
}
|
|
62
48
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
default: ""
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var autocompleteItemEvents = listboxItemEvents;
|
|
73
|
-
|
|
74
|
-
// src/components/autocomplete/autocomplete-item/element.gen.ts
|
|
75
|
-
var AutocompleteItemElement = class extends defineCustomElement2({
|
|
76
|
-
props: autocompleteItemProps,
|
|
77
|
-
events: autocompleteItemEvents,
|
|
78
|
-
setup: useAutocompleteItem
|
|
79
|
-
}) {
|
|
80
|
-
};
|
|
81
|
-
registerCustomElement2("prosekit-autocomplete-item", AutocompleteItemElement);
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/components/autocomplete/autocomplete-item/types.ts
|
|
51
|
+
/** @internal */
|
|
52
|
+
const autocompleteItemProps = { value: { default: "" } };
|
|
53
|
+
/** @internal */
|
|
54
|
+
const autocompleteItemEvents = listboxItemEvents;
|
|
82
55
|
|
|
83
|
-
|
|
84
|
-
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/components/autocomplete/autocomplete-item/element.gen.ts
|
|
58
|
+
const AutocompleteItemElementBase = defineCustomElement({
|
|
59
|
+
props: autocompleteItemProps,
|
|
60
|
+
events: autocompleteItemEvents,
|
|
61
|
+
setup: useAutocompleteItem
|
|
62
|
+
});
|
|
63
|
+
var AutocompleteItemElement = class extends AutocompleteItemElementBase {};
|
|
64
|
+
registerCustomElement("prosekit-autocomplete-item", AutocompleteItemElement);
|
|
85
65
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
createSignal,
|
|
89
|
-
useEffect as useEffect2
|
|
90
|
-
} from "@aria-ui/core";
|
|
91
|
-
import {
|
|
92
|
-
listboxProps,
|
|
93
|
-
useListbox
|
|
94
|
-
} from "@aria-ui/listbox/elements";
|
|
95
|
-
import {
|
|
96
|
-
defineDOMEventHandler,
|
|
97
|
-
Priority,
|
|
98
|
-
withPriority
|
|
99
|
-
} from "@prosekit/core";
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/components/autocomplete/autocomplete-list/setup.ts
|
|
100
68
|
function useAutocompleteList(element, { state, emit }) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
69
|
+
const open = openContext.consume(element);
|
|
70
|
+
const query = queryContext.consume(element);
|
|
71
|
+
const onSubmit = onSubmitContext.consume(element);
|
|
72
|
+
const keydownTarget = useKeyDownTarget(element, open, state.editor);
|
|
73
|
+
const listboxState = getStateWithDefaults({
|
|
74
|
+
filter: state.filter,
|
|
75
|
+
eventTarget: createSignal(keydownTarget)
|
|
76
|
+
}, listboxProps);
|
|
77
|
+
useEffect(element, () => {
|
|
78
|
+
element.addEventListener("valueChange", () => {
|
|
79
|
+
if (onSubmit) onSubmit.get()?.();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
useListbox(element, {
|
|
83
|
+
state: listboxState,
|
|
84
|
+
emit
|
|
85
|
+
});
|
|
86
|
+
useEffect(element, () => {
|
|
87
|
+
listboxState.query.set(query.get());
|
|
88
|
+
});
|
|
89
|
+
useEffect(element, () => {
|
|
90
|
+
if (!open.get()) {
|
|
91
|
+
listboxState.value.set("");
|
|
92
|
+
query.set("");
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
useEffect(element, () => {
|
|
96
|
+
if (!open.get()) listboxState.autoFocus.set(false);
|
|
97
|
+
else {
|
|
98
|
+
let canceled = false;
|
|
99
|
+
requestAnimationFrame(() => {
|
|
100
|
+
if (canceled) return;
|
|
101
|
+
listboxState.autoFocus.set(true);
|
|
102
|
+
});
|
|
103
|
+
return () => {
|
|
104
|
+
canceled = true;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
useEffect(element, () => {
|
|
109
|
+
element.tabIndex = -1;
|
|
110
|
+
});
|
|
143
111
|
}
|
|
144
112
|
function useKeyDownTarget(element, open, editor) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
removeEventListener: (type, listener) => {
|
|
170
|
-
if (type === "keydown") {
|
|
171
|
-
const index = keydownHandlers.indexOf(listener);
|
|
172
|
-
if (index !== -1) {
|
|
173
|
-
keydownHandlers.splice(index, 1);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
};
|
|
113
|
+
const keydownHandlers = [];
|
|
114
|
+
useEffect(element, () => {
|
|
115
|
+
const editorValue = editor.get();
|
|
116
|
+
if (!editorValue) return;
|
|
117
|
+
const extension = defineDOMEventHandler("keydown", (view, event) => {
|
|
118
|
+
if (view.composing || event.defaultPrevented || !open.get()) return false;
|
|
119
|
+
keydownHandlers.forEach((handler) => handler(event));
|
|
120
|
+
return event.defaultPrevented;
|
|
121
|
+
});
|
|
122
|
+
return editorValue.use(withPriority(extension, Priority.highest));
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
addEventListener: (type, listener) => {
|
|
126
|
+
if (type === "keydown") keydownHandlers.push(listener);
|
|
127
|
+
},
|
|
128
|
+
removeEventListener: (type, listener) => {
|
|
129
|
+
if (type === "keydown") {
|
|
130
|
+
const index = keydownHandlers.indexOf(listener);
|
|
131
|
+
if (index !== -1) keydownHandlers.splice(index, 1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
178
135
|
}
|
|
179
136
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
var autocompleteListProps = {
|
|
186
|
-
filter: listboxProps2.filter,
|
|
187
|
-
editor: { default: null }
|
|
188
|
-
};
|
|
189
|
-
var autocompleteListEvents = listboxEvents;
|
|
190
|
-
|
|
191
|
-
// src/components/autocomplete/autocomplete-list/element.gen.ts
|
|
192
|
-
var AutocompleteListElement = class extends defineCustomElement3({
|
|
193
|
-
props: autocompleteListProps,
|
|
194
|
-
events: autocompleteListEvents,
|
|
195
|
-
setup: useAutocompleteList
|
|
196
|
-
}) {
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/components/autocomplete/autocomplete-list/types.ts
|
|
139
|
+
const autocompleteListProps = {
|
|
140
|
+
filter: listboxProps$1.filter,
|
|
141
|
+
editor: { default: null }
|
|
197
142
|
};
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
// src/components/autocomplete/autocomplete-popover/element.gen.ts
|
|
201
|
-
import { defineCustomElement as defineCustomElement4, registerCustomElement as registerCustomElement4 } from "@aria-ui/core";
|
|
143
|
+
const autocompleteListEvents = { ...listboxEvents };
|
|
202
144
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
import { usePresence } from "@aria-ui/presence";
|
|
213
|
-
import {
|
|
214
|
-
defineKeymap,
|
|
215
|
-
Priority as Priority2,
|
|
216
|
-
withPriority as withPriority2
|
|
217
|
-
} from "@prosekit/core";
|
|
218
|
-
import {
|
|
219
|
-
AutocompleteRule,
|
|
220
|
-
defineAutocomplete
|
|
221
|
-
} from "@prosekit/extensions/autocomplete";
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/components/autocomplete/autocomplete-list/element.gen.ts
|
|
147
|
+
const AutocompleteListElementBase = defineCustomElement({
|
|
148
|
+
props: autocompleteListProps,
|
|
149
|
+
events: autocompleteListEvents,
|
|
150
|
+
setup: useAutocompleteList
|
|
151
|
+
});
|
|
152
|
+
var AutocompleteListElement = class extends AutocompleteListElementBase {};
|
|
153
|
+
registerCustomElement("prosekit-autocomplete-list", AutocompleteListElement);
|
|
222
154
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
createSignal as createSignal2,
|
|
226
|
-
useEffect as useEffect3
|
|
227
|
-
} from "@aria-ui/core";
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/hooks/use-first-rendering.ts
|
|
228
157
|
function useFirstRendering(host) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
158
|
+
const firstRendering = createSignal(true);
|
|
159
|
+
useEffect(host, () => {
|
|
160
|
+
requestAnimationFrame(() => {
|
|
161
|
+
firstRendering.set(false);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
return firstRendering;
|
|
236
165
|
}
|
|
237
166
|
|
|
238
|
-
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/components/autocomplete/autocomplete-popover/helpers.ts
|
|
239
169
|
function defaultQueryBuilder(match) {
|
|
240
|
-
|
|
170
|
+
return match[0].toLowerCase().replace(/[!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]/g, "").replace(/\s\s+/g, " ").trim();
|
|
241
171
|
}
|
|
242
172
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
useEffect4(host, () => {
|
|
272
|
-
const queryValue = query.get();
|
|
273
|
-
if (!firstRendering.peek()) {
|
|
274
|
-
emit("queryChange", queryValue);
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
useAnimationFrame(host, () => {
|
|
278
|
-
const presenceValue = presence.get();
|
|
279
|
-
return () => {
|
|
280
|
-
emit("openChange", presenceValue);
|
|
281
|
-
};
|
|
282
|
-
});
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/components/autocomplete/autocomplete-popover/setup.ts
|
|
175
|
+
function useAutocompletePopover(host, { state, emit }) {
|
|
176
|
+
const { editor, regex,...overlayState } = state;
|
|
177
|
+
const reference = createSignal(null);
|
|
178
|
+
const query = createSignal("");
|
|
179
|
+
const onDismiss = createSignal(null);
|
|
180
|
+
const onSubmit = createSignal(null);
|
|
181
|
+
const presence = createComputed(() => !!reference.get());
|
|
182
|
+
queryContext.provide(host, query);
|
|
183
|
+
onSubmitContext.provide(host, onSubmit);
|
|
184
|
+
openContext.provide(host, presence);
|
|
185
|
+
useEscapeKeydown(host, editor, createKeymapHandler(onDismiss, presence));
|
|
186
|
+
useAutocompleteExtension(host, editor, regex, reference, query, onDismiss, onSubmit);
|
|
187
|
+
useOverlayPositionerState(host, overlayState, { reference });
|
|
188
|
+
useAttribute(host, "data-state", () => presence.get() ? "open" : "closed");
|
|
189
|
+
usePresence(host, presence);
|
|
190
|
+
const firstRendering = useFirstRendering(host);
|
|
191
|
+
useEffect(host, () => {
|
|
192
|
+
const queryValue = query.get();
|
|
193
|
+
if (!firstRendering.peek()) emit("queryChange", queryValue);
|
|
194
|
+
});
|
|
195
|
+
useAnimationFrame(host, () => {
|
|
196
|
+
const presenceValue = presence.get();
|
|
197
|
+
return () => {
|
|
198
|
+
emit("openChange", presenceValue);
|
|
199
|
+
};
|
|
200
|
+
});
|
|
283
201
|
}
|
|
284
202
|
function useAutocompleteExtension(host, editor, regex, reference, query, onDismiss, onSubmit) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
regexValue,
|
|
294
|
-
reference,
|
|
295
|
-
query,
|
|
296
|
-
onDismiss,
|
|
297
|
-
onSubmit
|
|
298
|
-
);
|
|
299
|
-
const extension = defineAutocomplete(rule);
|
|
300
|
-
return editorValue.use(extension);
|
|
301
|
-
});
|
|
203
|
+
useEffect(host, () => {
|
|
204
|
+
const editorValue = editor.get();
|
|
205
|
+
const regexValue = regex.get();
|
|
206
|
+
if (!editorValue || !regexValue) return;
|
|
207
|
+
const rule = createAutocompleteRule(editorValue, regexValue, reference, query, onDismiss, onSubmit);
|
|
208
|
+
const extension = defineAutocomplete(rule);
|
|
209
|
+
return editorValue.use(extension);
|
|
210
|
+
});
|
|
302
211
|
}
|
|
303
212
|
function createAutocompleteRule(editor, regex, reference, query, onDismiss, onSubmit) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
onLeave: handleLeave
|
|
321
|
-
});
|
|
213
|
+
const handleEnter = (options) => {
|
|
214
|
+
const span = editor.view.dom.querySelector(".prosemirror-prediction-match");
|
|
215
|
+
if (span) reference.set(span);
|
|
216
|
+
query.set(defaultQueryBuilder(options.match));
|
|
217
|
+
onDismiss.set(options.ignoreMatch);
|
|
218
|
+
onSubmit.set(options.deleteMatch);
|
|
219
|
+
};
|
|
220
|
+
const handleLeave = () => {
|
|
221
|
+
reference.set(null);
|
|
222
|
+
query.set("");
|
|
223
|
+
};
|
|
224
|
+
return new AutocompleteRule({
|
|
225
|
+
regex,
|
|
226
|
+
onEnter: handleEnter,
|
|
227
|
+
onLeave: handleLeave
|
|
228
|
+
});
|
|
322
229
|
}
|
|
323
230
|
function createKeymapHandler(handler, enabled) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
return true;
|
|
332
|
-
};
|
|
231
|
+
return () => {
|
|
232
|
+
if (!enabled.get()) return false;
|
|
233
|
+
const fn = handler.peek();
|
|
234
|
+
if (!fn) return false;
|
|
235
|
+
fn();
|
|
236
|
+
return true;
|
|
237
|
+
};
|
|
333
238
|
}
|
|
334
239
|
function useEscapeKeydown(host, editor, handler) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
240
|
+
const keymap = { Escape: handler };
|
|
241
|
+
const extension = withPriority(defineKeymap(keymap), Priority.highest);
|
|
242
|
+
useEditorExtension(host, editor, extension);
|
|
338
243
|
}
|
|
339
244
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
boundary: { default: defaultBoundary },
|
|
357
|
-
overflowPadding: { default: 8 }
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/components/autocomplete/autocomplete-popover/types.ts
|
|
247
|
+
const body = typeof document !== "undefined" && document.querySelector("body");
|
|
248
|
+
const defaultBoundary = body || "clippingAncestors";
|
|
249
|
+
/** @internal */
|
|
250
|
+
const autocompletePopoverProps = {
|
|
251
|
+
...overlayPositionerProps,
|
|
252
|
+
editor: { default: null },
|
|
253
|
+
regex: { default: null },
|
|
254
|
+
placement: { default: "bottom-start" },
|
|
255
|
+
offset: { default: 4 },
|
|
256
|
+
inline: { default: true },
|
|
257
|
+
hoist: { default: true },
|
|
258
|
+
fitViewport: { default: true },
|
|
259
|
+
boundary: { default: defaultBoundary },
|
|
260
|
+
overflowPadding: { default: 8 }
|
|
358
261
|
};
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
262
|
+
/** @internal */
|
|
263
|
+
const autocompletePopoverEvents = {
|
|
264
|
+
...overlayPositionerEvents,
|
|
265
|
+
openChange: {},
|
|
266
|
+
queryChange: {}
|
|
363
267
|
};
|
|
364
268
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
AutocompletePopoverElement,
|
|
378
|
-
autocompleteEmptyEvents,
|
|
379
|
-
autocompleteEmptyProps,
|
|
380
|
-
autocompleteItemEvents,
|
|
381
|
-
autocompleteItemProps,
|
|
382
|
-
autocompleteListEvents,
|
|
383
|
-
autocompleteListProps,
|
|
384
|
-
autocompletePopoverEvents,
|
|
385
|
-
autocompletePopoverProps
|
|
386
|
-
};
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/components/autocomplete/autocomplete-popover/element.gen.ts
|
|
271
|
+
const AutocompletePopoverElementBase = defineCustomElement({
|
|
272
|
+
props: autocompletePopoverProps,
|
|
273
|
+
events: autocompletePopoverEvents,
|
|
274
|
+
setup: useAutocompletePopover
|
|
275
|
+
});
|
|
276
|
+
var AutocompletePopoverElement = class extends AutocompletePopoverElementBase {};
|
|
277
|
+
registerCustomElement("prosekit-autocomplete-popover", AutocompletePopoverElement);
|
|
278
|
+
|
|
279
|
+
//#endregion
|
|
280
|
+
export { AutocompleteEmptyElement, AutocompleteItemElement, AutocompleteListElement, AutocompletePopoverElement, autocompleteEmptyEvents, autocompleteEmptyProps, autocompleteItemEvents, autocompleteItemProps, autocompleteListEvents, autocompleteListProps, autocompletePopoverEvents, autocompletePopoverProps };
|