@prosekit/web 0.3.13 → 0.3.14
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.
|
@@ -179,6 +179,9 @@ declare const BlockDragHandleElement_base: {
|
|
|
179
179
|
prototype: HTMLElement;
|
|
180
180
|
};
|
|
181
181
|
|
|
182
|
+
/**
|
|
183
|
+
* @deprecated Use `BlockHandleDraggableProps` instead.
|
|
184
|
+
*/
|
|
182
185
|
declare interface BlockDragHandleProps {
|
|
183
186
|
/**
|
|
184
187
|
* The ProseKit editor instance.
|
|
@@ -190,14 +193,67 @@ declare interface BlockDragHandleProps {
|
|
|
190
193
|
export { BlockDragHandleProps }
|
|
191
194
|
export { BlockDragHandleProps as BlockDragHandleProps_alias_1 }
|
|
192
195
|
|
|
196
|
+
declare class BlockHandleAddElement extends BlockHandleAddElement_base {
|
|
197
|
+
}
|
|
198
|
+
export { BlockHandleAddElement }
|
|
199
|
+
export { BlockHandleAddElement as BlockHandleAddElement_alias_1 }
|
|
200
|
+
|
|
201
|
+
declare const BlockHandleAddElement_base: {
|
|
202
|
+
new (): BaseElement & BlockHandleAddProps;
|
|
203
|
+
prototype: HTMLElement;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
declare interface BlockHandleAddProps {
|
|
207
|
+
/**
|
|
208
|
+
* The ProseKit editor instance.
|
|
209
|
+
*
|
|
210
|
+
* @default null
|
|
211
|
+
*/
|
|
212
|
+
editor: Editor | null;
|
|
213
|
+
}
|
|
214
|
+
export { BlockHandleAddProps }
|
|
215
|
+
export { BlockHandleAddProps as BlockHandleAddProps_alias_1 }
|
|
216
|
+
|
|
217
|
+
declare class BlockHandleDraggableElement extends BlockHandleDraggableElement_base {
|
|
218
|
+
}
|
|
219
|
+
export { BlockHandleDraggableElement }
|
|
220
|
+
export { BlockHandleDraggableElement as BlockHandleDraggableElement_alias_1 }
|
|
221
|
+
|
|
222
|
+
declare const BlockHandleDraggableElement_base: {
|
|
223
|
+
new (): BaseElement & BlockHandleDraggableProps;
|
|
224
|
+
prototype: HTMLElement;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
declare interface BlockHandleDraggableProps {
|
|
228
|
+
/**
|
|
229
|
+
* The ProseKit editor instance.
|
|
230
|
+
*
|
|
231
|
+
* @default null
|
|
232
|
+
*/
|
|
233
|
+
editor: Editor | null;
|
|
234
|
+
}
|
|
235
|
+
export { BlockHandleDraggableProps }
|
|
236
|
+
export { BlockHandleDraggableProps as BlockHandleDraggableProps_alias_1 }
|
|
237
|
+
|
|
238
|
+
declare class BlockHandlePopoverElement extends BlockHandlePopoverElement_base {
|
|
239
|
+
}
|
|
240
|
+
export { BlockHandlePopoverElement }
|
|
241
|
+
export { BlockHandlePopoverElement as BlockHandlePopoverElement_alias_1 }
|
|
242
|
+
|
|
243
|
+
declare const BlockHandlePopoverElement_base: {
|
|
244
|
+
new (): BaseElement & BlockHandlePopoverProps;
|
|
245
|
+
prototype: HTMLElement;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
declare interface BlockHandlePopoverProps extends BlockPopoverProps {
|
|
249
|
+
}
|
|
250
|
+
export { BlockHandlePopoverProps }
|
|
251
|
+
export { BlockHandlePopoverProps as BlockHandlePopoverProps_alias_1 }
|
|
252
|
+
|
|
193
253
|
/**
|
|
194
254
|
* @internal
|
|
195
255
|
*/
|
|
196
|
-
export declare
|
|
197
|
-
pos: number | null;
|
|
198
|
-
node: ProseMirrorNode | null;
|
|
199
|
-
element: HTMLElement | null;
|
|
200
|
-
}
|
|
256
|
+
export declare type BlockPopoverContext = HoverState | null;
|
|
201
257
|
|
|
202
258
|
/**
|
|
203
259
|
* @internal
|
|
@@ -298,6 +354,43 @@ declare const defaultBlockDragHandleProps: Readonly<{
|
|
|
298
354
|
export { defaultBlockDragHandleProps }
|
|
299
355
|
export { defaultBlockDragHandleProps as defaultBlockDragHandleProps_alias_1 }
|
|
300
356
|
|
|
357
|
+
declare const defaultBlockHandleAddProps: Readonly<{
|
|
358
|
+
editor: null;
|
|
359
|
+
}>;
|
|
360
|
+
export { defaultBlockHandleAddProps }
|
|
361
|
+
export { defaultBlockHandleAddProps as defaultBlockHandleAddProps_alias_1 }
|
|
362
|
+
|
|
363
|
+
declare const defaultBlockHandleDraggableProps: Readonly<{
|
|
364
|
+
editor: null;
|
|
365
|
+
}>;
|
|
366
|
+
export { defaultBlockHandleDraggableProps }
|
|
367
|
+
export { defaultBlockHandleDraggableProps as defaultBlockHandleDraggableProps_alias_1 }
|
|
368
|
+
|
|
369
|
+
declare const defaultBlockHandlePopoverProps: Readonly<{
|
|
370
|
+
editor: null;
|
|
371
|
+
placement: "left-start";
|
|
372
|
+
offset: 4;
|
|
373
|
+
strategy: "absolute";
|
|
374
|
+
autoUpdate: true;
|
|
375
|
+
hoist: false;
|
|
376
|
+
transform: false;
|
|
377
|
+
flip: false;
|
|
378
|
+
shift: false;
|
|
379
|
+
overlap: false;
|
|
380
|
+
fitViewport: false;
|
|
381
|
+
sameWidth: false;
|
|
382
|
+
sameHeight: false;
|
|
383
|
+
inline: false;
|
|
384
|
+
hide: false;
|
|
385
|
+
boundary: "clippingAncestors";
|
|
386
|
+
rootBoundary: "viewport";
|
|
387
|
+
overflowPadding: 0;
|
|
388
|
+
elementContext: "floating";
|
|
389
|
+
altBoundary: true;
|
|
390
|
+
}>;
|
|
391
|
+
export { defaultBlockHandlePopoverProps }
|
|
392
|
+
export { defaultBlockHandlePopoverProps as defaultBlockHandlePopoverProps_alias_1 }
|
|
393
|
+
|
|
301
394
|
declare const defaultBlockPopoverProps: Readonly<{
|
|
302
395
|
editor: null;
|
|
303
396
|
placement: "left-start";
|
|
@@ -527,7 +620,7 @@ export declare function defineCustomElement(name: string, constructor: CustomEle
|
|
|
527
620
|
|
|
528
621
|
export declare function defineElementHoverHandler(handler: ElementHoverHandler): Union<readonly [Extension<ExtensionTyping<any, any, any>>, Extension<ExtensionTyping<any, any, any>>, Extension<ExtensionTyping<any, any, any>>]>;
|
|
529
622
|
|
|
530
|
-
export declare type ElementHoverHandler = (reference: VirtualElement | null,
|
|
623
|
+
export declare type ElementHoverHandler = (reference: VirtualElement | null, hoverState: HoverState | null) => void;
|
|
531
624
|
|
|
532
625
|
export declare function getHoveringCell(view: EditorView, event: MouseEvent): HoveringCellInfo | undefined;
|
|
533
626
|
|
|
@@ -541,6 +634,15 @@ export declare interface HoveringCellInfo {
|
|
|
541
634
|
colFirstCellPos: number;
|
|
542
635
|
}
|
|
543
636
|
|
|
637
|
+
/**
|
|
638
|
+
* @internal
|
|
639
|
+
*/
|
|
640
|
+
export declare interface HoverState {
|
|
641
|
+
element: HTMLElement;
|
|
642
|
+
node: ProseMirrorNode;
|
|
643
|
+
pos: number;
|
|
644
|
+
}
|
|
645
|
+
|
|
544
646
|
declare class InlinePopoverElement extends InlinePopoverElement_base {
|
|
545
647
|
}
|
|
546
648
|
export { InlinePopoverElement }
|
|
@@ -969,8 +1071,20 @@ export declare function useAutocompleteList(element: ConnectableElement, state:
|
|
|
969
1071
|
|
|
970
1072
|
export declare function useAutocompletePopover(host: ConnectableElement, state: SignalState<AutocompletePopoverProps>): void;
|
|
971
1073
|
|
|
1074
|
+
/**
|
|
1075
|
+
* @deprecated Use `useBlockHandleDraggable` instead.
|
|
1076
|
+
*/
|
|
972
1077
|
export declare function useBlockDragHandle(host: ConnectableElement, state: SignalState<BlockDragHandleProps>): void;
|
|
973
1078
|
|
|
1079
|
+
export declare function useBlockHandleAdd(host: ConnectableElement, state: SignalState<BlockHandleAddProps>): void;
|
|
1080
|
+
|
|
1081
|
+
export declare function useBlockHandleDraggable(host: ConnectableElement, state: SignalState<BlockHandleDraggableProps>): void;
|
|
1082
|
+
|
|
1083
|
+
export declare function useBlockHandlePopover(host: ConnectableElement, state: SignalState<BlockHandlePopoverProps>): void;
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* @deprecated Use `useBlockHandlePopover` instead.
|
|
1087
|
+
*/
|
|
974
1088
|
export declare function useBlockPopover(host: ConnectableElement, state: SignalState<BlockPopoverProps>): void;
|
|
975
1089
|
|
|
976
1090
|
export declare function useEditorExtension(host: ConnectableElement, editor: ReadonlySignal<Editor | null>, extension: Extension): void;
|
|
@@ -82,7 +82,6 @@ var defaultAutocompleteListProps = {
|
|
|
82
82
|
|
|
83
83
|
// src/components/autocomplete/autocomplete-list/state.ts
|
|
84
84
|
import {
|
|
85
|
-
createSignal,
|
|
86
85
|
mapSignals,
|
|
87
86
|
useEffect as useEffect2
|
|
88
87
|
} from "@aria-ui/core";
|
|
@@ -144,14 +143,11 @@ function useAutocompleteList(element, state) {
|
|
|
144
143
|
});
|
|
145
144
|
}
|
|
146
145
|
function useKeyboardHandler(element, open, editor) {
|
|
147
|
-
|
|
148
|
-
null
|
|
149
|
-
);
|
|
146
|
+
let keydownHandler = null;
|
|
150
147
|
let disposeKeydownHandler;
|
|
151
148
|
useEffect2(element, () => {
|
|
152
149
|
const editorValue = editor.get();
|
|
153
|
-
|
|
154
|
-
if (!editorValue || !keydownHandlerValue) {
|
|
150
|
+
if (!editorValue) {
|
|
155
151
|
return;
|
|
156
152
|
}
|
|
157
153
|
const extension = defineDOMEventHandler(
|
|
@@ -160,7 +156,7 @@ function useKeyboardHandler(element, open, editor) {
|
|
|
160
156
|
if (view.composing || event.defaultPrevented || !open.get()) {
|
|
161
157
|
return false;
|
|
162
158
|
}
|
|
163
|
-
|
|
159
|
+
keydownHandler == null ? void 0 : keydownHandler(event);
|
|
164
160
|
return event.defaultPrevented;
|
|
165
161
|
}
|
|
166
162
|
);
|
|
@@ -170,7 +166,7 @@ function useKeyboardHandler(element, open, editor) {
|
|
|
170
166
|
);
|
|
171
167
|
});
|
|
172
168
|
return (keydownHandlerValue) => {
|
|
173
|
-
keydownHandler
|
|
169
|
+
keydownHandler = keydownHandlerValue;
|
|
174
170
|
return () => {
|
|
175
171
|
disposeKeydownHandler == null ? void 0 : disposeKeydownHandler();
|
|
176
172
|
disposeKeydownHandler = void 0;
|
|
@@ -210,7 +206,7 @@ var defaultAutocompletePopoverProps = Object.freeze({
|
|
|
210
206
|
// src/components/autocomplete/autocomplete-popover/state.ts
|
|
211
207
|
import {
|
|
212
208
|
createComputed,
|
|
213
|
-
createSignal as
|
|
209
|
+
createSignal as createSignal2,
|
|
214
210
|
useAnimationFrame,
|
|
215
211
|
useAttribute,
|
|
216
212
|
useEffect as useEffect4
|
|
@@ -229,11 +225,11 @@ import {
|
|
|
229
225
|
|
|
230
226
|
// src/hooks/use-first-rendering.ts
|
|
231
227
|
import {
|
|
232
|
-
createSignal
|
|
228
|
+
createSignal,
|
|
233
229
|
useEffect as useEffect3
|
|
234
230
|
} from "@aria-ui/core";
|
|
235
231
|
function useFirstRendering(host) {
|
|
236
|
-
const firstRendering =
|
|
232
|
+
const firstRendering = createSignal(true);
|
|
237
233
|
useEffect3(host, () => {
|
|
238
234
|
requestAnimationFrame(() => {
|
|
239
235
|
firstRendering.set(false);
|
|
@@ -250,10 +246,10 @@ function defaultQueryBuilder(match) {
|
|
|
250
246
|
// src/components/autocomplete/autocomplete-popover/state.ts
|
|
251
247
|
function useAutocompletePopover(host, state) {
|
|
252
248
|
const { editor, regex, ...overlayState } = state;
|
|
253
|
-
const reference =
|
|
254
|
-
const query =
|
|
255
|
-
const onDismiss =
|
|
256
|
-
const onSubmit =
|
|
249
|
+
const reference = createSignal2(null);
|
|
250
|
+
const query = createSignal2("");
|
|
251
|
+
const onDismiss = createSignal2(null);
|
|
252
|
+
const onSubmit = createSignal2(null);
|
|
257
253
|
const presence = createComputed(() => !!reference.get());
|
|
258
254
|
queryContext.provide(host, query);
|
|
259
255
|
onSubmitContext.provide(host, onSubmit);
|
|
@@ -297,7 +293,7 @@ function useAutocompleteExtension(host, editor, regex, reference, query, onDismi
|
|
|
297
293
|
if (!editorValue || !regexValue) {
|
|
298
294
|
return;
|
|
299
295
|
}
|
|
300
|
-
|
|
296
|
+
const rule = createAutocompleteRule(
|
|
301
297
|
editorValue,
|
|
302
298
|
regexValue,
|
|
303
299
|
reference,
|
|
@@ -305,9 +301,11 @@ function useAutocompleteExtension(host, editor, regex, reference, query, onDismi
|
|
|
305
301
|
onDismiss,
|
|
306
302
|
onSubmit
|
|
307
303
|
);
|
|
304
|
+
const extension = defineAutocomplete(rule);
|
|
305
|
+
return editorValue.use(extension);
|
|
308
306
|
});
|
|
309
307
|
}
|
|
310
|
-
function
|
|
308
|
+
function createAutocompleteRule(editor, regex, reference, query, onDismiss, onSubmit) {
|
|
311
309
|
const handleEnter = (options) => {
|
|
312
310
|
const span = editor.view.dom.querySelector(".prosemirror-prediction-match");
|
|
313
311
|
if (span) {
|
|
@@ -323,13 +321,11 @@ function addAutocompleteExtension(editor, regex, reference, query, onDismiss, on
|
|
|
323
321
|
onDismiss.set(null);
|
|
324
322
|
onSubmit.set(null);
|
|
325
323
|
};
|
|
326
|
-
|
|
324
|
+
return new AutocompleteRule({
|
|
327
325
|
regex,
|
|
328
326
|
onEnter: handleEnter,
|
|
329
327
|
onLeave: handleLeave
|
|
330
328
|
});
|
|
331
|
-
const extension = defineAutocomplete(rule);
|
|
332
|
-
return editor.use(extension);
|
|
333
329
|
}
|
|
334
330
|
function createKeymapHandler(handler, enabled) {
|
|
335
331
|
return () => {
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
export { BlockDragHandleElement } from './_tsup-dts-rollup';
|
|
2
2
|
export { defaultBlockDragHandleProps } from './_tsup-dts-rollup';
|
|
3
3
|
export { BlockDragHandleProps } from './_tsup-dts-rollup';
|
|
4
|
+
export { BlockHandleAddElement } from './_tsup-dts-rollup';
|
|
5
|
+
export { defaultBlockHandleAddProps } from './_tsup-dts-rollup';
|
|
6
|
+
export { BlockHandleAddProps } from './_tsup-dts-rollup';
|
|
7
|
+
export { BlockHandleDraggableElement } from './_tsup-dts-rollup';
|
|
8
|
+
export { defaultBlockHandleDraggableProps } from './_tsup-dts-rollup';
|
|
9
|
+
export { BlockHandleDraggableProps } from './_tsup-dts-rollup';
|
|
10
|
+
export { BlockHandlePopoverElement } from './_tsup-dts-rollup';
|
|
11
|
+
export { defaultBlockHandlePopoverProps } from './_tsup-dts-rollup';
|
|
12
|
+
export { BlockHandlePopoverProps } from './_tsup-dts-rollup';
|
|
4
13
|
export { BlockPopoverElement } from './_tsup-dts-rollup';
|
|
5
14
|
export { defaultBlockPopoverProps } from './_tsup-dts-rollup';
|
|
6
15
|
export { BlockPopoverProps } from './_tsup-dts-rollup';
|
|
@@ -15,6 +15,8 @@ var defaultBlockDragHandleProps = Object.freeze({
|
|
|
15
15
|
|
|
16
16
|
// src/components/block-handle/block-drag-handle/state.ts
|
|
17
17
|
import {
|
|
18
|
+
createSignal,
|
|
19
|
+
useAttribute,
|
|
18
20
|
useEffect,
|
|
19
21
|
useEventListener
|
|
20
22
|
} from "@aria-ui/core";
|
|
@@ -25,11 +27,7 @@ import { NodeSelection } from "@prosekit/pm/state";
|
|
|
25
27
|
import { createContext } from "@aria-ui/core";
|
|
26
28
|
var blockPopoverContext = createContext(
|
|
27
29
|
"prosekit-block-popover-context",
|
|
28
|
-
|
|
29
|
-
pos: null,
|
|
30
|
-
node: null,
|
|
31
|
-
element: null
|
|
32
|
-
}
|
|
30
|
+
null
|
|
33
31
|
);
|
|
34
32
|
|
|
35
33
|
// src/components/block-handle/block-drag-handle/state.ts
|
|
@@ -38,10 +36,15 @@ function useBlockDragHandle(host, state) {
|
|
|
38
36
|
useEffect(host, () => {
|
|
39
37
|
host.draggable = true;
|
|
40
38
|
});
|
|
39
|
+
usePointerDownHandler(host, context, state.editor);
|
|
40
|
+
useDraggingPreview(host, context, state.editor);
|
|
41
|
+
useDataDraggingAttribute(host);
|
|
42
|
+
}
|
|
43
|
+
function usePointerDownHandler(host, context, editor) {
|
|
41
44
|
useEventListener(host, "pointerdown", () => {
|
|
42
45
|
var _a, _b;
|
|
43
46
|
const { pos } = (_a = context.get()) != null ? _a : {};
|
|
44
|
-
const { view } = (_b =
|
|
47
|
+
const { view } = (_b = editor.get()) != null ? _b : {};
|
|
45
48
|
if (pos == null || view == null) {
|
|
46
49
|
return;
|
|
47
50
|
}
|
|
@@ -52,13 +55,16 @@ function useBlockDragHandle(host, state) {
|
|
|
52
55
|
view.focus();
|
|
53
56
|
});
|
|
54
57
|
});
|
|
58
|
+
}
|
|
59
|
+
function useDraggingPreview(host, context, editor) {
|
|
55
60
|
useEventListener(host, "dragstart", (event) => {
|
|
56
|
-
var _a
|
|
57
|
-
const
|
|
58
|
-
const { view } = (
|
|
59
|
-
if (
|
|
61
|
+
var _a;
|
|
62
|
+
const hoverState = context.get();
|
|
63
|
+
const { view } = (_a = editor.get()) != null ? _a : {};
|
|
64
|
+
if (!hoverState || !view || !event.dataTransfer) {
|
|
60
65
|
return;
|
|
61
66
|
}
|
|
67
|
+
const { element, node } = hoverState;
|
|
62
68
|
event.dataTransfer.clearData();
|
|
63
69
|
event.dataTransfer.setData("text/html", element.outerHTML);
|
|
64
70
|
event.dataTransfer.effectAllowed = "copyMove";
|
|
@@ -69,15 +75,82 @@ function useBlockDragHandle(host, state) {
|
|
|
69
75
|
};
|
|
70
76
|
});
|
|
71
77
|
}
|
|
78
|
+
function useDataDraggingAttribute(host) {
|
|
79
|
+
const dragging = useDragging(host);
|
|
80
|
+
useAttribute(host, "data-dragging", () => dragging.get() ? "" : void 0);
|
|
81
|
+
}
|
|
82
|
+
function useDragging(host) {
|
|
83
|
+
const dragging = createSignal(false);
|
|
84
|
+
useEventListener(host, "dragstart", () => {
|
|
85
|
+
dragging.set(true);
|
|
86
|
+
});
|
|
87
|
+
useEventListener(host, "dragend", () => {
|
|
88
|
+
dragging.set(false);
|
|
89
|
+
});
|
|
90
|
+
return dragging;
|
|
91
|
+
}
|
|
72
92
|
|
|
73
93
|
// src/components/block-handle/block-drag-handle/element.gen.ts
|
|
74
94
|
var BlockDragHandleElement = class extends ElementBuilder(useBlockDragHandle, defaultBlockDragHandleProps) {
|
|
75
95
|
};
|
|
76
96
|
defineCustomElement("prosekit-block-drag-handle", BlockDragHandleElement);
|
|
77
97
|
|
|
78
|
-
// src/components/block-handle/block-
|
|
98
|
+
// src/components/block-handle/block-handle-add/element.gen.ts
|
|
79
99
|
import { ElementBuilder as ElementBuilder2 } from "@aria-ui/core";
|
|
80
100
|
|
|
101
|
+
// src/components/block-handle/block-handle-add/props.ts
|
|
102
|
+
var defaultBlockHandleAddProps = Object.freeze({
|
|
103
|
+
editor: null
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// src/components/block-handle/block-handle-add/state.ts
|
|
107
|
+
import {
|
|
108
|
+
useEventListener as useEventListener2
|
|
109
|
+
} from "@aria-ui/core";
|
|
110
|
+
import { insertDefaultBlock } from "@prosekit/core";
|
|
111
|
+
function useBlockHandleAdd(host, state) {
|
|
112
|
+
const context = blockPopoverContext.consume(host);
|
|
113
|
+
useEventListener2(host, "pointerdown", (event) => {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
const editor = state.editor.get();
|
|
116
|
+
const hoverState = context.get();
|
|
117
|
+
if (!editor || !hoverState) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const { node, pos } = hoverState;
|
|
121
|
+
editor.exec(insertDefaultBlock({ pos: pos + node.nodeSize }));
|
|
122
|
+
editor.focus();
|
|
123
|
+
context.set(null);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/components/block-handle/block-handle-add/element.gen.ts
|
|
128
|
+
var BlockHandleAddElement = class extends ElementBuilder2(useBlockHandleAdd, defaultBlockHandleAddProps) {
|
|
129
|
+
};
|
|
130
|
+
defineCustomElement("prosekit-block-handle-add", BlockHandleAddElement);
|
|
131
|
+
|
|
132
|
+
// src/components/block-handle/block-handle-draggable/element.gen.ts
|
|
133
|
+
import { ElementBuilder as ElementBuilder3 } from "@aria-ui/core";
|
|
134
|
+
|
|
135
|
+
// src/components/block-handle/block-handle-draggable/props.ts
|
|
136
|
+
var defaultBlockHandleDraggableProps = Object.freeze({
|
|
137
|
+
editor: null
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// src/components/block-handle/block-handle-draggable/state.ts
|
|
141
|
+
import "@aria-ui/core";
|
|
142
|
+
function useBlockHandleDraggable(host, state) {
|
|
143
|
+
useBlockDragHandle(host, state);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// src/components/block-handle/block-handle-draggable/element.gen.ts
|
|
147
|
+
var BlockHandleDraggableElement = class extends ElementBuilder3(useBlockHandleDraggable, defaultBlockHandleDraggableProps) {
|
|
148
|
+
};
|
|
149
|
+
defineCustomElement("prosekit-block-handle-draggable", BlockHandleDraggableElement);
|
|
150
|
+
|
|
151
|
+
// src/components/block-handle/block-handle-popover/element.gen.ts
|
|
152
|
+
import { ElementBuilder as ElementBuilder4 } from "@aria-ui/core";
|
|
153
|
+
|
|
81
154
|
// src/components/block-handle/block-popover/props.ts
|
|
82
155
|
import {
|
|
83
156
|
defaultOverlayPositionerProps
|
|
@@ -89,11 +162,18 @@ var defaultBlockPopoverProps = Object.freeze({
|
|
|
89
162
|
offset: 4
|
|
90
163
|
});
|
|
91
164
|
|
|
165
|
+
// src/components/block-handle/block-handle-popover/props.ts
|
|
166
|
+
var defaultBlockHandlePopoverProps = Object.freeze({
|
|
167
|
+
...defaultBlockPopoverProps
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// src/components/block-handle/block-handle-popover/state.ts
|
|
171
|
+
import "@aria-ui/core";
|
|
172
|
+
|
|
92
173
|
// src/components/block-handle/block-popover/state.ts
|
|
93
174
|
import {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
useAttribute,
|
|
175
|
+
createSignal as createSignal2,
|
|
176
|
+
useAttribute as useAttribute2,
|
|
97
177
|
useEffect as useEffect2
|
|
98
178
|
} from "@aria-ui/core";
|
|
99
179
|
import { useOverlayPositionerState } from "@aria-ui/overlay";
|
|
@@ -125,7 +205,7 @@ function defineElementHoverHandler(handler) {
|
|
|
125
205
|
left: rect.left + rect.width / 2
|
|
126
206
|
})) == null ? void 0 : _a.inside;
|
|
127
207
|
if (pos == null || pos < 0) {
|
|
128
|
-
handler(null, null
|
|
208
|
+
handler(null, null);
|
|
129
209
|
return;
|
|
130
210
|
}
|
|
131
211
|
const $pos = view.state.doc.resolve(pos);
|
|
@@ -135,8 +215,8 @@ function defineElementHoverHandler(handler) {
|
|
|
135
215
|
const ancestorPos = $pos.before($pos.depth);
|
|
136
216
|
const node2 = view.state.doc.nodeAt(ancestorPos);
|
|
137
217
|
const element2 = view.nodeDOM(ancestorPos);
|
|
138
|
-
if (!element2) {
|
|
139
|
-
handler(null, null
|
|
218
|
+
if (!element2 || !node2) {
|
|
219
|
+
handler(null, null);
|
|
140
220
|
return;
|
|
141
221
|
}
|
|
142
222
|
const reference = {
|
|
@@ -162,64 +242,78 @@ function defineElementHoverHandler(handler) {
|
|
|
162
242
|
};
|
|
163
243
|
}
|
|
164
244
|
};
|
|
165
|
-
handler(reference, element2, node2, ancestorPos);
|
|
245
|
+
handler(reference, { element: element2, node: node2, pos: ancestorPos });
|
|
166
246
|
return;
|
|
167
247
|
}
|
|
168
|
-
handler(element, element, node, pos);
|
|
248
|
+
handler(element, element && node && { element, node, pos });
|
|
169
249
|
};
|
|
170
250
|
return union(
|
|
171
251
|
defineDOMEventHandler("pointermove", throttle(handlePointerEvent, 200)),
|
|
172
252
|
defineDOMEventHandler("pointerout", handlePointerEvent),
|
|
173
|
-
defineDOMEventHandler("keypress", () => handler(null, null
|
|
253
|
+
defineDOMEventHandler("keypress", () => handler(null, null))
|
|
174
254
|
);
|
|
175
255
|
}
|
|
176
256
|
|
|
177
257
|
// src/components/block-handle/block-popover/state.ts
|
|
178
258
|
function useBlockPopover(host, state) {
|
|
179
259
|
const { editor, ...overlayState } = state;
|
|
180
|
-
const reference =
|
|
260
|
+
const reference = createSignal2(null);
|
|
181
261
|
useOverlayPositionerState(host, overlayState, { reference });
|
|
182
|
-
const context =
|
|
183
|
-
pos: null,
|
|
184
|
-
node: null,
|
|
185
|
-
element: null
|
|
186
|
-
});
|
|
262
|
+
const context = createSignal2(null);
|
|
187
263
|
blockPopoverContext.provide(host, context);
|
|
188
|
-
const open =
|
|
264
|
+
const open = createSignal2(false);
|
|
189
265
|
useEffect2(host, () => {
|
|
190
|
-
|
|
266
|
+
var _a;
|
|
267
|
+
open.set(!!((_a = context.get()) == null ? void 0 : _a.element));
|
|
191
268
|
});
|
|
192
|
-
useHoverExtension(host, editor, (referenceValue,
|
|
269
|
+
useHoverExtension(host, editor, (referenceValue, hoverState) => {
|
|
193
270
|
reference.set(referenceValue);
|
|
194
|
-
context.set(
|
|
271
|
+
context.set(hoverState);
|
|
195
272
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
usePresence(host, presence);
|
|
273
|
+
useAttribute2(host, "data-state", () => open.get() ? "open" : "closed");
|
|
274
|
+
usePresence(host, open);
|
|
199
275
|
}
|
|
200
276
|
function useHoverExtension(host, editor, handler) {
|
|
201
|
-
let
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (prevElement === element && prevPos === pos) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
prevElement = element;
|
|
209
|
-
prevPos = pos;
|
|
210
|
-
handler(reference, element, node, pos);
|
|
277
|
+
let prevHoverState = null;
|
|
278
|
+
const extension = defineElementHoverHandler((reference, hoverState) => {
|
|
279
|
+
if (isHoverStateEqual(prevHoverState, hoverState)) {
|
|
280
|
+
return;
|
|
211
281
|
}
|
|
212
|
-
|
|
282
|
+
prevHoverState = hoverState;
|
|
283
|
+
handler(reference, hoverState);
|
|
284
|
+
});
|
|
213
285
|
useEditorExtension(host, editor, extension);
|
|
214
286
|
}
|
|
287
|
+
function isHoverStateEqual(a, b) {
|
|
288
|
+
if (!a && !b) return true;
|
|
289
|
+
if (!a || !b) return false;
|
|
290
|
+
return a.element === b.element && a.pos === b.pos && a.node.eq(b.node);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// src/components/block-handle/block-handle-popover/state.ts
|
|
294
|
+
function useBlockHandlePopover(host, state) {
|
|
295
|
+
useBlockPopover(host, state);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// src/components/block-handle/block-handle-popover/element.gen.ts
|
|
299
|
+
var BlockHandlePopoverElement = class extends ElementBuilder4(useBlockHandlePopover, defaultBlockHandlePopoverProps) {
|
|
300
|
+
};
|
|
301
|
+
defineCustomElement("prosekit-block-handle-popover", BlockHandlePopoverElement);
|
|
215
302
|
|
|
216
303
|
// src/components/block-handle/block-popover/element.gen.ts
|
|
217
|
-
|
|
304
|
+
import { ElementBuilder as ElementBuilder5 } from "@aria-ui/core";
|
|
305
|
+
var BlockPopoverElement = class extends ElementBuilder5(useBlockPopover, defaultBlockPopoverProps) {
|
|
218
306
|
};
|
|
219
307
|
defineCustomElement("prosekit-block-popover", BlockPopoverElement);
|
|
220
308
|
export {
|
|
221
309
|
BlockDragHandleElement,
|
|
310
|
+
BlockHandleAddElement,
|
|
311
|
+
BlockHandleDraggableElement,
|
|
312
|
+
BlockHandlePopoverElement,
|
|
222
313
|
BlockPopoverElement,
|
|
223
314
|
defaultBlockDragHandleProps,
|
|
315
|
+
defaultBlockHandleAddProps,
|
|
316
|
+
defaultBlockHandleDraggableProps,
|
|
317
|
+
defaultBlockHandlePopoverProps,
|
|
224
318
|
defaultBlockPopoverProps
|
|
225
319
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosekit/web",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.14",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "ocavue",
|
|
@@ -82,9 +82,9 @@
|
|
|
82
82
|
"@zag-js/dom-query": "^0.65.1",
|
|
83
83
|
"just-omit": "^2.2.0",
|
|
84
84
|
"prosemirror-tables": "^1.5.0",
|
|
85
|
-
"@prosekit/
|
|
86
|
-
"@prosekit/
|
|
87
|
-
"@prosekit/
|
|
85
|
+
"@prosekit/extensions": "^0.7.14",
|
|
86
|
+
"@prosekit/pm": "^0.1.8",
|
|
87
|
+
"@prosekit/core": "^0.7.10"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"tsup": "^8.2.4",
|