@prosekit/web 0.7.1 → 0.7.3
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/inject-style-D5jj7cme.js +79 -0
- package/dist/prosekit-web-autocomplete.d.ts +58 -58
- package/dist/prosekit-web-block-handle.d.ts +42 -42
- package/dist/prosekit-web-block-handle.js +28 -10
- package/dist/prosekit-web-drop-indicator.d.ts +11 -11
- package/dist/prosekit-web-inline-popover.d.ts +49 -49
- package/dist/prosekit-web-resizable.d.ts +9 -9
- package/dist/prosekit-web-table-handle.d.ts +78 -78
- package/dist/prosekit-web-table-handle.js +78 -51
- package/package.json +6 -5
- package/dist/clone-element-CwLKm7c_.js +0 -41
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { getDocument, getId } from "@ocavue/utils";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/clone-element.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates a deep clone of an Element, including all computed styles so that
|
|
6
|
+
* it looks almost exactly the same as the original element.
|
|
7
|
+
*/
|
|
8
|
+
function deepCloneElement(element, important = false) {
|
|
9
|
+
const clonedElement = element.cloneNode(true);
|
|
10
|
+
const style = deepCopyStyles(element, clonedElement, important);
|
|
11
|
+
return [clonedElement, style];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a clone of an Element, including all computed styles so that
|
|
15
|
+
* it looks similar enough to the original element.
|
|
16
|
+
*/
|
|
17
|
+
function cloneElement(element, important = false) {
|
|
18
|
+
const clonedElement = element.cloneNode();
|
|
19
|
+
const style = copyStyles(element, clonedElement, important);
|
|
20
|
+
return [clonedElement, style];
|
|
21
|
+
}
|
|
22
|
+
function deepCopyStyles(source, target, important) {
|
|
23
|
+
const sources = [source];
|
|
24
|
+
const targets = [target];
|
|
25
|
+
const styles = [];
|
|
26
|
+
while (sources.length > 0 && sources.length === targets.length) {
|
|
27
|
+
const source$1 = sources.pop();
|
|
28
|
+
const target$1 = targets.pop();
|
|
29
|
+
if (!source$1 || !target$1) break;
|
|
30
|
+
const style = copyStyles(source$1, target$1, important);
|
|
31
|
+
if (style) styles.push(style);
|
|
32
|
+
sources.push(...source$1.children);
|
|
33
|
+
targets.push(...target$1.children);
|
|
34
|
+
}
|
|
35
|
+
return styles.join("\n");
|
|
36
|
+
}
|
|
37
|
+
function copyStyles(source, target, important) {
|
|
38
|
+
if (!source || !target) return "";
|
|
39
|
+
const view = source.ownerDocument?.defaultView;
|
|
40
|
+
if (!view) return "";
|
|
41
|
+
const sourceStyle = view.getComputedStyle(source);
|
|
42
|
+
const targetStyle = target.style;
|
|
43
|
+
if (!sourceStyle || !targetStyle) return "";
|
|
44
|
+
for (const key of sourceStyle) targetStyle.setProperty(key, sourceStyle.getPropertyValue(key), important ? "important" : sourceStyle.getPropertyPriority(key) || "");
|
|
45
|
+
const styles = [];
|
|
46
|
+
for (const pseudoSelector of [":before", ":after"]) {
|
|
47
|
+
const sourcePseudoStyle = view.getComputedStyle(source, pseudoSelector);
|
|
48
|
+
const targetPseudoStyle = view.getComputedStyle(target, pseudoSelector);
|
|
49
|
+
if (!sourcePseudoStyle) continue;
|
|
50
|
+
const content = sourcePseudoStyle.getPropertyValue("content");
|
|
51
|
+
const hasPseudoElement = content && content !== "none" && content !== "normal";
|
|
52
|
+
if (!hasPseudoElement) continue;
|
|
53
|
+
const cssProps = [];
|
|
54
|
+
for (const property of sourcePseudoStyle) {
|
|
55
|
+
const sourceValue = sourcePseudoStyle.getPropertyValue(property);
|
|
56
|
+
const sourcePriority = sourcePseudoStyle.getPropertyPriority(property);
|
|
57
|
+
const targetValue = targetPseudoStyle.getPropertyValue(property);
|
|
58
|
+
const targetPriority = targetPseudoStyle.getPropertyPriority(property);
|
|
59
|
+
if (sourceValue !== targetValue || sourcePriority !== targetPriority) cssProps.push(`${property}: ${sourceValue}${sourcePriority ? " !important" : ""};`);
|
|
60
|
+
}
|
|
61
|
+
const uniqueClassName = `clone-pseudo-element-${getId()}`;
|
|
62
|
+
target.classList.add(uniqueClassName);
|
|
63
|
+
styles.push(`.${uniqueClassName}${pseudoSelector} { ${cssProps.join(" ")} }`);
|
|
64
|
+
}
|
|
65
|
+
return styles.join("\n");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/utils/inject-style.ts
|
|
70
|
+
function injectStyle(container, styleText) {
|
|
71
|
+
if (!styleText) return;
|
|
72
|
+
const document = getDocument(container);
|
|
73
|
+
const style = document.createElement("style");
|
|
74
|
+
style.textContent = styleText;
|
|
75
|
+
container.appendChild(style);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
export { cloneElement, deepCloneElement, injectStyle };
|
|
@@ -20,19 +20,19 @@ declare class AutocompleteEmptyElement extends AutocompleteEmptyElementBase {}
|
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/components/autocomplete/autocomplete-empty/setup.d.ts
|
|
22
22
|
/**
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
25
|
declare const useAutocompleteEmpty: typeof useListboxEmpty;
|
|
26
26
|
//#endregion
|
|
27
27
|
//#region src/components/autocomplete/autocomplete-item/types.d.ts
|
|
28
28
|
interface AutocompleteItemProps {
|
|
29
29
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
* The value of the item, which will be matched against the query.
|
|
31
|
+
*
|
|
32
|
+
* If not provided, the value is the item's text content.
|
|
33
|
+
*
|
|
34
|
+
* @default ""
|
|
35
|
+
*/
|
|
36
36
|
value: string;
|
|
37
37
|
}
|
|
38
38
|
/** @internal */
|
|
@@ -47,21 +47,21 @@ declare class AutocompleteItemElement extends AutocompleteItemElementBase {}
|
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region src/components/autocomplete/autocomplete-item/setup.d.ts
|
|
49
49
|
/**
|
|
50
|
-
* @internal
|
|
51
|
-
*/
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
52
|
declare function useAutocompleteItem(element: ConnectableElement, {
|
|
53
53
|
state,
|
|
54
54
|
emit
|
|
55
55
|
}: SetupOptions<AutocompleteItemProps, AutocompleteItemEvents>): void;
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/components/autocomplete/autocomplete-list/types.d.ts
|
|
58
|
-
interface AutocompleteListProps extends Pick<ListboxProps,
|
|
58
|
+
interface AutocompleteListProps extends Pick<ListboxProps, 'filter'> {
|
|
59
59
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
* The ProseKit editor instance.
|
|
61
|
+
*
|
|
62
|
+
* @default null
|
|
63
|
+
* @hidden
|
|
64
|
+
*/
|
|
65
65
|
editor: Editor | null;
|
|
66
66
|
}
|
|
67
67
|
declare const autocompleteListProps: PropDeclarations<AutocompleteListProps>;
|
|
@@ -74,8 +74,8 @@ declare class AutocompleteListElement extends AutocompleteListElementBase {}
|
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/components/autocomplete/autocomplete-list/setup.d.ts
|
|
76
76
|
/**
|
|
77
|
-
* @internal
|
|
78
|
-
*/
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
79
|
declare function useAutocompleteList(element: ConnectableElement, {
|
|
80
80
|
state,
|
|
81
81
|
emit
|
|
@@ -84,61 +84,61 @@ declare function useAutocompleteList(element: ConnectableElement, {
|
|
|
84
84
|
//#region src/components/autocomplete/autocomplete-popover/types.d.ts
|
|
85
85
|
interface AutocompletePopoverProps extends OverlayPositionerProps {
|
|
86
86
|
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
* The ProseKit editor instance.
|
|
88
|
+
*
|
|
89
|
+
* @default null
|
|
90
|
+
* @hidden
|
|
91
|
+
*/
|
|
92
92
|
editor: Editor | null;
|
|
93
93
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
* The regular expression to match the query text to autocomplete.
|
|
95
|
+
*
|
|
96
|
+
* @default null
|
|
97
|
+
*/
|
|
98
98
|
regex: RegExp | null;
|
|
99
99
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
placement: OverlayPositionerProps[
|
|
100
|
+
* The placement of the popover, relative to the text cursor.
|
|
101
|
+
*
|
|
102
|
+
* @default "bottom-start"
|
|
103
|
+
*/
|
|
104
|
+
placement: OverlayPositionerProps['placement'];
|
|
105
105
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
offset: OverlayPositionerProps[
|
|
106
|
+
* The distance between the popover and the hovered block.
|
|
107
|
+
*
|
|
108
|
+
* @default 4
|
|
109
|
+
*/
|
|
110
|
+
offset: OverlayPositionerProps['offset'];
|
|
111
111
|
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
inline: OverlayPositionerProps[
|
|
112
|
+
* @default true
|
|
113
|
+
*/
|
|
114
|
+
inline: OverlayPositionerProps['inline'];
|
|
115
115
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
hoist: OverlayPositionerProps[
|
|
116
|
+
* @default true
|
|
117
|
+
*/
|
|
118
|
+
hoist: OverlayPositionerProps['hoist'];
|
|
119
119
|
/**
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
fitViewport: OverlayPositionerProps[
|
|
120
|
+
* @default true
|
|
121
|
+
*/
|
|
122
|
+
fitViewport: OverlayPositionerProps['fitViewport'];
|
|
123
123
|
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
boundary: OverlayPositionerProps[
|
|
124
|
+
* @default "The body element"
|
|
125
|
+
*/
|
|
126
|
+
boundary: OverlayPositionerProps['boundary'];
|
|
127
127
|
/**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
overflowPadding: OverlayPositionerProps[
|
|
128
|
+
* @default 8
|
|
129
|
+
*/
|
|
130
|
+
overflowPadding: OverlayPositionerProps['overflowPadding'];
|
|
131
131
|
}
|
|
132
132
|
/** @internal */
|
|
133
133
|
declare const autocompletePopoverProps: PropDeclarations<AutocompletePopoverProps>;
|
|
134
134
|
interface AutocompletePopoverEvents extends OverlayPositionerEvents {
|
|
135
135
|
/**
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
* Fired when the open state changes.
|
|
137
|
+
*/
|
|
138
138
|
openChange: CustomEvent<boolean>;
|
|
139
139
|
/**
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
* Fired when the query changes.
|
|
141
|
+
*/
|
|
142
142
|
queryChange: CustomEvent<string>;
|
|
143
143
|
}
|
|
144
144
|
/** @internal */
|
|
@@ -150,8 +150,8 @@ declare class AutocompletePopoverElement extends AutocompletePopoverElementBase
|
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region src/components/autocomplete/autocomplete-popover/setup.d.ts
|
|
152
152
|
/**
|
|
153
|
-
* @internal
|
|
154
|
-
*/
|
|
153
|
+
* @internal
|
|
154
|
+
*/
|
|
155
155
|
declare function useAutocompletePopover(host: ConnectableElement, {
|
|
156
156
|
state,
|
|
157
157
|
emit
|
|
@@ -7,11 +7,11 @@ import { Placement } from "@floating-ui/dom";
|
|
|
7
7
|
//#region src/components/block-handle/block-handle-add/types.d.ts
|
|
8
8
|
interface BlockHandleAddProps {
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
* The ProseKit editor instance.
|
|
11
|
+
*
|
|
12
|
+
* @default null
|
|
13
|
+
* @hidden
|
|
14
|
+
*/
|
|
15
15
|
editor: Editor | null;
|
|
16
16
|
}
|
|
17
17
|
/** @internal */
|
|
@@ -27,8 +27,8 @@ declare class BlockHandleAddElement extends BlockHandleAddElementBase {}
|
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/components/block-handle/block-handle-add/setup.d.ts
|
|
29
29
|
/**
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
32
|
declare function useBlockHandleAdd(host: ConnectableElement, {
|
|
33
33
|
state
|
|
34
34
|
}: {
|
|
@@ -38,11 +38,11 @@ declare function useBlockHandleAdd(host: ConnectableElement, {
|
|
|
38
38
|
//#region src/components/block-handle/block-handle-draggable/types.d.ts
|
|
39
39
|
interface BlockHandleDraggableProps {
|
|
40
40
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
* The ProseKit editor instance.
|
|
42
|
+
*
|
|
43
|
+
* @default null
|
|
44
|
+
* @hidden
|
|
45
|
+
*/
|
|
46
46
|
editor: Editor | null;
|
|
47
47
|
}
|
|
48
48
|
/** @internal */
|
|
@@ -58,8 +58,8 @@ declare class BlockHandleDraggableElement extends BlockHandleDraggableElementBas
|
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region src/components/block-handle/block-handle-draggable/setup.d.ts
|
|
60
60
|
/**
|
|
61
|
-
* @internal
|
|
62
|
-
*/
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
63
|
declare function useBlockHandleDraggable(host: ConnectableElement, {
|
|
64
64
|
state
|
|
65
65
|
}: {
|
|
@@ -67,49 +67,49 @@ declare function useBlockHandleDraggable(host: ConnectableElement, {
|
|
|
67
67
|
}): void;
|
|
68
68
|
//#endregion
|
|
69
69
|
//#region src/components/block-handle/block-handle-popover/types.d.ts
|
|
70
|
-
interface BlockHandlePopoverProps extends Omit<OverlayPositionerProps,
|
|
70
|
+
interface BlockHandlePopoverProps extends Omit<OverlayPositionerProps, 'placement' | 'hoist' | 'flip' | 'shift' | 'hide'> {
|
|
71
71
|
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
* The ProseKit editor instance.
|
|
73
|
+
*
|
|
74
|
+
* @default null
|
|
75
|
+
* @hidden
|
|
76
|
+
*/
|
|
77
77
|
editor: Editor | null;
|
|
78
78
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
* The placement of the popover, relative to the hovered block.
|
|
80
|
+
*
|
|
81
|
+
* @default "left"
|
|
82
|
+
*/
|
|
83
83
|
placement: Placement;
|
|
84
84
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
* Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
86
|
+
* to place the floating element on top of other page content.
|
|
87
|
+
*
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
90
|
hoist: boolean;
|
|
91
91
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
* @default false
|
|
93
|
+
* @hidden
|
|
94
|
+
*/
|
|
95
95
|
flip: boolean;
|
|
96
96
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
* @default false
|
|
98
|
+
* @hidden
|
|
99
|
+
*/
|
|
100
100
|
shift: boolean;
|
|
101
101
|
/**
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
* @default true
|
|
103
|
+
* @hidden
|
|
104
|
+
*/
|
|
105
105
|
hide: boolean;
|
|
106
106
|
}
|
|
107
107
|
/** @internal */
|
|
108
108
|
declare const blockHandlePopoverProps: PropDeclarations<BlockHandlePopoverProps>;
|
|
109
109
|
interface BlockHandlePopoverEvents extends OverlayPositionerEvents {
|
|
110
110
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
* Fired when the hovered block changes.
|
|
112
|
+
*/
|
|
113
113
|
stateChange: CustomEvent<{
|
|
114
114
|
node: ProseMirrorNode;
|
|
115
115
|
pos: number;
|
|
@@ -124,8 +124,8 @@ declare class BlockHandlePopoverElement extends BlockHandlePopoverElementBase {}
|
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/components/block-handle/block-handle-popover/setup.d.ts
|
|
126
126
|
/**
|
|
127
|
-
* @internal
|
|
128
|
-
*/
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
129
129
|
declare function useBlockHandlePopover(host: ConnectableElement, {
|
|
130
130
|
state,
|
|
131
131
|
emit
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEditorExtension } from "./use-editor-extension-Cc7ZG7uj.js";
|
|
2
2
|
import { getSafeEditorView } from "./get-safe-editor-view-DENm4avv.js";
|
|
3
3
|
import { assignStyles, useScrolling } from "./use-scrolling-BNfsQs3S.js";
|
|
4
|
-
import { deepCloneElement } from "./
|
|
4
|
+
import { deepCloneElement, injectStyle } from "./inject-style-D5jj7cme.js";
|
|
5
5
|
import { createComputed, createContext, createSignal, defineCustomElement, registerCustomElement, useAttribute, useEffect, useEventListener } from "@aria-ui/core";
|
|
6
6
|
import { defineDOMEventHandler, insertDefaultBlock, union } from "@prosekit/core";
|
|
7
7
|
import { overlayPositionerEvents, overlayPositionerProps, useOverlayPositionerState } from "@aria-ui/overlay/elements";
|
|
@@ -56,6 +56,21 @@ const BlockHandleAddElementBase = defineCustomElement({
|
|
|
56
56
|
var BlockHandleAddElement = class extends BlockHandleAddElementBase {};
|
|
57
57
|
registerCustomElement("prosekit-block-handle-add", BlockHandleAddElement);
|
|
58
58
|
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/utils/get-box-element.ts
|
|
61
|
+
/**
|
|
62
|
+
* Returns the element that has a box.
|
|
63
|
+
*/
|
|
64
|
+
function getBoxElement(element) {
|
|
65
|
+
const window = element.ownerDocument.defaultView;
|
|
66
|
+
if (!window) return;
|
|
67
|
+
const style = window.getComputedStyle(element);
|
|
68
|
+
const display = style.display;
|
|
69
|
+
if (display === "contents" && element.childElementCount === 1) return element.firstElementChild;
|
|
70
|
+
else if (display === "none") return;
|
|
71
|
+
return element;
|
|
72
|
+
}
|
|
73
|
+
|
|
59
74
|
//#endregion
|
|
60
75
|
//#region src/utils/get-client-rect.ts
|
|
61
76
|
/**
|
|
@@ -120,8 +135,9 @@ function setDragPreview(event, element) {
|
|
|
120
135
|
const borderY = Math.max(outsideY, 0);
|
|
121
136
|
assignStyles(container, {
|
|
122
137
|
position: "fixed",
|
|
123
|
-
top: "
|
|
124
|
-
left: "
|
|
138
|
+
top: "-1000vh",
|
|
139
|
+
left: "-1000vw",
|
|
140
|
+
pointerEvents: "none",
|
|
125
141
|
zIndex: maxZIndex,
|
|
126
142
|
borderLeft: `${borderX}px solid transparent`,
|
|
127
143
|
borderTop: `${borderY}px solid transparent`,
|
|
@@ -129,13 +145,13 @@ function setDragPreview(event, element) {
|
|
|
129
145
|
width: `${width + borderX}px`,
|
|
130
146
|
height: `${height + borderY}px`
|
|
131
147
|
});
|
|
132
|
-
const clonedElement = deepCloneElement(element);
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
});
|
|
148
|
+
const [clonedElement, styleText] = deepCloneElement(element, true);
|
|
149
|
+
clonedElement.style.setProperty("opacity", "0.5", "important");
|
|
150
|
+
clonedElement.style.setProperty("margin", "0", "important");
|
|
151
|
+
clonedElement.style.setProperty("outline-color", "transparent", "important");
|
|
137
152
|
document.body.appendChild(container);
|
|
138
153
|
container.appendChild(clonedElement);
|
|
154
|
+
injectStyle(container, styleText);
|
|
139
155
|
event.dataTransfer?.setDragImage(container, Math.max(-outsideX, 0), Math.max(-outsideY, 0));
|
|
140
156
|
requestAnimationFrame(() => {
|
|
141
157
|
container.remove();
|
|
@@ -187,10 +203,12 @@ function createDraggingPreview(view, hoverState, event) {
|
|
|
187
203
|
const { pos } = hoverState;
|
|
188
204
|
const element = view.nodeDOM(pos);
|
|
189
205
|
if (!element || !isHTMLElement(element)) return;
|
|
206
|
+
const boxElement = getBoxElement(element);
|
|
207
|
+
if (!boxElement || !isHTMLElement(boxElement)) return;
|
|
190
208
|
event.dataTransfer.clearData();
|
|
191
|
-
event.dataTransfer.setData("text/html",
|
|
209
|
+
event.dataTransfer.setData("text/html", boxElement.outerHTML);
|
|
192
210
|
event.dataTransfer.effectAllowed = "copyMove";
|
|
193
|
-
setDragPreview(event,
|
|
211
|
+
setDragPreview(event, boxElement);
|
|
194
212
|
}
|
|
195
213
|
function setViewDragging(view, hoverState) {
|
|
196
214
|
const { node, pos } = hoverState;
|
|
@@ -4,17 +4,17 @@ import { Editor } from "@prosekit/core";
|
|
|
4
4
|
//#region src/components/drop-indicator/drop-indicator/types.d.ts
|
|
5
5
|
interface DropIndicatorProps {
|
|
6
6
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
* The ProseKit editor instance.
|
|
8
|
+
*
|
|
9
|
+
* @default null
|
|
10
|
+
* @hidden
|
|
11
|
+
*/
|
|
12
12
|
editor: Editor | null;
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
* The line width in pixels.
|
|
15
|
+
*
|
|
16
|
+
* @default 2
|
|
17
|
+
*/
|
|
18
18
|
width: number;
|
|
19
19
|
}
|
|
20
20
|
/** @internal */
|
|
@@ -29,8 +29,8 @@ declare class DropIndicatorElement extends DropIndicatorElementBase {}
|
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/components/drop-indicator/drop-indicator/setup.d.ts
|
|
31
31
|
/**
|
|
32
|
-
* @internal
|
|
33
|
-
*/
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
34
|
declare function useDropIndicator(host: ConnectableElement, {
|
|
35
35
|
state
|
|
36
36
|
}: SetupOptions<DropIndicatorProps, DropIndicatorEvents>): void;
|
|
@@ -3,72 +3,72 @@ import { Editor } from "@prosekit/core";
|
|
|
3
3
|
import { OverlayPositionerEvents, OverlayPositionerProps } from "@aria-ui/overlay";
|
|
4
4
|
|
|
5
5
|
//#region src/components/inline-popover/inline-popover/types.d.ts
|
|
6
|
-
interface InlinePopoverProps extends Omit<OverlayPositionerProps,
|
|
6
|
+
interface InlinePopoverProps extends Omit<OverlayPositionerProps, 'placement' | 'offset' | 'hide' | 'overlap' | 'inline' | 'overflowPadding'> {
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
* The ProseKit editor instance.
|
|
9
|
+
*
|
|
10
|
+
* @default null
|
|
11
|
+
* @hidden
|
|
12
|
+
*/
|
|
13
13
|
editor: Editor | null;
|
|
14
14
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
* Whether the popover is open by default when some inline content is
|
|
16
|
+
* selected.
|
|
17
|
+
*
|
|
18
|
+
* When `defaultOpen` is true, the popover will open or close based on the
|
|
19
|
+
* inline selection. When `defaultOpen` is false, the popover will never be
|
|
20
|
+
* opened unless the `open` prop is true.
|
|
21
|
+
*
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
24
|
defaultOpen: boolean;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
* Whether the popover is open.
|
|
27
|
+
*
|
|
28
|
+
* Notice that the popover will be always hidden if the inline selection is
|
|
29
|
+
* empty.
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
33
|
open: boolean;
|
|
34
34
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
* Whether the inline popover should be dismissed when the editor receives an
|
|
36
|
+
* Escape key press.
|
|
37
|
+
*
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
40
|
dismissOnEscape: boolean;
|
|
41
41
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
placement: OverlayPositionerProps[
|
|
42
|
+
* @default "top"
|
|
43
|
+
*/
|
|
44
|
+
placement: OverlayPositionerProps['placement'];
|
|
45
45
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
offset: OverlayPositionerProps[
|
|
46
|
+
* @default 12
|
|
47
|
+
*/
|
|
48
|
+
offset: OverlayPositionerProps['offset'];
|
|
49
49
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
hide: OverlayPositionerProps[
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
hide: OverlayPositionerProps['hide'];
|
|
53
53
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
overlap: OverlayPositionerProps[
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
overlap: OverlayPositionerProps['overlap'];
|
|
57
57
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
inline: OverlayPositionerProps[
|
|
58
|
+
* @default true
|
|
59
|
+
*/
|
|
60
|
+
inline: OverlayPositionerProps['inline'];
|
|
61
61
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
overflowPadding: OverlayPositionerProps[
|
|
62
|
+
* @default 8
|
|
63
|
+
*/
|
|
64
|
+
overflowPadding: OverlayPositionerProps['overflowPadding'];
|
|
65
65
|
}
|
|
66
66
|
/** @internal */
|
|
67
67
|
declare const inlinePopoverProps: PropDeclarations<InlinePopoverProps>;
|
|
68
68
|
interface InlinePopoverEvents extends OverlayPositionerEvents {
|
|
69
69
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
* Fired when the open state changes.
|
|
71
|
+
*/
|
|
72
72
|
openChange: CustomEvent<boolean>;
|
|
73
73
|
}
|
|
74
74
|
/** @internal */
|
|
@@ -80,8 +80,8 @@ declare class InlinePopoverElement extends InlinePopoverElementBase {}
|
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/components/inline-popover/inline-popover/setup.d.ts
|
|
82
82
|
/**
|
|
83
|
-
* @internal
|
|
84
|
-
*/
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
85
|
declare function useInlinePopover(host: ConnectableElement, {
|
|
86
86
|
state,
|
|
87
87
|
emit
|
|
@@ -3,11 +3,11 @@ import { BaseElementConstructor, ConnectableElement, EventDeclarations, PropDecl
|
|
|
3
3
|
//#region src/components/resizable/resizable-handle/types.d.ts
|
|
4
4
|
interface ResizableHandleProps {
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
position:
|
|
6
|
+
* The position of the handle.
|
|
7
|
+
*
|
|
8
|
+
* @default "bottom-right"
|
|
9
|
+
*/
|
|
10
|
+
position: 'top' | 'right' | 'bottom' | 'left' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
11
11
|
}
|
|
12
12
|
/** @internal */
|
|
13
13
|
declare const resizableHandleProps: PropDeclarations<ResizableHandleProps>;
|
|
@@ -22,8 +22,8 @@ declare class ResizableHandleElement extends ResizableHandleElementBase {}
|
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/components/resizable/resizable-handle/setup.d.ts
|
|
24
24
|
/**
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
27
|
declare function useResizableHandle(host: ConnectableElement, {
|
|
28
28
|
state
|
|
29
29
|
}: {
|
|
@@ -57,8 +57,8 @@ declare class ResizableRootElement extends ResizableRootElementBase {}
|
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region src/components/resizable/resizable-root/setup.d.ts
|
|
59
59
|
/**
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
62
|
declare function useResizableRoot(host: ConnectableElement, {
|
|
63
63
|
state,
|
|
64
64
|
emit
|
|
@@ -7,41 +7,41 @@ import { Placement } from "@floating-ui/dom";
|
|
|
7
7
|
import { MenuItemEvents, MenuItemProps } from "@aria-ui/menu";
|
|
8
8
|
|
|
9
9
|
//#region src/components/table-handle/table-handle-column-root/types.d.ts
|
|
10
|
-
interface TableHandleColumnRootProps extends Omit<OverlayPositionerProps,
|
|
10
|
+
interface TableHandleColumnRootProps extends Omit<OverlayPositionerProps, 'placement' | 'hoist' | 'flip' | 'shift' | 'hide'> {
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
* The ProseKit editor instance.
|
|
13
|
+
*
|
|
14
|
+
* @default null
|
|
15
|
+
* @hidden
|
|
16
|
+
*/
|
|
17
17
|
editor: Editor | null;
|
|
18
18
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
* The placement of the popover, relative to the hovered table cell.
|
|
20
|
+
*
|
|
21
|
+
* @default "top"
|
|
22
|
+
*/
|
|
23
23
|
placement: Placement;
|
|
24
24
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
* Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
26
|
+
* to place the floating element on top of other page content.
|
|
27
|
+
*
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
30
|
hoist: boolean;
|
|
31
31
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
* @default false
|
|
33
|
+
* @hidden
|
|
34
|
+
*/
|
|
35
35
|
flip: boolean;
|
|
36
36
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
* @default false
|
|
38
|
+
* @hidden
|
|
39
|
+
*/
|
|
40
40
|
shift: boolean;
|
|
41
41
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
* @default true
|
|
43
|
+
* @hidden
|
|
44
|
+
*/
|
|
45
45
|
hide: boolean;
|
|
46
46
|
}
|
|
47
47
|
/** @internal */
|
|
@@ -57,8 +57,8 @@ declare class TableHandleColumnRootElement extends TableHandleColumnRootElementB
|
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region src/components/table-handle/table-handle-column-root/setup.d.ts
|
|
59
59
|
/**
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
62
|
declare function useTableHandleColumnRoot(host: ConnectableElement, {
|
|
63
63
|
state
|
|
64
64
|
}: {
|
|
@@ -83,8 +83,8 @@ declare class TableHandleColumnTriggerElement extends TableHandleColumnTriggerEl
|
|
|
83
83
|
//#endregion
|
|
84
84
|
//#region src/components/table-handle/table-handle-column-trigger/setup.d.ts
|
|
85
85
|
/**
|
|
86
|
-
* @internal
|
|
87
|
-
*/
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
88
|
declare function useTableHandleColumnTrigger(host: ConnectableElement, {
|
|
89
89
|
state
|
|
90
90
|
}: SetupOptions<TableHandleColumnTriggerProps, TableHandleColumnTriggerEvents>): void;
|
|
@@ -103,8 +103,8 @@ declare class TableHandleDragPreviewElement extends TableHandleDragPreviewElemen
|
|
|
103
103
|
//#endregion
|
|
104
104
|
//#region src/components/table-handle/table-handle-drag-preview/setup.d.ts
|
|
105
105
|
/**
|
|
106
|
-
* @internal
|
|
107
|
-
*/
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
108
|
declare function useTableHandleDragPreview(host: ConnectableElement, {
|
|
109
109
|
state
|
|
110
110
|
}: {
|
|
@@ -125,8 +125,8 @@ declare class TableHandleDropIndicatorElement extends TableHandleDropIndicatorEl
|
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region src/components/table-handle/table-handle-drop-indicator/setup.d.ts
|
|
127
127
|
/**
|
|
128
|
-
* @internal
|
|
129
|
-
*/
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
130
130
|
declare function useTableHandleDropIndicator(host: ConnectableElement, {
|
|
131
131
|
state
|
|
132
132
|
}: {
|
|
@@ -134,15 +134,15 @@ declare function useTableHandleDropIndicator(host: ConnectableElement, {
|
|
|
134
134
|
}): void;
|
|
135
135
|
//#endregion
|
|
136
136
|
//#region src/components/table-handle/table-handle-popover-content/types.d.ts
|
|
137
|
-
interface TableHandlePopoverContentProps extends Omit<MenuContentProps,
|
|
137
|
+
interface TableHandlePopoverContentProps extends Omit<MenuContentProps, 'placement' | 'offset'> {
|
|
138
138
|
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
placement: MenuContentProps[
|
|
139
|
+
* @default 'bottom-start'
|
|
140
|
+
*/
|
|
141
|
+
placement: MenuContentProps['placement'];
|
|
142
142
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
offset: MenuContentProps[
|
|
143
|
+
* @default {mainAxis: -4, crossAxis: 4}
|
|
144
|
+
*/
|
|
145
|
+
offset: MenuContentProps['offset'];
|
|
146
146
|
editor: Editor | null;
|
|
147
147
|
}
|
|
148
148
|
/** @internal */
|
|
@@ -157,8 +157,8 @@ declare class TableHandlePopoverContentElement extends TableHandlePopoverContent
|
|
|
157
157
|
//#endregion
|
|
158
158
|
//#region src/components/table-handle/table-handle-popover-content/setup.d.ts
|
|
159
159
|
/**
|
|
160
|
-
* @internal
|
|
161
|
-
*/
|
|
160
|
+
* @internal
|
|
161
|
+
*/
|
|
162
162
|
declare function useTableHandlePopoverContent(host: ConnectableElement, {
|
|
163
163
|
state,
|
|
164
164
|
emit
|
|
@@ -178,8 +178,8 @@ declare class TableHandlePopoverItemElement extends TableHandlePopoverItemElemen
|
|
|
178
178
|
//#endregion
|
|
179
179
|
//#region src/components/table-handle/table-handle-popover-item/setup.d.ts
|
|
180
180
|
/**
|
|
181
|
-
* @internal
|
|
182
|
-
*/
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
183
|
declare function useTableHandlePopoverItem(element: ConnectableElement, {
|
|
184
184
|
state,
|
|
185
185
|
emit
|
|
@@ -188,11 +188,11 @@ declare function useTableHandlePopoverItem(element: ConnectableElement, {
|
|
|
188
188
|
//#region src/components/table-handle/table-handle-root/types.d.ts
|
|
189
189
|
interface TableHandleRootProps {
|
|
190
190
|
/**
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
* The ProseKit editor instance.
|
|
192
|
+
*
|
|
193
|
+
* @default null
|
|
194
|
+
* @hidden
|
|
195
|
+
*/
|
|
196
196
|
editor: Editor | null;
|
|
197
197
|
}
|
|
198
198
|
/** @internal */
|
|
@@ -208,8 +208,8 @@ declare class TableHandleRootElement extends TableHandleRootElementBase {}
|
|
|
208
208
|
//#endregion
|
|
209
209
|
//#region src/components/table-handle/table-handle-root/setup.d.ts
|
|
210
210
|
/**
|
|
211
|
-
* @internal
|
|
212
|
-
*/
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
213
|
declare function useTableHandleRoot(host: ConnectableElement, {
|
|
214
214
|
state
|
|
215
215
|
}: {
|
|
@@ -217,41 +217,41 @@ declare function useTableHandleRoot(host: ConnectableElement, {
|
|
|
217
217
|
}): void;
|
|
218
218
|
//#endregion
|
|
219
219
|
//#region src/components/table-handle/table-handle-row-root/types.d.ts
|
|
220
|
-
interface TableHandleRowRootProps extends Omit<OverlayPositionerProps,
|
|
220
|
+
interface TableHandleRowRootProps extends Omit<OverlayPositionerProps, 'placement' | 'hoist' | 'flip' | 'shift' | 'hide'> {
|
|
221
221
|
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
222
|
+
* The ProseKit editor instance.
|
|
223
|
+
*
|
|
224
|
+
* @default null
|
|
225
|
+
* @hidden
|
|
226
|
+
*/
|
|
227
227
|
editor: Editor | null;
|
|
228
228
|
/**
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
* The placement of the popover, relative to the hovered table cell.
|
|
230
|
+
*
|
|
231
|
+
* @default "left"
|
|
232
|
+
*/
|
|
233
233
|
placement: Placement;
|
|
234
234
|
/**
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
235
|
+
* Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
236
|
+
* to place the floating element on top of other page content.
|
|
237
|
+
*
|
|
238
|
+
* @default false
|
|
239
|
+
*/
|
|
240
240
|
hoist: boolean;
|
|
241
241
|
/**
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
* @default false
|
|
243
|
+
* @hidden
|
|
244
|
+
*/
|
|
245
245
|
flip: boolean;
|
|
246
246
|
/**
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
* @default false
|
|
248
|
+
* @hidden
|
|
249
|
+
*/
|
|
250
250
|
shift: boolean;
|
|
251
251
|
/**
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
* @default true
|
|
253
|
+
* @hidden
|
|
254
|
+
*/
|
|
255
255
|
hide: boolean;
|
|
256
256
|
}
|
|
257
257
|
/** @internal */
|
|
@@ -267,8 +267,8 @@ declare class TableHandleRowRootElement extends TableHandleRowRootElementBase {}
|
|
|
267
267
|
//#endregion
|
|
268
268
|
//#region src/components/table-handle/table-handle-row-root/setup.d.ts
|
|
269
269
|
/**
|
|
270
|
-
* @internal
|
|
271
|
-
*/
|
|
270
|
+
* @internal
|
|
271
|
+
*/
|
|
272
272
|
declare function useTableHandleRowRoot(host: ConnectableElement, {
|
|
273
273
|
state
|
|
274
274
|
}: SetupOptions<TableHandleRowRootProps, TableHandleRowRootEvents>): void;
|
|
@@ -292,8 +292,8 @@ declare class TableHandleRowTriggerElement extends TableHandleRowTriggerElementB
|
|
|
292
292
|
//#endregion
|
|
293
293
|
//#region src/components/table-handle/table-handle-row-trigger/setup.d.ts
|
|
294
294
|
/**
|
|
295
|
-
* @internal
|
|
296
|
-
*/
|
|
295
|
+
* @internal
|
|
296
|
+
*/
|
|
297
297
|
declare function useTableHandleRowTrigger(host: ConnectableElement, {
|
|
298
298
|
state
|
|
299
299
|
}: SetupOptions<TableHandleRowTriggerProps, TableHandleRowTriggerEvents>): void;
|
|
@@ -2,12 +2,12 @@ import { getStateWithDefaults } from "./get-default-state-CIEy7xrl.js";
|
|
|
2
2
|
import { useEditorExtension } from "./use-editor-extension-Cc7ZG7uj.js";
|
|
3
3
|
import { getSafeEditorView } from "./get-safe-editor-view-DENm4avv.js";
|
|
4
4
|
import { assignStyles, useScrolling } from "./use-scrolling-BNfsQs3S.js";
|
|
5
|
-
import { cloneElement, deepCloneElement } from "./
|
|
5
|
+
import { cloneElement, deepCloneElement, injectStyle } from "./inject-style-D5jj7cme.js";
|
|
6
6
|
import { createComputed, createContext, createSignal, defineCustomElement, defineEmit, registerCustomElement, useAttribute, useEffect, useEventListener } from "@aria-ui/core";
|
|
7
7
|
import { defineDOMEventHandler, union } from "@prosekit/core";
|
|
8
8
|
import { useOverlayPositionerState } from "@aria-ui/overlay/elements";
|
|
9
9
|
import { usePresence } from "@aria-ui/presence";
|
|
10
|
-
import { isHTMLElement } from "@ocavue/utils";
|
|
10
|
+
import { isHTMLElement, once } from "@ocavue/utils";
|
|
11
11
|
import { overlayPositionerEvents as overlayPositionerEvents$1, overlayPositionerProps as overlayPositionerProps$1 } from "@aria-ui/overlay";
|
|
12
12
|
import { menuContentEvents, menuContentProps, menuRootEvents, menuRootProps, useMenuContent, useMenuItem, useMenuRoot, useMenuTrigger } from "@aria-ui/menu/elements";
|
|
13
13
|
import { moveTableColumn, moveTableRow, selectTableColumn, selectTableRow } from "@prosekit/extensions/table";
|
|
@@ -146,6 +146,7 @@ function useTableHandleColumnTrigger(host, { state }) {
|
|
|
146
146
|
dataTransfer.effectAllowed = "move";
|
|
147
147
|
const emptyImage = getEmptyImage();
|
|
148
148
|
if (emptyImage) dataTransfer.setDragImage(emptyImage, 0, 0);
|
|
149
|
+
dataTransfer.setData("application/x-prosekit-table-handle-drag", "");
|
|
149
150
|
}
|
|
150
151
|
const prev = dndContext.peek();
|
|
151
152
|
const index = context.peek()?.colIndex;
|
|
@@ -163,24 +164,6 @@ function useTableHandleColumnTrigger(host, { state }) {
|
|
|
163
164
|
startY: event.clientY
|
|
164
165
|
});
|
|
165
166
|
});
|
|
166
|
-
useEventListener(host, "drag", (event) => {
|
|
167
|
-
const prev = dndContext.peek();
|
|
168
|
-
if (event.clientX === 0 && event.clientY === 0) return;
|
|
169
|
-
dndContext.set({
|
|
170
|
-
...prev,
|
|
171
|
-
direction: "col",
|
|
172
|
-
dragging: true,
|
|
173
|
-
x: event.clientX,
|
|
174
|
-
y: event.clientY
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
useEventListener(host, "dragend", () => {
|
|
178
|
-
const prev = dndContext.peek();
|
|
179
|
-
dndContext.set({
|
|
180
|
-
...prev,
|
|
181
|
-
dragging: false
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
167
|
}
|
|
185
168
|
|
|
186
169
|
//#endregion
|
|
@@ -286,6 +269,45 @@ function getDndRelatedDOMs(view, cellPos, draggingIndex, direction) {
|
|
|
286
269
|
};
|
|
287
270
|
}
|
|
288
271
|
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/utils/css-feature-detection.ts
|
|
274
|
+
const isColorMixSupported = once(() => {
|
|
275
|
+
try {
|
|
276
|
+
return CSS.supports("background-color", "color-mix(in srgb, red, blue)");
|
|
277
|
+
} catch {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/utils/fade-color.ts
|
|
284
|
+
/**
|
|
285
|
+
* Convert a color to a color with opacity
|
|
286
|
+
* @param color - The color to convert
|
|
287
|
+
* @param opacity - The opacity to apply
|
|
288
|
+
* @returns The converted color if color-mix is supported, otherwise undefined
|
|
289
|
+
*/
|
|
290
|
+
function fadeColor(color, opacity) {
|
|
291
|
+
if (isColorMixSupported()) {
|
|
292
|
+
const transparentWeight = (1 - opacity) * 100;
|
|
293
|
+
const colorWeight = opacity * 100;
|
|
294
|
+
return `color-mix(in srgb, ${color} ${colorWeight}%, transparent ${transparentWeight}%)`;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
//#endregion
|
|
299
|
+
//#region src/utils/get-effective-background-color.ts
|
|
300
|
+
function getEffectiveBackgroundColor(element) {
|
|
301
|
+
let current = element;
|
|
302
|
+
while (current) {
|
|
303
|
+
const style = current.ownerDocument.defaultView?.getComputedStyle(current);
|
|
304
|
+
const backgroundColor = style?.backgroundColor;
|
|
305
|
+
if (backgroundColor && backgroundColor !== "transparent" && backgroundColor !== "rgba(0, 0, 0, 0)") return backgroundColor;
|
|
306
|
+
current = current.parentElement;
|
|
307
|
+
}
|
|
308
|
+
return void 0;
|
|
309
|
+
}
|
|
310
|
+
|
|
289
311
|
//#endregion
|
|
290
312
|
//#region src/components/table-handle/table-handle-drag-preview/render-preview.ts
|
|
291
313
|
function clearPreviewDOM(previewRoot) {
|
|
@@ -293,35 +315,40 @@ function clearPreviewDOM(previewRoot) {
|
|
|
293
315
|
}
|
|
294
316
|
function createPreviewDOM(table, previewRoot, index, direction) {
|
|
295
317
|
clearPreviewDOM(previewRoot);
|
|
296
|
-
const previewTable =
|
|
318
|
+
const [previewTable, previewTableStyle] = cloneElement(table);
|
|
319
|
+
injectStyle(previewRoot, previewTableStyle);
|
|
320
|
+
unsetSize(previewTable);
|
|
297
321
|
const tableBody = table.querySelector("tbody");
|
|
298
|
-
const previewTableBody = tableBody ?
|
|
322
|
+
const [previewTableBody, previewTableBodyStyle] = tableBody ? cloneElement(tableBody) : [table.ownerDocument.createElement("tbody"), ""];
|
|
323
|
+
injectStyle(previewRoot, previewTableBodyStyle);
|
|
299
324
|
unsetSize(previewTableBody);
|
|
300
|
-
|
|
325
|
+
const backgroundColor = getEffectiveBackgroundColor(table);
|
|
326
|
+
if (backgroundColor) {
|
|
327
|
+
const backgroundColorWithOpacity = fadeColor(backgroundColor, .8);
|
|
328
|
+
if (backgroundColorWithOpacity) assignStyles(previewTable, { backgroundColor: backgroundColorWithOpacity });
|
|
329
|
+
}
|
|
301
330
|
previewTable.appendChild(previewTableBody);
|
|
302
331
|
previewRoot.appendChild(previewTable);
|
|
303
332
|
const rows = table.querySelectorAll("tr");
|
|
304
333
|
if (direction === "row") {
|
|
305
334
|
const row = rows[index];
|
|
306
|
-
const previewRow = deepCloneElement(row);
|
|
335
|
+
const [previewRow, previewRowStyle] = deepCloneElement(row);
|
|
336
|
+
injectStyle(previewRoot, previewRowStyle);
|
|
307
337
|
previewTableBody.appendChild(previewRow);
|
|
308
338
|
} else rows.forEach((row) => {
|
|
309
|
-
const previewRow =
|
|
339
|
+
const [previewRow, previewRowStyle] = cloneElement(row);
|
|
340
|
+
injectStyle(previewRoot, previewRowStyle);
|
|
310
341
|
unsetSize(previewRow);
|
|
311
342
|
const cells = row.querySelectorAll("td");
|
|
312
343
|
const cell = cells[index];
|
|
313
344
|
if (cell) {
|
|
314
|
-
const previewCell = deepCloneElement(cell);
|
|
345
|
+
const [previewCell, previewCellStyle] = deepCloneElement(cell);
|
|
346
|
+
injectStyle(previewRoot, previewCellStyle);
|
|
315
347
|
previewRow.appendChild(previewCell);
|
|
316
348
|
previewTableBody.appendChild(previewRow);
|
|
317
349
|
}
|
|
318
350
|
});
|
|
319
351
|
}
|
|
320
|
-
function cloneElementWithoutSize(element) {
|
|
321
|
-
const clonedElement = cloneElement(element);
|
|
322
|
-
unsetSize(clonedElement);
|
|
323
|
-
return clonedElement;
|
|
324
|
-
}
|
|
325
352
|
function unsetSize(element) {
|
|
326
353
|
assignStyles(element, {
|
|
327
354
|
width: "unset",
|
|
@@ -752,12 +779,12 @@ function useSelecting(host, editor, enabled) {
|
|
|
752
779
|
function useDrop(host, editor, dndContext) {
|
|
753
780
|
const dragging = createComputed(() => dndContext.get().dragging);
|
|
754
781
|
useEffect(host, () => {
|
|
755
|
-
|
|
756
|
-
const view = getSafeEditorView(editor.peek());
|
|
782
|
+
const view = getSafeEditorView(editor.get());
|
|
757
783
|
if (!view || !view.editable) return;
|
|
758
784
|
const ownerDocument = view.dom?.ownerDocument;
|
|
759
785
|
if (!ownerDocument) return;
|
|
760
786
|
const handleDrop = () => {
|
|
787
|
+
if (!dragging.peek()) return;
|
|
761
788
|
const editorValue = editor.peek();
|
|
762
789
|
if (!editorValue) return;
|
|
763
790
|
const { droppingIndex, draggingIndex, direction } = dndContext.peek();
|
|
@@ -784,13 +811,31 @@ function useDrop(host, editor, dndContext) {
|
|
|
784
811
|
}
|
|
785
812
|
};
|
|
786
813
|
const handleDragOver = (event) => {
|
|
814
|
+
if (!dragging.peek()) return;
|
|
787
815
|
event.preventDefault();
|
|
816
|
+
const prev = dndContext.peek();
|
|
817
|
+
dndContext.set({
|
|
818
|
+
...prev,
|
|
819
|
+
dragging: true,
|
|
820
|
+
x: event.clientX,
|
|
821
|
+
y: event.clientY
|
|
822
|
+
});
|
|
823
|
+
};
|
|
824
|
+
const handleDragEnd = () => {
|
|
825
|
+
if (!dragging.peek()) return;
|
|
826
|
+
const prev = dndContext.peek();
|
|
827
|
+
dndContext.set({
|
|
828
|
+
...prev,
|
|
829
|
+
dragging: false
|
|
830
|
+
});
|
|
788
831
|
};
|
|
789
832
|
ownerDocument.addEventListener("dragover", handleDragOver);
|
|
790
833
|
ownerDocument.addEventListener("drop", handleDrop);
|
|
834
|
+
ownerDocument.addEventListener("dragend", handleDragEnd);
|
|
791
835
|
return () => {
|
|
792
836
|
ownerDocument.removeEventListener("dragover", handleDragOver);
|
|
793
837
|
ownerDocument.removeEventListener("drop", handleDrop);
|
|
838
|
+
ownerDocument.removeEventListener("dragend", handleDragEnd);
|
|
794
839
|
};
|
|
795
840
|
});
|
|
796
841
|
}
|
|
@@ -1002,24 +1047,6 @@ function useTableHandleRowTrigger(host, { state }) {
|
|
|
1002
1047
|
startY: event.clientY
|
|
1003
1048
|
});
|
|
1004
1049
|
});
|
|
1005
|
-
useEventListener(host, "drag", (event) => {
|
|
1006
|
-
const prev = dndContext.peek();
|
|
1007
|
-
if (event.clientX === 0 && event.clientY === 0) return;
|
|
1008
|
-
dndContext.set({
|
|
1009
|
-
...prev,
|
|
1010
|
-
direction: "row",
|
|
1011
|
-
dragging: true,
|
|
1012
|
-
x: event.clientX,
|
|
1013
|
-
y: event.clientY
|
|
1014
|
-
});
|
|
1015
|
-
});
|
|
1016
|
-
useEventListener(host, "dragend", () => {
|
|
1017
|
-
const prev = dndContext.peek();
|
|
1018
|
-
dndContext.set({
|
|
1019
|
-
...prev,
|
|
1020
|
-
dragging: false
|
|
1021
|
-
});
|
|
1022
|
-
});
|
|
1023
1050
|
}
|
|
1024
1051
|
|
|
1025
1052
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosekit/web",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "A collection of web components for ProseKit",
|
|
7
7
|
"author": {
|
|
@@ -76,16 +76,17 @@
|
|
|
76
76
|
"@aria-ui/presence": "^0.0.19",
|
|
77
77
|
"@aria-ui/tooltip": "^0.0.29",
|
|
78
78
|
"@floating-ui/dom": "^1.7.3",
|
|
79
|
-
"@ocavue/utils": "^0.
|
|
79
|
+
"@ocavue/utils": "^0.7.1",
|
|
80
80
|
"@zag-js/dom-query": "^1.21.1",
|
|
81
81
|
"prosemirror-tables": "^1.7.1",
|
|
82
82
|
"@prosekit/core": "^0.8.3",
|
|
83
|
-
"@prosekit/extensions": "^0.11.
|
|
83
|
+
"@prosekit/extensions": "^0.11.4",
|
|
84
84
|
"@prosekit/pm": "^0.1.11"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"tsdown": "^0.13.
|
|
88
|
-
"
|
|
87
|
+
"tsdown": "^0.13.4",
|
|
88
|
+
"type-fest": "^4.41.0",
|
|
89
|
+
"typescript": "~5.9.2",
|
|
89
90
|
"vitest": "^3.2.4",
|
|
90
91
|
"@prosekit/config-tsdown": "0.0.0",
|
|
91
92
|
"@prosekit/config-vitest": "0.0.0"
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//#region src/utils/clone-element.ts
|
|
2
|
-
/**
|
|
3
|
-
* Creates a deep clone of an Element, including all computed styles so that
|
|
4
|
-
* it looks almost exactly the same as the original element.
|
|
5
|
-
*/
|
|
6
|
-
function deepCloneElement(element) {
|
|
7
|
-
const clonedElement = element.cloneNode(true);
|
|
8
|
-
deepCopyStyles(element, clonedElement);
|
|
9
|
-
return clonedElement;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Creates a clone of an Element, including all computed styles so that
|
|
13
|
-
* it looks similar enough to the original element.
|
|
14
|
-
*/
|
|
15
|
-
function cloneElement(element) {
|
|
16
|
-
const clonedElement = element.cloneNode();
|
|
17
|
-
copyStyles(element, clonedElement);
|
|
18
|
-
return clonedElement;
|
|
19
|
-
}
|
|
20
|
-
function deepCopyStyles(source, target) {
|
|
21
|
-
const sources = [source];
|
|
22
|
-
const targets = [target];
|
|
23
|
-
while (sources.length > 0 && sources.length === targets.length) {
|
|
24
|
-
const source$1 = sources.pop();
|
|
25
|
-
const target$1 = targets.pop();
|
|
26
|
-
if (!source$1 || !target$1) return;
|
|
27
|
-
copyStyles(source$1, target$1);
|
|
28
|
-
sources.push(...source$1.children);
|
|
29
|
-
targets.push(...target$1.children);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function copyStyles(source, target) {
|
|
33
|
-
if (!source || !target) return;
|
|
34
|
-
const sourceStyle = source.ownerDocument?.defaultView?.getComputedStyle(source);
|
|
35
|
-
const targetStyle = target.style;
|
|
36
|
-
if (!sourceStyle || !targetStyle) return;
|
|
37
|
-
for (const key of sourceStyle) targetStyle.setProperty(key, sourceStyle.getPropertyValue(key), sourceStyle.getPropertyPriority(key));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
export { cloneElement, deepCloneElement };
|