@prosekit/web 0.3.12 → 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.
- package/dist/_tsup-dts-rollup.d.ts +426 -6
- package/dist/prosekit-web-autocomplete.js +16 -20
- package/dist/prosekit-web-block-handle.d.ts +9 -0
- package/dist/prosekit-web-block-handle.js +139 -45
- package/dist/prosekit-web-table-handle.d.ts +21 -0
- package/dist/prosekit-web-table-handle.js +440 -0
- package/package.json +14 -4
|
@@ -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
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { TableHandleColumnRootElement } from './_tsup-dts-rollup';
|
|
2
|
+
export { defaultTableHandleColumnRootProps } from './_tsup-dts-rollup';
|
|
3
|
+
export { TableHandleColumnRootProps } from './_tsup-dts-rollup';
|
|
4
|
+
export { TableHandleColumnTriggerElement } from './_tsup-dts-rollup';
|
|
5
|
+
export { defaultTableHandleColumnTriggerProps } from './_tsup-dts-rollup';
|
|
6
|
+
export { TableHandleColumnTriggerProps } from './_tsup-dts-rollup';
|
|
7
|
+
export { TableHandlePopoverContentElement } from './_tsup-dts-rollup';
|
|
8
|
+
export { defaultTableHandlePopoverContentProps } from './_tsup-dts-rollup';
|
|
9
|
+
export { TableHandlePopoverContentProps } from './_tsup-dts-rollup';
|
|
10
|
+
export { TableHandlePopoverItemElement } from './_tsup-dts-rollup';
|
|
11
|
+
export { defaultTableHandlePopoverItemProps } from './_tsup-dts-rollup';
|
|
12
|
+
export { TableHandlePopoverItemProps } from './_tsup-dts-rollup';
|
|
13
|
+
export { TableHandleRootElement } from './_tsup-dts-rollup';
|
|
14
|
+
export { defaultTableHandleRootProps } from './_tsup-dts-rollup';
|
|
15
|
+
export { TableHandleRootProps } from './_tsup-dts-rollup';
|
|
16
|
+
export { TableHandleRowRootElement } from './_tsup-dts-rollup';
|
|
17
|
+
export { defaultTableHandleRowRootProps } from './_tsup-dts-rollup';
|
|
18
|
+
export { TableHandleRowRootProps } from './_tsup-dts-rollup';
|
|
19
|
+
export { TableHandleRowTriggerElement } from './_tsup-dts-rollup';
|
|
20
|
+
export { defaultTableHandleRowTriggerProps } from './_tsup-dts-rollup';
|
|
21
|
+
export { TableHandleRowTriggerProps } from './_tsup-dts-rollup';
|