@prosekit/web 0.5.2 → 0.5.4
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/_tsup-dts-rollup.d.ts +26 -8
- package/dist/{chunk-MZSYOTZT.js → chunk-WTW6FOH3.js} +1 -2
- package/dist/prosekit-web-autocomplete.js +3 -5
- package/dist/prosekit-web-block-handle.js +207 -53
- package/dist/prosekit-web-inline-popover.js +2 -2
- package/dist/prosekit-web-resizable.js +4 -8
- package/dist/prosekit-web-table-handle.js +10 -18
- package/package.json +14 -14
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BaseElementConstructor } from '@aria-ui/core';
|
|
2
2
|
import { ConnectableElement } from '@aria-ui/core';
|
|
3
3
|
import { Context } from '@aria-ui/core';
|
|
4
|
-
import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
|
|
5
4
|
import type { defineTableCommands } from '@prosekit/extensions/table';
|
|
6
5
|
import { Editor } from '@prosekit/core';
|
|
7
6
|
import type { EditorView } from '@prosekit/pm/view';
|
|
@@ -17,7 +16,6 @@ import { MenuContentEvents } from '@aria-ui/menu/elements';
|
|
|
17
16
|
import { MenuContentProps } from '@aria-ui/menu/elements';
|
|
18
17
|
import { MenuItemEvents } from '@aria-ui/menu';
|
|
19
18
|
import { MenuItemProps } from '@aria-ui/menu';
|
|
20
|
-
import { Options } from 'tsup';
|
|
21
19
|
import { OverlayPositionerEvents } from '@aria-ui/overlay/elements';
|
|
22
20
|
import { OverlayPositionerEvents as OverlayPositionerEvents_2 } from '@aria-ui/overlay';
|
|
23
21
|
import { OverlayPositionerProps } from '@aria-ui/overlay/elements';
|
|
@@ -335,7 +333,7 @@ declare const blockHandlePopoverEvents: EventDeclarations<BlockHandlePopoverEven
|
|
|
335
333
|
export { blockHandlePopoverEvents }
|
|
336
334
|
export { blockHandlePopoverEvents as blockHandlePopoverEvents_alias_1 }
|
|
337
335
|
|
|
338
|
-
declare interface BlockHandlePopoverProps extends Omit<OverlayPositionerProps, 'placement'> {
|
|
336
|
+
declare interface BlockHandlePopoverProps extends Omit<OverlayPositionerProps, 'placement' | 'hoist'> {
|
|
339
337
|
/**
|
|
340
338
|
* The ProseKit editor instance.
|
|
341
339
|
*
|
|
@@ -346,9 +344,16 @@ declare interface BlockHandlePopoverProps extends Omit<OverlayPositionerProps, '
|
|
|
346
344
|
/**
|
|
347
345
|
* The placement of the popover, relative to the hovered block.
|
|
348
346
|
*
|
|
349
|
-
* @default "left
|
|
347
|
+
* @default "left"
|
|
350
348
|
*/
|
|
351
349
|
placement: Placement;
|
|
350
|
+
/**
|
|
351
|
+
* Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
352
|
+
* to place the floating element on top of other page content.
|
|
353
|
+
*
|
|
354
|
+
* @default false
|
|
355
|
+
*/
|
|
356
|
+
hoist: boolean;
|
|
352
357
|
}
|
|
353
358
|
export { BlockHandlePopoverProps }
|
|
354
359
|
export { BlockHandlePopoverProps as BlockHandlePopoverProps_alias_1 }
|
|
@@ -370,10 +375,6 @@ export declare const blockPopoverContext: Context<BlockPopoverContext>;
|
|
|
370
375
|
|
|
371
376
|
export declare function calcResize(position: 'top' | 'right' | 'bottom' | 'left' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right', w: number, h: number, dx: number, dy: number, aspectRatio: number | null | undefined): [w: number, h: number];
|
|
372
377
|
|
|
373
|
-
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
|
374
|
-
|
|
375
|
-
export { default_alias_1 }
|
|
376
|
-
|
|
377
378
|
export declare function defaultQueryBuilder(match: RegExpExecArray): string;
|
|
378
379
|
|
|
379
380
|
export declare function defineCustomElement(name: string, constructor: CustomElementConstructor, options?: ElementDefinitionOptions): void;
|
|
@@ -382,6 +383,16 @@ export declare function defineElementHoverHandler(handler: ElementHoverHandler):
|
|
|
382
383
|
|
|
383
384
|
export declare type ElementHoverHandler = (reference: VirtualElement | null, hoverState: HoverState | null) => void;
|
|
384
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Similar to `element.getBoundingClientRect`, but handles `display: contents` elements.
|
|
388
|
+
*/
|
|
389
|
+
export declare function getClientRect(element: Element): {
|
|
390
|
+
top: number;
|
|
391
|
+
right: number;
|
|
392
|
+
bottom: number;
|
|
393
|
+
left: number;
|
|
394
|
+
};
|
|
395
|
+
|
|
385
396
|
export declare function getHoveringCell(view: EditorView, event: MouseEvent): HoveringCellInfo | undefined;
|
|
386
397
|
|
|
387
398
|
export declare function getStateWithDefaults<Props extends Record<string, any> = Record<string, any>>(state: Partial<SignalState<Props>>, props: PropDeclarations<Props>): SignalState<Props>;
|
|
@@ -603,6 +614,13 @@ export { popoverTriggerProps as popoverTriggerProps_alias_1 }
|
|
|
603
614
|
|
|
604
615
|
export declare const queryContext: Context<string>;
|
|
605
616
|
|
|
617
|
+
export declare interface Rect {
|
|
618
|
+
top: number;
|
|
619
|
+
right: number;
|
|
620
|
+
bottom: number;
|
|
621
|
+
left: number;
|
|
622
|
+
}
|
|
623
|
+
|
|
606
624
|
declare class ResizableHandleElement extends ResizableHandleElement_base {
|
|
607
625
|
}
|
|
608
626
|
export { ResizableHandleElement }
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-ZGQ225UP.js";
|
|
4
4
|
import {
|
|
5
5
|
useEditorExtension
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WTW6FOH3.js";
|
|
7
7
|
|
|
8
8
|
// src/components/autocomplete/autocomplete-empty/element.gen.ts
|
|
9
9
|
import { defineCustomElement, registerCustomElement } from "@aria-ui/core";
|
|
@@ -54,9 +54,8 @@ function useAutocompleteItem(element, { state, emit }) {
|
|
|
54
54
|
useListboxItem(element, { state, emit });
|
|
55
55
|
const open = openContext.consume(element);
|
|
56
56
|
useEffect(element, () => {
|
|
57
|
-
var _a;
|
|
58
57
|
if (!state.value.peek() && open.get()) {
|
|
59
|
-
state.value.set(
|
|
58
|
+
state.value.set(element.textContent ?? "");
|
|
60
59
|
}
|
|
61
60
|
});
|
|
62
61
|
}
|
|
@@ -109,9 +108,8 @@ function useAutocompleteList(element, { state, emit }) {
|
|
|
109
108
|
);
|
|
110
109
|
useEffect2(element, () => {
|
|
111
110
|
element.addEventListener("valueChange", () => {
|
|
112
|
-
var _a;
|
|
113
111
|
if (onSubmit) {
|
|
114
|
-
|
|
112
|
+
onSubmit.get()?.();
|
|
115
113
|
}
|
|
116
114
|
});
|
|
117
115
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useEditorExtension
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WTW6FOH3.js";
|
|
4
4
|
|
|
5
5
|
// src/components/block-handle/block-handle-add/element.gen.ts
|
|
6
6
|
import { defineCustomElement, registerCustomElement } from "@aria-ui/core";
|
|
@@ -76,9 +76,8 @@ function useBlockHandleDraggable(host, { state }) {
|
|
|
76
76
|
}
|
|
77
77
|
function usePointerDownHandler(host, context, editor) {
|
|
78
78
|
useEventListener2(host, "pointerdown", () => {
|
|
79
|
-
|
|
80
|
-
const {
|
|
81
|
-
const { view } = (_b = editor.get()) != null ? _b : {};
|
|
79
|
+
const { pos } = context.get() ?? {};
|
|
80
|
+
const { view } = editor.get() ?? {};
|
|
82
81
|
if (pos == null || view == null) {
|
|
83
82
|
return;
|
|
84
83
|
}
|
|
@@ -92,9 +91,8 @@ function usePointerDownHandler(host, context, editor) {
|
|
|
92
91
|
}
|
|
93
92
|
function useDraggingPreview(host, context, editor) {
|
|
94
93
|
useEventListener2(host, "dragstart", (event) => {
|
|
95
|
-
var _a;
|
|
96
94
|
const hoverState = context.get();
|
|
97
|
-
const { view } =
|
|
95
|
+
const { view } = editor.get() ?? {};
|
|
98
96
|
if (!hoverState || !view || !event.dataTransfer) {
|
|
99
97
|
return;
|
|
100
98
|
}
|
|
@@ -157,6 +155,30 @@ import {
|
|
|
157
155
|
union
|
|
158
156
|
} from "@prosekit/core";
|
|
159
157
|
|
|
158
|
+
// src/utils/get-client-rect.ts
|
|
159
|
+
function getClientRect(element) {
|
|
160
|
+
const rect = element.getBoundingClientRect();
|
|
161
|
+
if (rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0) {
|
|
162
|
+
if (element.getClientRects().length === 0) {
|
|
163
|
+
const children = Array.from(element.children);
|
|
164
|
+
const rects = children.map((child) => getClientRect(child)).filter((x) => !!x);
|
|
165
|
+
if (rects.length === 0) {
|
|
166
|
+
return rect;
|
|
167
|
+
}
|
|
168
|
+
if (rects.length === 1) {
|
|
169
|
+
return rects[0];
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
top: Math.min(...rects.map((rect2) => rect2.top)),
|
|
173
|
+
right: Math.max(...rects.map((rect2) => rect2.right)),
|
|
174
|
+
bottom: Math.max(...rects.map((rect2) => rect2.bottom)),
|
|
175
|
+
left: Math.min(...rects.map((rect2) => rect2.left))
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return rect;
|
|
180
|
+
}
|
|
181
|
+
|
|
160
182
|
// src/utils/throttle.ts
|
|
161
183
|
function throttle(callback, wait) {
|
|
162
184
|
let lastTime = 0;
|
|
@@ -170,57 +192,39 @@ function throttle(callback, wait) {
|
|
|
170
192
|
}
|
|
171
193
|
|
|
172
194
|
// src/components/block-handle/block-handle-popover/pointer-move.ts
|
|
195
|
+
var TEXT_NODE = 3;
|
|
196
|
+
var ELEMENT_NODE = 1;
|
|
173
197
|
function defineElementHoverHandler(handler) {
|
|
198
|
+
const handleElement = (element, node, pos, parentElement) => {
|
|
199
|
+
const reference = {
|
|
200
|
+
contextElement: element,
|
|
201
|
+
getBoundingClientRect: () => {
|
|
202
|
+
const rect = findFirstLineRect(parentElement, element);
|
|
203
|
+
return rect ? fulfillRect(rect) : fallbackRect;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
handler(reference, { element, node, pos });
|
|
207
|
+
};
|
|
174
208
|
const handlePointerEvent = (view, event) => {
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
top: event.clientY,
|
|
179
|
-
// Use the center of the editor
|
|
180
|
-
left: rect.left + rect.width / 2
|
|
181
|
-
})) == null ? void 0 : _a.inside;
|
|
182
|
-
if (pos == null || pos < 0) {
|
|
209
|
+
const { x, y } = event;
|
|
210
|
+
const block = findBlockByCoordinate(view, x, y);
|
|
211
|
+
if (!block) {
|
|
183
212
|
handler(null, null);
|
|
184
213
|
return;
|
|
185
214
|
}
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const ancestorPos = $pos.before($pos.depth);
|
|
191
|
-
const node2 = view.state.doc.nodeAt(ancestorPos);
|
|
192
|
-
const element2 = view.nodeDOM(ancestorPos);
|
|
193
|
-
if (!element2 || !node2) {
|
|
194
|
-
handler(null, null);
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
const reference = {
|
|
198
|
-
contextElement: element2,
|
|
199
|
-
// Get the bounding client rect of the parent node, including its
|
|
200
|
-
// margins.
|
|
201
|
-
getBoundingClientRect: () => {
|
|
202
|
-
const rect2 = element2.getBoundingClientRect();
|
|
203
|
-
const style = window.getComputedStyle(element2);
|
|
204
|
-
const marginTop = Number.parseInt(style.marginTop, 10) || 0;
|
|
205
|
-
const marginRight = Number.parseInt(style.marginRight, 10) || 0;
|
|
206
|
-
const marginBottom = Number.parseInt(style.marginBottom, 10) || 0;
|
|
207
|
-
const marginLeft = Number.parseInt(style.marginLeft, 10) || 0;
|
|
208
|
-
return {
|
|
209
|
-
top: rect2.top - marginTop,
|
|
210
|
-
right: rect2.right + marginRight,
|
|
211
|
-
bottom: rect2.bottom + marginBottom,
|
|
212
|
-
left: rect2.left - marginLeft,
|
|
213
|
-
width: rect2.width + marginLeft + marginRight,
|
|
214
|
-
height: rect2.height + marginTop + marginBottom,
|
|
215
|
-
x: rect2.x - marginLeft,
|
|
216
|
-
y: rect2.y - marginTop
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
handler(reference, { element: element2, node: node2, pos: ancestorPos });
|
|
215
|
+
const { node, pos } = block;
|
|
216
|
+
const element = getElementAtPos(view, pos);
|
|
217
|
+
if (!element) {
|
|
218
|
+
handler(null, null);
|
|
221
219
|
return;
|
|
222
220
|
}
|
|
223
|
-
|
|
221
|
+
const $pos = view.state.doc.resolve(pos);
|
|
222
|
+
let parentElement;
|
|
223
|
+
if ($pos.depth > 0 && $pos.index($pos.depth) === 0) {
|
|
224
|
+
const parentPos = $pos.before($pos.depth);
|
|
225
|
+
parentElement = view.nodeDOM(parentPos);
|
|
226
|
+
}
|
|
227
|
+
handleElement(element, node, pos, parentElement);
|
|
224
228
|
};
|
|
225
229
|
return union(
|
|
226
230
|
defineDOMEventHandler("pointermove", throttle(handlePointerEvent, 200)),
|
|
@@ -228,6 +232,154 @@ function defineElementHoverHandler(handler) {
|
|
|
228
232
|
defineDOMEventHandler("keypress", () => handler(null, null))
|
|
229
233
|
);
|
|
230
234
|
}
|
|
235
|
+
function getElementAtPos(view, pos) {
|
|
236
|
+
const node = view.nodeDOM(pos);
|
|
237
|
+
if (node && node.nodeType === ELEMENT_NODE) {
|
|
238
|
+
return node;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function findBlockByCoordinate(view, x, y) {
|
|
242
|
+
const dom = view.dom;
|
|
243
|
+
const rect = getClientRect(dom);
|
|
244
|
+
if (!isWithinRect(rect, x, y)) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
let parent = view.state.doc;
|
|
248
|
+
let pos = -1;
|
|
249
|
+
while (parent) {
|
|
250
|
+
if (parent.isBlock && (parent.isTextblock || parent.isAtom)) {
|
|
251
|
+
return { node: parent, pos };
|
|
252
|
+
}
|
|
253
|
+
const children = [];
|
|
254
|
+
const positions = [];
|
|
255
|
+
parent.forEach((child, offset) => {
|
|
256
|
+
children.push(child);
|
|
257
|
+
positions.push(offset + pos + 1);
|
|
258
|
+
});
|
|
259
|
+
let lo = 0;
|
|
260
|
+
let hi = children.length - 1;
|
|
261
|
+
while (lo <= hi) {
|
|
262
|
+
const i = hi - (hi - lo >> 1);
|
|
263
|
+
const childDOM = view.nodeDOM(positions[i]);
|
|
264
|
+
const childRect = getNodeRect(childDOM);
|
|
265
|
+
if (!childRect) {
|
|
266
|
+
console.warn("[prosekit] Unable to get rect at position", positions[i]);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (childRect.top > y) {
|
|
270
|
+
hi = i - 1;
|
|
271
|
+
} else if (childRect.bottom < y) {
|
|
272
|
+
lo = i + 1;
|
|
273
|
+
} else {
|
|
274
|
+
lo = i;
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (lo > hi) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
parent = children[lo];
|
|
282
|
+
pos = positions[lo];
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
function getNodeRect(node) {
|
|
286
|
+
if (!node || node.nodeType !== ELEMENT_NODE) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const element = node;
|
|
290
|
+
if (!element.isConnected) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
return getClientRect(element);
|
|
294
|
+
}
|
|
295
|
+
function isWithinRect(rect, x, y) {
|
|
296
|
+
return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
|
|
297
|
+
}
|
|
298
|
+
function findFirstLineRect(outer, inner) {
|
|
299
|
+
if (outer && !outer.isConnected) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (inner && !inner.isConnected) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (outer && inner) {
|
|
306
|
+
const outerRect = findOuterRect(outer);
|
|
307
|
+
const innerRect = findFirstLineRectInNode(inner);
|
|
308
|
+
if (outerRect && innerRect) {
|
|
309
|
+
const { top, bottom } = innerRect;
|
|
310
|
+
const { left, right } = outerRect;
|
|
311
|
+
return { top, bottom, left, right };
|
|
312
|
+
} else {
|
|
313
|
+
return outerRect || innerRect;
|
|
314
|
+
}
|
|
315
|
+
} else if (outer) {
|
|
316
|
+
return findFirstLineRectInNode(outer);
|
|
317
|
+
} else if (inner) {
|
|
318
|
+
return findFirstLineRectInNode(inner);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function findOuterRect(node) {
|
|
322
|
+
if (node.nodeType !== ELEMENT_NODE) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
const element = node;
|
|
326
|
+
const rect = getClientRect(element);
|
|
327
|
+
const style = element.ownerDocument.defaultView?.getComputedStyle(element);
|
|
328
|
+
const marginLeft = style && Number.parseInt(style.marginLeft, 10) || 0;
|
|
329
|
+
const marginRight = style && Number.parseInt(style.marginRight, 10) || 0;
|
|
330
|
+
const left = rect.left - marginLeft;
|
|
331
|
+
const right = rect.right + marginRight;
|
|
332
|
+
return { top: rect.top, bottom: rect.bottom, left, right };
|
|
333
|
+
}
|
|
334
|
+
function findFirstLineRectInNode(node) {
|
|
335
|
+
switch (node.nodeType) {
|
|
336
|
+
case TEXT_NODE:
|
|
337
|
+
return findFirstLineRectInTextNode(node);
|
|
338
|
+
case ELEMENT_NODE:
|
|
339
|
+
return findFirstLineRectInElement(node);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function findFirstLineRectInTextNode(node) {
|
|
343
|
+
const ownerDocument = node.ownerDocument;
|
|
344
|
+
if (!ownerDocument) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
const range = ownerDocument.createRange();
|
|
348
|
+
range.setStart(node, 0);
|
|
349
|
+
range.setEnd(node, 0);
|
|
350
|
+
const rects = range.getClientRects();
|
|
351
|
+
return rects[0];
|
|
352
|
+
}
|
|
353
|
+
function findFirstLineRectInElement(element) {
|
|
354
|
+
if (element.nodeName === "BR") {
|
|
355
|
+
return element.getBoundingClientRect();
|
|
356
|
+
}
|
|
357
|
+
const rect = getClientRect(element);
|
|
358
|
+
const style = element.ownerDocument.defaultView?.getComputedStyle(element);
|
|
359
|
+
const marginLeft = style && Number.parseInt(style.marginLeft, 10) || 0;
|
|
360
|
+
const marginRight = style && Number.parseInt(style.marginRight, 10) || 0;
|
|
361
|
+
const left = rect.left - marginLeft;
|
|
362
|
+
const right = rect.right + marginRight;
|
|
363
|
+
const lineHeight = style && Number.parseInt(style.lineHeight, 10) || 24;
|
|
364
|
+
const paddingTop = style && Number.parseInt(style.paddingTop, 10) || 0;
|
|
365
|
+
const borderTop = style && Number.parseInt(style.borderTopWidth, 10) || 0;
|
|
366
|
+
const top = rect.top + paddingTop + borderTop;
|
|
367
|
+
const bottom = top + lineHeight;
|
|
368
|
+
return { top, bottom, left, right };
|
|
369
|
+
}
|
|
370
|
+
function fulfillRect({ top, right, bottom, left }) {
|
|
371
|
+
return { top, right, bottom, left, width: right - left, height: bottom - top, x: left, y: top };
|
|
372
|
+
}
|
|
373
|
+
var fallbackRect = Object.freeze({
|
|
374
|
+
top: -9999,
|
|
375
|
+
right: -9999,
|
|
376
|
+
bottom: -9999,
|
|
377
|
+
left: -9999,
|
|
378
|
+
width: 0,
|
|
379
|
+
height: 0,
|
|
380
|
+
x: -9999,
|
|
381
|
+
y: -9999
|
|
382
|
+
});
|
|
231
383
|
|
|
232
384
|
// src/components/block-handle/block-handle-popover/setup.ts
|
|
233
385
|
function useBlockHandlePopover(host, { state }) {
|
|
@@ -238,8 +390,7 @@ function useBlockHandlePopover(host, { state }) {
|
|
|
238
390
|
blockPopoverContext.provide(host, context);
|
|
239
391
|
const open = createSignal2(false);
|
|
240
392
|
useEffect2(host, () => {
|
|
241
|
-
|
|
242
|
-
open.set(!!((_a = context.get()) == null ? void 0 : _a.element));
|
|
393
|
+
open.set(!!context.get()?.element);
|
|
243
394
|
});
|
|
244
395
|
useHoverExtension(host, editor, (referenceValue, hoverState) => {
|
|
245
396
|
reference.set(referenceValue);
|
|
@@ -272,7 +423,10 @@ import {
|
|
|
272
423
|
var blockHandlePopoverProps = {
|
|
273
424
|
...overlayPositionerProps,
|
|
274
425
|
editor: { default: null },
|
|
275
|
-
placement: { default: "left
|
|
426
|
+
placement: { default: "left" },
|
|
427
|
+
// Enabling `hoist` will cause the block handle to have a small delay when
|
|
428
|
+
// scrolling the page.
|
|
429
|
+
hoist: { default: false }
|
|
276
430
|
};
|
|
277
431
|
var blockHandlePopoverEvents = {};
|
|
278
432
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useEditorExtension
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WTW6FOH3.js";
|
|
4
4
|
|
|
5
5
|
// src/components/inline-popover/inline-popover/element.gen.ts
|
|
6
6
|
import { defineCustomElement, registerCustomElement } from "@aria-ui/core";
|
|
@@ -69,7 +69,7 @@ function getDomDecoration(view) {
|
|
|
69
69
|
}
|
|
70
70
|
function getDomRange(view) {
|
|
71
71
|
const win = view.dom.ownerDocument.defaultView;
|
|
72
|
-
const selection = win
|
|
72
|
+
const selection = win?.getSelection();
|
|
73
73
|
if (!selection || selection.isCollapsed) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
@@ -121,19 +121,17 @@ function useResizableHandleState(host, state, context) {
|
|
|
121
121
|
let aspectRatio = 1;
|
|
122
122
|
const pointerPressing = createSignal(false);
|
|
123
123
|
const handlePointerDown = (event) => {
|
|
124
|
-
var _a;
|
|
125
124
|
event.preventDefault();
|
|
126
125
|
pointerPressing.set(true);
|
|
127
126
|
startX = event.x;
|
|
128
127
|
startY = event.y;
|
|
129
|
-
const size =
|
|
128
|
+
const size = context.onResizeStart.get()?.();
|
|
130
129
|
if (size) {
|
|
131
130
|
;
|
|
132
131
|
[width, height, aspectRatio] = size;
|
|
133
132
|
}
|
|
134
133
|
};
|
|
135
134
|
const handlePointerMove = (event) => {
|
|
136
|
-
var _a;
|
|
137
135
|
event.preventDefault();
|
|
138
136
|
const dx = event.x - startX;
|
|
139
137
|
const dy = event.y - startY;
|
|
@@ -145,13 +143,12 @@ function useResizableHandleState(host, state, context) {
|
|
|
145
143
|
dy,
|
|
146
144
|
aspectRatio
|
|
147
145
|
);
|
|
148
|
-
|
|
146
|
+
context.onResize.get()?.(w, h);
|
|
149
147
|
};
|
|
150
148
|
const handlePointerUp = (event) => {
|
|
151
|
-
var _a;
|
|
152
149
|
event.preventDefault();
|
|
153
150
|
pointerPressing.set(false);
|
|
154
|
-
|
|
151
|
+
context.onResizeEnd.get()?.();
|
|
155
152
|
};
|
|
156
153
|
useEffect(host, () => {
|
|
157
154
|
host.addEventListener("pointerdown", handlePointerDown);
|
|
@@ -200,9 +197,8 @@ import {
|
|
|
200
197
|
function useResizableRoot(host, { state, emit }) {
|
|
201
198
|
const resizing = createSignal2(false);
|
|
202
199
|
const onResizeStart = () => {
|
|
203
|
-
var _a;
|
|
204
200
|
const { width, height } = host.getBoundingClientRect();
|
|
205
|
-
let aspectRatio =
|
|
201
|
+
let aspectRatio = state.aspectRatio.peek() ?? width / height;
|
|
206
202
|
if (!isFinitePositiveNumber(aspectRatio)) {
|
|
207
203
|
aspectRatio = 0;
|
|
208
204
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-ZGQ225UP.js";
|
|
4
4
|
import {
|
|
5
5
|
useEditorExtension
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WTW6FOH3.js";
|
|
7
7
|
|
|
8
8
|
// src/components/table-handle/table-handle-column-root/element.gen.ts
|
|
9
9
|
import { defineCustomElement, registerCustomElement } from "@aria-ui/core";
|
|
@@ -34,13 +34,11 @@ function useTableHandleColumnRoot(host, { state }) {
|
|
|
34
34
|
const { editor, ...overlayState } = state;
|
|
35
35
|
const rootContext = tableHandleRootContext.consume(host);
|
|
36
36
|
const colFirstCellPos = createComputed(() => {
|
|
37
|
-
|
|
38
|
-
return (_a = rootContext.get()) == null ? void 0 : _a.colFirstCellPos;
|
|
37
|
+
return rootContext.get()?.colFirstCellPos;
|
|
39
38
|
});
|
|
40
39
|
const referenceCell = createComputed(() => {
|
|
41
|
-
var _a;
|
|
42
40
|
const pos = colFirstCellPos.get();
|
|
43
|
-
const view =
|
|
41
|
+
const view = editor.get()?.view;
|
|
44
42
|
if (!pos || !view) return null;
|
|
45
43
|
return view.nodeDOM(pos);
|
|
46
44
|
});
|
|
@@ -99,9 +97,8 @@ function useTableHandleColumnTrigger(host, { state }) {
|
|
|
99
97
|
useMenuTrigger(host);
|
|
100
98
|
const context = tableHandleRootContext.consume(host);
|
|
101
99
|
useEventListener(host, "pointerdown", () => {
|
|
102
|
-
var _a;
|
|
103
100
|
const editor = state.editor.peek();
|
|
104
|
-
const cellPos =
|
|
101
|
+
const cellPos = context.peek()?.cellPos;
|
|
105
102
|
if (!editor || !cellPos) return;
|
|
106
103
|
editor.exec(selectTableColumn({ head: cellPos }));
|
|
107
104
|
});
|
|
@@ -289,9 +286,8 @@ function isHoveringCellInfoEqual(a, b) {
|
|
|
289
286
|
return a.rowIndex === b.rowIndex && a.colIndex === b.colIndex && a.cellPos === b.cellPos && a.rowFirstCellPos === b.rowFirstCellPos && a.colFirstCellPos === b.colFirstCellPos;
|
|
290
287
|
}
|
|
291
288
|
function domCellAround(target) {
|
|
292
|
-
var _a;
|
|
293
289
|
while (target && target.nodeName != "TD" && target.nodeName != "TH") {
|
|
294
|
-
target =
|
|
290
|
+
target = target.classList?.contains("ProseMirror") ? null : target.parentNode;
|
|
295
291
|
}
|
|
296
292
|
return target;
|
|
297
293
|
}
|
|
@@ -361,18 +357,17 @@ function useHoveringCell(host, editor) {
|
|
|
361
357
|
function defineCellHoverHandler(handler) {
|
|
362
358
|
const pointerHandler = (view, event) => {
|
|
363
359
|
const hoveringCell = getHoveringCell(view, event);
|
|
364
|
-
return handler(hoveringCell
|
|
360
|
+
return handler(hoveringCell ?? null);
|
|
365
361
|
};
|
|
366
362
|
return defineDOMEventHandler2("pointerover", pointerHandler);
|
|
367
363
|
}
|
|
368
364
|
function useSelecting(host, editor, isInTable) {
|
|
369
365
|
const selecting = createSignal4(false);
|
|
370
366
|
useEffect3(host, () => {
|
|
371
|
-
var _a;
|
|
372
367
|
if (!isInTable.get()) {
|
|
373
368
|
return;
|
|
374
369
|
}
|
|
375
|
-
const root =
|
|
370
|
+
const root = editor.peek()?.view.root;
|
|
376
371
|
if (!root) {
|
|
377
372
|
return;
|
|
378
373
|
}
|
|
@@ -433,13 +428,11 @@ function useTableHandleRowRoot(host, { state }) {
|
|
|
433
428
|
const { editor, ...overlayState } = state;
|
|
434
429
|
const rootContext = tableHandleRootContext.consume(host);
|
|
435
430
|
const rowFirstCellPos = createComputed4(() => {
|
|
436
|
-
|
|
437
|
-
return (_a = rootContext.get()) == null ? void 0 : _a.rowFirstCellPos;
|
|
431
|
+
return rootContext.get()?.rowFirstCellPos;
|
|
438
432
|
});
|
|
439
433
|
const referenceCell = createComputed4(() => {
|
|
440
|
-
var _a;
|
|
441
434
|
const pos = rowFirstCellPos.get();
|
|
442
|
-
const view =
|
|
435
|
+
const view = editor.get()?.view;
|
|
443
436
|
if (!pos || !view) return null;
|
|
444
437
|
return view.nodeDOM(pos);
|
|
445
438
|
});
|
|
@@ -501,9 +494,8 @@ function useTableHandleRowTrigger(host, {
|
|
|
501
494
|
useMenuTrigger2(host);
|
|
502
495
|
const context = tableHandleRootContext.consume(host);
|
|
503
496
|
useEventListener2(host, "pointerdown", () => {
|
|
504
|
-
var _a;
|
|
505
497
|
const editor = state.editor.peek();
|
|
506
|
-
const cellPos =
|
|
498
|
+
const cellPos = context.peek()?.cellPos;
|
|
507
499
|
if (!editor || !cellPos) return;
|
|
508
500
|
editor.exec(selectTableRow({ head: cellPos }));
|
|
509
501
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosekit/web",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.4",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "ocavue",
|
|
@@ -71,31 +71,31 @@
|
|
|
71
71
|
],
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@aria-ui/collection": "^0.0.4",
|
|
74
|
-
"@aria-ui/core": "^0.0.
|
|
75
|
-
"@aria-ui/listbox": "^0.0.
|
|
76
|
-
"@aria-ui/menu": "^0.0.
|
|
77
|
-
"@aria-ui/overlay": "^0.0.
|
|
78
|
-
"@aria-ui/popover": "^0.0.
|
|
79
|
-
"@aria-ui/presence": "^0.0.
|
|
80
|
-
"@aria-ui/tooltip": "^0.0.
|
|
81
|
-
"@floating-ui/dom": "^1.6.
|
|
82
|
-
"@zag-js/dom-query": "^0.
|
|
74
|
+
"@aria-ui/core": "^0.0.20",
|
|
75
|
+
"@aria-ui/listbox": "^0.0.23",
|
|
76
|
+
"@aria-ui/menu": "^0.0.18",
|
|
77
|
+
"@aria-ui/overlay": "^0.0.23",
|
|
78
|
+
"@aria-ui/popover": "^0.0.26",
|
|
79
|
+
"@aria-ui/presence": "^0.0.18",
|
|
80
|
+
"@aria-ui/tooltip": "^0.0.28",
|
|
81
|
+
"@floating-ui/dom": "^1.6.13",
|
|
82
|
+
"@zag-js/dom-query": "^0.81.2",
|
|
83
83
|
"just-map-values": "^3.2.0",
|
|
84
84
|
"just-omit": "^2.2.0",
|
|
85
|
-
"prosemirror-tables": "^1.6.
|
|
85
|
+
"prosemirror-tables": "^1.6.2",
|
|
86
86
|
"@prosekit/core": "^0.7.14",
|
|
87
87
|
"@prosekit/extensions": "^0.7.23",
|
|
88
88
|
"@prosekit/pm": "^0.1.9"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"tsup": "^8.3.5",
|
|
92
|
-
"typescript": "~5.
|
|
92
|
+
"typescript": "~5.7.2",
|
|
93
93
|
"vitest": "^2.1.8",
|
|
94
94
|
"@prosekit/dev": "0.0.0"
|
|
95
95
|
},
|
|
96
96
|
"scripts": {
|
|
97
|
-
"build:
|
|
98
|
-
"build:
|
|
97
|
+
"build:tsc": "tsc -b tsconfig.json",
|
|
98
|
+
"build:tsup": "tsup"
|
|
99
99
|
},
|
|
100
100
|
"types": "./dist/prosekit-web.d.ts",
|
|
101
101
|
"typesVersions": {
|