@prosekit/web 0.1.8 → 0.1.10
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/{chunk-LCDA7GFP.js → chunk-Y2CJYXR5.js} +1 -4
- package/dist/prosekit-web-autocomplete.js +81 -163
- package/dist/prosekit-web-block-handle.js +33 -77
- package/dist/prosekit-web-inline-popover.js +38 -57
- package/dist/prosekit-web-popover.js +1 -1
- package/dist/prosekit-web-resizable.js +51 -142
- package/dist/prosekit-web-tooltip.js +4 -4
- package/package.json +6 -6
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// src/utils/define-custom-element.ts
|
|
2
2
|
function defineCustomElement(name, constructor, options) {
|
|
3
|
-
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
customElements.define(name, constructor, options);
|
|
3
|
+
typeof customElements != "undefined" && customElements.define(name, constructor, options);
|
|
7
4
|
}
|
|
8
5
|
|
|
9
6
|
export {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-VJEVDINM.js";
|
|
4
4
|
import {
|
|
5
5
|
defineCustomElement
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-Y2CJYXR5.js";
|
|
7
7
|
|
|
8
8
|
// src/components/autocomplete/autocomplete-empty/element.gen.ts
|
|
9
9
|
import { ElementMixin } from "@aria-ui/core";
|
|
@@ -14,8 +14,7 @@ var defaultAutocompleteEmptyProps = {};
|
|
|
14
14
|
// src/components/autocomplete/autocomplete-empty/state.ts
|
|
15
15
|
import { useListboxEmpty } from "@aria-ui/listbox";
|
|
16
16
|
function useAutocompleteEmpty(element, _props) {
|
|
17
|
-
useListboxEmpty(element);
|
|
18
|
-
return {};
|
|
17
|
+
return useListboxEmpty(element), {};
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
// src/components/autocomplete/autocomplete-empty/element.gen.ts
|
|
@@ -43,27 +42,21 @@ import { createContext } from "@aria-ui/core";
|
|
|
43
42
|
var queryContext = createContext(
|
|
44
43
|
"prosekit/autocomplete-popover/query",
|
|
45
44
|
""
|
|
46
|
-
)
|
|
47
|
-
var onSubmitContext = createContext(
|
|
45
|
+
), onSubmitContext = createContext(
|
|
48
46
|
"prosekit/autocomplete-popover/onSubmit",
|
|
49
47
|
null
|
|
50
|
-
)
|
|
51
|
-
var openContext = createContext(
|
|
48
|
+
), openContext = createContext(
|
|
52
49
|
"prosekit/autocomplete-popover/open",
|
|
53
|
-
|
|
50
|
+
!1
|
|
54
51
|
);
|
|
55
52
|
|
|
56
53
|
// src/components/autocomplete/autocomplete-item/state.ts
|
|
57
54
|
function useAutocompleteItem(element, props) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
useEffect(element, () => {
|
|
55
|
+
let { onSelect, value } = useListboxItem(element, props), open = openContext.consume(element);
|
|
56
|
+
return useEffect(element, () => {
|
|
61
57
|
var _a;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
return { onSelect, value };
|
|
58
|
+
!value.peek() && open.value && (value.value = (_a = element.textContent) != null ? _a : "");
|
|
59
|
+
}), { onSelect, value };
|
|
67
60
|
}
|
|
68
61
|
|
|
69
62
|
// src/components/autocomplete/autocomplete-item/element.gen.ts
|
|
@@ -76,8 +69,7 @@ import { ElementMixin as ElementMixin3 } from "@aria-ui/core";
|
|
|
76
69
|
|
|
77
70
|
// src/components/autocomplete/autocomplete-list/props.ts
|
|
78
71
|
import { defaultListboxProps } from "@aria-ui/listbox";
|
|
79
|
-
var defaultFilter = defaultListboxProps.filter
|
|
80
|
-
var defaultAutocompleteListProps = {
|
|
72
|
+
var defaultFilter = defaultListboxProps.filter, defaultAutocompleteListProps = {
|
|
81
73
|
filter: defaultFilter,
|
|
82
74
|
editor: null
|
|
83
75
|
};
|
|
@@ -95,19 +87,10 @@ import {
|
|
|
95
87
|
withPriority
|
|
96
88
|
} from "@prosekit/core";
|
|
97
89
|
function useAutocompleteList(element, props) {
|
|
98
|
-
|
|
99
|
-
const editor = createSignal(fullProps.editor);
|
|
100
|
-
const open = openContext.consume(element);
|
|
101
|
-
const query = queryContext.consume(element);
|
|
102
|
-
const onSubmit = onSubmitContext.consume(element);
|
|
103
|
-
const onKeydownHandlerAdd = useKeyboardHandler(element, open, editor);
|
|
104
|
-
const onValueChange = (value) => {
|
|
90
|
+
let fullProps = assignProps(defaultAutocompleteListProps, props), editor = createSignal(fullProps.editor), open = openContext.consume(element), query = queryContext.consume(element), onSubmit = onSubmitContext.consume(element), onKeydownHandlerAdd = useKeyboardHandler(element, open, editor), onValueChange = (value) => {
|
|
105
91
|
var _a;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
const {
|
|
92
|
+
value && ((_a = onSubmit.peek()) == null || _a());
|
|
93
|
+
}, {
|
|
111
94
|
query: listboxQuery,
|
|
112
95
|
value: listboxValue,
|
|
113
96
|
filter,
|
|
@@ -117,68 +100,43 @@ function useAutocompleteList(element, props) {
|
|
|
117
100
|
onValueChange,
|
|
118
101
|
filter: fullProps.filter
|
|
119
102
|
});
|
|
120
|
-
useEffect2(element, () => {
|
|
103
|
+
return useEffect2(element, () => {
|
|
121
104
|
listboxQuery.value = query.value;
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
let canceled = false;
|
|
134
|
-
requestAnimationFrame(() => {
|
|
135
|
-
if (canceled)
|
|
136
|
-
return;
|
|
137
|
-
autoFocus.value = true;
|
|
138
|
-
});
|
|
139
|
-
return () => {
|
|
140
|
-
canceled = true;
|
|
105
|
+
}), useEffect2(element, () => {
|
|
106
|
+
open.value || (listboxValue.value = "", query.value = "");
|
|
107
|
+
}), useEffect2(element, () => {
|
|
108
|
+
if (!open.value)
|
|
109
|
+
autoFocus.value = !1;
|
|
110
|
+
else {
|
|
111
|
+
let canceled = !1;
|
|
112
|
+
return requestAnimationFrame(() => {
|
|
113
|
+
canceled || (autoFocus.value = !0);
|
|
114
|
+
}), () => {
|
|
115
|
+
canceled = !0;
|
|
141
116
|
};
|
|
142
117
|
}
|
|
143
|
-
})
|
|
144
|
-
useEffect2(element, () => {
|
|
118
|
+
}), useEffect2(element, () => {
|
|
145
119
|
element.tabIndex = -1;
|
|
146
|
-
});
|
|
147
|
-
return { editor, filter };
|
|
120
|
+
}), { editor, filter };
|
|
148
121
|
}
|
|
149
122
|
function useKeyboardHandler(element, open, editor) {
|
|
150
|
-
|
|
123
|
+
let keydownHandler = createSignal(
|
|
151
124
|
null
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const keydownHandlerValue = keydownHandler.value;
|
|
157
|
-
if (!editorValue || !keydownHandlerValue) {
|
|
125
|
+
), disposeKeydownHandler = null;
|
|
126
|
+
return useEffect2(element, () => {
|
|
127
|
+
let editorValue = editor.value, keydownHandlerValue = keydownHandler.value;
|
|
128
|
+
if (!editorValue || !keydownHandlerValue)
|
|
158
129
|
return;
|
|
159
|
-
|
|
160
|
-
const extension = defineDOMEventHandler(
|
|
130
|
+
let extension = defineDOMEventHandler(
|
|
161
131
|
"keydown",
|
|
162
|
-
(view, event) =>
|
|
163
|
-
if (view.composing || event.defaultPrevented || !open.value) {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
keydownHandlerValue(event);
|
|
167
|
-
return event.defaultPrevented;
|
|
168
|
-
}
|
|
132
|
+
(view, event) => view.composing || event.defaultPrevented || !open.value ? !1 : (keydownHandlerValue(event), event.defaultPrevented)
|
|
169
133
|
);
|
|
170
|
-
disposeKeydownHandler == null
|
|
171
|
-
disposeKeydownHandler = editorValue.use(
|
|
134
|
+
disposeKeydownHandler == null || disposeKeydownHandler(), disposeKeydownHandler = editorValue.use(
|
|
172
135
|
withPriority(extension, Priority.highest)
|
|
173
136
|
);
|
|
137
|
+
}), (keydownHandlerValue) => (keydownHandler.value = keydownHandlerValue, () => {
|
|
138
|
+
disposeKeydownHandler == null || disposeKeydownHandler(), disposeKeydownHandler = null;
|
|
174
139
|
});
|
|
175
|
-
return (keydownHandlerValue) => {
|
|
176
|
-
keydownHandler.value = keydownHandlerValue;
|
|
177
|
-
return () => {
|
|
178
|
-
disposeKeydownHandler == null ? void 0 : disposeKeydownHandler();
|
|
179
|
-
disposeKeydownHandler = null;
|
|
180
|
-
};
|
|
181
|
-
};
|
|
182
140
|
}
|
|
183
141
|
|
|
184
142
|
// src/components/autocomplete/autocomplete-list/element.gen.ts
|
|
@@ -191,9 +149,7 @@ import { ElementMixin as ElementMixin4 } from "@aria-ui/core";
|
|
|
191
149
|
|
|
192
150
|
// src/components/autocomplete/autocomplete-popover/props.ts
|
|
193
151
|
import { defaultOverlayPositionerProps } from "@aria-ui/overlay";
|
|
194
|
-
var body = typeof document
|
|
195
|
-
var defaultBoundary = body || "clippingAncestors";
|
|
196
|
-
var defaultAutocompletePopoverProps = Object.freeze({
|
|
152
|
+
var body = typeof document != "undefined" && document.querySelector("body"), defaultBoundary = body || "clippingAncestors", defaultAutocompletePopoverProps = Object.freeze({
|
|
197
153
|
...defaultOverlayPositionerProps,
|
|
198
154
|
editor: null,
|
|
199
155
|
regex: null,
|
|
@@ -201,9 +157,9 @@ var defaultAutocompletePopoverProps = Object.freeze({
|
|
|
201
157
|
onOpenChange: null,
|
|
202
158
|
placement: "bottom-start",
|
|
203
159
|
offset: 4,
|
|
204
|
-
inline:
|
|
205
|
-
hoist:
|
|
206
|
-
fitViewport:
|
|
160
|
+
inline: !0,
|
|
161
|
+
hoist: !0,
|
|
162
|
+
fitViewport: !0,
|
|
207
163
|
boundary: defaultBoundary,
|
|
208
164
|
overflowPadding: 8
|
|
209
165
|
});
|
|
@@ -235,13 +191,12 @@ import {
|
|
|
235
191
|
useEffect as useEffect3
|
|
236
192
|
} from "@aria-ui/core";
|
|
237
193
|
function useFirstRendering(host) {
|
|
238
|
-
|
|
239
|
-
useEffect3(host, () => {
|
|
194
|
+
let firstRendering = createSignal2(!0);
|
|
195
|
+
return useEffect3(host, () => {
|
|
240
196
|
requestAnimationFrame(() => {
|
|
241
|
-
firstRendering.value =
|
|
197
|
+
firstRendering.value = !1;
|
|
242
198
|
});
|
|
243
|
-
});
|
|
244
|
-
return firstRendering;
|
|
199
|
+
}), firstRendering;
|
|
245
200
|
}
|
|
246
201
|
|
|
247
202
|
// src/components/autocomplete/autocomplete-popover/helpers.ts
|
|
@@ -251,22 +206,12 @@ function defaultQueryBuilder(match) {
|
|
|
251
206
|
|
|
252
207
|
// src/components/autocomplete/autocomplete-popover/state.ts
|
|
253
208
|
function useAutocompletePopover(host, props) {
|
|
254
|
-
|
|
255
|
-
useAutocompletePopoverState(host, state);
|
|
256
|
-
return state;
|
|
209
|
+
let state = mapSignals(assignProps2(defaultAutocompletePopoverProps, props));
|
|
210
|
+
return useAutocompletePopoverState(host, state), state;
|
|
257
211
|
}
|
|
258
212
|
function useAutocompletePopoverState(host, state) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const query = createSignal3("");
|
|
262
|
-
const onDismiss = createSignal3(null);
|
|
263
|
-
const onSubmit = createSignal3(null);
|
|
264
|
-
const presence = createComputed(() => !!reference.value);
|
|
265
|
-
queryContext.provide(host, query);
|
|
266
|
-
onSubmitContext.provide(host, onSubmit);
|
|
267
|
-
openContext.provide(host, presence);
|
|
268
|
-
useEscapeKeydown(host, editor, createKeymapHandler(onDismiss, presence));
|
|
269
|
-
useAutocompleteExtension(
|
|
213
|
+
let { editor, regex, ...overlayState } = state, reference = createSignal3(null), query = createSignal3(""), onDismiss = createSignal3(null), onSubmit = createSignal3(null), presence = createComputed(() => !!reference.value);
|
|
214
|
+
queryContext.provide(host, query), onSubmitContext.provide(host, onSubmit), openContext.provide(host, presence), useEscapeKeydown(host, editor, createKeymapHandler(onDismiss, presence)), useAutocompleteExtension(
|
|
270
215
|
host,
|
|
271
216
|
editor,
|
|
272
217
|
regex,
|
|
@@ -274,84 +219,57 @@ function useAutocompletePopoverState(host, state) {
|
|
|
274
219
|
query,
|
|
275
220
|
onDismiss,
|
|
276
221
|
onSubmit
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
usePresence(host, presence);
|
|
280
|
-
const firstRendering = useFirstRendering(host);
|
|
222
|
+
), useOverlayPositionerState(host, overlayState, { reference }), usePresence(host, presence);
|
|
223
|
+
let firstRendering = useFirstRendering(host);
|
|
281
224
|
useEffect4(host, () => {
|
|
282
225
|
var _a;
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if (!onOpenChangeValue) {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
return () => {
|
|
295
|
-
onOpenChangeValue(presenceValue);
|
|
296
|
-
};
|
|
226
|
+
let queryValue = query.value;
|
|
227
|
+
firstRendering.peek() || (_a = state.onQueryChange.peek()) == null || _a(queryValue);
|
|
228
|
+
}), useAnimationFrame(host, () => {
|
|
229
|
+
let presenceValue = presence.value, onOpenChangeValue = state.onOpenChange.peek();
|
|
230
|
+
if (onOpenChangeValue)
|
|
231
|
+
return () => {
|
|
232
|
+
onOpenChangeValue(presenceValue);
|
|
233
|
+
};
|
|
297
234
|
});
|
|
298
235
|
}
|
|
299
236
|
function useAutocompleteExtension(host, editor, regex, reference, query, onDismiss, onSubmit) {
|
|
300
237
|
useEffect4(host, () => {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
onDismiss,
|
|
312
|
-
onSubmit
|
|
313
|
-
);
|
|
238
|
+
let editorValue = editor.value, regexValue = regex.value;
|
|
239
|
+
if (!(!editorValue || !regexValue))
|
|
240
|
+
return addAutocompleteExtension(
|
|
241
|
+
editorValue,
|
|
242
|
+
regexValue,
|
|
243
|
+
reference,
|
|
244
|
+
query,
|
|
245
|
+
onDismiss,
|
|
246
|
+
onSubmit
|
|
247
|
+
);
|
|
314
248
|
});
|
|
315
249
|
}
|
|
316
250
|
function addAutocompleteExtension(editor, regex, reference, query, onDismiss, onSubmit) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
onDismiss.value = options.ignoreMatch;
|
|
324
|
-
onSubmit.value = options.deleteMatch;
|
|
325
|
-
};
|
|
326
|
-
const handleLeave = () => {
|
|
327
|
-
reference.value = null;
|
|
328
|
-
query.value = "";
|
|
329
|
-
onDismiss.value = null;
|
|
330
|
-
onSubmit.value = null;
|
|
331
|
-
};
|
|
332
|
-
const rule = new AutocompleteRule({
|
|
251
|
+
let handleEnter = (options) => {
|
|
252
|
+
let span = editor.view.dom.querySelector(".prosemirror-prediction-match");
|
|
253
|
+
span && (reference.value = span), query.value = defaultQueryBuilder(options.match), onDismiss.value = options.ignoreMatch, onSubmit.value = options.deleteMatch;
|
|
254
|
+
}, handleLeave = () => {
|
|
255
|
+
reference.value = null, query.value = "", onDismiss.value = null, onSubmit.value = null;
|
|
256
|
+
}, rule = new AutocompleteRule({
|
|
333
257
|
regex,
|
|
334
258
|
onEnter: handleEnter,
|
|
335
259
|
onLeave: handleLeave
|
|
336
|
-
});
|
|
337
|
-
const extension = defineAutocomplete(rule);
|
|
260
|
+
}), extension = defineAutocomplete(rule);
|
|
338
261
|
return editor.use(extension);
|
|
339
262
|
}
|
|
340
263
|
function createKeymapHandler(handler, enabled) {
|
|
341
264
|
return () => {
|
|
342
|
-
if (!enabled.value)
|
|
343
|
-
return
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if (!fn)
|
|
347
|
-
return false;
|
|
348
|
-
fn();
|
|
349
|
-
return true;
|
|
265
|
+
if (!enabled.value)
|
|
266
|
+
return !1;
|
|
267
|
+
let fn = handler.peek();
|
|
268
|
+
return fn ? (fn(), !0) : !1;
|
|
350
269
|
};
|
|
351
270
|
}
|
|
352
271
|
function useEscapeKeydown(host, editor, handler) {
|
|
353
|
-
|
|
354
|
-
const extension = withPriority2(defineKeymap(keymap), Priority2.highest);
|
|
272
|
+
let extension = withPriority2(defineKeymap({ Escape: handler }), Priority2.highest);
|
|
355
273
|
return useEditorExtension(host, editor, extension);
|
|
356
274
|
}
|
|
357
275
|
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-VJEVDINM.js";
|
|
4
4
|
import {
|
|
5
5
|
defineCustomElement
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-Y2CJYXR5.js";
|
|
7
7
|
|
|
8
8
|
// src/components/block-handle/block-drag-handle/element.gen.ts
|
|
9
9
|
import { ElementMixin } from "@aria-ui/core";
|
|
@@ -36,42 +36,25 @@ var blockPopoverContext = createContext(
|
|
|
36
36
|
|
|
37
37
|
// src/components/block-handle/block-drag-handle/state.ts
|
|
38
38
|
function useBlockDragHandle(host, props) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
useEventListener(host, "pointerdown", () => {
|
|
39
|
+
let context = blockPopoverContext.consume(host), state = mapSignals(assignProps(defaultBlockDragHandleProps, props));
|
|
40
|
+
return useEffect(host, () => {
|
|
41
|
+
host.draggable = !0;
|
|
42
|
+
}), useEventListener(host, "pointerdown", () => {
|
|
45
43
|
var _a, _b;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (pos == null || view == null) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
view.dispatch(
|
|
44
|
+
let { pos } = (_a = context.value) != null ? _a : {}, { view } = (_b = state.editor.value) != null ? _b : {};
|
|
45
|
+
pos == null || view == null || (view.dispatch(
|
|
52
46
|
view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos))
|
|
53
|
-
)
|
|
54
|
-
requestAnimationFrame(() => {
|
|
47
|
+
), requestAnimationFrame(() => {
|
|
55
48
|
view.focus();
|
|
56
|
-
});
|
|
57
|
-
})
|
|
58
|
-
useEventListener(host, "dragstart", (event) => {
|
|
49
|
+
}));
|
|
50
|
+
}), useEventListener(host, "dragstart", (event) => {
|
|
59
51
|
var _a, _b;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (pos == null || !element || !node || !view || !event.dataTransfer) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
event.dataTransfer.clearData();
|
|
66
|
-
event.dataTransfer.setData("text/html", element.outerHTML);
|
|
67
|
-
event.dataTransfer.effectAllowed = "copyMove";
|
|
68
|
-
event.dataTransfer.setDragImage(element, 0, 0);
|
|
69
|
-
view.dragging = {
|
|
52
|
+
let { pos, element, node } = (_a = context.value) != null ? _a : {}, { view } = (_b = state.editor.value) != null ? _b : {};
|
|
53
|
+
pos == null || !element || !node || !view || !event.dataTransfer || (event.dataTransfer.clearData(), event.dataTransfer.setData("text/html", element.outerHTML), event.dataTransfer.effectAllowed = "copyMove", event.dataTransfer.setDragImage(element, 0, 0), view.dragging = {
|
|
70
54
|
slice: new Slice(Fragment.from(node), 0, 0),
|
|
71
|
-
move:
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
return state;
|
|
55
|
+
move: !0
|
|
56
|
+
});
|
|
57
|
+
}), state;
|
|
75
58
|
}
|
|
76
59
|
|
|
77
60
|
// src/components/block-handle/block-drag-handle/element.gen.ts
|
|
@@ -110,20 +93,16 @@ import { defineDOMEventHandler, union } from "@prosekit/core";
|
|
|
110
93
|
function throttle(callback, wait) {
|
|
111
94
|
let lastTime = 0;
|
|
112
95
|
return (...args) => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
callback(...args);
|
|
116
|
-
lastTime = now;
|
|
117
|
-
}
|
|
96
|
+
let now = Date.now();
|
|
97
|
+
now - lastTime >= wait && (callback(...args), lastTime = now);
|
|
118
98
|
};
|
|
119
99
|
}
|
|
120
100
|
|
|
121
101
|
// src/components/block-handle/block-popover/pointer-move.ts
|
|
122
102
|
function defineElementHoverHandler(handler) {
|
|
123
|
-
|
|
103
|
+
let handlePointerEvent = (view, event) => {
|
|
124
104
|
var _a;
|
|
125
|
-
|
|
126
|
-
const pos = (_a = view.posAtCoords({
|
|
105
|
+
let rect = view.dom.getBoundingClientRect(), pos = (_a = view.posAtCoords({
|
|
127
106
|
top: event.clientY,
|
|
128
107
|
// Use the center of the editor
|
|
129
108
|
left: rect.left + rect.width / 2
|
|
@@ -132,28 +111,19 @@ function defineElementHoverHandler(handler) {
|
|
|
132
111
|
handler(null, null, null, null);
|
|
133
112
|
return;
|
|
134
113
|
}
|
|
135
|
-
|
|
136
|
-
const node = view.state.doc.nodeAt(pos);
|
|
137
|
-
const element = view.nodeDOM(pos);
|
|
114
|
+
let $pos = view.state.doc.resolve(pos), node = view.state.doc.nodeAt(pos), element = view.nodeDOM(pos);
|
|
138
115
|
if ($pos.depth >= 1 && $pos.index($pos.depth) === 0) {
|
|
139
|
-
|
|
140
|
-
const node2 = view.state.doc.nodeAt(ancestorPos);
|
|
141
|
-
const element2 = view.nodeDOM(ancestorPos);
|
|
116
|
+
let ancestorPos = $pos.before($pos.depth), node2 = view.state.doc.nodeAt(ancestorPos), element2 = view.nodeDOM(ancestorPos);
|
|
142
117
|
if (!element2) {
|
|
143
118
|
handler(null, null, null, null);
|
|
144
119
|
return;
|
|
145
120
|
}
|
|
146
|
-
|
|
121
|
+
handler({
|
|
147
122
|
contextElement: element2,
|
|
148
123
|
// Get the bounding client rect of the parent node, including its
|
|
149
124
|
// margins.
|
|
150
125
|
getBoundingClientRect: () => {
|
|
151
|
-
|
|
152
|
-
const style = window.getComputedStyle(element2);
|
|
153
|
-
const marginTop = Number.parseInt(style.marginTop, 10) || 0;
|
|
154
|
-
const marginRight = Number.parseInt(style.marginRight, 10) || 0;
|
|
155
|
-
const marginBottom = Number.parseInt(style.marginBottom, 10) || 0;
|
|
156
|
-
const marginLeft = Number.parseInt(style.marginLeft, 10) || 0;
|
|
126
|
+
let rect2 = element2.getBoundingClientRect(), style = window.getComputedStyle(element2), marginTop = Number.parseInt(style.marginTop, 10) || 0, marginRight = Number.parseInt(style.marginRight, 10) || 0, marginBottom = Number.parseInt(style.marginBottom, 10) || 0, marginLeft = Number.parseInt(style.marginLeft, 10) || 0;
|
|
157
127
|
return {
|
|
158
128
|
top: rect2.top - marginTop,
|
|
159
129
|
right: rect2.right + marginRight,
|
|
@@ -165,8 +135,7 @@ function defineElementHoverHandler(handler) {
|
|
|
165
135
|
y: rect2.y - marginTop
|
|
166
136
|
};
|
|
167
137
|
}
|
|
168
|
-
};
|
|
169
|
-
handler(reference, element2, node2, ancestorPos);
|
|
138
|
+
}, element2, node2, ancestorPos);
|
|
170
139
|
return;
|
|
171
140
|
}
|
|
172
141
|
handler(element, element, node, pos);
|
|
@@ -180,40 +149,27 @@ function defineElementHoverHandler(handler) {
|
|
|
180
149
|
|
|
181
150
|
// src/components/block-handle/block-popover/state.ts
|
|
182
151
|
function useBlockPopover(host, props) {
|
|
183
|
-
|
|
184
|
-
const { editor, ...overlayState } = state;
|
|
185
|
-
const reference = createSignal(null);
|
|
152
|
+
let state = mapSignals2(assignProps2(defaultBlockPopoverProps, props)), { editor, ...overlayState } = state, reference = createSignal(null);
|
|
186
153
|
useOverlayPositionerState(host, overlayState, { reference });
|
|
187
|
-
|
|
154
|
+
let context = createSignal({
|
|
188
155
|
pos: null,
|
|
189
156
|
node: null,
|
|
190
157
|
element: null
|
|
191
158
|
});
|
|
192
159
|
blockPopoverContext.provide(host, context);
|
|
193
|
-
|
|
160
|
+
let open = createSignal(!1);
|
|
194
161
|
useEffect2(host, () => {
|
|
195
162
|
open.value = !!context.value.element;
|
|
163
|
+
}), useHoverExtension(host, editor, (referenceValue, element, node, pos) => {
|
|
164
|
+
reference.value = referenceValue, context.value = { element, node, pos };
|
|
196
165
|
});
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
context.value = { element, node, pos };
|
|
200
|
-
});
|
|
201
|
-
const presence = createComputed(() => !!reference.value);
|
|
202
|
-
useAttribute(host, "data-state", () => presence.value ? "open" : "closed");
|
|
203
|
-
usePresence(host, presence);
|
|
204
|
-
return state;
|
|
166
|
+
let presence = createComputed(() => !!reference.value);
|
|
167
|
+
return useAttribute(host, "data-state", () => presence.value ? "open" : "closed"), usePresence(host, presence), state;
|
|
205
168
|
}
|
|
206
169
|
function useHoverExtension(host, editor, handler) {
|
|
207
|
-
let prevElement = null
|
|
208
|
-
let prevPos = null;
|
|
209
|
-
const extension = defineElementHoverHandler(
|
|
170
|
+
let prevElement = null, prevPos = null, extension = defineElementHoverHandler(
|
|
210
171
|
(reference, element, node, pos) => {
|
|
211
|
-
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
prevElement = element;
|
|
215
|
-
prevPos = pos;
|
|
216
|
-
handler(reference, element, node, pos);
|
|
172
|
+
prevElement === element && prevPos === pos || (prevElement = element, prevPos = pos, handler(reference, element, node, pos));
|
|
217
173
|
}
|
|
218
174
|
);
|
|
219
175
|
useEditorExtension(host, editor, extension);
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-VJEVDINM.js";
|
|
4
4
|
import {
|
|
5
5
|
defineCustomElement
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-Y2CJYXR5.js";
|
|
7
7
|
|
|
8
8
|
// src/components/inline-popover/inline-popover/element.gen.ts
|
|
9
9
|
import { ElementMixin } from "@aria-ui/core";
|
|
@@ -13,18 +13,18 @@ import { defaultOverlayPositionerProps } from "@aria-ui/overlay";
|
|
|
13
13
|
var defaultInlinePopoverProps = Object.freeze({
|
|
14
14
|
...defaultOverlayPositionerProps,
|
|
15
15
|
editor: null,
|
|
16
|
-
open:
|
|
16
|
+
open: !0,
|
|
17
17
|
onOpenChange: null,
|
|
18
18
|
placement: "top",
|
|
19
19
|
offset: 12,
|
|
20
|
-
shift:
|
|
21
|
-
flip:
|
|
22
|
-
hide:
|
|
23
|
-
overlap:
|
|
24
|
-
inline:
|
|
20
|
+
shift: !0,
|
|
21
|
+
flip: !0,
|
|
22
|
+
hide: !0,
|
|
23
|
+
overlap: !0,
|
|
24
|
+
inline: !0,
|
|
25
25
|
overflowPadding: 8,
|
|
26
26
|
// Don't need boundary when hoist is true.
|
|
27
|
-
hoist:
|
|
27
|
+
hoist: !0,
|
|
28
28
|
boundary: []
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -45,14 +45,14 @@ import {
|
|
|
45
45
|
defineFocusChangeHandler
|
|
46
46
|
} from "@prosekit/core";
|
|
47
47
|
function useEditorFocusChangeEvent(host, editor, handler) {
|
|
48
|
-
|
|
48
|
+
let extension = defineFocusChangeHandler(handler);
|
|
49
49
|
useEditorExtension(host, editor, extension);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// src/hooks/use-editor-update-event.ts
|
|
53
53
|
import { defineUpdateHandler } from "@prosekit/core";
|
|
54
54
|
function useEditorUpdateEvent(host, editor, handler) {
|
|
55
|
-
|
|
55
|
+
let extension = defineUpdateHandler(handler);
|
|
56
56
|
useEditorExtension(host, editor, extension);
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -61,52 +61,44 @@ import { isTextSelection } from "@prosekit/core";
|
|
|
61
61
|
|
|
62
62
|
// src/utils/is-in-code-block.ts
|
|
63
63
|
function isInCodeBlock(selection) {
|
|
64
|
-
|
|
64
|
+
let type = selection.$from.parent.type;
|
|
65
65
|
return type.spec.code && type.isBlock;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// src/components/inline-popover/inline-popover/virtual-selection-element.ts
|
|
69
69
|
function getVirtualSelectionElement(view) {
|
|
70
|
-
if (typeof window
|
|
70
|
+
if (typeof window == "undefined" || view.isDestroyed)
|
|
71
71
|
return null;
|
|
72
|
-
|
|
73
|
-
const selection = view.state.selection;
|
|
72
|
+
let selection = view.state.selection;
|
|
74
73
|
if (!selection.empty && !isInCodeBlock(selection) && isTextSelection(selection)) {
|
|
75
|
-
|
|
76
|
-
if (decoration)
|
|
74
|
+
let decoration = getInlineDecoration(view);
|
|
75
|
+
if (decoration)
|
|
77
76
|
return decoration;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (range) {
|
|
77
|
+
let range = getDomRange();
|
|
78
|
+
if (range)
|
|
81
79
|
return {
|
|
82
80
|
contextElement: view.dom,
|
|
83
81
|
getBoundingClientRect: () => range.getBoundingClientRect(),
|
|
84
82
|
getClientRects: () => range.getClientRects()
|
|
85
83
|
};
|
|
86
|
-
}
|
|
87
84
|
}
|
|
88
85
|
return null;
|
|
89
86
|
}
|
|
90
87
|
function getDomRange() {
|
|
91
|
-
|
|
92
|
-
if (!selection || selection.isCollapsed)
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const range = typeof selection.rangeCount === "number" && selection.rangeCount > 0 && selection.getRangeAt(0);
|
|
96
|
-
if (!range) {
|
|
88
|
+
let selection = window.getSelection();
|
|
89
|
+
if (!selection || selection.isCollapsed)
|
|
97
90
|
return;
|
|
98
|
-
|
|
99
|
-
|
|
91
|
+
let range = typeof selection.rangeCount == "number" && selection.rangeCount > 0 && selection.getRangeAt(0);
|
|
92
|
+
if (range)
|
|
93
|
+
return range;
|
|
100
94
|
}
|
|
101
95
|
function getInlineDecoration(view) {
|
|
102
|
-
|
|
103
|
-
if (match.length === 0)
|
|
96
|
+
let match = view.dom.querySelectorAll(".prosekit-virtual-selection");
|
|
97
|
+
if (match.length === 0)
|
|
104
98
|
return;
|
|
105
|
-
|
|
106
|
-
if (match.length === 1) {
|
|
99
|
+
if (match.length === 1)
|
|
107
100
|
return match[0];
|
|
108
|
-
|
|
109
|
-
const items = Array.from(match);
|
|
101
|
+
let items = Array.from(match);
|
|
110
102
|
return {
|
|
111
103
|
contextElement: items[0],
|
|
112
104
|
getBoundingClientRect: () => items[0].getBoundingClientRect(),
|
|
@@ -116,37 +108,26 @@ function getInlineDecoration(view) {
|
|
|
116
108
|
|
|
117
109
|
// src/components/inline-popover/inline-popover/state.ts
|
|
118
110
|
function useInlinePopover(host, props) {
|
|
119
|
-
|
|
120
|
-
useInlinePopoverState(host, state);
|
|
121
|
-
return state;
|
|
111
|
+
let state = mapSignals(assignProps(defaultInlinePopoverProps, props));
|
|
112
|
+
return useInlinePopoverState(host, state), state;
|
|
122
113
|
}
|
|
123
114
|
function useInlinePopoverState(host, state) {
|
|
124
|
-
|
|
125
|
-
const reference = useInlinePopoverReference(host, editor);
|
|
115
|
+
let { editor, open, onOpenChange, ...overlayState } = state, reference = useInlinePopoverReference(host, editor);
|
|
126
116
|
useOverlayPositionerState(host, overlayState, { reference });
|
|
127
|
-
|
|
128
|
-
useAttribute(host, "data-state", () => presence.value ? "open" : "closed")
|
|
129
|
-
usePresence(host, presence);
|
|
130
|
-
useEffect(host, () => {
|
|
117
|
+
let presence = createComputed(() => !!reference.value && open.value);
|
|
118
|
+
useAttribute(host, "data-state", () => presence.value ? "open" : "closed"), usePresence(host, presence), useEffect(host, () => {
|
|
131
119
|
var _a;
|
|
132
|
-
|
|
133
|
-
(_a = onOpenChange.peek()) == null
|
|
120
|
+
let presenceValue = presence.value;
|
|
121
|
+
(_a = onOpenChange.peek()) == null || _a(presenceValue);
|
|
134
122
|
});
|
|
135
123
|
}
|
|
136
124
|
function useInlinePopoverReference(host, editor) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
useEditorFocusChangeEvent(host, editor, (focus) => {
|
|
125
|
+
let reference = createSignal(null), editorFocused = !1;
|
|
126
|
+
return useEditorFocusChangeEvent(host, editor, (focus) => {
|
|
140
127
|
editorFocused = focus;
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (isPopoverFocused) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
reference.value = getVirtualSelectionElement(view);
|
|
148
|
-
});
|
|
149
|
-
return reference;
|
|
128
|
+
}), useEditorUpdateEvent(host, editor, (view) => {
|
|
129
|
+
!editorFocused && host.contains(host.ownerDocument.activeElement) || (reference.value = getVirtualSelectionElement(view));
|
|
130
|
+
}), reference;
|
|
150
131
|
}
|
|
151
132
|
|
|
152
133
|
// src/components/inline-popover/inline-popover/element.gen.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineCustomElement
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Y2CJYXR5.js";
|
|
4
4
|
|
|
5
5
|
// src/components/resizable/resizable-handle/element.gen.ts
|
|
6
6
|
import { ElementMixin } from "@aria-ui/core";
|
|
@@ -24,26 +24,22 @@ import { createContext } from "@aria-ui/core";
|
|
|
24
24
|
var onResizeContext = createContext(
|
|
25
25
|
"prosekit/resizable/onResize",
|
|
26
26
|
null
|
|
27
|
-
)
|
|
28
|
-
var onResizeStartContext = createContext(
|
|
27
|
+
), onResizeStartContext = createContext(
|
|
29
28
|
"prosekit/resizable/onResizeStart",
|
|
30
29
|
null
|
|
31
|
-
)
|
|
32
|
-
var onResizeEndContext = createContext(
|
|
30
|
+
), onResizeEndContext = createContext(
|
|
33
31
|
"prosekit/resizable/onResizeEnd",
|
|
34
32
|
null
|
|
35
33
|
);
|
|
36
34
|
|
|
37
35
|
// src/utils/is-finite-positive-number.ts
|
|
38
36
|
function isFinitePositiveNumber(value) {
|
|
39
|
-
return typeof value
|
|
37
|
+
return typeof value == "number" && Number.isFinite(value) && value > 0;
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
// src/components/resizable/resizable-handle/calc-resize.ts
|
|
43
41
|
function calcResize(position, w, h, dx, dy, aspectRatio) {
|
|
44
|
-
aspectRatio = aspectRatio ? aspectRatio :
|
|
45
|
-
aspectRatio = isFinitePositiveNumber(aspectRatio) ? aspectRatio : 1;
|
|
46
|
-
switch (position) {
|
|
42
|
+
switch (aspectRatio = aspectRatio || w / h, aspectRatio = isFinitePositiveNumber(aspectRatio) ? aspectRatio : 1, position) {
|
|
47
43
|
case "bottom-right":
|
|
48
44
|
return calcBottomRightResize(w, h, dx, dy, aspectRatio);
|
|
49
45
|
case "bottom-left":
|
|
@@ -65,92 +61,38 @@ function calcResize(position, w, h, dx, dy, aspectRatio) {
|
|
|
65
61
|
}
|
|
66
62
|
}
|
|
67
63
|
var calcBottomRightResize = (w, h, dx, dy, r) => {
|
|
68
|
-
w += dx;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
w
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
w -=
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
w
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
w += dx;
|
|
85
|
-
h -= dy;
|
|
86
|
-
const sum = w + h;
|
|
87
|
-
h = sum / (r + 1);
|
|
88
|
-
w = sum - h;
|
|
89
|
-
return [w, h];
|
|
90
|
-
};
|
|
91
|
-
var calcTopLeftResize = (w, h, dx, dy, r) => {
|
|
92
|
-
w -= dx;
|
|
93
|
-
h -= dy;
|
|
94
|
-
const sum = w + h;
|
|
95
|
-
h = sum / (r + 1);
|
|
96
|
-
w = sum - h;
|
|
97
|
-
return [w, h];
|
|
98
|
-
};
|
|
99
|
-
var calcTopResize = (w, h, dx, dy, r) => {
|
|
100
|
-
h -= dy;
|
|
101
|
-
w = h * r;
|
|
102
|
-
return [w, h];
|
|
103
|
-
};
|
|
104
|
-
var calcRightResize = (w, h, dx, dy, r) => {
|
|
105
|
-
w += dx;
|
|
106
|
-
h = w / r;
|
|
107
|
-
return [w, h];
|
|
108
|
-
};
|
|
109
|
-
var calcBottomResize = (w, h, dx, dy, r) => {
|
|
110
|
-
h += dy;
|
|
111
|
-
w = h * r;
|
|
112
|
-
return [w, h];
|
|
113
|
-
};
|
|
114
|
-
var calcLeftResize = (w, h, dx, dy, r) => {
|
|
115
|
-
w -= dx;
|
|
116
|
-
h = w / r;
|
|
117
|
-
return [w, h];
|
|
118
|
-
};
|
|
64
|
+
w += dx, h += dy;
|
|
65
|
+
let sum = w + h;
|
|
66
|
+
return h = sum / (r + 1), w = sum - h, [w, h];
|
|
67
|
+
}, calcBottomLeftResize = (w, h, dx, dy, r) => {
|
|
68
|
+
w -= dx, h += dy;
|
|
69
|
+
let sum = w + h;
|
|
70
|
+
return h = sum / (r + 1), w = sum - h, [w, h];
|
|
71
|
+
}, calcTopRightResize = (w, h, dx, dy, r) => {
|
|
72
|
+
w += dx, h -= dy;
|
|
73
|
+
let sum = w + h;
|
|
74
|
+
return h = sum / (r + 1), w = sum - h, [w, h];
|
|
75
|
+
}, calcTopLeftResize = (w, h, dx, dy, r) => {
|
|
76
|
+
w -= dx, h -= dy;
|
|
77
|
+
let sum = w + h;
|
|
78
|
+
return h = sum / (r + 1), w = sum - h, [w, h];
|
|
79
|
+
}, calcTopResize = (w, h, dx, dy, r) => (h -= dy, w = h * r, [w, h]), calcRightResize = (w, h, dx, dy, r) => (w += dx, h = w / r, [w, h]), calcBottomResize = (w, h, dx, dy, r) => (h += dy, w = h * r, [w, h]), calcLeftResize = (w, h, dx, dy, r) => (w -= dx, h = w / r, [w, h]);
|
|
119
80
|
|
|
120
81
|
// src/components/resizable/resizable-handle/state.ts
|
|
121
82
|
function useResizableHandle(host, props) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const onResizeStart = onResizeStartContext.consume(host);
|
|
125
|
-
const onResizeEnd = onResizeEndContext.consume(host);
|
|
126
|
-
useResizableHandleState(host, state, { onResize, onResizeStart, onResizeEnd });
|
|
127
|
-
return state;
|
|
83
|
+
let state = mapSignals(assignProps(defaultResizableHandleProps, props)), onResize = onResizeContext.consume(host), onResizeStart = onResizeStartContext.consume(host), onResizeEnd = onResizeEndContext.consume(host);
|
|
84
|
+
return useResizableHandleState(host, state, { onResize, onResizeStart, onResizeEnd }), state;
|
|
128
85
|
}
|
|
129
86
|
function useResizableHandleState(host, state, context) {
|
|
130
|
-
let startX = 0
|
|
131
|
-
let startY = 0;
|
|
132
|
-
let width = 0;
|
|
133
|
-
let height = 0;
|
|
134
|
-
let aspectRatio = 1;
|
|
135
|
-
const pointerPressing = createSignal(false);
|
|
136
|
-
const handlePointerDown = (event) => {
|
|
87
|
+
let startX = 0, startY = 0, width = 0, height = 0, aspectRatio = 1, pointerPressing = createSignal(!1), handlePointerDown = (event) => {
|
|
137
88
|
var _a, _b;
|
|
138
|
-
event.preventDefault();
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const size = (_b = (_a = context.onResizeStart).value) == null ? void 0 : _b.call(_a);
|
|
143
|
-
if (size) {
|
|
144
|
-
;
|
|
145
|
-
[width, height, aspectRatio] = size;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
const handlePointerMove = (event) => {
|
|
89
|
+
event.preventDefault(), pointerPressing.value = !0, startX = event.x, startY = event.y;
|
|
90
|
+
let size = (_b = (_a = context.onResizeStart).value) == null ? void 0 : _b.call(_a);
|
|
91
|
+
size && ([width, height, aspectRatio] = size);
|
|
92
|
+
}, handlePointerMove = (event) => {
|
|
149
93
|
var _a, _b;
|
|
150
94
|
event.preventDefault();
|
|
151
|
-
|
|
152
|
-
const dy = event.y - startY;
|
|
153
|
-
const [w, h] = calcResize(
|
|
95
|
+
let dx = event.x - startX, dy = event.y - startY, [w, h] = calcResize(
|
|
154
96
|
state.position.peek(),
|
|
155
97
|
width,
|
|
156
98
|
height,
|
|
@@ -158,30 +100,19 @@ function useResizableHandleState(host, state, context) {
|
|
|
158
100
|
dy,
|
|
159
101
|
aspectRatio
|
|
160
102
|
);
|
|
161
|
-
(_b = (_a = context.onResize).value) == null
|
|
162
|
-
}
|
|
163
|
-
const handlePointerUp = (event) => {
|
|
103
|
+
(_b = (_a = context.onResize).value) == null || _b.call(_a, w, h);
|
|
104
|
+
}, handlePointerUp = (event) => {
|
|
164
105
|
var _a, _b;
|
|
165
|
-
event.preventDefault();
|
|
166
|
-
pointerPressing.value = false;
|
|
167
|
-
(_b = (_a = context.onResizeEnd).value) == null ? void 0 : _b.call(_a);
|
|
106
|
+
event.preventDefault(), pointerPressing.value = !1, (_b = (_a = context.onResizeEnd).value) == null || _b.call(_a);
|
|
168
107
|
};
|
|
169
|
-
useEffect(host, () => {
|
|
170
|
-
host.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
};
|
|
174
|
-
});
|
|
175
|
-
useEffect(host, () => {
|
|
176
|
-
if (!pointerPressing.value) {
|
|
108
|
+
useEffect(host, () => (host.addEventListener("pointerdown", handlePointerDown), () => {
|
|
109
|
+
host.removeEventListener("pointerdown", handlePointerDown);
|
|
110
|
+
})), useEffect(host, () => {
|
|
111
|
+
if (!pointerPressing.value)
|
|
177
112
|
return;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
win.addEventListener("pointerup", handlePointerUp);
|
|
182
|
-
return () => {
|
|
183
|
-
win.removeEventListener("pointermove", handlePointerMove);
|
|
184
|
-
win.removeEventListener("pointerup", handlePointerUp);
|
|
113
|
+
let win = getWindow(host);
|
|
114
|
+
return win.addEventListener("pointermove", handlePointerMove), win.addEventListener("pointerup", handlePointerUp), () => {
|
|
115
|
+
win.removeEventListener("pointermove", handlePointerMove), win.removeEventListener("pointerup", handlePointerUp);
|
|
185
116
|
};
|
|
186
117
|
});
|
|
187
118
|
}
|
|
@@ -212,36 +143,23 @@ import {
|
|
|
212
143
|
useEffect as useEffect2
|
|
213
144
|
} from "@aria-ui/core";
|
|
214
145
|
function useResizableRoot(host, props) {
|
|
215
|
-
|
|
216
|
-
useResizableRootState(host, state);
|
|
217
|
-
return state;
|
|
146
|
+
let state = mapSignals2(assignProps2(defaultResizableRootProps, props));
|
|
147
|
+
return useResizableRootState(host, state), state;
|
|
218
148
|
}
|
|
219
149
|
function useResizableRootState(host, state) {
|
|
220
|
-
|
|
150
|
+
let onResizeStart = () => {
|
|
221
151
|
var _a, _b;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
aspectRatio = 0;
|
|
226
|
-
}
|
|
227
|
-
(_b = state.onSizeChangeStart.peek()) == null ? void 0 : _b({ width, height });
|
|
228
|
-
return [width, height, aspectRatio];
|
|
229
|
-
};
|
|
230
|
-
const onResize = (width, height) => {
|
|
152
|
+
let { width, height } = host.getBoundingClientRect(), aspectRatio = (_a = state.aspectRatio.peek()) != null ? _a : width / height;
|
|
153
|
+
return isFinitePositiveNumber(aspectRatio) || (aspectRatio = 0), (_b = state.onSizeChangeStart.peek()) == null || _b({ width, height }), [width, height, aspectRatio];
|
|
154
|
+
}, onResize = (width, height) => {
|
|
231
155
|
var _a;
|
|
232
|
-
(_a = state.onSizeChange.peek()) == null
|
|
233
|
-
|
|
234
|
-
state.height.value = height;
|
|
235
|
-
};
|
|
236
|
-
const onResizeEnd = () => {
|
|
156
|
+
(_a = state.onSizeChange.peek()) == null || _a({ width, height }), state.width.value = width, state.height.value = height;
|
|
157
|
+
}, onResizeEnd = () => {
|
|
237
158
|
var _a;
|
|
238
|
-
|
|
239
|
-
(_a = state.onSizeChangeEnd.peek()) == null
|
|
159
|
+
let { width, height } = host.getBoundingClientRect();
|
|
160
|
+
(_a = state.onSizeChangeEnd.peek()) == null || _a({ width, height });
|
|
240
161
|
};
|
|
241
|
-
onResizeStartContext.provide(host, createSignal2(onResizeStart))
|
|
242
|
-
onResizeContext.provide(host, createSignal2(onResize));
|
|
243
|
-
onResizeEndContext.provide(host, createSignal2(onResizeEnd));
|
|
244
|
-
useEffect2(host, () => {
|
|
162
|
+
onResizeStartContext.provide(host, createSignal2(onResizeStart)), onResizeContext.provide(host, createSignal2(onResize)), onResizeEndContext.provide(host, createSignal2(onResizeEnd)), useEffect2(host, () => {
|
|
245
163
|
updateResizableRootStyles(
|
|
246
164
|
host,
|
|
247
165
|
state.width.value,
|
|
@@ -251,16 +169,7 @@ function useResizableRootState(host, state) {
|
|
|
251
169
|
});
|
|
252
170
|
}
|
|
253
171
|
function updateResizableRootStyles(host, width, height, aspectRatio) {
|
|
254
|
-
host.style.width = isFinitePositiveNumber(width) ? `${width}px` : "";
|
|
255
|
-
host.style.height = isFinitePositiveNumber(height) ? `${height}px` : "";
|
|
256
|
-
if (isFinitePositiveNumber(aspectRatio)) {
|
|
257
|
-
host.style.aspectRatio = `${aspectRatio}`;
|
|
258
|
-
if (width && width > 0 && aspectRatio >= 1) {
|
|
259
|
-
host.style.height = "auto";
|
|
260
|
-
} else if (height && height > 0 && aspectRatio <= 1) {
|
|
261
|
-
host.style.width = "auto";
|
|
262
|
-
}
|
|
263
|
-
}
|
|
172
|
+
host.style.width = isFinitePositiveNumber(width) ? `${width}px` : "", host.style.height = isFinitePositiveNumber(height) ? `${height}px` : "", isFinitePositiveNumber(aspectRatio) && (host.style.aspectRatio = `${aspectRatio}`, width && width > 0 && aspectRatio >= 1 ? host.style.height = "auto" : height && height > 0 && aspectRatio <= 1 && (host.style.width = "auto"));
|
|
264
173
|
}
|
|
265
174
|
|
|
266
175
|
// src/components/resizable/resizable-root/element.gen.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineCustomElement
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Y2CJYXR5.js";
|
|
4
4
|
|
|
5
5
|
// src/components/tooltip/tooltip-content/element.gen.ts
|
|
6
6
|
import { ElementMixin } from "@aria-ui/core";
|
|
@@ -9,12 +9,12 @@ import { ElementMixin } from "@aria-ui/core";
|
|
|
9
9
|
import { defaultTooltipContentProps as defaultProps } from "@aria-ui/tooltip";
|
|
10
10
|
var defaultTooltipContentProps = {
|
|
11
11
|
...defaultProps,
|
|
12
|
-
shift:
|
|
13
|
-
flip:
|
|
12
|
+
shift: !0,
|
|
13
|
+
flip: !0,
|
|
14
14
|
offset: 6,
|
|
15
15
|
overflowPadding: 4,
|
|
16
16
|
// Don't need boundary when hoist is true.
|
|
17
|
-
hoist:
|
|
17
|
+
hoist: !0,
|
|
18
18
|
boundary: []
|
|
19
19
|
};
|
|
20
20
|
|
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.10",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "ocavue",
|
|
@@ -73,13 +73,13 @@
|
|
|
73
73
|
"@aria-ui/presence": "^0.0.9",
|
|
74
74
|
"@aria-ui/tooltip": "^0.0.16",
|
|
75
75
|
"@floating-ui/dom": "^1.6.5",
|
|
76
|
-
"@
|
|
77
|
-
"@prosekit/
|
|
78
|
-
"@prosekit/pm": "^0.1.
|
|
79
|
-
"@
|
|
76
|
+
"@zag-js/dom-query": "^0.53.0",
|
|
77
|
+
"@prosekit/core": "^0.5.5",
|
|
78
|
+
"@prosekit/pm": "^0.1.5",
|
|
79
|
+
"@prosekit/extensions": "^0.5.3"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"tsup": "^8.0
|
|
82
|
+
"tsup": "^8.1.0",
|
|
83
83
|
"typescript": "^5.4.5",
|
|
84
84
|
"vitest": "^1.6.0",
|
|
85
85
|
"@prosekit/dev": "0.0.0"
|