@prosekit/web 0.8.0-beta.0 → 0.8.0-beta.1
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/prosekit-web-autocomplete.d.ts +112 -90
- package/dist/prosekit-web-autocomplete.d.ts.map +1 -1
- package/dist/prosekit-web-autocomplete.js +292 -217
- package/dist/prosekit-web-autocomplete.js.map +1 -1
- package/dist/prosekit-web-block-handle.d.ts +95 -62
- package/dist/prosekit-web-block-handle.d.ts.map +1 -1
- package/dist/prosekit-web-block-handle.js +219 -114
- package/dist/prosekit-web-block-handle.js.map +1 -1
- package/dist/prosekit-web-drop-indicator.d.ts +13 -15
- package/dist/prosekit-web-drop-indicator.d.ts.map +1 -1
- package/dist/prosekit-web-drop-indicator.js +34 -30
- package/dist/prosekit-web-drop-indicator.js.map +1 -1
- package/dist/prosekit-web-inline-popover.d.ts +88 -54
- package/dist/prosekit-web-inline-popover.d.ts.map +1 -1
- package/dist/prosekit-web-inline-popover.js +129 -79
- package/dist/prosekit-web-inline-popover.js.map +1 -1
- package/dist/prosekit-web-menu.d.ts +13 -0
- package/dist/prosekit-web-menu.d.ts.map +1 -0
- package/dist/prosekit-web-menu.js +53 -0
- package/dist/prosekit-web-menu.js.map +1 -0
- package/dist/prosekit-web-popover.d.ts +7 -26
- package/dist/prosekit-web-popover.d.ts.map +1 -1
- package/dist/prosekit-web-popover.js +31 -29
- package/dist/prosekit-web-popover.js.map +1 -1
- package/dist/prosekit-web-resizable.d.ts +92 -51
- package/dist/prosekit-web-resizable.d.ts.map +1 -1
- package/dist/prosekit-web-resizable.js +139 -131
- package/dist/prosekit-web-resizable.js.map +1 -1
- package/dist/prosekit-web-table-handle.d.ts +166 -199
- package/dist/prosekit-web-table-handle.d.ts.map +1 -1
- package/dist/prosekit-web-table-handle.js +495 -496
- package/dist/prosekit-web-table-handle.js.map +1 -1
- package/dist/prosekit-web-tooltip.d.ts +7 -26
- package/dist/prosekit-web-tooltip.d.ts.map +1 -1
- package/dist/prosekit-web-tooltip.js +31 -29
- package/dist/prosekit-web-tooltip.js.map +1 -1
- package/dist/use-editor-extension.js +2 -2
- package/dist/use-editor-extension.js.map +1 -1
- package/dist/use-scrolling.js +17 -8
- package/dist/use-scrolling.js.map +1 -1
- package/package.json +28 -23
- package/src/components/autocomplete/autocomplete-empty.ts +45 -0
- package/src/components/autocomplete/autocomplete-item.ts +65 -0
- package/src/components/autocomplete/autocomplete-popup.ts +95 -0
- package/src/components/autocomplete/autocomplete-positioner.ts +98 -0
- package/src/components/autocomplete/autocomplete-root.ts +280 -0
- package/src/components/autocomplete/context.ts +16 -14
- package/src/components/autocomplete/index.ts +65 -0
- package/src/components/block-handle/block-handle-add.ts +71 -0
- package/src/components/block-handle/block-handle-draggable.ts +158 -0
- package/src/components/block-handle/block-handle-popup.ts +43 -0
- package/src/components/block-handle/block-handle-positioner.ts +89 -0
- package/src/components/block-handle/block-handle-root.ts +116 -0
- package/src/components/block-handle/context.ts +9 -18
- package/src/components/block-handle/hover-state.ts +16 -0
- package/src/components/block-handle/index.ts +59 -0
- package/src/components/block-handle/{block-handle-popover/pointer-move.ts → pointer-move.ts} +8 -7
- package/src/components/block-handle/{block-handle-draggable/set-drag-preview.ts → set-drag-preview.ts} +4 -4
- package/src/components/block-handle/use-hover-extension.ts +65 -0
- package/src/components/drop-indicator/drop-indicator.ts +128 -0
- package/src/components/drop-indicator/index.ts +18 -0
- package/src/components/inline-popover/index.ts +41 -0
- package/src/components/inline-popover/inline-popover-popup.ts +52 -0
- package/src/components/inline-popover/inline-popover-positioner.ts +98 -0
- package/src/components/inline-popover/inline-popover-root.ts +122 -0
- package/src/components/inline-popover/store.ts +6 -0
- package/src/components/menu/index.ts +92 -0
- package/src/components/popover/index.ts +53 -0
- package/src/components/resizable/{resizable-handle/calc-resize.ts → calc-resize.ts} +1 -1
- package/src/components/resizable/context.ts +3 -6
- package/src/components/resizable/index.ts +32 -0
- package/src/components/resizable/resizable-handle.ts +134 -0
- package/src/components/resizable/resizable-root.ts +184 -0
- package/src/components/table-handle/dnd.ts +16 -27
- package/src/components/table-handle/index.ts +125 -0
- package/src/components/table-handle/{table-handle-drag-preview/render-preview.ts → render-preview.ts} +5 -5
- package/src/components/table-handle/shared.ts +61 -0
- package/src/components/table-handle/store.ts +117 -0
- package/src/components/table-handle/table-handle-column-menu-root.ts +51 -0
- package/src/components/table-handle/table-handle-column-menu-trigger.ts +107 -0
- package/src/components/table-handle/table-handle-column-popup.ts +44 -0
- package/src/components/table-handle/table-handle-column-positioner.ts +67 -0
- package/src/components/table-handle/table-handle-drag-preview.ts +169 -0
- package/src/components/table-handle/table-handle-drop-indicator.ts +166 -0
- package/src/components/table-handle/table-handle-root.ts +103 -0
- package/src/components/table-handle/table-handle-row-menu-root.ts +51 -0
- package/src/components/table-handle/table-handle-row-menu-trigger.ts +107 -0
- package/src/components/table-handle/table-handle-row-popup.ts +42 -0
- package/src/components/table-handle/table-handle-row-positioner.ts +67 -0
- package/src/components/table-handle/use-drop.ts +74 -0
- package/src/components/table-handle/{hooks/use-empty-image.ts → use-empty-image.ts} +2 -3
- package/src/components/table-handle/utils.ts +0 -11
- package/src/components/tooltip/index.ts +52 -0
- package/src/hooks/use-editor-extension.ts +4 -4
- package/src/hooks/use-editor-focus-event.ts +4 -4
- package/src/hooks/use-editor-typing.ts +12 -16
- package/src/hooks/use-editor-update-event.ts +4 -4
- package/src/hooks/use-keymap.ts +4 -4
- package/src/hooks/use-scrolling.ts +11 -10
- package/src/hooks/use-selecting.ts +8 -15
- package/src/utils/event.ts +28 -0
- package/src/utils/lazy-signal.spec.ts +68 -0
- package/src/utils/lazy-signal.ts +17 -0
- package/src/utils/prefers-reduced-motion.ts +6 -0
- package/src/utils/prevent-default.ts +3 -0
- package/src/utils/use-html-element-at.ts +17 -0
- package/src/utils/use-no-focus.ts +7 -0
- package/dist/get-default-state.js +0 -11
- package/dist/get-default-state.js.map +0 -1
- package/src/components/autocomplete/autocomplete-empty/element.gen.ts +0 -18
- package/src/components/autocomplete/autocomplete-empty/setup.ts +0 -6
- package/src/components/autocomplete/autocomplete-empty/types.ts +0 -13
- package/src/components/autocomplete/autocomplete-item/element.gen.ts +0 -18
- package/src/components/autocomplete/autocomplete-item/setup.ts +0 -30
- package/src/components/autocomplete/autocomplete-item/types.ts +0 -25
- package/src/components/autocomplete/autocomplete-list/element.gen.ts +0 -18
- package/src/components/autocomplete/autocomplete-list/setup.ts +0 -125
- package/src/components/autocomplete/autocomplete-list/types.ts +0 -22
- package/src/components/autocomplete/autocomplete-popover/element.gen.ts +0 -18
- package/src/components/autocomplete/autocomplete-popover/setup.ts +0 -169
- package/src/components/autocomplete/autocomplete-popover/types.ts +0 -100
- package/src/components/autocomplete/index.gen.ts +0 -17
- package/src/components/block-handle/block-handle-add/element.gen.ts +0 -18
- package/src/components/block-handle/block-handle-add/setup.ts +0 -33
- package/src/components/block-handle/block-handle-add/types.ts +0 -23
- package/src/components/block-handle/block-handle-draggable/element.gen.ts +0 -18
- package/src/components/block-handle/block-handle-draggable/setup.ts +0 -113
- package/src/components/block-handle/block-handle-draggable/types.ts +0 -23
- package/src/components/block-handle/block-handle-popover/element.gen.ts +0 -18
- package/src/components/block-handle/block-handle-popover/setup.ts +0 -68
- package/src/components/block-handle/block-handle-popover/types.ts +0 -81
- package/src/components/block-handle/index.gen.ts +0 -13
- package/src/components/drop-indicator/drop-indicator/element.gen.ts +0 -18
- package/src/components/drop-indicator/drop-indicator/setup.ts +0 -75
- package/src/components/drop-indicator/drop-indicator/types.ts +0 -31
- package/src/components/drop-indicator/index.gen.ts +0 -5
- package/src/components/inline-popover/index.gen.ts +0 -5
- package/src/components/inline-popover/inline-popover/element.gen.ts +0 -18
- package/src/components/inline-popover/inline-popover/setup.ts +0 -111
- package/src/components/inline-popover/inline-popover/types.ts +0 -112
- package/src/components/popover/index.gen.ts +0 -13
- package/src/components/popover/popover-content/element.gen.ts +0 -18
- package/src/components/popover/popover-content/setup.ts +0 -1
- package/src/components/popover/popover-content/types.ts +0 -6
- package/src/components/popover/popover-root/element.gen.ts +0 -18
- package/src/components/popover/popover-root/setup.ts +0 -1
- package/src/components/popover/popover-root/types.ts +0 -6
- package/src/components/popover/popover-trigger/element.gen.ts +0 -18
- package/src/components/popover/popover-trigger/setup.ts +0 -1
- package/src/components/popover/popover-trigger/types.ts +0 -6
- package/src/components/resizable/index.gen.ts +0 -9
- package/src/components/resizable/resizable-handle/element.gen.ts +0 -18
- package/src/components/resizable/resizable-handle/setup.ts +0 -106
- package/src/components/resizable/resizable-handle/types.ts +0 -29
- package/src/components/resizable/resizable-root/element.gen.ts +0 -18
- package/src/components/resizable/resizable-root/setup.ts +0 -84
- package/src/components/resizable/resizable-root/types.ts +0 -59
- package/src/components/table-handle/context.ts +0 -43
- package/src/components/table-handle/hooks/use-drop.ts +0 -85
- package/src/components/table-handle/index.gen.ts +0 -37
- package/src/components/table-handle/table-handle-column-root/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-column-root/setup.ts +0 -60
- package/src/components/table-handle/table-handle-column-root/types.ts +0 -73
- package/src/components/table-handle/table-handle-column-trigger/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-column-trigger/setup.ts +0 -64
- package/src/components/table-handle/table-handle-column-trigger/types.ts +0 -20
- package/src/components/table-handle/table-handle-drag-preview/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-drag-preview/setup.ts +0 -57
- package/src/components/table-handle/table-handle-drag-preview/types.ts +0 -14
- package/src/components/table-handle/table-handle-drag-preview/updater.ts +0 -90
- package/src/components/table-handle/table-handle-drop-indicator/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-drop-indicator/setup.ts +0 -52
- package/src/components/table-handle/table-handle-drop-indicator/types.ts +0 -15
- package/src/components/table-handle/table-handle-drop-indicator/updater.ts +0 -96
- package/src/components/table-handle/table-handle-popover-content/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-popover-content/setup.ts +0 -83
- package/src/components/table-handle/table-handle-popover-content/types.ts +0 -32
- package/src/components/table-handle/table-handle-popover-item/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-popover-item/setup.ts +0 -17
- package/src/components/table-handle/table-handle-popover-item/types.ts +0 -16
- package/src/components/table-handle/table-handle-root/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-root/setup.ts +0 -86
- package/src/components/table-handle/table-handle-root/types.ts +0 -23
- package/src/components/table-handle/table-handle-row-root/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-row-root/setup.ts +0 -70
- package/src/components/table-handle/table-handle-row-root/types.ts +0 -68
- package/src/components/table-handle/table-handle-row-trigger/element.gen.ts +0 -18
- package/src/components/table-handle/table-handle-row-trigger/setup.ts +0 -63
- package/src/components/table-handle/table-handle-row-trigger/types.ts +0 -23
- package/src/components/tooltip/index.gen.ts +0 -13
- package/src/components/tooltip/tooltip-content/element.gen.ts +0 -18
- package/src/components/tooltip/tooltip-content/setup.ts +0 -1
- package/src/components/tooltip/tooltip-content/types.ts +0 -6
- package/src/components/tooltip/tooltip-root/element.gen.ts +0 -18
- package/src/components/tooltip/tooltip-root/setup.ts +0 -1
- package/src/components/tooltip/tooltip-root/types.ts +0 -6
- package/src/components/tooltip/tooltip-trigger/element.gen.ts +0 -18
- package/src/components/tooltip/tooltip-trigger/setup.ts +0 -1
- package/src/components/tooltip/tooltip-trigger/types.ts +0 -6
- package/src/hooks/use-first-rendering.ts +0 -15
- package/src/utils/get-default-state.spec.ts +0 -42
- package/src/utils/get-default-state.ts +0 -18
- /package/src/components/autocomplete/{autocomplete-popover/helpers.spec.ts → helpers.spec.ts} +0 -0
- /package/src/components/autocomplete/{autocomplete-popover/helpers.ts → helpers.ts} +0 -0
- /package/src/components/inline-popover/{inline-popover/virtual-selection-element.ts → virtual-selection-element.ts} +0 -0
- /package/src/components/resizable/{resizable-handle/calc-resize.spec.ts → calc-resize.spec.ts} +0 -0
- /package/src/components/table-handle/{table-handle-drop-indicator/calc-drag-over.ts → calc-drag-over.ts} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as useEditorExtension } from "./use-editor-extension.js";
|
|
2
2
|
import { t as getSafeEditorView } from "./get-safe-editor-view.js";
|
|
3
3
|
import { n as assignStyles, t as useScrolling } from "./use-scrolling.js";
|
|
4
|
-
import {
|
|
4
|
+
import { computed, createContext, createSignal, defineCustomElement, defineProps, onMount, registerCustomElement, useEffect, useEventListener } from "@aria-ui/core";
|
|
5
|
+
import { OverlayPopupPropsDeclaration, OverlayPositionerPropsDeclaration, createOverlayStore, setupOverlayPopup, setupOverlayPositioner } from "@aria-ui/elements/overlay";
|
|
5
6
|
import { defineDOMEventHandler, insertDefaultBlock, union } from "@prosekit/core";
|
|
6
|
-
import {
|
|
7
|
-
import { usePresence } from "@aria-ui/presence";
|
|
7
|
+
import { useAttribute } from "@aria-ui/utils";
|
|
8
8
|
import { isElement, isHTMLElement, isTextNode, throttle } from "@ocavue/utils";
|
|
9
9
|
import { Fragment, Slice } from "@prosekit/pm/model";
|
|
10
10
|
import { NodeSelection } from "@prosekit/pm/state";
|
|
@@ -12,44 +12,54 @@ import { NodeSelection } from "@prosekit/pm/state";
|
|
|
12
12
|
/**
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
var BlockHandleStore = class {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.hoverState = createSignal(void 0);
|
|
18
|
+
this.dragging = createSignal(false);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
const blockHandleStoreContext = createContext("prosekit-block-handle-store");
|
|
16
25
|
/**
|
|
17
26
|
* @internal
|
|
18
27
|
*/
|
|
19
|
-
const
|
|
28
|
+
const blockHandleOverlayStoreContext = createContext("prosekit-block-handle-overlay-store");
|
|
20
29
|
//#endregion
|
|
21
|
-
//#region src/components/block-handle/block-handle-add
|
|
30
|
+
//#region src/components/block-handle/block-handle-add.ts
|
|
31
|
+
/** @internal */
|
|
32
|
+
const BlockHandleAddPropsDeclaration = /* @__PURE__ */ defineProps({ editor: {
|
|
33
|
+
default: null,
|
|
34
|
+
attribute: false,
|
|
35
|
+
type: "json"
|
|
36
|
+
} });
|
|
22
37
|
/**
|
|
23
38
|
* @internal
|
|
24
39
|
*/
|
|
25
|
-
function
|
|
26
|
-
const
|
|
40
|
+
function setupBlockHandleAdd(host, props) {
|
|
41
|
+
const getStore = blockHandleStoreContext.consume(host);
|
|
27
42
|
useEventListener(host, "pointerdown", (event) => {
|
|
28
43
|
event.preventDefault();
|
|
29
|
-
const
|
|
30
|
-
const
|
|
44
|
+
const store = getStore();
|
|
45
|
+
const editor = props.editor.get();
|
|
46
|
+
const hoverState = store?.hoverState.get();
|
|
31
47
|
if (!editor || !hoverState) return;
|
|
32
48
|
const { node, pos } = hoverState;
|
|
33
49
|
editor.exec(insertDefaultBlock({ pos: pos + node.nodeSize }));
|
|
34
50
|
editor.focus();
|
|
35
|
-
|
|
51
|
+
store?.hoverState.set(void 0);
|
|
36
52
|
});
|
|
37
53
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/** @internal */
|
|
43
|
-
const blockHandleAddEvents = {};
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/components/block-handle/block-handle-add/element.gen.ts
|
|
46
|
-
const BlockHandleAddElementBase = defineCustomElement({
|
|
47
|
-
props: blockHandleAddProps,
|
|
48
|
-
events: blockHandleAddEvents,
|
|
49
|
-
setup: useBlockHandleAdd
|
|
50
|
-
});
|
|
54
|
+
const BlockHandleAddElementBase = defineCustomElement(setupBlockHandleAdd, BlockHandleAddPropsDeclaration);
|
|
55
|
+
/**
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
51
58
|
var BlockHandleAddElement = class extends BlockHandleAddElementBase {};
|
|
52
|
-
|
|
59
|
+
/** @internal */
|
|
60
|
+
function registerBlockHandleAddElement() {
|
|
61
|
+
registerCustomElement("prosekit-block-handle-add", BlockHandleAddElement);
|
|
62
|
+
}
|
|
53
63
|
//#endregion
|
|
54
64
|
//#region src/constants.ts
|
|
55
65
|
const DRAGGING_CLASS_NAME = "prosekit-dragging";
|
|
@@ -110,7 +120,7 @@ function addExtra(element, rect, options) {
|
|
|
110
120
|
//#region src/utils/max-z-index.ts
|
|
111
121
|
const maxZIndex = "2147483647";
|
|
112
122
|
//#endregion
|
|
113
|
-
//#region src/components/block-handle/
|
|
123
|
+
//#region src/components/block-handle/set-drag-preview.ts
|
|
114
124
|
/**
|
|
115
125
|
* Sets a drag preview image for the given element and ensures the preview position
|
|
116
126
|
* relative to the pointer is correct.
|
|
@@ -164,21 +174,27 @@ function setDragPreview(event, element) {
|
|
|
164
174
|
});
|
|
165
175
|
}
|
|
166
176
|
//#endregion
|
|
167
|
-
//#region src/components/block-handle/block-handle-draggable
|
|
177
|
+
//#region src/components/block-handle/block-handle-draggable.ts
|
|
178
|
+
/** @internal */
|
|
179
|
+
const BlockHandleDraggablePropsDeclaration = /* @__PURE__ */ defineProps({ editor: {
|
|
180
|
+
default: null,
|
|
181
|
+
attribute: false,
|
|
182
|
+
type: "json"
|
|
183
|
+
} });
|
|
168
184
|
/**
|
|
169
185
|
* @internal
|
|
170
186
|
*/
|
|
171
|
-
function
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
useEffect(host, () => {
|
|
187
|
+
function setupBlockHandleDraggable(host, props) {
|
|
188
|
+
const getStore = blockHandleStoreContext.consume(host);
|
|
189
|
+
onMount(host, () => {
|
|
175
190
|
host.draggable = true;
|
|
176
191
|
});
|
|
177
|
-
usePointerDownHandler(host,
|
|
192
|
+
usePointerDownHandler(host, () => getStore()?.hoverState.get() ?? null, props.editor.get);
|
|
178
193
|
useEventListener(host, "dragstart", (event) => {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const
|
|
194
|
+
const store = getStore();
|
|
195
|
+
store?.dragging.set(true);
|
|
196
|
+
const view = getSafeEditorView(props.editor.get());
|
|
197
|
+
const hoverState = store?.hoverState.get();
|
|
182
198
|
if (view && hoverState) {
|
|
183
199
|
view.dom.classList.add(DRAGGING_CLASS_NAME);
|
|
184
200
|
createDraggingPreview(view, hoverState, event);
|
|
@@ -186,18 +202,19 @@ function useBlockHandleDraggable(host, { state }) {
|
|
|
186
202
|
}
|
|
187
203
|
});
|
|
188
204
|
useEventListener(host, "dragend", () => {
|
|
189
|
-
dragging.set(false);
|
|
190
|
-
const view = getSafeEditorView(
|
|
205
|
+
getStore()?.dragging.set(false);
|
|
206
|
+
const view = getSafeEditorView(props.editor.get());
|
|
191
207
|
if (view) view.dom.classList.remove(DRAGGING_CLASS_NAME);
|
|
192
208
|
});
|
|
193
|
-
useAttribute(host, "data-dragging", () => dragging.get() ? "" : void 0);
|
|
209
|
+
useAttribute(host, "data-dragging", () => getStore()?.dragging.get() ? "" : void 0);
|
|
194
210
|
}
|
|
195
|
-
function usePointerDownHandler(host,
|
|
211
|
+
function usePointerDownHandler(host, getHoverState, getEditor) {
|
|
196
212
|
useEventListener(host, "pointerdown", () => {
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
if (pos == null || view
|
|
200
|
-
view
|
|
213
|
+
const hoverState = getHoverState();
|
|
214
|
+
const editor = getEditor();
|
|
215
|
+
if (hoverState?.pos == null || !editor?.view) return;
|
|
216
|
+
const { view } = editor;
|
|
217
|
+
view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, hoverState.pos)));
|
|
201
218
|
requestAnimationFrame(() => {
|
|
202
219
|
view.focus();
|
|
203
220
|
});
|
|
@@ -221,23 +238,92 @@ function setViewDragging(view, hoverState) {
|
|
|
221
238
|
node: NodeSelection.create(view.state.doc, pos)
|
|
222
239
|
};
|
|
223
240
|
}
|
|
241
|
+
const BlockHandleDraggableElementBase = defineCustomElement(setupBlockHandleDraggable, BlockHandleDraggablePropsDeclaration);
|
|
242
|
+
/**
|
|
243
|
+
* @public
|
|
244
|
+
*/
|
|
245
|
+
var BlockHandleDraggableElement = class extends BlockHandleDraggableElementBase {};
|
|
246
|
+
/** @internal */
|
|
247
|
+
function registerBlockHandleDraggableElement() {
|
|
248
|
+
registerCustomElement("prosekit-block-handle-draggable", BlockHandleDraggableElement);
|
|
249
|
+
}
|
|
224
250
|
//#endregion
|
|
225
|
-
//#region src/components/block-handle/block-handle-
|
|
251
|
+
//#region src/components/block-handle/block-handle-popup.ts
|
|
252
|
+
/** @internal */
|
|
253
|
+
const BlockHandlePopupPropsDeclaration = OverlayPopupPropsDeclaration;
|
|
226
254
|
/** @internal */
|
|
227
|
-
|
|
255
|
+
function setupBlockHandlePopup(host, _props) {
|
|
256
|
+
setupOverlayPopup(host, blockHandleOverlayStoreContext.consume(host));
|
|
257
|
+
}
|
|
258
|
+
const BlockHandlePopupElementBase = defineCustomElement(setupBlockHandlePopup, BlockHandlePopupPropsDeclaration);
|
|
259
|
+
/**
|
|
260
|
+
* @public
|
|
261
|
+
*/
|
|
262
|
+
var BlockHandlePopupElement = class extends BlockHandlePopupElementBase {};
|
|
228
263
|
/** @internal */
|
|
229
|
-
|
|
264
|
+
function registerBlockHandlePopupElement() {
|
|
265
|
+
registerCustomElement("prosekit-block-handle-popup", BlockHandlePopupElement);
|
|
266
|
+
}
|
|
230
267
|
//#endregion
|
|
231
|
-
//#region src/components/block-handle/block-handle-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
268
|
+
//#region src/components/block-handle/block-handle-positioner.ts
|
|
269
|
+
/** @internal */
|
|
270
|
+
const BlockHandlePositionerPropsDeclaration = /* @__PURE__ */ defineProps({
|
|
271
|
+
...OverlayPositionerPropsDeclaration,
|
|
272
|
+
placement: {
|
|
273
|
+
default: "left",
|
|
274
|
+
attribute: "placement",
|
|
275
|
+
type: "string"
|
|
276
|
+
},
|
|
277
|
+
hoist: {
|
|
278
|
+
default: false,
|
|
279
|
+
attribute: "hoist",
|
|
280
|
+
type: "boolean"
|
|
281
|
+
},
|
|
282
|
+
flip: {
|
|
283
|
+
default: false,
|
|
284
|
+
attribute: false,
|
|
285
|
+
type: "json"
|
|
286
|
+
},
|
|
287
|
+
shift: {
|
|
288
|
+
default: false,
|
|
289
|
+
attribute: "shift",
|
|
290
|
+
type: "boolean"
|
|
291
|
+
},
|
|
292
|
+
hide: {
|
|
293
|
+
default: true,
|
|
294
|
+
attribute: "hide",
|
|
295
|
+
type: "boolean"
|
|
296
|
+
}
|
|
236
297
|
});
|
|
237
|
-
|
|
238
|
-
|
|
298
|
+
/** @internal */
|
|
299
|
+
function setupBlockHandlePositioner(host, props) {
|
|
300
|
+
setupOverlayPositioner(host, props, blockHandleOverlayStoreContext.consume(host));
|
|
301
|
+
}
|
|
302
|
+
const BlockHandlePositionerElementBase = defineCustomElement(setupBlockHandlePositioner, BlockHandlePositionerPropsDeclaration);
|
|
303
|
+
/**
|
|
304
|
+
* @public
|
|
305
|
+
*/
|
|
306
|
+
var BlockHandlePositionerElement = class extends BlockHandlePositionerElementBase {};
|
|
307
|
+
/** @internal */
|
|
308
|
+
function registerBlockHandlePositionerElement() {
|
|
309
|
+
registerCustomElement("prosekit-block-handle-positioner", BlockHandlePositionerElement);
|
|
310
|
+
}
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region src/utils/prefers-reduced-motion.ts
|
|
313
|
+
function prefersReducedMotion() {
|
|
314
|
+
if (typeof window === "undefined") return false;
|
|
315
|
+
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
316
|
+
}
|
|
239
317
|
//#endregion
|
|
240
|
-
//#region src/components/block-handle/
|
|
318
|
+
//#region src/components/block-handle/hover-state.ts
|
|
319
|
+
/**
|
|
320
|
+
* @internal
|
|
321
|
+
*/
|
|
322
|
+
function isHoverStateEqual(a, b) {
|
|
323
|
+
return a.pos === b.pos && a.node.eq(b.node);
|
|
324
|
+
}
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/components/block-handle/pointer-move.ts
|
|
241
327
|
function defineElementHoverHandler(handler) {
|
|
242
328
|
const handleElement = (node, pos, element, parentElement) => {
|
|
243
329
|
handler({
|
|
@@ -265,13 +351,13 @@ function defineElementHoverHandler(handler) {
|
|
|
265
351
|
lastY = y;
|
|
266
352
|
const block = findBlockByCoords(view, x, y);
|
|
267
353
|
if (!block) {
|
|
268
|
-
handler(
|
|
354
|
+
handler();
|
|
269
355
|
return;
|
|
270
356
|
}
|
|
271
357
|
const { node, pos } = block;
|
|
272
358
|
const element = view.nodeDOM(pos);
|
|
273
359
|
if (!element || !isHTMLElement(element)) {
|
|
274
|
-
handler(
|
|
360
|
+
handler();
|
|
275
361
|
return;
|
|
276
362
|
}
|
|
277
363
|
const $pos = view.state.doc.resolve(pos);
|
|
@@ -281,7 +367,7 @@ function defineElementHoverHandler(handler) {
|
|
|
281
367
|
handleElement(parentNode, parentPos, element, view.nodeDOM(parentPos));
|
|
282
368
|
} else handleElement(node, pos, element);
|
|
283
369
|
};
|
|
284
|
-
return union(defineDOMEventHandler("pointermove", throttle(handlePointerEvent, 200)), defineDOMEventHandler("pointerenter", handlePointerEvent), defineDOMEventHandler("pointerout", handlePointerEvent), defineDOMEventHandler("keypress", () => handler(
|
|
370
|
+
return union(defineDOMEventHandler("pointermove", throttle(handlePointerEvent, 200)), defineDOMEventHandler("pointerenter", handlePointerEvent), defineDOMEventHandler("pointerout", handlePointerEvent), defineDOMEventHandler("keypress", () => handler()));
|
|
285
371
|
}
|
|
286
372
|
function findBlockByCoords(view, x, y) {
|
|
287
373
|
if (!isWithinRect(getClientRect(view.dom), x, y)) return;
|
|
@@ -405,71 +491,90 @@ const fallbackRect = Object.freeze({
|
|
|
405
491
|
y: -9999
|
|
406
492
|
});
|
|
407
493
|
//#endregion
|
|
408
|
-
//#region src/components/block-handle/
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
const
|
|
414
|
-
const reference = createSignal(null);
|
|
415
|
-
useOverlayPositionerState(host, overlayState, { reference });
|
|
416
|
-
const context = createSignal(null);
|
|
417
|
-
blockPopoverContext.provide(host, context);
|
|
418
|
-
const dragging = createSignal(false);
|
|
419
|
-
draggingContext.provide(host, dragging);
|
|
420
|
-
const scrolling = useScrolling(host);
|
|
421
|
-
const open = createComputed(() => {
|
|
422
|
-
return !!context.get() && !scrolling.get();
|
|
423
|
-
});
|
|
424
|
-
useHoverExtension(host, editor, (referenceValue, hoverState) => {
|
|
425
|
-
reference.set(referenceValue);
|
|
426
|
-
context.set(hoverState);
|
|
427
|
-
emit("stateChange", hoverState ? {
|
|
428
|
-
node: hoverState.node,
|
|
429
|
-
pos: hoverState.pos
|
|
430
|
-
} : null);
|
|
431
|
-
});
|
|
432
|
-
useAttribute(host, "data-state", () => open.get() ? "open" : "closed");
|
|
433
|
-
usePresence(host, open);
|
|
434
|
-
}
|
|
435
|
-
function useHoverExtension(host, editor, handler) {
|
|
436
|
-
let prevHoverState = null;
|
|
437
|
-
useEditorExtension(host, editor, defineElementHoverHandler((reference, hoverState) => {
|
|
438
|
-
if (isHoverStateEqual(prevHoverState, hoverState)) return;
|
|
494
|
+
//#region src/components/block-handle/use-hover-extension.ts
|
|
495
|
+
function useHoverExtension(host, getEditor, handler) {
|
|
496
|
+
const invalidTimeoutMs = prefersReducedMotion() ? 0 : 180;
|
|
497
|
+
let invalidTimeoutId;
|
|
498
|
+
let prevHoverState;
|
|
499
|
+
const callHandler = (reference, hoverState) => {
|
|
439
500
|
prevHoverState = hoverState;
|
|
440
501
|
handler(reference, hoverState);
|
|
502
|
+
};
|
|
503
|
+
useEditorExtension(host, getEditor, defineElementHoverHandler((reference, hoverState) => {
|
|
504
|
+
if (hoverState && invalidTimeoutId != null) {
|
|
505
|
+
clearTimeout(invalidTimeoutId);
|
|
506
|
+
invalidTimeoutId = void 0;
|
|
507
|
+
}
|
|
508
|
+
if (prevHoverState && hoverState) {
|
|
509
|
+
if (isHoverStateEqual(prevHoverState, hoverState)) return;
|
|
510
|
+
callHandler(reference, hoverState);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
if (!prevHoverState && !hoverState) return;
|
|
514
|
+
if (!prevHoverState && hoverState) {
|
|
515
|
+
callHandler(reference, hoverState);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
if (prevHoverState && !hoverState) {
|
|
519
|
+
if (invalidTimeoutId != null) return;
|
|
520
|
+
invalidTimeoutId = setTimeout(() => {
|
|
521
|
+
callHandler(reference, void 0);
|
|
522
|
+
invalidTimeoutId = void 0;
|
|
523
|
+
}, invalidTimeoutMs);
|
|
524
|
+
}
|
|
441
525
|
}));
|
|
442
526
|
}
|
|
443
|
-
function isHoverStateEqual(a, b) {
|
|
444
|
-
return !a && !b || a && b && a.pos === b.pos && a.node.eq(b.node);
|
|
445
|
-
}
|
|
446
527
|
//#endregion
|
|
447
|
-
//#region src/components/block-handle/block-handle-
|
|
528
|
+
//#region src/components/block-handle/block-handle-root.ts
|
|
448
529
|
/** @internal */
|
|
449
|
-
const
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
530
|
+
const BlockHandleRootPropsDeclaration = /* @__PURE__ */ defineProps({ editor: {
|
|
531
|
+
default: null,
|
|
532
|
+
attribute: false,
|
|
533
|
+
type: "json"
|
|
534
|
+
} });
|
|
535
|
+
/**
|
|
536
|
+
* @public
|
|
537
|
+
*/
|
|
538
|
+
var BlockHandleStateChangeEvent = class extends Event {
|
|
539
|
+
constructor(state) {
|
|
540
|
+
super("stateChange", { bubbles: true });
|
|
541
|
+
this.detail = state;
|
|
542
|
+
}
|
|
457
543
|
};
|
|
544
|
+
/**
|
|
545
|
+
* @internal
|
|
546
|
+
*/
|
|
547
|
+
function setupBlockHandleRoot(host, props) {
|
|
548
|
+
const getEditor = props.editor.get;
|
|
549
|
+
const store = new BlockHandleStore();
|
|
550
|
+
blockHandleStoreContext.provide(host, store);
|
|
551
|
+
const reference = createSignal(void 0);
|
|
552
|
+
const getScrolling = useScrolling(host);
|
|
553
|
+
const overlayStore = createOverlayStore(computed(() => !!store.hoverState.get() && !getScrolling()), () => {}, () => true, () => false, (event) => host.dispatchEvent(event));
|
|
554
|
+
useHoverExtension(host, getEditor, (ref, hoverState) => {
|
|
555
|
+
reference.set(ref ?? void 0);
|
|
556
|
+
store.hoverState.set(hoverState);
|
|
557
|
+
const state = hoverState ? {
|
|
558
|
+
node: hoverState.node,
|
|
559
|
+
pos: hoverState.pos
|
|
560
|
+
} : null;
|
|
561
|
+
host.dispatchEvent(new BlockHandleStateChangeEvent(state));
|
|
562
|
+
});
|
|
563
|
+
useEffect(host, () => {
|
|
564
|
+
overlayStore.setAnchorElement(reference.get());
|
|
565
|
+
});
|
|
566
|
+
blockHandleOverlayStoreContext.provide(host, overlayStore);
|
|
567
|
+
}
|
|
568
|
+
const BlockHandleRootElementBase = defineCustomElement(setupBlockHandleRoot, BlockHandleRootPropsDeclaration);
|
|
569
|
+
/**
|
|
570
|
+
* @public
|
|
571
|
+
*/
|
|
572
|
+
var BlockHandleRootElement = class extends BlockHandleRootElementBase {};
|
|
458
573
|
/** @internal */
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
};
|
|
463
|
-
//#endregion
|
|
464
|
-
//#region src/components/block-handle/block-handle-popover/element.gen.ts
|
|
465
|
-
const BlockHandlePopoverElementBase = defineCustomElement({
|
|
466
|
-
props: blockHandlePopoverProps,
|
|
467
|
-
events: blockHandlePopoverEvents,
|
|
468
|
-
setup: useBlockHandlePopover
|
|
469
|
-
});
|
|
470
|
-
var BlockHandlePopoverElement = class extends BlockHandlePopoverElementBase {};
|
|
471
|
-
registerCustomElement("prosekit-block-handle-popover", BlockHandlePopoverElement);
|
|
574
|
+
function registerBlockHandleRootElement() {
|
|
575
|
+
registerCustomElement("prosekit-block-handle-root", BlockHandleRootElement);
|
|
576
|
+
}
|
|
472
577
|
//#endregion
|
|
473
|
-
export { BlockHandleAddElement, BlockHandleDraggableElement,
|
|
578
|
+
export { BlockHandleAddElement, BlockHandleAddPropsDeclaration, BlockHandleDraggableElement, BlockHandleDraggablePropsDeclaration, BlockHandlePopupElement, BlockHandlePopupPropsDeclaration, BlockHandlePositionerElement, BlockHandlePositionerPropsDeclaration, BlockHandleRootElement, BlockHandleRootPropsDeclaration, BlockHandleStateChangeEvent, registerBlockHandleAddElement, registerBlockHandleDraggableElement, registerBlockHandlePopupElement, registerBlockHandlePositionerElement, registerBlockHandleRootElement, setupBlockHandleAdd, setupBlockHandleDraggable, setupBlockHandlePopup, setupBlockHandlePositioner, setupBlockHandleRoot };
|
|
474
579
|
|
|
475
580
|
//# sourceMappingURL=prosekit-web-block-handle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-block-handle.js","names":[],"sources":["../src/components/block-handle/context.ts","../src/components/block-handle/block-handle-add/setup.ts","../src/components/block-handle/block-handle-add/types.ts","../src/components/block-handle/block-handle-add/element.gen.ts","../src/constants.ts","../src/utils/get-client-rect.ts","../src/utils/max-z-index.ts","../src/components/block-handle/block-handle-draggable/set-drag-preview.ts","../src/components/block-handle/block-handle-draggable/setup.ts","../src/components/block-handle/block-handle-draggable/types.ts","../src/components/block-handle/block-handle-draggable/element.gen.ts","../src/components/block-handle/block-handle-popover/pointer-move.ts","../src/components/block-handle/block-handle-popover/setup.ts","../src/components/block-handle/block-handle-popover/types.ts","../src/components/block-handle/block-handle-popover/element.gen.ts"],"sourcesContent":["import { createContext, type Context } from '@aria-ui/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport interface HoverState {\n node: ProseMirrorNode\n pos: number\n}\n\n/**\n * @internal\n */\nexport type BlockPopoverContext = HoverState | null\n\n/**\n * @internal\n */\nexport const blockPopoverContext: Context<BlockPopoverContext> = createContext(\n 'prosekit-block-popover-context',\n null,\n)\n\n/**\n * @internal\n */\nexport const draggingContext: Context<boolean> = createContext(\n 'prosekit-block-handle-dragging-context',\n false,\n)\n","import { useEventListener, type ConnectableElement, type SignalState } from '@aria-ui/core'\nimport { insertDefaultBlock } from '@prosekit/core'\n\nimport { blockPopoverContext } from '../context.ts'\n\nimport type { BlockHandleAddProps } from './types.ts'\n\n/**\n * @internal\n */\nexport function useBlockHandleAdd(\n host: ConnectableElement,\n { state }: { state: SignalState<BlockHandleAddProps> },\n): void {\n const context = blockPopoverContext.consume(host)\n\n useEventListener(host, 'pointerdown', (event) => {\n event.preventDefault()\n\n const editor = state.editor.get()\n const hoverState = context.get()\n if (!editor || !hoverState) {\n return\n }\n\n const { node, pos } = hoverState\n editor.exec(insertDefaultBlock({ pos: pos + node.nodeSize }))\n editor.focus()\n\n // Hide the drag handle\n context.set(null)\n })\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nexport interface BlockHandleAddProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const blockHandleAddProps: PropDeclarations<BlockHandleAddProps> = {\n editor: { default: null },\n}\n\n/** @internal */\nexport interface BlockHandleAddEvents {}\n\n/** @internal */\nexport const blockHandleAddEvents: EventDeclarations<BlockHandleAddEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useBlockHandleAdd } from \"./setup.ts\"\nimport { blockHandleAddEvents, blockHandleAddProps, type BlockHandleAddEvents, type BlockHandleAddProps } from \"./types.ts\"\n\nconst BlockHandleAddElementBase: BaseElementConstructor<BlockHandleAddProps> = defineCustomElement<\n BlockHandleAddProps,\n BlockHandleAddEvents\n>({\n props: blockHandleAddProps,\n events: blockHandleAddEvents,\n setup: useBlockHandleAdd,\n})\nclass BlockHandleAddElement extends BlockHandleAddElementBase {}\n\nregisterCustomElement('prosekit-block-handle-add', BlockHandleAddElement)\n \nexport { BlockHandleAddElement }\n","export const DRAGGING_CLASS_NAME = 'prosekit-dragging'\n","interface Rect {\n top: number\n bottom: number\n right: number\n left: number\n}\n\ninterface IncludeExtraOptions {\n top?: boolean\n bottom?: boolean\n right?: boolean\n left?: boolean\n}\n\n/**\n * Similar to `element.getBoundingClientRect`, but handles `display: contents` CSS\n * property and optionally includes margins and outlines.\n */\nexport function getClientRect(element: Element, includeExtra?: IncludeExtraOptions | false): Rect {\n const rect = element.getBoundingClientRect()\n if (rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0) {\n // Suspiciously rect, probably an element with `display: contents`, in\n // which case `element.getClientRects()` will return an empty array.\n if (element.getClientRects().length === 0) {\n const children = [...element.children]\n const rects = children.map(child => getClientRect(child, includeExtra))\n if (rects.length === 0) {\n return rect\n }\n if (rects.length === 1) {\n return rects[0]\n }\n let { top, bottom, left, right } = rects[0]\n for (let i = 1; i < rects.length; i++) {\n const r = rects[i]\n if (r.top < top) top = r.top\n if (r.bottom > bottom) bottom = r.bottom\n if (r.left < left) left = r.left\n if (r.right > right) right = r.right\n }\n return { top, bottom, left, right }\n }\n }\n return includeExtra ? addExtra(element, rect, includeExtra) : rect\n}\n\nfunction addExtra(element: Element, rect: Rect, options: IncludeExtraOptions): Rect {\n const view = element.ownerDocument?.defaultView\n if (!view) {\n return rect\n }\n\n const style = view.getComputedStyle(element)\n const marginTop = options.top ? Number.parseFloat(style.marginTop) || 0 : 0\n const marginBottom = options.bottom ? Number.parseFloat(style.marginBottom) || 0 : 0\n const marginRight = options.right ? Number.parseFloat(style.marginRight) || 0 : 0\n const marginLeft = options.left ? Number.parseFloat(style.marginLeft) || 0 : 0\n\n const outlineWidth = Number.parseFloat(style.outlineWidth) || 0\n const outlineOffset = Number.parseFloat(style.outlineOffset) || 0\n const outline = Math.max(outlineWidth + outlineOffset, 0)\n const outlineTop = options.top ? outline : 0\n const outlineBottom = options.bottom ? outline : 0\n const outlineRight = options.right ? outline : 0\n const outlineLeft = options.left ? outline : 0\n\n return {\n top: rect.top - Math.max(marginTop, outlineTop),\n bottom: rect.bottom + Math.max(marginBottom, outlineBottom),\n right: rect.right + Math.max(marginRight, outlineRight),\n left: rect.left - Math.max(marginLeft, outlineLeft),\n }\n}\n","// Maximum possible z-index\n// https://stackoverflow.com/questions/491052/minimum-and-maximum-value-of-z-index\nexport const maxZIndex = '2147483647'\n","import { DRAGGING_CLASS_NAME } from '../../../constants.ts'\nimport { assignStyles } from '../../../utils/assign-styles.ts'\nimport { getClientRect } from '../../../utils/get-client-rect.ts'\nimport { maxZIndex } from '../../../utils/max-z-index.ts'\n\n/**\n * Sets a drag preview image for the given element and ensures the preview position\n * relative to the pointer is correct.\n *\n * This function does the following:\n *\n * - Creates a temporary container element.\n * - Puts the container at the end of the document body.\n * - Sets event's drag image.\n * - Removes the container from the document body after the next frame.\n */\nexport function setDragPreview(event: DragEvent, element: HTMLElement): void {\n const { top, bottom, left, right } = getClientRect(element, { left: true, right: true, top: true, bottom: true })\n const width = right - left\n const height = bottom - top\n const elementX = left\n const elementY = top\n\n const { clientX, clientY } = event\n\n const document = element.ownerDocument\n\n const container = document.createElement('div')\n\n // Add some class names so that all styles applied to\n // given class names can also be applied to the drag preview.\n container.classList.add('ProseMirror', DRAGGING_CLASS_NAME)\n\n // If outsideX is positive, the point is at the left side of the element.\n const outsideX = Math.round(elementX - clientX)\n // If outsideY is positive, the point is above the element.\n const outsideY = Math.round(elementY - clientY)\n\n const borderX = Math.max(outsideX, 0)\n const borderY = Math.max(outsideY, 0)\n assignStyles(container, {\n // Ensuring we don't cause reflow when adding the element to the page using\n // `position:fixed` rather than `position:absolute` so we are positioned on\n // the current viewport. `position:fixed` also creates a new stacking\n // context, so we don't need to do that here.\n // https://github.com/atlassian/pragmatic-drag-and-drop/blob/56276552/packages/core/src/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.ts#L60\n position: 'fixed',\n\n // The element is positioned off-screen to avoid capturing the content of\n // the page on Safari when the dragging element has a transparent background\n // on Safari. See https://github.com/prosekit/prosekit/issues/1153 for more\n // details.\n top: '-1000vh',\n left: '-1000vw',\n\n // The element should not be interactive.\n pointerEvents: 'none',\n\n zIndex: maxZIndex,\n\n // Only reliable cross browser technique found to push a drag preview away\n // from the cursor is to use transparent borders on the container.\n // https://github.com/atlassian/pragmatic-drag-and-drop/blob/56276552/packages/core/src/public-utils/element/custom-native-drag-preview/pointer-outside-of-preview.ts#L13-L18\n borderLeft: `${borderX}px solid transparent`,\n borderTop: `${borderY}px solid transparent`,\n\n boxSizing: 'border-box',\n width: `${width + borderX}px`,\n height: `${height + borderY}px`,\n })\n\n const clonedElement = element.cloneNode(true) as HTMLElement\n\n // A hardcoded opacity.\n clonedElement.style.setProperty('opacity', '0.8', 'important')\n // Hide the outline of the cloned element.\n clonedElement.style.setProperty('outline-color', 'transparent', 'important')\n\n container.appendChild(clonedElement)\n document.body.appendChild(container)\n\n event.dataTransfer?.setDragImage(container, Math.max(-outsideX, 0), Math.max(-outsideY, 0))\n\n requestAnimationFrame(() => {\n container.remove()\n })\n}\n","import { useAttribute, useEffect, useEventListener, type ConnectableElement, type ReadonlySignal, type SignalState } from '@aria-ui/core'\nimport { isHTMLElement } from '@ocavue/utils'\nimport type { Editor } from '@prosekit/core'\nimport type { ViewDragging } from '@prosekit/extensions/drop-indicator'\nimport { Fragment, Slice } from '@prosekit/pm/model'\nimport { NodeSelection } from '@prosekit/pm/state'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { DRAGGING_CLASS_NAME } from '../../../constants.ts'\nimport { getSafeEditorView } from '../../../utils/get-safe-editor-view.ts'\nimport { blockPopoverContext, draggingContext, type BlockPopoverContext, type HoverState } from '../context.ts'\n\nimport { setDragPreview } from './set-drag-preview.ts'\nimport type { BlockHandleDraggableProps } from './types.ts'\n\n/**\n * @internal\n */\nexport function useBlockHandleDraggable(\n host: ConnectableElement,\n { state }: { state: SignalState<BlockHandleDraggableProps> },\n): void {\n const context = blockPopoverContext.consume(host)\n const dragging = draggingContext.consume(host)\n\n useEffect(host, () => {\n host.draggable = true\n })\n\n usePointerDownHandler(host, context, state.editor)\n\n useEventListener(host, 'dragstart', (event) => {\n dragging.set(true)\n\n const view = getSafeEditorView(state.editor.get())\n const hoverState = context.get()\n\n if (view && hoverState) {\n view.dom.classList.add(DRAGGING_CLASS_NAME)\n createDraggingPreview(view, hoverState, event)\n setViewDragging(view, hoverState)\n }\n })\n\n useEventListener(host, 'dragend', () => {\n dragging.set(false)\n\n const view = getSafeEditorView(state.editor.get())\n if (view) {\n view.dom.classList.remove(DRAGGING_CLASS_NAME)\n }\n })\n\n useAttribute(host, 'data-dragging', () => (dragging.get() ? '' : undefined))\n}\n\nfunction usePointerDownHandler(\n host: ConnectableElement,\n context: ReadonlySignal<BlockPopoverContext>,\n editor: ReadonlySignal<Editor | null>,\n) {\n useEventListener(host, 'pointerdown', () => {\n const { pos } = context.get() ?? {}\n const { view } = editor.get() ?? {}\n\n if (pos == null || view == null) {\n return\n }\n\n view.dispatch(\n view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos)),\n )\n\n // Clicking the handle will blur the editor, so we need to focus it again.\n // We cannot call `event.preventDefault()` here to prevent the blur\n // because it will prevent the drag event from firing.\n requestAnimationFrame(() => {\n view.focus()\n })\n })\n}\n\nfunction createDraggingPreview(view: EditorView, hoverState: HoverState, event: DragEvent): void {\n if (!event.dataTransfer) {\n return\n }\n\n const { pos } = hoverState\n\n const element = view.nodeDOM(pos)\n if (!element || !isHTMLElement(element)) {\n return\n }\n\n event.dataTransfer.clearData()\n event.dataTransfer.setData('text/html', element.outerHTML)\n event.dataTransfer.effectAllowed = 'copyMove'\n setDragPreview(event, element)\n\n return\n}\n\nfunction setViewDragging(view: EditorView, hoverState: HoverState): void {\n const { node, pos } = hoverState\n\n const dragging: ViewDragging = {\n slice: new Slice(Fragment.from(node), 0, 0),\n move: true,\n node: NodeSelection.create(view.state.doc, pos),\n }\n\n view.dragging = dragging\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nexport interface BlockHandleDraggableProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const blockHandleDraggableProps: PropDeclarations<BlockHandleDraggableProps> = {\n editor: { default: null },\n}\n\n/** @internal */\nexport interface BlockHandleDraggableEvents {}\n\n/** @internal */\nexport const blockHandleDraggableEvents: EventDeclarations<BlockHandleDraggableEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useBlockHandleDraggable } from \"./setup.ts\"\nimport { blockHandleDraggableEvents, blockHandleDraggableProps, type BlockHandleDraggableEvents, type BlockHandleDraggableProps } from \"./types.ts\"\n\nconst BlockHandleDraggableElementBase: BaseElementConstructor<BlockHandleDraggableProps> = defineCustomElement<\n BlockHandleDraggableProps,\n BlockHandleDraggableEvents\n>({\n props: blockHandleDraggableProps,\n events: blockHandleDraggableEvents,\n setup: useBlockHandleDraggable,\n})\nclass BlockHandleDraggableElement extends BlockHandleDraggableElementBase {}\n\nregisterCustomElement('prosekit-block-handle-draggable', BlockHandleDraggableElement)\n \nexport { BlockHandleDraggableElement }\n","import type { VirtualElement } from '@floating-ui/dom'\nimport { isElement, isHTMLElement, isTextNode, throttle } from '@ocavue/utils'\nimport { defineDOMEventHandler, union, type PlainExtension } from '@prosekit/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { getClientRect } from '../../../utils/get-client-rect.ts'\nimport type { HoverState } from '../context.ts'\n\nexport type ElementHoverHandler = (\n reference: VirtualElement | null,\n hoverState: HoverState | null,\n) => void\n\nexport function defineElementHoverHandler(handler: ElementHoverHandler): PlainExtension {\n const handleElement = (\n node: ProseMirrorNode,\n pos: number,\n element: HTMLElement,\n parentElement?: Node | null,\n ) => {\n const reference: VirtualElement = {\n contextElement: element,\n\n getBoundingClientRect: () => {\n const rect = findFirstLineRect(parentElement, element)\n return rect ? fulfillRect(rect) : fallbackRect\n },\n }\n\n handler(reference, { node, pos })\n }\n\n let lastX = -1\n let lastY = -1\n let lastTime = -1\n\n const handlePointerEvent = (view: EditorView, event: PointerEvent) => {\n const { x, y } = event\n\n // Simple performance optimization. If the pointer is not moving, we don't\n // want to recalculate the block handle position within a short period of\n // time window.\n if (lastX === x && lastY === y) {\n const now = Date.now()\n if (now - lastTime < 100) {\n return\n }\n lastTime = now\n }\n lastX = x\n lastY = y\n\n const block = findBlockByCoords(view, x, y)\n if (!block) {\n handler(null, null)\n return\n }\n\n const { node, pos } = block\n const element = view.nodeDOM(pos)\n if (!element || !isHTMLElement(element)) {\n handler(null, null)\n return\n }\n\n // If `node` is the first child of another non-doc block node, for example a\n // list node or a blockquote node, we want to put the block handle agains\n // the parent node.\n const $pos = view.state.doc.resolve(pos)\n if ($pos.depth > 0 && $pos.index($pos.depth) === 0) {\n const parentPos = $pos.before($pos.depth)\n const parentNode = $pos.parent\n const parentElement = view.nodeDOM(parentPos)\n handleElement(parentNode, parentPos, element, parentElement)\n } else {\n handleElement(node, pos, element)\n }\n }\n\n return union(\n defineDOMEventHandler('pointermove', throttle(handlePointerEvent, 200)),\n defineDOMEventHandler('pointerenter', handlePointerEvent),\n defineDOMEventHandler('pointerout', handlePointerEvent),\n defineDOMEventHandler('keypress', () => handler(null, null)),\n )\n}\n\nfunction findBlockByCoords(view: EditorView, x: number, y: number): { node: ProseMirrorNode; pos: number } | undefined {\n const rect = getClientRect(view.dom)\n if (!isWithinRect(rect, x, y)) {\n return\n }\n\n let parent: ProseMirrorNode | undefined = view.state.doc\n let pos = -1\n\n while (parent) {\n if (parent.isBlock && (parent.isTextblock || parent.isAtom || parent.type.spec.isolating)) {\n return { node: parent, pos }\n }\n\n // Collect all children and their positions\n const children: ProseMirrorNode[] = []\n const positions: number[] = []\n parent.forEach((child, offset) => {\n children.push(child)\n positions.push(offset + pos + 1)\n })\n\n let lo = 0\n let hi = children.length - 1\n\n while (lo <= hi) {\n const i = hi - ((hi - lo) >> 1)\n const childDOM = view.nodeDOM(positions[i])\n const childRect = getNodeRect(childDOM)\n if (!childRect) {\n console.warn(`[prosekit] Unable to get rect at position: ${positions[i]}`)\n return\n }\n if (childRect.top > y) {\n hi = i - 1\n } else if (childRect.bottom < y) {\n lo = i + 1\n } else {\n lo = i\n break\n }\n }\n\n if (lo > hi) {\n return\n }\n\n parent = children[lo]\n pos = positions[lo]\n }\n}\n\nfunction getNodeRect(node: Node | null | undefined): Rect | undefined {\n if (node && isElement(node) && node.isConnected) {\n return getClientRect(node)\n }\n}\n\nfunction isWithinRect(rect: Rect, x: number, y: number) {\n return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom\n}\n\ninterface Rect {\n top: number\n right: number\n bottom: number\n left: number\n}\n\nfunction findFirstLineRect(outer?: Node | null, inner?: Node | null): Rect | undefined {\n if (outer && !outer.isConnected) {\n return\n }\n if (inner && !inner.isConnected) {\n return\n }\n\n if (outer && inner) {\n const outerRect = findOuterRect(outer)\n const innerRect = findFirstLineRectInNode(inner)\n if (outerRect && innerRect) {\n const { top, bottom } = innerRect\n const { left, right } = outerRect\n return { top, bottom, left, right }\n } else {\n return outerRect || innerRect\n }\n } else if (outer) {\n return findFirstLineRectInNode(outer)\n } else if (inner) {\n return findFirstLineRectInNode(inner)\n }\n}\n\nfunction findOuterRect(node: Node): Rect | undefined {\n if (!isElement(node)) {\n return\n }\n\n return getClientRect(node, { left: true, right: true })\n}\n\nfunction findFirstLineRectInNode(node: Node): Rect | undefined {\n if (isElement(node)) {\n return findFirstLineRectInElement(node)\n } else if (isTextNode(node)) {\n return findFirstLineRectInTextNode(node)\n }\n}\n\nfunction findFirstLineRectInTextNode(node: Text): Rect | undefined {\n const ownerDocument = node.ownerDocument\n if (!ownerDocument) {\n return\n }\n const range = ownerDocument.createRange()\n range.setStart(node, 0)\n range.setEnd(node, 0)\n const rects = range.getClientRects()\n return rects[0]\n}\n\nfunction findFirstLineRectInElement(element: Element): Rect | undefined {\n if (element.nodeName === 'BR') {\n return element.getBoundingClientRect()\n }\n\n const rect = getClientRect(element)\n const style = element.ownerDocument.defaultView?.getComputedStyle(element)\n const marginLeft = style && Number.parseInt(style.marginLeft, 10) || 0\n const marginRight = style && Number.parseInt(style.marginRight, 10) || 0\n const left = rect.left - marginLeft\n const right = rect.right + marginRight\n\n const lineHeight = style && Number.parseInt(style.lineHeight, 10) || 24\n const paddingTop = style && Number.parseInt(style.paddingTop, 10) || 0\n const borderTop = style && Number.parseInt(style.borderTopWidth, 10) || 0\n const top = rect.top + paddingTop + borderTop\n const bottom = top + lineHeight\n\n return { top, bottom, left, right }\n}\n\nfunction fulfillRect({ top, right, bottom, left }: Rect) {\n return { top, right, bottom, left, width: right - left, height: bottom - top, x: left, y: top }\n}\n\n// A fallback rect that is far away from the screen. It should not be used through.\nconst fallbackRect = Object.freeze({\n top: -9999,\n right: -9999,\n bottom: -9999,\n left: -9999,\n width: 0,\n height: 0,\n x: -9999,\n y: -9999,\n})\n","import { createComputed, createSignal, useAttribute, type ConnectableElement, type ReadonlySignal, type SetupOptions } from '@aria-ui/core'\nimport { useOverlayPositionerState } from '@aria-ui/overlay/elements'\nimport { usePresence } from '@aria-ui/presence'\nimport type { VirtualElement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nimport { useEditorExtension } from '../../../hooks/use-editor-extension.ts'\nimport { useScrolling } from '../../../hooks/use-scrolling.ts'\nimport { blockPopoverContext, draggingContext, type BlockPopoverContext, type HoverState } from '../context.ts'\n\nimport { defineElementHoverHandler, type ElementHoverHandler } from './pointer-move.ts'\nimport type { BlockHandlePopoverEvents, BlockHandlePopoverProps } from './types.ts'\n\n/**\n * @internal\n */\nexport function useBlockHandlePopover(\n host: ConnectableElement,\n { state, emit }: SetupOptions<BlockHandlePopoverProps, BlockHandlePopoverEvents>,\n): void {\n const { editor, ...overlayState } = state\n const reference = createSignal<VirtualElement | null>(null)\n useOverlayPositionerState(host, overlayState, { reference })\n\n const context = createSignal<BlockPopoverContext>(null)\n blockPopoverContext.provide(host, context)\n\n const dragging = createSignal(false)\n draggingContext.provide(host, dragging)\n\n const scrolling = useScrolling(host)\n const open = createComputed(() => {\n return !!context.get() && !scrolling.get()\n })\n\n useHoverExtension(host, editor, (referenceValue, hoverState) => {\n reference.set(referenceValue)\n context.set(hoverState)\n const stateChangeDetails = hoverState ? { node: hoverState.node, pos: hoverState.pos } : null\n emit('stateChange', stateChangeDetails)\n })\n\n useAttribute(host, 'data-state', () => (open.get() ? 'open' : 'closed'))\n usePresence(host, open)\n}\n\nfunction useHoverExtension(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: ElementHoverHandler,\n) {\n let prevHoverState: HoverState | null = null\n\n const extension = defineElementHoverHandler((reference, hoverState) => {\n if (isHoverStateEqual(prevHoverState, hoverState)) {\n return\n }\n\n prevHoverState = hoverState\n handler(reference, hoverState)\n })\n\n useEditorExtension(host, editor, extension)\n}\n\nfunction isHoverStateEqual(a: HoverState | null, b: HoverState | null) {\n return (!a && !b) || (a && b && a.pos === b.pos && a.node.eq(b.node))\n}\n","import type { EventDeclarations, PropDeclarations } from '@aria-ui/core'\nimport {\n overlayPositionerEvents,\n overlayPositionerProps,\n type OverlayPositionerEvents,\n type OverlayPositionerProps,\n} from '@aria-ui/overlay/elements'\nimport type { Placement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\n\nexport interface BlockHandlePopoverProps extends Omit<OverlayPositionerProps, 'placement' | 'hoist' | 'flip' | 'shift' | 'hide'> {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * The placement of the popover, relative to the hovered block.\n *\n * @default \"left\"\n */\n placement: Placement\n\n /**\n * Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)\n * to place the floating element on top of other page content.\n *\n * @default false\n */\n hoist: boolean\n\n /**\n * @default false\n * @hidden\n */\n flip: boolean\n\n /**\n * @default false\n * @hidden\n */\n shift: boolean\n\n /**\n * @default true\n * @hidden\n */\n hide: boolean\n}\n\n/** @internal */\nexport const blockHandlePopoverProps: PropDeclarations<BlockHandlePopoverProps> = {\n ...overlayPositionerProps,\n editor: { default: null },\n placement: { default: 'left' },\n\n // Enabling `hoist` will cause the popover to have a small delay when\n // scrolling the page.\n hoist: { default: false },\n\n flip: { default: false },\n shift: { default: false },\n hide: { default: true },\n}\n\nexport interface BlockHandlePopoverEvents extends OverlayPositionerEvents {\n /**\n * Fired when the hovered block changes.\n */\n stateChange: CustomEvent<{ node: ProseMirrorNode; pos: number } | null>\n}\n\n/** @internal */\nexport const blockHandlePopoverEvents: EventDeclarations<BlockHandlePopoverEvents> = {\n ...overlayPositionerEvents,\n stateChange: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useBlockHandlePopover } from \"./setup.ts\"\nimport { blockHandlePopoverEvents, blockHandlePopoverProps, type BlockHandlePopoverEvents, type BlockHandlePopoverProps } from \"./types.ts\"\n\nconst BlockHandlePopoverElementBase: BaseElementConstructor<BlockHandlePopoverProps> = defineCustomElement<\n BlockHandlePopoverProps,\n BlockHandlePopoverEvents\n>({\n props: blockHandlePopoverProps,\n events: blockHandlePopoverEvents,\n setup: useBlockHandlePopover,\n})\nclass BlockHandlePopoverElement extends BlockHandlePopoverElementBase {}\n\nregisterCustomElement('prosekit-block-handle-popover', BlockHandlePopoverElement)\n \nexport { BlockHandlePopoverElement }\n"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAa,sBAAoD,cAC/D,kCACA,KACD;;;;AAKD,MAAa,kBAAoC,cAC/C,0CACA,MACD;;;;;;ACpBD,SAAgB,kBACd,MACA,EAAE,SACI;CACN,MAAM,UAAU,oBAAoB,QAAQ,KAAK;AAEjD,kBAAiB,MAAM,gBAAgB,UAAU;AAC/C,QAAM,gBAAgB;EAEtB,MAAM,SAAS,MAAM,OAAO,KAAK;EACjC,MAAM,aAAa,QAAQ,KAAK;AAChC,MAAI,CAAC,UAAU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,MAAI,kBAAkB,gBAAgB,WAAW,CAC/C;AAGF,mBAAiB;AACjB,UAAQ,WAAW,WAAW;GAC9B,CAEyC;;AAG7C,SAAS,kBAAkB,GAAsB,GAAsB;AACrE,QAAQ,CAAC,KAAK,CAAC,KAAO,KAAK,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK;;;;;ACXtE,MAAa,0BAAqE;CAChF,GAAG;CACH,QAAQ,EAAE,SAAS,MAAM;CACzB,WAAW,EAAE,SAAS,QAAQ;CAI9B,OAAO,EAAE,SAAS,OAAO;CAEzB,MAAM,EAAE,SAAS,OAAO;CACxB,OAAO,EAAE,SAAS,OAAO;CACzB,MAAM,EAAE,SAAS,MAAM;CACxB;;AAUD,MAAa,2BAAwE;CACnF,GAAG;CACH,aAAa,EAAE;CAChB;;;AC3ED,MAAM,gCAAiF,oBAGrF;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,4BAAN,cAAwC,8BAA8B;AAEtE,sBAAsB,iCAAiC,0BAA0B"}
|
|
1
|
+
{"version":3,"file":"prosekit-web-block-handle.js","names":[],"sources":["../src/components/block-handle/context.ts","../src/components/block-handle/block-handle-add.ts","../src/constants.ts","../src/utils/get-client-rect.ts","../src/utils/max-z-index.ts","../src/components/block-handle/set-drag-preview.ts","../src/components/block-handle/block-handle-draggable.ts","../src/components/block-handle/block-handle-popup.ts","../src/components/block-handle/block-handle-positioner.ts","../src/utils/prefers-reduced-motion.ts","../src/components/block-handle/hover-state.ts","../src/components/block-handle/pointer-move.ts","../src/components/block-handle/use-hover-extension.ts","../src/components/block-handle/block-handle-root.ts"],"sourcesContent":["import { createContext, createSignal, type Context, type Signal } from '@aria-ui/core'\nimport type { OverlayStore } from '@aria-ui/elements/overlay'\n\nimport type { HoverState } from './hover-state.ts'\n\n/**\n * @internal\n */\nexport class BlockHandleStore {\n readonly hoverState: Signal<HoverState | undefined> = createSignal<HoverState | undefined>(undefined)\n readonly dragging: Signal<boolean> = createSignal(false)\n}\n\n/**\n * @internal\n */\nexport const blockHandleStoreContext: Context<BlockHandleStore> = createContext<BlockHandleStore>('prosekit-block-handle-store')\n\n/**\n * @internal\n */\nexport const blockHandleOverlayStoreContext: Context<OverlayStore> = createContext<OverlayStore>('prosekit-block-handle-overlay-store')\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEventListener,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { insertDefaultBlock, type Editor } from '@prosekit/core'\n\nimport { blockHandleStoreContext } from './context.ts'\n\nexport interface BlockHandleAddProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const BlockHandleAddPropsDeclaration: PropsDeclaration<BlockHandleAddProps> = /* @__PURE__ */ defineProps<BlockHandleAddProps>({\n editor: { default: null, attribute: false, type: 'json' },\n})\n\n/**\n * @internal\n */\nexport function setupBlockHandleAdd(\n host: HostElement,\n props: State<BlockHandleAddProps>,\n): void {\n const getStore = blockHandleStoreContext.consume(host)\n\n useEventListener(host, 'pointerdown', (event) => {\n event.preventDefault()\n\n const store = getStore()\n const editor = props.editor.get()\n const hoverState = store?.hoverState.get()\n if (!editor || !hoverState) {\n return\n }\n\n const { node, pos } = hoverState\n editor.exec(insertDefaultBlock({ pos: pos + node.nodeSize }))\n editor.focus()\n\n // Hide the drag handle\n store?.hoverState.set(undefined)\n })\n}\n\nconst BlockHandleAddElementBase: HostElementConstructor<BlockHandleAddProps> = defineCustomElement(\n setupBlockHandleAdd,\n BlockHandleAddPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class BlockHandleAddElement extends BlockHandleAddElementBase {}\n\n/** @internal */\nexport function registerBlockHandleAddElement(): void {\n registerCustomElement('prosekit-block-handle-add', BlockHandleAddElement)\n}\n","export const DRAGGING_CLASS_NAME = 'prosekit-dragging'\n","interface Rect {\n top: number\n bottom: number\n right: number\n left: number\n}\n\ninterface IncludeExtraOptions {\n top?: boolean\n bottom?: boolean\n right?: boolean\n left?: boolean\n}\n\n/**\n * Similar to `element.getBoundingClientRect`, but handles `display: contents` CSS\n * property and optionally includes margins and outlines.\n */\nexport function getClientRect(element: Element, includeExtra?: IncludeExtraOptions | false): Rect {\n const rect = element.getBoundingClientRect()\n if (rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0) {\n // Suspiciously rect, probably an element with `display: contents`, in\n // which case `element.getClientRects()` will return an empty array.\n if (element.getClientRects().length === 0) {\n const children = [...element.children]\n const rects = children.map(child => getClientRect(child, includeExtra))\n if (rects.length === 0) {\n return rect\n }\n if (rects.length === 1) {\n return rects[0]\n }\n let { top, bottom, left, right } = rects[0]\n for (let i = 1; i < rects.length; i++) {\n const r = rects[i]\n if (r.top < top) top = r.top\n if (r.bottom > bottom) bottom = r.bottom\n if (r.left < left) left = r.left\n if (r.right > right) right = r.right\n }\n return { top, bottom, left, right }\n }\n }\n return includeExtra ? addExtra(element, rect, includeExtra) : rect\n}\n\nfunction addExtra(element: Element, rect: Rect, options: IncludeExtraOptions): Rect {\n const view = element.ownerDocument?.defaultView\n if (!view) {\n return rect\n }\n\n const style = view.getComputedStyle(element)\n const marginTop = options.top ? Number.parseFloat(style.marginTop) || 0 : 0\n const marginBottom = options.bottom ? Number.parseFloat(style.marginBottom) || 0 : 0\n const marginRight = options.right ? Number.parseFloat(style.marginRight) || 0 : 0\n const marginLeft = options.left ? Number.parseFloat(style.marginLeft) || 0 : 0\n\n const outlineWidth = Number.parseFloat(style.outlineWidth) || 0\n const outlineOffset = Number.parseFloat(style.outlineOffset) || 0\n const outline = Math.max(outlineWidth + outlineOffset, 0)\n const outlineTop = options.top ? outline : 0\n const outlineBottom = options.bottom ? outline : 0\n const outlineRight = options.right ? outline : 0\n const outlineLeft = options.left ? outline : 0\n\n return {\n top: rect.top - Math.max(marginTop, outlineTop),\n bottom: rect.bottom + Math.max(marginBottom, outlineBottom),\n right: rect.right + Math.max(marginRight, outlineRight),\n left: rect.left - Math.max(marginLeft, outlineLeft),\n }\n}\n","// Maximum possible z-index\n// https://stackoverflow.com/questions/491052/minimum-and-maximum-value-of-z-index\nexport const maxZIndex = '2147483647'\n","import { DRAGGING_CLASS_NAME } from '../../constants.ts'\nimport { assignStyles } from '../../utils/assign-styles.ts'\nimport { getClientRect } from '../../utils/get-client-rect.ts'\nimport { maxZIndex } from '../../utils/max-z-index.ts'\n\n/**\n * Sets a drag preview image for the given element and ensures the preview position\n * relative to the pointer is correct.\n *\n * This function does the following:\n *\n * - Creates a temporary container element.\n * - Puts the container at the end of the document body.\n * - Sets event's drag image.\n * - Removes the container from the document body after the next frame.\n */\nexport function setDragPreview(event: DragEvent, element: HTMLElement): void {\n const { top, bottom, left, right } = getClientRect(element, { left: true, right: true, top: true, bottom: true })\n const width = right - left\n const height = bottom - top\n const elementX = left\n const elementY = top\n\n const { clientX, clientY } = event\n\n const document = element.ownerDocument\n\n const container = document.createElement('div')\n\n // Add some class names so that all styles applied to\n // given class names can also be applied to the drag preview.\n container.classList.add('ProseMirror', DRAGGING_CLASS_NAME)\n\n // If outsideX is positive, the point is at the left side of the element.\n const outsideX = Math.round(elementX - clientX)\n // If outsideY is positive, the point is above the element.\n const outsideY = Math.round(elementY - clientY)\n\n const borderX = Math.max(outsideX, 0)\n const borderY = Math.max(outsideY, 0)\n assignStyles(container, {\n // Ensuring we don't cause reflow when adding the element to the page using\n // `position:fixed` rather than `position:absolute` so we are positioned on\n // the current viewport. `position:fixed` also creates a new stacking\n // context, so we don't need to do that here.\n // https://github.com/atlassian/pragmatic-drag-and-drop/blob/56276552/packages/core/src/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.ts#L60\n position: 'fixed',\n\n // The element is positioned off-screen to avoid capturing the content of\n // the page on Safari when the dragging element has a transparent background\n // on Safari. See https://github.com/prosekit/prosekit/issues/1153 for more\n // details.\n top: '-1000vh',\n left: '-1000vw',\n\n // The element should not be interactive.\n pointerEvents: 'none',\n\n zIndex: maxZIndex,\n\n // Only reliable cross browser technique found to push a drag preview away\n // from the cursor is to use transparent borders on the container.\n // https://github.com/atlassian/pragmatic-drag-and-drop/blob/56276552/packages/core/src/public-utils/element/custom-native-drag-preview/pointer-outside-of-preview.ts#L13-L18\n borderLeft: `${borderX}px solid transparent`,\n borderTop: `${borderY}px solid transparent`,\n\n boxSizing: 'border-box',\n width: `${width + borderX}px`,\n height: `${height + borderY}px`,\n })\n\n const clonedElement = element.cloneNode(true) as HTMLElement\n\n // A hardcoded opacity.\n clonedElement.style.setProperty('opacity', '0.8', 'important')\n // Hide the outline of the cloned element.\n clonedElement.style.setProperty('outline-color', 'transparent', 'important')\n\n container.appendChild(clonedElement)\n document.body.appendChild(container)\n\n event.dataTransfer?.setDragImage(container, Math.max(-outsideX, 0), Math.max(-outsideY, 0))\n\n requestAnimationFrame(() => {\n container.remove()\n })\n}\n","import {\n defineCustomElement,\n defineProps,\n onMount,\n registerCustomElement,\n useEventListener,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { useAttribute } from '@aria-ui/utils'\nimport { isHTMLElement } from '@ocavue/utils'\nimport type { Editor } from '@prosekit/core'\nimport type { ViewDragging } from '@prosekit/extensions/drop-indicator'\nimport { Fragment, Slice } from '@prosekit/pm/model'\nimport { NodeSelection } from '@prosekit/pm/state'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { DRAGGING_CLASS_NAME } from '../../constants.ts'\nimport { getSafeEditorView } from '../../utils/get-safe-editor-view.ts'\n\nimport { blockHandleStoreContext } from './context.ts'\nimport type { HoverState } from './hover-state.ts'\nimport { setDragPreview } from './set-drag-preview.ts'\n\nexport interface BlockHandleDraggableProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const BlockHandleDraggablePropsDeclaration: PropsDeclaration<BlockHandleDraggableProps> = /* @__PURE__ */ defineProps<\n BlockHandleDraggableProps\n>({\n editor: { default: null, attribute: false, type: 'json' },\n})\n\n/**\n * @internal\n */\nexport function setupBlockHandleDraggable(\n host: HostElement,\n props: State<BlockHandleDraggableProps>,\n): void {\n const getStore = blockHandleStoreContext.consume(host)\n\n onMount(host, () => {\n host.draggable = true\n })\n\n usePointerDownHandler(host, () => getStore()?.hoverState.get() ?? null, props.editor.get)\n\n useEventListener(host, 'dragstart', (event) => {\n const store = getStore()\n store?.dragging.set(true)\n\n const view = getSafeEditorView(props.editor.get())\n const hoverState = store?.hoverState.get()\n\n if (view && hoverState) {\n view.dom.classList.add(DRAGGING_CLASS_NAME)\n createDraggingPreview(view, hoverState, event)\n setViewDragging(view, hoverState)\n }\n })\n\n useEventListener(host, 'dragend', () => {\n const store = getStore()\n store?.dragging.set(false)\n\n const view = getSafeEditorView(props.editor.get())\n if (view) {\n view.dom.classList.remove(DRAGGING_CLASS_NAME)\n }\n })\n\n useAttribute(host, 'data-dragging', () => (getStore()?.dragging.get() ? '' : undefined))\n}\n\nfunction usePointerDownHandler(\n host: HostElement,\n getHoverState: () => HoverState | null,\n getEditor: () => Editor | null,\n) {\n useEventListener(host, 'pointerdown', () => {\n const hoverState = getHoverState()\n const editor = getEditor()\n\n if (hoverState?.pos == null || !editor?.view) {\n return\n }\n\n const { view } = editor\n view.dispatch(\n view.state.tr.setSelection(NodeSelection.create(view.state.doc, hoverState.pos)),\n )\n\n // Clicking the handle will blur the editor, so we need to focus it again.\n // We cannot call `event.preventDefault()` here to prevent the blur\n // because it will prevent the drag event from firing.\n requestAnimationFrame(() => {\n view.focus()\n })\n })\n}\n\nfunction createDraggingPreview(view: EditorView, hoverState: HoverState, event: DragEvent): void {\n if (!event.dataTransfer) {\n return\n }\n\n const { pos } = hoverState\n\n const element = view.nodeDOM(pos)\n if (!element || !isHTMLElement(element)) {\n return\n }\n\n event.dataTransfer.clearData()\n event.dataTransfer.setData('text/html', element.outerHTML)\n event.dataTransfer.effectAllowed = 'copyMove'\n setDragPreview(event, element)\n\n return\n}\n\nfunction setViewDragging(view: EditorView, hoverState: HoverState): void {\n const { node, pos } = hoverState\n\n const dragging: ViewDragging = {\n slice: new Slice(Fragment.from(node), 0, 0),\n move: true,\n node: NodeSelection.create(view.state.doc, pos),\n }\n\n view.dragging = dragging\n}\n\nconst BlockHandleDraggableElementBase: HostElementConstructor<BlockHandleDraggableProps> = defineCustomElement(\n setupBlockHandleDraggable,\n BlockHandleDraggablePropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class BlockHandleDraggableElement extends BlockHandleDraggableElementBase {}\n\n/** @internal */\nexport function registerBlockHandleDraggableElement(): void {\n registerCustomElement('prosekit-block-handle-draggable', BlockHandleDraggableElement)\n}\n","import {\n defineCustomElement,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { OverlayPopupPropsDeclaration, setupOverlayPopup, type OverlayPopupProps } from '@aria-ui/elements/overlay'\n\nimport { blockHandleOverlayStoreContext } from './context.ts'\n\n/**\n * @public\n */\nexport interface BlockHandlePopupProps extends OverlayPopupProps {}\n\n/** @internal */\nexport const BlockHandlePopupPropsDeclaration: PropsDeclaration<BlockHandlePopupProps> = OverlayPopupPropsDeclaration\n\n/** @internal */\nexport function setupBlockHandlePopup(\n host: HostElement,\n _props: State<BlockHandlePopupProps>,\n): void {\n const getOverlayStore = blockHandleOverlayStoreContext.consume(host)\n setupOverlayPopup(host, getOverlayStore)\n}\n\nconst BlockHandlePopupElementBase: HostElementConstructor<BlockHandlePopupProps> = defineCustomElement(\n setupBlockHandlePopup,\n BlockHandlePopupPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class BlockHandlePopupElement extends BlockHandlePopupElementBase {}\n\n/** @internal */\nexport function registerBlockHandlePopupElement(): void {\n registerCustomElement('prosekit-block-handle-popup', BlockHandlePopupElement)\n}\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { OverlayPositionerPropsDeclaration, setupOverlayPositioner, type OverlayPositionerProps } from '@aria-ui/elements/overlay'\nimport type { Placement } from '@floating-ui/dom'\n\nimport { blockHandleOverlayStoreContext } from './context.ts'\n\n/**\n * @public\n */\nexport interface BlockHandlePositionerProps extends Omit<OverlayPositionerProps, 'placement' | 'hoist' | 'flip' | 'shift' | 'hide'> {\n /**\n * The placement of the popover, relative to the hovered block.\n *\n * @default \"left\"\n */\n placement: Placement\n\n /**\n * Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)\n * to place the floating element on top of other page content.\n *\n * @default false\n */\n hoist: boolean\n\n /**\n * @default false\n * @hidden\n */\n flip: boolean\n\n /**\n * @default false\n * @hidden\n */\n shift: boolean\n\n /**\n * @default true\n * @hidden\n */\n hide: boolean\n}\n\n/** @internal */\nexport const BlockHandlePositionerPropsDeclaration: PropsDeclaration<BlockHandlePositionerProps> = /* @__PURE__ */ defineProps<\n BlockHandlePositionerProps\n>({\n ...OverlayPositionerPropsDeclaration,\n placement: { default: 'left', attribute: 'placement', type: 'string' },\n // Enabling `hoist` will cause the popover to have a small delay when\n // scrolling the page.\n hoist: { default: false, attribute: 'hoist', type: 'boolean' },\n flip: { default: false, attribute: false, type: 'json' },\n shift: { default: false, attribute: 'shift', type: 'boolean' },\n hide: { default: true, attribute: 'hide', type: 'boolean' },\n})\n\n/** @internal */\nexport function setupBlockHandlePositioner(\n host: HostElement,\n props: State<BlockHandlePositionerProps>,\n): void {\n const getOverlayStore = blockHandleOverlayStoreContext.consume(host)\n setupOverlayPositioner(host, props as unknown as State<OverlayPositionerProps>, getOverlayStore)\n}\n\nconst BlockHandlePositionerElementBase: HostElementConstructor<BlockHandlePositionerProps> = defineCustomElement(\n setupBlockHandlePositioner,\n BlockHandlePositionerPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class BlockHandlePositionerElement extends BlockHandlePositionerElementBase {}\n\n/** @internal */\nexport function registerBlockHandlePositionerElement(): void {\n registerCustomElement('prosekit-block-handle-positioner', BlockHandlePositionerElement)\n}\n","export function prefersReducedMotion(): boolean {\n if (typeof window === 'undefined') {\n return false\n }\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches\n}\n","import type { ProseMirrorNode } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport interface HoverState {\n node: ProseMirrorNode\n pos: number\n}\n\n/**\n * @internal\n */\nexport function isHoverStateEqual(a: HoverState, b: HoverState): boolean {\n return a.pos === b.pos && a.node.eq(b.node)\n}\n","import type { VirtualElement } from '@floating-ui/dom'\nimport { isElement, isHTMLElement, isTextNode, throttle } from '@ocavue/utils'\nimport { defineDOMEventHandler, union, type PlainExtension } from '@prosekit/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { getClientRect } from '../../utils/get-client-rect.ts'\n\nimport type { HoverState } from './hover-state.ts'\n\nexport type ElementHoverHandler = (\n reference?: VirtualElement,\n hoverState?: HoverState,\n) => void\n\nexport function defineElementHoverHandler(handler: ElementHoverHandler): PlainExtension {\n const handleElement = (\n node: ProseMirrorNode,\n pos: number,\n element: HTMLElement,\n parentElement?: Node | null,\n ) => {\n const reference: VirtualElement = {\n contextElement: element,\n\n getBoundingClientRect: () => {\n const rect = findFirstLineRect(parentElement, element)\n return rect ? fulfillRect(rect) : fallbackRect\n },\n }\n\n handler(reference, { node, pos })\n }\n\n let lastX = -1\n let lastY = -1\n let lastTime = -1\n\n const handlePointerEvent = (view: EditorView, event: PointerEvent) => {\n const { x, y } = event\n\n // Simple performance optimization. If the pointer is not moving, we don't\n // want to recalculate the block handle position within a short period of\n // time window.\n if (lastX === x && lastY === y) {\n const now = Date.now()\n if (now - lastTime < 100) {\n return\n }\n lastTime = now\n }\n lastX = x\n lastY = y\n\n const block = findBlockByCoords(view, x, y)\n if (!block) {\n handler()\n return\n }\n\n const { node, pos } = block\n const element = view.nodeDOM(pos)\n if (!element || !isHTMLElement(element)) {\n handler()\n return\n }\n\n // If `node` is the first child of another non-doc block node, for example a\n // list node or a blockquote node, we want to put the block handle agains\n // the parent node.\n const $pos = view.state.doc.resolve(pos)\n if ($pos.depth > 0 && $pos.index($pos.depth) === 0) {\n const parentPos = $pos.before($pos.depth)\n const parentNode = $pos.parent\n const parentElement = view.nodeDOM(parentPos)\n handleElement(parentNode, parentPos, element, parentElement)\n } else {\n handleElement(node, pos, element)\n }\n }\n\n return union(\n defineDOMEventHandler('pointermove', throttle(handlePointerEvent, 200)),\n defineDOMEventHandler('pointerenter', handlePointerEvent),\n defineDOMEventHandler('pointerout', handlePointerEvent),\n defineDOMEventHandler('keypress', () => handler()),\n )\n}\n\nfunction findBlockByCoords(view: EditorView, x: number, y: number): { node: ProseMirrorNode; pos: number } | undefined {\n const rect = getClientRect(view.dom)\n if (!isWithinRect(rect, x, y)) {\n return\n }\n\n let parent: ProseMirrorNode | undefined = view.state.doc\n let pos = -1\n\n while (parent) {\n if (parent.isBlock && (parent.isTextblock || parent.isAtom || parent.type.spec.isolating)) {\n return { node: parent, pos }\n }\n\n // Collect all children and their positions\n const children: ProseMirrorNode[] = []\n const positions: number[] = []\n parent.forEach((child, offset) => {\n children.push(child)\n positions.push(offset + pos + 1)\n })\n\n let lo = 0\n let hi = children.length - 1\n\n while (lo <= hi) {\n const i = hi - ((hi - lo) >> 1)\n const childDOM = view.nodeDOM(positions[i])\n const childRect = getNodeRect(childDOM)\n if (!childRect) {\n console.warn(`[prosekit] Unable to get rect at position: ${positions[i]}`)\n return\n }\n if (childRect.top > y) {\n hi = i - 1\n } else if (childRect.bottom < y) {\n lo = i + 1\n } else {\n lo = i\n break\n }\n }\n\n if (lo > hi) {\n return\n }\n\n parent = children[lo]\n pos = positions[lo]\n }\n}\n\nfunction getNodeRect(node: Node | null | undefined): Rect | undefined {\n if (node && isElement(node) && node.isConnected) {\n return getClientRect(node)\n }\n}\n\nfunction isWithinRect(rect: Rect, x: number, y: number) {\n return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom\n}\n\ninterface Rect {\n top: number\n right: number\n bottom: number\n left: number\n}\n\nfunction findFirstLineRect(outer?: Node | null, inner?: Node | null): Rect | undefined {\n if (outer && !outer.isConnected) {\n return\n }\n if (inner && !inner.isConnected) {\n return\n }\n\n if (outer && inner) {\n const outerRect = findOuterRect(outer)\n const innerRect = findFirstLineRectInNode(inner)\n if (outerRect && innerRect) {\n const { top, bottom } = innerRect\n const { left, right } = outerRect\n return { top, bottom, left, right }\n } else {\n return outerRect || innerRect\n }\n } else if (outer) {\n return findFirstLineRectInNode(outer)\n } else if (inner) {\n return findFirstLineRectInNode(inner)\n }\n}\n\nfunction findOuterRect(node: Node): Rect | undefined {\n if (!isElement(node)) {\n return\n }\n\n return getClientRect(node, { left: true, right: true })\n}\n\nfunction findFirstLineRectInNode(node: Node): Rect | undefined {\n if (isElement(node)) {\n return findFirstLineRectInElement(node)\n } else if (isTextNode(node)) {\n return findFirstLineRectInTextNode(node)\n }\n}\n\nfunction findFirstLineRectInTextNode(node: Text): Rect | undefined {\n const ownerDocument = node.ownerDocument\n if (!ownerDocument) {\n return\n }\n const range = ownerDocument.createRange()\n range.setStart(node, 0)\n range.setEnd(node, 0)\n const rects = range.getClientRects()\n return rects[0]\n}\n\nfunction findFirstLineRectInElement(element: Element): Rect | undefined {\n if (element.nodeName === 'BR') {\n return element.getBoundingClientRect()\n }\n\n const rect = getClientRect(element)\n const style = element.ownerDocument.defaultView?.getComputedStyle(element)\n const marginLeft = style && Number.parseInt(style.marginLeft, 10) || 0\n const marginRight = style && Number.parseInt(style.marginRight, 10) || 0\n const left = rect.left - marginLeft\n const right = rect.right + marginRight\n\n const lineHeight = style && Number.parseInt(style.lineHeight, 10) || 24\n const paddingTop = style && Number.parseInt(style.paddingTop, 10) || 0\n const borderTop = style && Number.parseInt(style.borderTopWidth, 10) || 0\n const top = rect.top + paddingTop + borderTop\n const bottom = top + lineHeight\n\n return { top, bottom, left, right }\n}\n\nfunction fulfillRect({ top, right, bottom, left }: Rect) {\n return { top, right, bottom, left, width: right - left, height: bottom - top, x: left, y: top }\n}\n\n// A fallback rect that is far away from the screen. It should not be used through.\nconst fallbackRect = Object.freeze({\n top: -9999,\n right: -9999,\n bottom: -9999,\n left: -9999,\n width: 0,\n height: 0,\n x: -9999,\n y: -9999,\n})\n","import type { HostElement } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nimport { useEditorExtension } from '../../hooks/use-editor-extension.ts'\nimport { prefersReducedMotion } from '../../utils/prefers-reduced-motion.ts'\n\nimport { isHoverStateEqual, type HoverState } from './hover-state.ts'\nimport { defineElementHoverHandler, type ElementHoverHandler } from './pointer-move.ts'\n\nexport function useHoverExtension(\n host: HostElement,\n getEditor: () => Editor | null,\n handler: ElementHoverHandler,\n): void {\n const invalidTimeoutMs = prefersReducedMotion() ? 0 : 180\n\n let invalidTimeoutId: ReturnType<typeof setTimeout> | undefined\n\n let prevHoverState: HoverState | undefined\n\n const callHandler: ElementHoverHandler = (reference, hoverState) => {\n prevHoverState = hoverState\n handler(reference, hoverState)\n }\n\n const extension = defineElementHoverHandler((reference, hoverState) => {\n if (hoverState && invalidTimeoutId != null) {\n clearTimeout(invalidTimeoutId)\n invalidTimeoutId = undefined\n }\n\n if (prevHoverState && hoverState) {\n if (isHoverStateEqual(prevHoverState, hoverState)) {\n return\n }\n callHandler(reference, hoverState)\n return\n }\n\n if (!prevHoverState && !hoverState) {\n return\n }\n\n if (!prevHoverState && hoverState) {\n callHandler(reference, hoverState)\n return\n }\n\n if (prevHoverState && !hoverState) {\n if (invalidTimeoutId != null) {\n return\n }\n\n // Wait for a short period of time before invalidating the hover state.\n // This ensures smoother animation when the pointer moves between two\n // blocks with a small gap.\n invalidTimeoutId = setTimeout(() => {\n callHandler(reference, undefined)\n invalidTimeoutId = undefined\n }, invalidTimeoutMs)\n }\n })\n\n useEditorExtension(host, getEditor, extension)\n}\n","import {\n computed,\n createSignal,\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEffect,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { createOverlayStore } from '@aria-ui/elements/overlay'\nimport type { VirtualElement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\n\nimport { useScrolling } from '../../hooks/use-scrolling.ts'\n\nimport { blockHandleOverlayStoreContext, BlockHandleStore, blockHandleStoreContext } from './context.ts'\nimport { useHoverExtension } from './use-hover-extension.ts'\n\nexport interface BlockHandleRootProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const BlockHandleRootPropsDeclaration: PropsDeclaration<BlockHandleRootProps> = /* @__PURE__ */ defineProps<\n BlockHandleRootProps\n>({\n editor: { default: null, attribute: false, type: 'json' },\n})\n\n/**\n * @public\n */\nexport class BlockHandleStateChangeEvent extends Event {\n /**\n * The currently hovered block's node and position, or `null` if no block is hovered.\n */\n detail: { node: ProseMirrorNode; pos: number } | null\n constructor(state: { node: ProseMirrorNode; pos: number } | null) {\n super('stateChange', { bubbles: true })\n this.detail = state\n }\n}\n\n/**\n * @public\n */\nexport interface BlockHandleRootEvents {\n /**\n * Fired when the hovered block changes.\n */\n stateChange: BlockHandleStateChangeEvent\n}\n\n/**\n * @internal\n */\nexport function setupBlockHandleRoot(\n host: HostElement,\n props: State<BlockHandleRootProps>,\n): void {\n const getEditor = props.editor.get\n\n const store = new BlockHandleStore()\n blockHandleStoreContext.provide(host, store)\n\n const reference = createSignal<VirtualElement | undefined>(undefined)\n const getScrolling = useScrolling(host)\n\n const getOpen = computed(() => !!store.hoverState.get() && !getScrolling())\n\n const overlayStore = createOverlayStore(\n getOpen,\n () => {},\n () => true,\n () => false,\n (event) => host.dispatchEvent(event),\n )\n\n useHoverExtension(host, getEditor, (ref, hoverState) => {\n reference.set(ref ?? undefined)\n store.hoverState.set(hoverState)\n const state = hoverState ? { node: hoverState.node, pos: hoverState.pos } : null\n host.dispatchEvent(new BlockHandleStateChangeEvent(state))\n })\n\n useEffect(host, () => {\n overlayStore.setAnchorElement(reference.get())\n })\n\n blockHandleOverlayStoreContext.provide(host, overlayStore)\n}\n\nconst BlockHandleRootElementBase: HostElementConstructor<BlockHandleRootProps> = defineCustomElement(\n setupBlockHandleRoot,\n BlockHandleRootPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class BlockHandleRootElement extends BlockHandleRootElementBase {}\n\n/** @internal */\nexport function registerBlockHandleRootElement(): void {\n registerCustomElement('prosekit-block-handle-root', BlockHandleRootElement)\n}\n"],"mappings":";;;;;;;;;;;;;;AAQA,IAAa,mBAAb,MAA8B;;oBAC0B,aAAqC,KAAA,EAAU;kBAChE,aAAa,MAAM;;;;;;AAM1D,MAAa,0BAAqD,cAAgC,8BAA8B;;;;AAKhI,MAAa,iCAAwD,cAA4B,sCAAsC;;;;ACIvI,MAAa,iCAAwF,4BAAiC,EACpI,QAAQ;CAAE,SAAS;CAAM,WAAW;CAAO,MAAM;CAAQ,EAC1D,CAAC;;;;AAKF,SAAgB,oBACd,MACA,OACM;CACN,MAAM,WAAW,wBAAwB,QAAQ,KAAK;AAEtD,kBAAiB,MAAM,gBAAgB,UAAU;AAC/C,QAAM,gBAAgB;EAEtB,MAAM,QAAQ,UAAU;EACxB,MAAM,SAAS,MAAM,OAAO,KAAK;EACjC,MAAM,aAAa,OAAO,WAAW,KAAK;AAC1C,MAAI,CAAC,UAAU,CAAC,WACd;EAGF,MAAM,EAAE,MAAM,QAAQ;AACtB,SAAO,KAAK,mBAAmB,EAAE,KAAK,MAAM,KAAK,UAAU,CAAC,CAAC;AAC7D,SAAO,OAAO;AAGd,SAAO,WAAW,IAAI,KAAA,EAAU;GAChC;;AAGJ,MAAM,4BAAyE,oBAC7E,qBACA,+BACD;;;;AAKD,IAAa,wBAAb,cAA2C,0BAA0B;;AAGrE,SAAgB,gCAAsC;AACpD,uBA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