@prosekit/web 0.7.1 → 0.7.2
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-RwRNoINh.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 +3 -2
- 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 +57 -13
- package/package.json +6 -6
- 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) {
|
|
9
|
+
const clonedElement = element.cloneNode(true);
|
|
10
|
+
const style = deepCopyStyles(element, clonedElement);
|
|
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) {
|
|
18
|
+
const clonedElement = element.cloneNode();
|
|
19
|
+
const style = copyStyles(element, clonedElement);
|
|
20
|
+
return [clonedElement, style];
|
|
21
|
+
}
|
|
22
|
+
function deepCopyStyles(source, target) {
|
|
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);
|
|
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) {
|
|
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), 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-RwRNoINh.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";
|
|
@@ -129,13 +129,14 @@ function setDragPreview(event, element) {
|
|
|
129
129
|
width: `${width + borderX}px`,
|
|
130
130
|
height: `${height + borderY}px`
|
|
131
131
|
});
|
|
132
|
-
const clonedElement = deepCloneElement(element);
|
|
132
|
+
const [clonedElement, styleText] = deepCloneElement(element);
|
|
133
133
|
assignStyles(clonedElement, {
|
|
134
134
|
opacity: "0.5",
|
|
135
135
|
margin: "0"
|
|
136
136
|
});
|
|
137
137
|
document.body.appendChild(container);
|
|
138
138
|
container.appendChild(clonedElement);
|
|
139
|
+
injectStyle(container, styleText);
|
|
139
140
|
event.dataTransfer?.setDragImage(container, Math.max(-outsideX, 0), Math.max(-outsideY, 0));
|
|
140
141
|
requestAnimationFrame(() => {
|
|
141
142
|
container.remove();
|
|
@@ -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-RwRNoINh.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";
|
|
@@ -286,6 +286,45 @@ function getDndRelatedDOMs(view, cellPos, draggingIndex, direction) {
|
|
|
286
286
|
};
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/utils/css-feature-detection.ts
|
|
291
|
+
const isColorMixSupported = once(() => {
|
|
292
|
+
try {
|
|
293
|
+
return CSS.supports("background-color", "color-mix(in srgb, red, blue)");
|
|
294
|
+
} catch {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region src/utils/fade-color.ts
|
|
301
|
+
/**
|
|
302
|
+
* Convert a color to a color with opacity
|
|
303
|
+
* @param color - The color to convert
|
|
304
|
+
* @param opacity - The opacity to apply
|
|
305
|
+
* @returns The converted color if color-mix is supported, otherwise undefined
|
|
306
|
+
*/
|
|
307
|
+
function fadeColor(color, opacity) {
|
|
308
|
+
if (isColorMixSupported()) {
|
|
309
|
+
const transparentWeight = (1 - opacity) * 100;
|
|
310
|
+
const colorWeight = opacity * 100;
|
|
311
|
+
return `color-mix(in srgb, ${color} ${colorWeight}%, transparent ${transparentWeight}%)`;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region src/utils/get-effective-background-color.ts
|
|
317
|
+
function getEffectiveBackgroundColor(element) {
|
|
318
|
+
let current = element;
|
|
319
|
+
while (current) {
|
|
320
|
+
const style = current.ownerDocument.defaultView?.getComputedStyle(current);
|
|
321
|
+
const backgroundColor = style?.backgroundColor;
|
|
322
|
+
if (backgroundColor && backgroundColor !== "transparent" && backgroundColor !== "rgba(0, 0, 0, 0)") return backgroundColor;
|
|
323
|
+
current = current.parentElement;
|
|
324
|
+
}
|
|
325
|
+
return void 0;
|
|
326
|
+
}
|
|
327
|
+
|
|
289
328
|
//#endregion
|
|
290
329
|
//#region src/components/table-handle/table-handle-drag-preview/render-preview.ts
|
|
291
330
|
function clearPreviewDOM(previewRoot) {
|
|
@@ -293,35 +332,40 @@ function clearPreviewDOM(previewRoot) {
|
|
|
293
332
|
}
|
|
294
333
|
function createPreviewDOM(table, previewRoot, index, direction) {
|
|
295
334
|
clearPreviewDOM(previewRoot);
|
|
296
|
-
const previewTable =
|
|
335
|
+
const [previewTable, previewTableStyle] = cloneElement(table);
|
|
336
|
+
injectStyle(previewRoot, previewTableStyle);
|
|
337
|
+
unsetSize(previewTable);
|
|
297
338
|
const tableBody = table.querySelector("tbody");
|
|
298
|
-
const previewTableBody = tableBody ?
|
|
339
|
+
const [previewTableBody, previewTableBodyStyle] = tableBody ? cloneElement(tableBody) : [table.ownerDocument.createElement("tbody"), ""];
|
|
340
|
+
injectStyle(previewRoot, previewTableBodyStyle);
|
|
299
341
|
unsetSize(previewTableBody);
|
|
300
|
-
|
|
342
|
+
const backgroundColor = getEffectiveBackgroundColor(table);
|
|
343
|
+
if (backgroundColor) {
|
|
344
|
+
const backgroundColorWithOpacity = fadeColor(backgroundColor, .8);
|
|
345
|
+
if (backgroundColorWithOpacity) assignStyles(previewTable, { backgroundColor: backgroundColorWithOpacity });
|
|
346
|
+
}
|
|
301
347
|
previewTable.appendChild(previewTableBody);
|
|
302
348
|
previewRoot.appendChild(previewTable);
|
|
303
349
|
const rows = table.querySelectorAll("tr");
|
|
304
350
|
if (direction === "row") {
|
|
305
351
|
const row = rows[index];
|
|
306
|
-
const previewRow = deepCloneElement(row);
|
|
352
|
+
const [previewRow, previewRowStyle] = deepCloneElement(row);
|
|
353
|
+
injectStyle(previewRoot, previewRowStyle);
|
|
307
354
|
previewTableBody.appendChild(previewRow);
|
|
308
355
|
} else rows.forEach((row) => {
|
|
309
|
-
const previewRow =
|
|
356
|
+
const [previewRow, previewRowStyle] = cloneElement(row);
|
|
357
|
+
injectStyle(previewRoot, previewRowStyle);
|
|
310
358
|
unsetSize(previewRow);
|
|
311
359
|
const cells = row.querySelectorAll("td");
|
|
312
360
|
const cell = cells[index];
|
|
313
361
|
if (cell) {
|
|
314
|
-
const previewCell = deepCloneElement(cell);
|
|
362
|
+
const [previewCell, previewCellStyle] = deepCloneElement(cell);
|
|
363
|
+
injectStyle(previewRoot, previewCellStyle);
|
|
315
364
|
previewRow.appendChild(previewCell);
|
|
316
365
|
previewTableBody.appendChild(previewRow);
|
|
317
366
|
}
|
|
318
367
|
});
|
|
319
368
|
}
|
|
320
|
-
function cloneElementWithoutSize(element) {
|
|
321
|
-
const clonedElement = cloneElement(element);
|
|
322
|
-
unsetSize(clonedElement);
|
|
323
|
-
return clonedElement;
|
|
324
|
-
}
|
|
325
369
|
function unsetSize(element) {
|
|
326
370
|
assignStyles(element, {
|
|
327
371
|
width: "unset",
|
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.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "A collection of web components for ProseKit",
|
|
7
7
|
"author": {
|
|
@@ -76,19 +76,19 @@
|
|
|
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.2",
|
|
84
84
|
"@prosekit/pm": "^0.1.11"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"tsdown": "^0.13.
|
|
87
|
+
"tsdown": "^0.13.2",
|
|
88
88
|
"typescript": "~5.8.3",
|
|
89
89
|
"vitest": "^3.2.4",
|
|
90
|
-
"@prosekit/config-
|
|
91
|
-
"@prosekit/config-
|
|
90
|
+
"@prosekit/config-vitest": "0.0.0",
|
|
91
|
+
"@prosekit/config-tsdown": "0.0.0"
|
|
92
92
|
},
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"dev": {}
|
|
@@ -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 };
|