@prosekit/web 0.5.6 → 0.5.8
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 +135 -20
- package/dist/prosekit-web-autocomplete.js +240 -349
- package/dist/prosekit-web-block-handle.d.ts +88 -15
- package/dist/prosekit-web-block-handle.js +422 -392
- 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 +34 -15
- package/dist/prosekit-web-popover.js +31 -70
- package/dist/prosekit-web-resizable.d.ts +52 -10
- package/dist/prosekit-web-resizable.js +210 -238
- package/dist/prosekit-web-table-handle.d.ts +165 -35
- package/dist/prosekit-web-table-handle.js +364 -491
- package/dist/prosekit-web-tooltip.d.ts +34 -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 -22
- 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,277 @@
|
|
|
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 } 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
|
+
});
|
|
61
44
|
}
|
|
62
45
|
|
|
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);
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/components/autocomplete/autocomplete-item/types.ts
|
|
48
|
+
/** @internal */
|
|
49
|
+
const autocompleteItemProps = { value: { default: "" } };
|
|
50
|
+
/** @internal */
|
|
51
|
+
const autocompleteItemEvents = listboxItemEvents;
|
|
82
52
|
|
|
83
|
-
|
|
84
|
-
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/components/autocomplete/autocomplete-item/element.gen.ts
|
|
55
|
+
const AutocompleteItemElementBase = defineCustomElement({
|
|
56
|
+
props: autocompleteItemProps,
|
|
57
|
+
events: autocompleteItemEvents,
|
|
58
|
+
setup: useAutocompleteItem
|
|
59
|
+
});
|
|
60
|
+
var AutocompleteItemElement = class extends AutocompleteItemElementBase {};
|
|
61
|
+
registerCustomElement("prosekit-autocomplete-item", AutocompleteItemElement);
|
|
85
62
|
|
|
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";
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/components/autocomplete/autocomplete-list/setup.ts
|
|
100
65
|
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
|
-
|
|
66
|
+
const open = openContext.consume(element);
|
|
67
|
+
const query = queryContext.consume(element);
|
|
68
|
+
const onSubmit = onSubmitContext.consume(element);
|
|
69
|
+
const keydownTarget = useKeyDownTarget(element, open, state.editor);
|
|
70
|
+
const listboxState = getStateWithDefaults({
|
|
71
|
+
filter: state.filter,
|
|
72
|
+
eventTarget: createSignal(keydownTarget)
|
|
73
|
+
}, listboxProps);
|
|
74
|
+
useEffect(element, () => {
|
|
75
|
+
element.addEventListener("valueChange", () => {
|
|
76
|
+
if (onSubmit) onSubmit.get()?.();
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
useListbox(element, {
|
|
80
|
+
state: listboxState,
|
|
81
|
+
emit
|
|
82
|
+
});
|
|
83
|
+
useEffect(element, () => {
|
|
84
|
+
listboxState.query.set(query.get());
|
|
85
|
+
});
|
|
86
|
+
useEffect(element, () => {
|
|
87
|
+
if (!open.get()) {
|
|
88
|
+
listboxState.value.set("");
|
|
89
|
+
query.set("");
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
useEffect(element, () => {
|
|
93
|
+
if (!open.get()) listboxState.autoFocus.set(false);
|
|
94
|
+
else {
|
|
95
|
+
let canceled = false;
|
|
96
|
+
requestAnimationFrame(() => {
|
|
97
|
+
if (canceled) return;
|
|
98
|
+
listboxState.autoFocus.set(true);
|
|
99
|
+
});
|
|
100
|
+
return () => {
|
|
101
|
+
canceled = true;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
useEffect(element, () => {
|
|
106
|
+
element.tabIndex = -1;
|
|
107
|
+
});
|
|
143
108
|
}
|
|
144
109
|
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
|
-
};
|
|
110
|
+
const keydownHandlers = [];
|
|
111
|
+
useEffect(element, () => {
|
|
112
|
+
const editorValue = editor.get();
|
|
113
|
+
if (!editorValue) return;
|
|
114
|
+
const extension = defineDOMEventHandler("keydown", (view, event) => {
|
|
115
|
+
if (view.composing || event.defaultPrevented || !open.get()) return false;
|
|
116
|
+
keydownHandlers.forEach((handler) => handler(event));
|
|
117
|
+
return event.defaultPrevented;
|
|
118
|
+
});
|
|
119
|
+
return editorValue.use(withPriority(extension, Priority.highest));
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
addEventListener: (type, listener) => {
|
|
123
|
+
if (type === "keydown") keydownHandlers.push(listener);
|
|
124
|
+
},
|
|
125
|
+
removeEventListener: (type, listener) => {
|
|
126
|
+
if (type === "keydown") {
|
|
127
|
+
const index = keydownHandlers.indexOf(listener);
|
|
128
|
+
if (index !== -1) keydownHandlers.splice(index, 1);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
178
132
|
}
|
|
179
133
|
|
|
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
|
-
}) {
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/components/autocomplete/autocomplete-list/types.ts
|
|
136
|
+
const autocompleteListProps = {
|
|
137
|
+
filter: listboxProps$1.filter,
|
|
138
|
+
editor: { default: null }
|
|
197
139
|
};
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
// src/components/autocomplete/autocomplete-popover/element.gen.ts
|
|
201
|
-
import { defineCustomElement as defineCustomElement4, registerCustomElement as registerCustomElement4 } from "@aria-ui/core";
|
|
140
|
+
const autocompleteListEvents = { ...listboxEvents };
|
|
202
141
|
|
|
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";
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/components/autocomplete/autocomplete-list/element.gen.ts
|
|
144
|
+
const AutocompleteListElementBase = defineCustomElement({
|
|
145
|
+
props: autocompleteListProps,
|
|
146
|
+
events: autocompleteListEvents,
|
|
147
|
+
setup: useAutocompleteList
|
|
148
|
+
});
|
|
149
|
+
var AutocompleteListElement = class extends AutocompleteListElementBase {};
|
|
150
|
+
registerCustomElement("prosekit-autocomplete-list", AutocompleteListElement);
|
|
222
151
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
createSignal as createSignal2,
|
|
226
|
-
useEffect as useEffect3
|
|
227
|
-
} from "@aria-ui/core";
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/hooks/use-first-rendering.ts
|
|
228
154
|
function useFirstRendering(host) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
155
|
+
const firstRendering = createSignal(true);
|
|
156
|
+
useEffect(host, () => {
|
|
157
|
+
requestAnimationFrame(() => {
|
|
158
|
+
firstRendering.set(false);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
return firstRendering;
|
|
236
162
|
}
|
|
237
163
|
|
|
238
|
-
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/components/autocomplete/autocomplete-popover/helpers.ts
|
|
239
166
|
function defaultQueryBuilder(match) {
|
|
240
|
-
|
|
167
|
+
return match[0].toLowerCase().replace(/[!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]/g, "").replace(/\s\s+/g, " ").trim();
|
|
241
168
|
}
|
|
242
169
|
|
|
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
|
-
});
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/components/autocomplete/autocomplete-popover/setup.ts
|
|
172
|
+
function useAutocompletePopover(host, { state, emit }) {
|
|
173
|
+
const { editor, regex,...overlayState } = state;
|
|
174
|
+
const reference = createSignal(null);
|
|
175
|
+
const query = createSignal("");
|
|
176
|
+
const onDismiss = createSignal(null);
|
|
177
|
+
const onSubmit = createSignal(null);
|
|
178
|
+
const presence = createComputed(() => !!reference.get());
|
|
179
|
+
queryContext.provide(host, query);
|
|
180
|
+
onSubmitContext.provide(host, onSubmit);
|
|
181
|
+
openContext.provide(host, presence);
|
|
182
|
+
useEscapeKeydown(host, editor, createKeymapHandler(onDismiss, presence));
|
|
183
|
+
useAutocompleteExtension(host, editor, regex, reference, query, onDismiss, onSubmit);
|
|
184
|
+
useOverlayPositionerState(host, overlayState, { reference });
|
|
185
|
+
useAttribute(host, "data-state", () => presence.get() ? "open" : "closed");
|
|
186
|
+
usePresence(host, presence);
|
|
187
|
+
const firstRendering = useFirstRendering(host);
|
|
188
|
+
useEffect(host, () => {
|
|
189
|
+
const queryValue = query.get();
|
|
190
|
+
if (!firstRendering.peek()) emit("queryChange", queryValue);
|
|
191
|
+
});
|
|
192
|
+
useAnimationFrame(host, () => {
|
|
193
|
+
const presenceValue = presence.get();
|
|
194
|
+
return () => {
|
|
195
|
+
emit("openChange", presenceValue);
|
|
196
|
+
};
|
|
197
|
+
});
|
|
283
198
|
}
|
|
284
199
|
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
|
-
});
|
|
200
|
+
useEffect(host, () => {
|
|
201
|
+
const editorValue = editor.get();
|
|
202
|
+
const regexValue = regex.get();
|
|
203
|
+
if (!editorValue || !regexValue) return;
|
|
204
|
+
const rule = createAutocompleteRule(editorValue, regexValue, reference, query, onDismiss, onSubmit);
|
|
205
|
+
const extension = defineAutocomplete(rule);
|
|
206
|
+
return editorValue.use(extension);
|
|
207
|
+
});
|
|
302
208
|
}
|
|
303
209
|
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
|
-
});
|
|
210
|
+
const handleEnter = (options) => {
|
|
211
|
+
const span = editor.view.dom.querySelector(".prosemirror-prediction-match");
|
|
212
|
+
if (span) reference.set(span);
|
|
213
|
+
query.set(defaultQueryBuilder(options.match));
|
|
214
|
+
onDismiss.set(options.ignoreMatch);
|
|
215
|
+
onSubmit.set(options.deleteMatch);
|
|
216
|
+
};
|
|
217
|
+
const handleLeave = () => {
|
|
218
|
+
reference.set(null);
|
|
219
|
+
query.set("");
|
|
220
|
+
};
|
|
221
|
+
return new AutocompleteRule({
|
|
222
|
+
regex,
|
|
223
|
+
onEnter: handleEnter,
|
|
224
|
+
onLeave: handleLeave
|
|
225
|
+
});
|
|
322
226
|
}
|
|
323
227
|
function createKeymapHandler(handler, enabled) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
return true;
|
|
332
|
-
};
|
|
228
|
+
return () => {
|
|
229
|
+
if (!enabled.get()) return false;
|
|
230
|
+
const fn = handler.peek();
|
|
231
|
+
if (!fn) return false;
|
|
232
|
+
fn();
|
|
233
|
+
return true;
|
|
234
|
+
};
|
|
333
235
|
}
|
|
334
236
|
function useEscapeKeydown(host, editor, handler) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
237
|
+
const keymap = { Escape: handler };
|
|
238
|
+
const extension = withPriority(defineKeymap(keymap), Priority.highest);
|
|
239
|
+
useEditorExtension(host, editor, extension);
|
|
338
240
|
}
|
|
339
241
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
boundary: { default: defaultBoundary },
|
|
357
|
-
overflowPadding: { default: 8 }
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/components/autocomplete/autocomplete-popover/types.ts
|
|
244
|
+
const body = typeof document !== "undefined" && document.querySelector("body");
|
|
245
|
+
const defaultBoundary = body || "clippingAncestors";
|
|
246
|
+
/** @internal */
|
|
247
|
+
const autocompletePopoverProps = {
|
|
248
|
+
...overlayPositionerProps,
|
|
249
|
+
editor: { default: null },
|
|
250
|
+
regex: { default: null },
|
|
251
|
+
placement: { default: "bottom-start" },
|
|
252
|
+
offset: { default: 4 },
|
|
253
|
+
inline: { default: true },
|
|
254
|
+
hoist: { default: true },
|
|
255
|
+
fitViewport: { default: true },
|
|
256
|
+
boundary: { default: defaultBoundary },
|
|
257
|
+
overflowPadding: { default: 8 }
|
|
358
258
|
};
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
259
|
+
/** @internal */
|
|
260
|
+
const autocompletePopoverEvents = {
|
|
261
|
+
...overlayPositionerEvents,
|
|
262
|
+
openChange: {},
|
|
263
|
+
queryChange: {}
|
|
363
264
|
};
|
|
364
265
|
|
|
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
|
-
};
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/components/autocomplete/autocomplete-popover/element.gen.ts
|
|
268
|
+
const AutocompletePopoverElementBase = defineCustomElement({
|
|
269
|
+
props: autocompletePopoverProps,
|
|
270
|
+
events: autocompletePopoverEvents,
|
|
271
|
+
setup: useAutocompletePopover
|
|
272
|
+
});
|
|
273
|
+
var AutocompletePopoverElement = class extends AutocompletePopoverElementBase {};
|
|
274
|
+
registerCustomElement("prosekit-autocomplete-popover", AutocompletePopoverElement);
|
|
275
|
+
|
|
276
|
+
//#endregion
|
|
277
|
+
export { AutocompleteEmptyElement, AutocompleteItemElement, AutocompleteListElement, AutocompletePopoverElement, autocompleteEmptyEvents, autocompleteEmptyProps, autocompleteItemEvents, autocompleteItemProps, autocompleteListEvents, autocompleteListProps, autocompletePopoverEvents, autocompletePopoverProps };
|