@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,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HostElement, HostElementConstructor, PropsDeclaration, State } from "@aria-ui/core";
|
|
2
2
|
import { Editor } from "@prosekit/core";
|
|
3
3
|
|
|
4
|
-
//#region src/components/drop-indicator/drop-indicator
|
|
4
|
+
//#region src/components/drop-indicator/drop-indicator.d.ts
|
|
5
5
|
interface DropIndicatorProps {
|
|
6
6
|
/**
|
|
7
7
|
* The ProseKit editor instance.
|
|
@@ -18,22 +18,20 @@ interface DropIndicatorProps {
|
|
|
18
18
|
width: number;
|
|
19
19
|
}
|
|
20
20
|
/** @internal */
|
|
21
|
-
declare const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
declare const DropIndicatorPropsDeclaration: PropsDeclaration<DropIndicatorProps>;
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
declare function setupDropIndicator(host: HostElement, props: State<DropIndicatorProps>): void;
|
|
26
|
+
declare const DropIndicatorElementBase: HostElementConstructor<DropIndicatorProps>;
|
|
27
|
+
/**
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
28
30
|
declare class DropIndicatorElement extends DropIndicatorElementBase {}
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/components/drop-indicator/drop-indicator/setup.d.ts
|
|
31
31
|
/**
|
|
32
32
|
* @internal
|
|
33
33
|
*/
|
|
34
|
-
declare function
|
|
35
|
-
state
|
|
36
|
-
}: SetupOptions<DropIndicatorProps, DropIndicatorEvents>): void;
|
|
34
|
+
declare function registerDropIndicatorElement(): void;
|
|
37
35
|
//#endregion
|
|
38
|
-
export { DropIndicatorElement, type
|
|
36
|
+
export { DropIndicatorElement, type DropIndicatorProps, DropIndicatorPropsDeclaration, registerDropIndicatorElement, setupDropIndicator };
|
|
39
37
|
//# sourceMappingURL=prosekit-web-drop-indicator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-drop-indicator.d.ts","names":[],"sources":["../src/components/drop-indicator/drop-indicator
|
|
1
|
+
{"version":3,"file":"prosekit-web-drop-indicator.d.ts","names":[],"sources":["../src/components/drop-indicator/drop-indicator.ts"],"mappings":";;;;UAoBiB,kBAAA;;AAAjB;;;;;EAOE,MAAA,EAAQ,MAAA;EAOR;;;AAIF;;EAJE,KAAA;AAAA;;cAIW,6BAAA,EAA+B,gBAAA,CAAiB,kBAAA;;;;iBAgB7C,kBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,kBAAA;AAAA,cAwDT,wBAAA,EAA0B,sBAAA,CAAuB,kBAAA;;;;cAQ1C,oBAAA,SAA6B,wBAAA;;;;iBAK1B,4BAAA,CAAA"}
|
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
import { t as useEditorExtension } from "./use-editor-extension.js";
|
|
2
2
|
import { n as assignStyles, t as useScrolling } from "./use-scrolling.js";
|
|
3
|
-
import {
|
|
4
|
-
import { usePresence } from "@aria-ui/
|
|
3
|
+
import { computed, createSignal, defineCustomElement, defineProps, registerCustomElement, useEffect } from "@aria-ui/core";
|
|
4
|
+
import { usePresence } from "@aria-ui/utils";
|
|
5
5
|
import { defineDropIndicator } from "@prosekit/extensions/drop-indicator";
|
|
6
|
-
//#region src/components/drop-indicator/drop-indicator
|
|
6
|
+
//#region src/components/drop-indicator/drop-indicator.ts
|
|
7
|
+
/** @internal */
|
|
8
|
+
const DropIndicatorPropsDeclaration = /* @__PURE__ */ defineProps({
|
|
9
|
+
editor: {
|
|
10
|
+
default: null,
|
|
11
|
+
attribute: false,
|
|
12
|
+
type: "json"
|
|
13
|
+
},
|
|
14
|
+
width: {
|
|
15
|
+
default: 2,
|
|
16
|
+
attribute: "width",
|
|
17
|
+
type: "number"
|
|
18
|
+
}
|
|
19
|
+
});
|
|
7
20
|
/**
|
|
8
21
|
* @internal
|
|
9
22
|
*/
|
|
10
|
-
function
|
|
23
|
+
function setupDropIndicator(host, props) {
|
|
11
24
|
const context = createSignal(null);
|
|
12
25
|
const extension = defineDropIndicator({
|
|
13
26
|
onShow: (options) => context.set(options),
|
|
14
27
|
onHide: () => context.set(null)
|
|
15
28
|
});
|
|
16
|
-
useEditorExtension(host,
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
usePresence(host,
|
|
20
|
-
return !!context.get() && !scrolling.get();
|
|
21
|
-
}));
|
|
29
|
+
useEditorExtension(host, props.editor.get, extension);
|
|
30
|
+
const getLine = computed(() => context.get()?.line);
|
|
31
|
+
const getScrolling = useScrolling(host);
|
|
32
|
+
usePresence(host, computed(() => !!context.get() && !getScrolling()));
|
|
22
33
|
useEffect(host, () => {
|
|
23
|
-
const lineValue =
|
|
24
|
-
const lineWidth =
|
|
34
|
+
const lineValue = getLine();
|
|
35
|
+
const lineWidth = props.width.get();
|
|
25
36
|
if (!lineValue) return;
|
|
26
37
|
const { p1: { x: x1, y: y1 }, p2: { x: x2, y: y2 } } = lineValue;
|
|
27
38
|
const horizontal = y1 === y2;
|
|
@@ -51,25 +62,18 @@ function useDropIndicator(host, { state }) {
|
|
|
51
62
|
});
|
|
52
63
|
});
|
|
53
64
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
editor: { default: null },
|
|
59
|
-
width: { default: 2 }
|
|
60
|
-
});
|
|
61
|
-
/** @internal */
|
|
62
|
-
const dropIndicatorEvents = {};
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/components/drop-indicator/drop-indicator/element.gen.ts
|
|
65
|
-
const DropIndicatorElementBase = defineCustomElement({
|
|
66
|
-
props: dropIndicatorProps,
|
|
67
|
-
events: dropIndicatorEvents,
|
|
68
|
-
setup: useDropIndicator
|
|
69
|
-
});
|
|
65
|
+
const DropIndicatorElementBase = defineCustomElement(setupDropIndicator, DropIndicatorPropsDeclaration);
|
|
66
|
+
/**
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
70
69
|
var DropIndicatorElement = class extends DropIndicatorElementBase {};
|
|
71
|
-
|
|
70
|
+
/**
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
function registerDropIndicatorElement() {
|
|
74
|
+
registerCustomElement("prosekit-drop-indicator", DropIndicatorElement);
|
|
75
|
+
}
|
|
72
76
|
//#endregion
|
|
73
|
-
export { DropIndicatorElement,
|
|
77
|
+
export { DropIndicatorElement, DropIndicatorPropsDeclaration, registerDropIndicatorElement, setupDropIndicator };
|
|
74
78
|
|
|
75
79
|
//# sourceMappingURL=prosekit-web-drop-indicator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-drop-indicator.js","names":[],"sources":["../src/components/drop-indicator/drop-indicator
|
|
1
|
+
{"version":3,"file":"prosekit-web-drop-indicator.js","names":[],"sources":["../src/components/drop-indicator/drop-indicator.ts"],"sourcesContent":["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 { usePresence } from '@aria-ui/utils'\nimport type { Editor } from '@prosekit/core'\nimport { defineDropIndicator, type ShowHandlerOptions } from '@prosekit/extensions/drop-indicator'\n\nimport { useEditorExtension } from '../../hooks/use-editor-extension.ts'\nimport { useScrolling } from '../../hooks/use-scrolling.ts'\nimport { assignStyles } from '../../utils/assign-styles.ts'\n\nexport interface DropIndicatorProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * The line width in pixels.\n *\n * @default 2\n */\n width: number\n}\n\n/** @internal */\nexport const DropIndicatorPropsDeclaration: PropsDeclaration<DropIndicatorProps> = /* @__PURE__ */ defineProps<DropIndicatorProps>({\n editor: {\n default: null,\n attribute: false,\n type: 'json',\n },\n width: {\n default: 2,\n attribute: 'width',\n type: 'number',\n },\n})\n\n/**\n * @internal\n */\nexport function setupDropIndicator(\n host: HostElement,\n props: State<DropIndicatorProps>,\n): void {\n type DropIndicatorContext = ShowHandlerOptions | null\n const context = createSignal<DropIndicatorContext>(null)\n\n const extension = defineDropIndicator({\n onShow: (options) => context.set(options),\n onHide: () => context.set(null),\n })\n\n useEditorExtension(host, props.editor.get, extension)\n\n const getLine = computed(() => context.get()?.line)\n const getScrolling = useScrolling(host)\n const getPresence = computed(() => !!context.get() && !getScrolling())\n usePresence(host, getPresence)\n\n useEffect(host, () => {\n const lineValue = getLine()\n const lineWidth = props.width.get()\n\n if (!lineValue) return\n\n const { p1: { x: x1, y: y1 }, p2: { x: x2, y: y2 } } = lineValue\n const horizontal = y1 === y2\n\n let width: number\n let height: number\n let top: number = y1\n let left: number = x1\n\n if (horizontal) {\n width = x2 - x1\n height = lineWidth\n top -= lineWidth / 2\n } else {\n width = lineWidth\n height = y2 - y1\n left -= lineWidth / 2\n }\n\n top = Math.round(top)\n left = Math.round(left)\n\n assignStyles(host, {\n position: 'fixed',\n pointerEvents: 'none',\n width: `${width}px`,\n height: `${height}px`,\n transform: `translate(${left}px, ${top}px)`,\n left: '0px',\n top: '0px',\n })\n })\n}\n\nconst DropIndicatorElementBase: HostElementConstructor<DropIndicatorProps> = defineCustomElement(\n setupDropIndicator,\n DropIndicatorPropsDeclaration,\n)\n\n/**\n * @public\n */\nexport class DropIndicatorElement extends DropIndicatorElementBase {}\n\n/**\n * @internal\n */\nexport function registerDropIndicatorElement(): void {\n registerCustomElement('prosekit-drop-indicator', DropIndicatorElement)\n}\n"],"mappings":";;;;;;;AAsCA,MAAa,gCAAsF,4BAAgC;CACjI,QAAQ;EACN,SAAS;EACT,WAAW;EACX,MAAM;EACP;CACD,OAAO;EACL,SAAS;EACT,WAAW;EACX,MAAM;EACP;CACF,CAAC;;;;AAKF,SAAgB,mBACd,MACA,OACM;CAEN,MAAM,UAAU,aAAmC,KAAK;CAExD,MAAM,YAAY,oBAAoB;EACpC,SAAS,YAAY,QAAQ,IAAI,QAAQ;EACzC,cAAc,QAAQ,IAAI,KAAK;EAChC,CAAC;AAEF,oBAAmB,MAAM,MAAM,OAAO,KAAK,UAAU;CAErD,MAAM,UAAU,eAAe,QAAQ,KAAK,EAAE,KAAK;CACnD,MAAM,eAAe,aAAa,KAAK;AAEvC,aAAY,MADQ,eAAe,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,cAAc,CAAC,CACxC;AAE9B,WAAU,YAAY;EACpB,MAAM,YAAY,SAAS;EAC3B,MAAM,YAAY,MAAM,MAAM,KAAK;AAEnC,MAAI,CAAC,UAAW;EAEhB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,MAAM,IAAI,EAAE,GAAG,IAAI,GAAG,SAAS;EACvD,MAAM,aAAa,OAAO;EAE1B,IAAI;EACJ,IAAI;EACJ,IAAI,MAAc;EAClB,IAAI,OAAe;AAEnB,MAAI,YAAY;AACd,WAAQ,KAAK;AACb,YAAS;AACT,UAAO,YAAY;SACd;AACL,WAAQ;AACR,YAAS,KAAK;AACd,WAAQ,YAAY;;AAGtB,QAAM,KAAK,MAAM,IAAI;AACrB,SAAO,KAAK,MAAM,KAAK;AAEvB,eAAa,MAAM;GACjB,UAAU;GACV,eAAe;GACf,OAAO,GAAG,MAAM;GAChB,QAAQ,GAAG,OAAO;GAClB,WAAW,aAAa,KAAK,MAAM,IAAI;GACvC,MAAM;GACN,KAAK;GACN,CAAC;GACF;;AAGJ,MAAM,2BAAuE,oBAC3E,oBACA,8BACD;;;;AAKD,IAAa,uBAAb,cAA0C,yBAAyB;;;;AAKnE,SAAgB,+BAAqC;AACnD,uBAAsB,2BAA2B,qBAAqB"}
|
|
@@ -1,91 +1,125 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HostElement, HostElementConstructor, PropsDeclaration, State } from "@aria-ui/core";
|
|
2
|
+
import { OpenChangeEvent, OpenChangeEvent as OpenChangeEvent$1, OverlayPopupProps, OverlayPositionerProps, OverlayRootProps } from "@aria-ui/elements/overlay";
|
|
2
3
|
import { Editor } from "@prosekit/core";
|
|
3
|
-
import { OverlayPositionerEvents, OverlayPositionerProps } from "@aria-ui/overlay";
|
|
4
4
|
|
|
5
|
-
//#region src/components/inline-popover/inline-popover
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
* Notice that the popover will be always hidden if the inline selection is
|
|
29
|
-
* empty.
|
|
30
|
-
*
|
|
31
|
-
* @default false
|
|
32
|
-
*/
|
|
33
|
-
open: boolean;
|
|
5
|
+
//#region src/components/inline-popover/inline-popover-popup.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
interface InlinePopoverPopupProps extends OverlayPopupProps {}
|
|
10
|
+
/** @internal */
|
|
11
|
+
declare const InlinePopoverPopupPropsDeclaration: PropsDeclaration<InlinePopoverPopupProps>;
|
|
12
|
+
/** @internal */
|
|
13
|
+
declare function setupInlinePopoverPopup(host: HostElement, _props: State<InlinePopoverPopupProps>): void;
|
|
14
|
+
declare const InlinePopoverPopupElementBase: HostElementConstructor<InlinePopoverPopupProps>;
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
declare class InlinePopoverPopupElement extends InlinePopoverPopupElementBase {}
|
|
19
|
+
/** @internal */
|
|
20
|
+
declare function registerInlinePopoverPopupElement(): void;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/components/inline-popover/inline-popover-positioner.d.ts
|
|
23
|
+
/**
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
interface InlinePopoverPositionerProps extends OverlayPositionerProps {
|
|
34
27
|
/**
|
|
35
|
-
*
|
|
36
|
-
* Escape key press.
|
|
28
|
+
* The initial placement of the floating element
|
|
37
29
|
*
|
|
38
|
-
* @default true
|
|
39
|
-
*/
|
|
40
|
-
dismissOnEscape: boolean;
|
|
41
|
-
/**
|
|
42
30
|
* @default "top"
|
|
43
31
|
*/
|
|
44
32
|
placement: OverlayPositionerProps['placement'];
|
|
45
33
|
/**
|
|
34
|
+
* The distance between the reference and floating element.
|
|
35
|
+
*
|
|
46
36
|
* @default 12
|
|
47
37
|
*/
|
|
48
38
|
offset: OverlayPositionerProps['offset'];
|
|
49
39
|
/**
|
|
40
|
+
* Whether to hide the floating element when the reference element or the
|
|
41
|
+
* floating element is fully clipped.
|
|
42
|
+
*
|
|
50
43
|
* @default true
|
|
51
44
|
*/
|
|
52
45
|
hide: OverlayPositionerProps['hide'];
|
|
53
46
|
/**
|
|
47
|
+
* Whether the floating element can overlap the reference element to keep it
|
|
48
|
+
* in view.
|
|
49
|
+
*
|
|
54
50
|
* @default true
|
|
55
51
|
*/
|
|
56
52
|
overlap: OverlayPositionerProps['overlap'];
|
|
57
53
|
/**
|
|
54
|
+
* Whether to improve positioning for inline reference elements that span over
|
|
55
|
+
* multiple lines.
|
|
56
|
+
*
|
|
58
57
|
* @default true
|
|
59
58
|
*/
|
|
60
59
|
inline: OverlayPositionerProps['inline'];
|
|
61
60
|
/**
|
|
61
|
+
* Describes the virtual padding around the boundary to check for overflow.
|
|
62
|
+
*
|
|
62
63
|
* @default 8
|
|
63
64
|
*/
|
|
64
65
|
overflowPadding: OverlayPositionerProps['overflowPadding'];
|
|
65
66
|
}
|
|
66
67
|
/** @internal */
|
|
67
|
-
declare const
|
|
68
|
-
|
|
68
|
+
declare const InlinePopoverPositionerPropsDeclaration: PropsDeclaration<InlinePopoverPositionerProps>;
|
|
69
|
+
/** @internal */
|
|
70
|
+
declare function setupInlinePopoverPositioner(host: HostElement, props: State<InlinePopoverPositionerProps>): void;
|
|
71
|
+
declare const InlinePopoverPositionerElementBase: HostElementConstructor<InlinePopoverPositionerProps>;
|
|
72
|
+
/**
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
declare class InlinePopoverPositionerElement extends InlinePopoverPositionerElementBase {}
|
|
76
|
+
/** @internal */
|
|
77
|
+
declare function registerInlinePopoverPositionerElement(): void;
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/components/inline-popover/inline-popover-root.d.ts
|
|
80
|
+
/**
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
interface InlinePopoverRootProps extends OverlayRootProps {
|
|
84
|
+
/**
|
|
85
|
+
* The ProseKit editor instance.
|
|
86
|
+
*
|
|
87
|
+
* @default null
|
|
88
|
+
* @hidden
|
|
89
|
+
*/
|
|
90
|
+
editor: Editor | null;
|
|
91
|
+
/**
|
|
92
|
+
* Whether the popover is open by default when some inline content is
|
|
93
|
+
* selected.
|
|
94
|
+
*
|
|
95
|
+
* @default true
|
|
96
|
+
*/
|
|
97
|
+
defaultOpen: boolean;
|
|
69
98
|
/**
|
|
70
|
-
*
|
|
99
|
+
* Whether the inline popover should be dismissed when the editor receives an
|
|
100
|
+
* Escape key press.
|
|
101
|
+
*
|
|
102
|
+
* @default true
|
|
71
103
|
*/
|
|
72
|
-
|
|
104
|
+
dismissOnEscape: boolean;
|
|
73
105
|
}
|
|
74
106
|
/** @internal */
|
|
75
|
-
declare const
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/components/inline-popover/inline-popover/element.gen.d.ts
|
|
78
|
-
declare const InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps>;
|
|
79
|
-
declare class InlinePopoverElement extends InlinePopoverElementBase {}
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/components/inline-popover/inline-popover/setup.d.ts
|
|
107
|
+
declare const InlinePopoverRootPropsDeclaration: PropsDeclaration<InlinePopoverRootProps>;
|
|
82
108
|
/**
|
|
83
|
-
* @
|
|
109
|
+
* @public
|
|
84
110
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
111
|
+
interface InlinePopoverRootEvents {
|
|
112
|
+
openChange: OpenChangeEvent$1;
|
|
113
|
+
}
|
|
114
|
+
/** @internal */
|
|
115
|
+
declare function setupInlinePopoverRoot(host: HostElement, props: State<InlinePopoverRootProps>): void;
|
|
116
|
+
declare const InlinePopoverRootElementBase: HostElementConstructor<InlinePopoverRootProps>;
|
|
117
|
+
/**
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
declare class InlinePopoverRootElement extends InlinePopoverRootElementBase {}
|
|
121
|
+
/** @internal */
|
|
122
|
+
declare function registerInlinePopoverRootElement(): void;
|
|
89
123
|
//#endregion
|
|
90
|
-
export {
|
|
124
|
+
export { InlinePopoverPopupElement, type InlinePopoverPopupProps, InlinePopoverPopupPropsDeclaration, InlinePopoverPositionerElement, type InlinePopoverPositionerProps, InlinePopoverPositionerPropsDeclaration, InlinePopoverRootElement, type InlinePopoverRootEvents, type InlinePopoverRootProps, InlinePopoverRootPropsDeclaration, OpenChangeEvent, registerInlinePopoverPopupElement, registerInlinePopoverPositionerElement, registerInlinePopoverRootElement, setupInlinePopoverPopup, setupInlinePopoverPositioner, setupInlinePopoverRoot };
|
|
91
125
|
//# sourceMappingURL=prosekit-web-inline-popover.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-inline-popover.d.ts","names":[],"sources":["../src/components/inline-popover/inline-popover
|
|
1
|
+
{"version":3,"file":"prosekit-web-inline-popover.d.ts","names":[],"sources":["../src/components/inline-popover/inline-popover-popup.ts","../src/components/inline-popover/inline-popover-positioner.ts","../src/components/inline-popover/inline-popover-root.ts"],"mappings":";;;;;;;;UAkBiB,uBAAA,SAAgC,iBAAA;;cAGpC,kCAAA,EAAoC,gBAAA,CAAiB,uBAAA;;iBAGlD,uBAAA,CACd,IAAA,EAAM,WAAA,EACN,MAAA,EAAQ,KAAA,CAAM,uBAAA;AAAA,cAYV,6BAAA,EAA+B,sBAAA,CAAuB,uBAAA;;;;cAQ/C,yBAAA,SAAkC,6BAAA;;iBAG/B,iCAAA,CAAA;;;;;;UCjCC,4BAAA,SAAqC,sBAAA;EDEb;;;;AAGzC;ECCE,SAAA,EAAW,sBAAA;;;;ADEb;;ECKE,MAAA,EAAQ,sBAAA;EDJF;;;;;;ECYN,IAAA,EAAM,sBAAA;EDXE;;;;;AAUT;ECSC,OAAA,EAAS,sBAAA;;;;ADCX;;;ECOE,MAAA,EAAQ,sBAAA;EDPkE;AAG5E;;;;ECWE,eAAA,EAAiB,sBAAA;AAAA;;cAIN,uCAAA,EAAyC,gBAAA,CAAiB,4BAAA;AAhDvE;AAAA,iBA6DgB,4BAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,4BAAA;AAAA,cAKT,kCAAA,EAAoC,sBAAA,CAAuB,4BAAA;;;;cAQpD,8BAAA,SAAuC,kCAAA;;iBAGpC,sCAAA,CAAA;;;;AD7EhB;;UEMiB,sBAAA,SAA+B,gBAAA;EFNC;;AAGjD;;;;EEUE,MAAA,EAAQ,MAAA;EFPM;;;;;;EEed,WAAA;EFba;;;;;;EEqBb,eAAA;AAAA;AFXD;AAAA,cEeY,iCAAA,EAAmC,gBAAA,CAAiB,sBAAA;;;;UAYhD,uBAAA;EACf,UAAA,EAAY,iBAAA;AAAA;;iBAIE,sBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,sBAAA;AAAA,cAsCT,4BAAA,EAA8B,sBAAA,CAAuB,sBAAA;;;;cAQ9C,wBAAA,SAAiC,4BAAA;;iBAG9B,gCAAA,CAAA"}
|
|
@@ -1,31 +1,104 @@
|
|
|
1
1
|
import { t as useEditorExtension } from "./use-editor-extension.js";
|
|
2
|
-
import {
|
|
2
|
+
import { computed, createContext, defineCustomElement, defineProps, onMount, registerCustomElement } from "@aria-ui/core";
|
|
3
|
+
import { OpenChangeEvent, OverlayPopupPropsDeclaration, OverlayPositionerPropsDeclaration, OverlayRootPropsDeclaration, setupOverlayPopup, setupOverlayPositioner, useOverlayStore } from "@aria-ui/elements/overlay";
|
|
3
4
|
import { containsInlineNode, defineFocusChangeHandler, defineKeymap, defineUpdateHandler, isInCodeBlock, isTextSelection } from "@prosekit/core";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { usePresence } from "@aria-ui/utils";
|
|
6
|
+
//#region src/components/inline-popover/store.ts
|
|
7
|
+
const InlinePopoverStoreContext = createContext("prosekit-inline-popover-store");
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/components/inline-popover/inline-popover-popup.ts
|
|
10
|
+
/** @internal */
|
|
11
|
+
const InlinePopoverPopupPropsDeclaration = OverlayPopupPropsDeclaration;
|
|
12
|
+
/** @internal */
|
|
13
|
+
function setupInlinePopoverPopup(host, _props) {
|
|
14
|
+
const getStore = InlinePopoverStoreContext.consume(host);
|
|
15
|
+
setupOverlayPopup(host, getStore);
|
|
16
|
+
usePresence(host, computed(() => getStore()?.getIsOpen() ?? false));
|
|
17
|
+
onMount(host, () => {
|
|
18
|
+
host.role = "dialog";
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
const InlinePopoverPopupElementBase = defineCustomElement(setupInlinePopoverPopup, InlinePopoverPopupPropsDeclaration);
|
|
22
|
+
/**
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
var InlinePopoverPopupElement = class extends InlinePopoverPopupElementBase {};
|
|
26
|
+
/** @internal */
|
|
27
|
+
function registerInlinePopoverPopupElement() {
|
|
28
|
+
registerCustomElement("prosekit-inline-popover-popup", InlinePopoverPopupElement);
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/components/inline-popover/inline-popover-positioner.ts
|
|
32
|
+
/** @internal */
|
|
33
|
+
const InlinePopoverPositionerPropsDeclaration = /* @__PURE__ */ defineProps({
|
|
34
|
+
...OverlayPositionerPropsDeclaration,
|
|
35
|
+
placement: {
|
|
36
|
+
default: "top",
|
|
37
|
+
attribute: "placement",
|
|
38
|
+
type: "string"
|
|
39
|
+
},
|
|
40
|
+
offset: {
|
|
41
|
+
default: 12,
|
|
42
|
+
attribute: false,
|
|
43
|
+
type: "json"
|
|
44
|
+
},
|
|
45
|
+
hide: {
|
|
46
|
+
default: true,
|
|
47
|
+
attribute: "hide",
|
|
48
|
+
type: "boolean"
|
|
49
|
+
},
|
|
50
|
+
overlap: {
|
|
51
|
+
default: true,
|
|
52
|
+
attribute: "overlap",
|
|
53
|
+
type: "boolean"
|
|
54
|
+
},
|
|
55
|
+
inline: {
|
|
56
|
+
default: true,
|
|
57
|
+
attribute: "inline",
|
|
58
|
+
type: "boolean"
|
|
59
|
+
},
|
|
60
|
+
overflowPadding: {
|
|
61
|
+
default: 8,
|
|
62
|
+
attribute: "overflow-padding",
|
|
63
|
+
type: "number"
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
/** @internal */
|
|
67
|
+
function setupInlinePopoverPositioner(host, props) {
|
|
68
|
+
setupOverlayPositioner(host, props, InlinePopoverStoreContext.consume(host));
|
|
69
|
+
}
|
|
70
|
+
const InlinePopoverPositionerElementBase = defineCustomElement(setupInlinePopoverPositioner, InlinePopoverPositionerPropsDeclaration);
|
|
71
|
+
/**
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
var InlinePopoverPositionerElement = class extends InlinePopoverPositionerElementBase {};
|
|
75
|
+
/** @internal */
|
|
76
|
+
function registerInlinePopoverPositionerElement() {
|
|
77
|
+
registerCustomElement("prosekit-inline-popover-positioner", InlinePopoverPositionerElement);
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
7
80
|
//#region src/hooks/use-editor-focus-event.ts
|
|
8
81
|
/**
|
|
9
82
|
* @internal
|
|
10
83
|
*/
|
|
11
|
-
function useEditorFocusChangeEvent(host,
|
|
12
|
-
useEditorExtension(host,
|
|
84
|
+
function useEditorFocusChangeEvent(host, getEditor, handler) {
|
|
85
|
+
useEditorExtension(host, getEditor, defineFocusChangeHandler(handler));
|
|
13
86
|
}
|
|
14
87
|
//#endregion
|
|
15
88
|
//#region src/hooks/use-editor-update-event.ts
|
|
16
89
|
/**
|
|
17
90
|
* @internal
|
|
18
91
|
*/
|
|
19
|
-
function useEditorUpdateEvent(host,
|
|
20
|
-
useEditorExtension(host,
|
|
92
|
+
function useEditorUpdateEvent(host, getEditor, handler) {
|
|
93
|
+
useEditorExtension(host, getEditor, defineUpdateHandler(handler));
|
|
21
94
|
}
|
|
22
95
|
//#endregion
|
|
23
96
|
//#region src/hooks/use-keymap.ts
|
|
24
|
-
function useKeymap(host,
|
|
25
|
-
useEditorExtension(host,
|
|
97
|
+
function useKeymap(host, getEditor, keymap) {
|
|
98
|
+
useEditorExtension(host, getEditor, defineKeymap(keymap));
|
|
26
99
|
}
|
|
27
100
|
//#endregion
|
|
28
|
-
//#region src/components/inline-popover/
|
|
101
|
+
//#region src/components/inline-popover/virtual-selection-element.ts
|
|
29
102
|
function getVirtualSelectionElement(view) {
|
|
30
103
|
if (typeof window === "undefined" || view.isDestroyed) return;
|
|
31
104
|
const selection = view.state.selection;
|
|
@@ -58,84 +131,61 @@ function getInlineDecoration(view) {
|
|
|
58
131
|
};
|
|
59
132
|
}
|
|
60
133
|
//#endregion
|
|
61
|
-
//#region src/components/inline-popover/inline-popover
|
|
62
|
-
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return true;
|
|
86
|
-
} });
|
|
87
|
-
useOverlayPositionerState(host, overlayState, { reference });
|
|
88
|
-
useAttribute(host, "data-state", () => open.get() ? "open" : "closed");
|
|
89
|
-
usePresence(host, open);
|
|
90
|
-
}
|
|
91
|
-
function useInlinePopoverReference(host, editor) {
|
|
92
|
-
const reference = createSignal(null);
|
|
134
|
+
//#region src/components/inline-popover/inline-popover-root.ts
|
|
135
|
+
/** @internal */
|
|
136
|
+
const InlinePopoverRootPropsDeclaration = /* @__PURE__ */ defineProps({
|
|
137
|
+
...OverlayRootPropsDeclaration,
|
|
138
|
+
editor: {
|
|
139
|
+
default: null,
|
|
140
|
+
attribute: false,
|
|
141
|
+
type: "json"
|
|
142
|
+
},
|
|
143
|
+
defaultOpen: {
|
|
144
|
+
default: true,
|
|
145
|
+
attribute: "default-open",
|
|
146
|
+
type: "boolean"
|
|
147
|
+
},
|
|
148
|
+
dismissOnEscape: {
|
|
149
|
+
default: true,
|
|
150
|
+
attribute: "dismiss-on-escape",
|
|
151
|
+
type: "boolean"
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
/** @internal */
|
|
155
|
+
function setupInlinePopoverRoot(host, props) {
|
|
156
|
+
const store = useOverlayStore(host, props);
|
|
157
|
+
InlinePopoverStoreContext.provide(host, store);
|
|
93
158
|
let editorFocused = false;
|
|
94
|
-
useEditorFocusChangeEvent(host, editor, (focus) => {
|
|
159
|
+
useEditorFocusChangeEvent(host, props.editor.get, (focus) => {
|
|
95
160
|
editorFocused = focus;
|
|
96
161
|
});
|
|
97
162
|
let prevSelection;
|
|
98
|
-
useEditorUpdateEvent(host, editor, (view) => {
|
|
163
|
+
useEditorUpdateEvent(host, props.editor.get, (view) => {
|
|
99
164
|
if (!editorFocused && host.contains(host.ownerDocument.activeElement)) return;
|
|
100
165
|
const { selection } = view.state;
|
|
101
|
-
|
|
166
|
+
if (prevSelection?.eq(selection)) return;
|
|
102
167
|
prevSelection = selection;
|
|
103
|
-
|
|
104
|
-
|
|
168
|
+
const reference = getVirtualSelectionElement(view);
|
|
169
|
+
store.setAnchorElement(reference);
|
|
170
|
+
if (reference && props.defaultOpen.get()) store.requestOpenChange(true);
|
|
171
|
+
else if (!reference) store.requestOpenChange(false);
|
|
105
172
|
});
|
|
106
|
-
|
|
173
|
+
useKeymap(host, props.editor.get, { Escape: () => {
|
|
174
|
+
if (!props.dismissOnEscape.get() || !store.getIsOpen()) return false;
|
|
175
|
+
store.requestOpenChange(false);
|
|
176
|
+
return true;
|
|
177
|
+
} });
|
|
107
178
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
editor: { default: null },
|
|
114
|
-
defaultOpen: { default: true },
|
|
115
|
-
open: { default: false },
|
|
116
|
-
dismissOnEscape: { default: true },
|
|
117
|
-
placement: { default: "top" },
|
|
118
|
-
offset: { default: 12 },
|
|
119
|
-
hide: { default: true },
|
|
120
|
-
overlap: { default: true },
|
|
121
|
-
inline: { default: true },
|
|
122
|
-
overflowPadding: { default: 8 }
|
|
123
|
-
});
|
|
179
|
+
const InlinePopoverRootElementBase = defineCustomElement(setupInlinePopoverRoot, InlinePopoverRootPropsDeclaration);
|
|
180
|
+
/**
|
|
181
|
+
* @public
|
|
182
|
+
*/
|
|
183
|
+
var InlinePopoverRootElement = class extends InlinePopoverRootElementBase {};
|
|
124
184
|
/** @internal */
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
};
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region src/components/inline-popover/inline-popover/element.gen.ts
|
|
131
|
-
const InlinePopoverElementBase = defineCustomElement({
|
|
132
|
-
props: inlinePopoverProps,
|
|
133
|
-
events: inlinePopoverEvents,
|
|
134
|
-
setup: useInlinePopover
|
|
135
|
-
});
|
|
136
|
-
var InlinePopoverElement = class extends InlinePopoverElementBase {};
|
|
137
|
-
registerCustomElement("prosekit-inline-popover", InlinePopoverElement);
|
|
185
|
+
function registerInlinePopoverRootElement() {
|
|
186
|
+
registerCustomElement("prosekit-inline-popover-root", InlinePopoverRootElement);
|
|
187
|
+
}
|
|
138
188
|
//#endregion
|
|
139
|
-
export {
|
|
189
|
+
export { InlinePopoverPopupElement, InlinePopoverPopupPropsDeclaration, InlinePopoverPositionerElement, InlinePopoverPositionerPropsDeclaration, InlinePopoverRootElement, InlinePopoverRootPropsDeclaration, OpenChangeEvent, registerInlinePopoverPopupElement, registerInlinePopoverPositionerElement, registerInlinePopoverRootElement, setupInlinePopoverPopup, setupInlinePopoverPositioner, setupInlinePopoverRoot };
|
|
140
190
|
|
|
141
191
|
//# sourceMappingURL=prosekit-web-inline-popover.js.map
|