@prosekit/web 0.8.0-beta.0 → 0.8.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +94 -53
- package/dist/prosekit-web-inline-popover.d.ts.map +1 -1
- package/dist/prosekit-web-inline-popover.js +134 -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 +26 -21
- 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 +118 -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,132 @@
|
|
|
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
|
-
|
|
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 Omit<OverlayPositionerProps, 'placement' | 'offset' | 'hide' | 'hoist' | 'overlap' | 'inline' | 'overflowPadding'> {
|
|
7
27
|
/**
|
|
8
|
-
* The
|
|
28
|
+
* The initial placement of the floating element
|
|
9
29
|
*
|
|
10
|
-
* @default
|
|
11
|
-
* @hidden
|
|
30
|
+
* @default "top"
|
|
12
31
|
*/
|
|
13
|
-
|
|
32
|
+
placement: OverlayPositionerProps['placement'];
|
|
14
33
|
/**
|
|
15
|
-
*
|
|
16
|
-
* selected.
|
|
34
|
+
* The distance between the reference and floating element.
|
|
17
35
|
*
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
36
|
+
* @default 12
|
|
37
|
+
*/
|
|
38
|
+
offset: OverlayPositionerProps['offset'];
|
|
39
|
+
/**
|
|
40
|
+
* Whether to hide the floating element when the reference element or the
|
|
41
|
+
* floating element is fully clipped.
|
|
21
42
|
*
|
|
22
43
|
* @default true
|
|
23
44
|
*/
|
|
24
|
-
|
|
45
|
+
hide: OverlayPositionerProps['hide'];
|
|
25
46
|
/**
|
|
26
|
-
* Whether the
|
|
27
|
-
*
|
|
28
|
-
* Notice that the popover will be always hidden if the inline selection is
|
|
29
|
-
* empty.
|
|
47
|
+
* Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
48
|
+
* to place the floating element on top of other page content.
|
|
30
49
|
*
|
|
31
50
|
* @default false
|
|
32
51
|
*/
|
|
33
|
-
|
|
52
|
+
hoist: boolean;
|
|
34
53
|
/**
|
|
35
|
-
* Whether the
|
|
36
|
-
*
|
|
54
|
+
* Whether the floating element can overlap the reference element to keep it
|
|
55
|
+
* in view.
|
|
37
56
|
*
|
|
38
57
|
* @default true
|
|
39
58
|
*/
|
|
40
|
-
|
|
59
|
+
overlap: OverlayPositionerProps['overlap'];
|
|
41
60
|
/**
|
|
42
|
-
*
|
|
61
|
+
* Whether to improve positioning for inline reference elements that span over
|
|
62
|
+
* multiple lines.
|
|
63
|
+
*
|
|
64
|
+
* @default true
|
|
43
65
|
*/
|
|
44
|
-
|
|
66
|
+
inline: OverlayPositionerProps['inline'];
|
|
45
67
|
/**
|
|
46
|
-
*
|
|
68
|
+
* Describes the virtual padding around the boundary to check for overflow.
|
|
69
|
+
*
|
|
70
|
+
* @default 8
|
|
47
71
|
*/
|
|
48
|
-
|
|
72
|
+
overflowPadding: OverlayPositionerProps['overflowPadding'];
|
|
73
|
+
}
|
|
74
|
+
/** @internal */
|
|
75
|
+
declare const InlinePopoverPositionerPropsDeclaration: PropsDeclaration<InlinePopoverPositionerProps>;
|
|
76
|
+
/** @internal */
|
|
77
|
+
declare function setupInlinePopoverPositioner(host: HostElement, props: State<InlinePopoverPositionerProps>): void;
|
|
78
|
+
declare const InlinePopoverPositionerElementBase: HostElementConstructor<InlinePopoverPositionerProps>;
|
|
79
|
+
/**
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
declare class InlinePopoverPositionerElement extends InlinePopoverPositionerElementBase {}
|
|
83
|
+
/** @internal */
|
|
84
|
+
declare function registerInlinePopoverPositionerElement(): void;
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/components/inline-popover/inline-popover-root.d.ts
|
|
87
|
+
/**
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
interface InlinePopoverRootProps extends OverlayRootProps {
|
|
49
91
|
/**
|
|
50
|
-
*
|
|
92
|
+
* The ProseKit editor instance.
|
|
93
|
+
*
|
|
94
|
+
* @default null
|
|
95
|
+
* @hidden
|
|
51
96
|
*/
|
|
52
|
-
|
|
97
|
+
editor: Editor | null;
|
|
53
98
|
/**
|
|
99
|
+
* Whether the popover is open by default when some inline content is
|
|
100
|
+
* selected.
|
|
101
|
+
*
|
|
54
102
|
* @default true
|
|
55
103
|
*/
|
|
56
|
-
|
|
104
|
+
defaultOpen: boolean;
|
|
57
105
|
/**
|
|
106
|
+
* Whether the inline popover should be dismissed when the editor receives an
|
|
107
|
+
* Escape key press.
|
|
108
|
+
*
|
|
58
109
|
* @default true
|
|
59
110
|
*/
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @default 8
|
|
63
|
-
*/
|
|
64
|
-
overflowPadding: OverlayPositionerProps['overflowPadding'];
|
|
111
|
+
dismissOnEscape: boolean;
|
|
65
112
|
}
|
|
66
113
|
/** @internal */
|
|
67
|
-
declare const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
openChange:
|
|
114
|
+
declare const InlinePopoverRootPropsDeclaration: PropsDeclaration<InlinePopoverRootProps>;
|
|
115
|
+
/**
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
interface InlinePopoverRootEvents {
|
|
119
|
+
openChange: OpenChangeEvent$1;
|
|
73
120
|
}
|
|
74
121
|
/** @internal */
|
|
75
|
-
declare
|
|
76
|
-
|
|
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
|
|
122
|
+
declare function setupInlinePopoverRoot(host: HostElement, props: State<InlinePopoverRootProps>): void;
|
|
123
|
+
declare const InlinePopoverRootElementBase: HostElementConstructor<InlinePopoverRootProps>;
|
|
82
124
|
/**
|
|
83
|
-
* @
|
|
125
|
+
* @public
|
|
84
126
|
*/
|
|
85
|
-
declare
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}: SetupOptions<InlinePopoverProps, InlinePopoverEvents>): void;
|
|
127
|
+
declare class InlinePopoverRootElement extends InlinePopoverRootElementBase {}
|
|
128
|
+
/** @internal */
|
|
129
|
+
declare function registerInlinePopoverRootElement(): void;
|
|
89
130
|
//#endregion
|
|
90
|
-
export {
|
|
131
|
+
export { InlinePopoverPopupElement, type InlinePopoverPopupProps, InlinePopoverPopupPropsDeclaration, InlinePopoverPositionerElement, type InlinePopoverPositionerProps, InlinePopoverPositionerPropsDeclaration, InlinePopoverRootElement, type InlinePopoverRootEvents, type InlinePopoverRootProps, InlinePopoverRootPropsDeclaration, OpenChangeEvent, registerInlinePopoverPopupElement, registerInlinePopoverPositionerElement, registerInlinePopoverRootElement, setupInlinePopoverPopup, setupInlinePopoverPositioner, setupInlinePopoverRoot };
|
|
91
132
|
//# 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,SACf,IAAA,CACE,sBAAA;EDAqC;;;;AAGzC;ECYE,SAAA,EAAW,sBAAA;;;;ADTb;;ECgBE,MAAA,EAAQ,sBAAA;EDfF;;;;;;ECuBN,IAAA,EAAM,sBAAA;EDtBE;;;;;AAUT;ECoBC,KAAA;;;;ADVF;;;ECkBE,OAAA,EAAS,sBAAA;EDlBiE;AAG5E;;;;;ECuBE,MAAA,EAAQ,sBAAA;;;AAxDV;;;EA+DE,eAAA,EAAiB,sBAAA;AAAA;;cAIN,uCAAA,EAAyC,gBAAA,CAAiB,4BAAA;;iBAcvD,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;;;;ADjGhB;;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,109 @@
|
|
|
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
|
+
hoist: {
|
|
51
|
+
default: false,
|
|
52
|
+
attribute: "hoist",
|
|
53
|
+
type: "boolean"
|
|
54
|
+
},
|
|
55
|
+
overlap: {
|
|
56
|
+
default: true,
|
|
57
|
+
attribute: "overlap",
|
|
58
|
+
type: "boolean"
|
|
59
|
+
},
|
|
60
|
+
inline: {
|
|
61
|
+
default: true,
|
|
62
|
+
attribute: "inline",
|
|
63
|
+
type: "boolean"
|
|
64
|
+
},
|
|
65
|
+
overflowPadding: {
|
|
66
|
+
default: 8,
|
|
67
|
+
attribute: "overflow-padding",
|
|
68
|
+
type: "number"
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
/** @internal */
|
|
72
|
+
function setupInlinePopoverPositioner(host, props) {
|
|
73
|
+
setupOverlayPositioner(host, props, InlinePopoverStoreContext.consume(host));
|
|
74
|
+
}
|
|
75
|
+
const InlinePopoverPositionerElementBase = defineCustomElement(setupInlinePopoverPositioner, InlinePopoverPositionerPropsDeclaration);
|
|
76
|
+
/**
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
var InlinePopoverPositionerElement = class extends InlinePopoverPositionerElementBase {};
|
|
80
|
+
/** @internal */
|
|
81
|
+
function registerInlinePopoverPositionerElement() {
|
|
82
|
+
registerCustomElement("prosekit-inline-popover-positioner", InlinePopoverPositionerElement);
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
7
85
|
//#region src/hooks/use-editor-focus-event.ts
|
|
8
86
|
/**
|
|
9
87
|
* @internal
|
|
10
88
|
*/
|
|
11
|
-
function useEditorFocusChangeEvent(host,
|
|
12
|
-
useEditorExtension(host,
|
|
89
|
+
function useEditorFocusChangeEvent(host, getEditor, handler) {
|
|
90
|
+
useEditorExtension(host, getEditor, defineFocusChangeHandler(handler));
|
|
13
91
|
}
|
|
14
92
|
//#endregion
|
|
15
93
|
//#region src/hooks/use-editor-update-event.ts
|
|
16
94
|
/**
|
|
17
95
|
* @internal
|
|
18
96
|
*/
|
|
19
|
-
function useEditorUpdateEvent(host,
|
|
20
|
-
useEditorExtension(host,
|
|
97
|
+
function useEditorUpdateEvent(host, getEditor, handler) {
|
|
98
|
+
useEditorExtension(host, getEditor, defineUpdateHandler(handler));
|
|
21
99
|
}
|
|
22
100
|
//#endregion
|
|
23
101
|
//#region src/hooks/use-keymap.ts
|
|
24
|
-
function useKeymap(host,
|
|
25
|
-
useEditorExtension(host,
|
|
102
|
+
function useKeymap(host, getEditor, keymap) {
|
|
103
|
+
useEditorExtension(host, getEditor, defineKeymap(keymap));
|
|
26
104
|
}
|
|
27
105
|
//#endregion
|
|
28
|
-
//#region src/components/inline-popover/
|
|
106
|
+
//#region src/components/inline-popover/virtual-selection-element.ts
|
|
29
107
|
function getVirtualSelectionElement(view) {
|
|
30
108
|
if (typeof window === "undefined" || view.isDestroyed) return;
|
|
31
109
|
const selection = view.state.selection;
|
|
@@ -58,84 +136,61 @@ function getInlineDecoration(view) {
|
|
|
58
136
|
};
|
|
59
137
|
}
|
|
60
138
|
//#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);
|
|
139
|
+
//#region src/components/inline-popover/inline-popover-root.ts
|
|
140
|
+
/** @internal */
|
|
141
|
+
const InlinePopoverRootPropsDeclaration = /* @__PURE__ */ defineProps({
|
|
142
|
+
...OverlayRootPropsDeclaration,
|
|
143
|
+
editor: {
|
|
144
|
+
default: null,
|
|
145
|
+
attribute: false,
|
|
146
|
+
type: "json"
|
|
147
|
+
},
|
|
148
|
+
defaultOpen: {
|
|
149
|
+
default: true,
|
|
150
|
+
attribute: "default-open",
|
|
151
|
+
type: "boolean"
|
|
152
|
+
},
|
|
153
|
+
dismissOnEscape: {
|
|
154
|
+
default: true,
|
|
155
|
+
attribute: "dismiss-on-escape",
|
|
156
|
+
type: "boolean"
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
/** @internal */
|
|
160
|
+
function setupInlinePopoverRoot(host, props) {
|
|
161
|
+
const store = useOverlayStore(host, props);
|
|
162
|
+
InlinePopoverStoreContext.provide(host, store);
|
|
93
163
|
let editorFocused = false;
|
|
94
|
-
useEditorFocusChangeEvent(host, editor, (focus) => {
|
|
164
|
+
useEditorFocusChangeEvent(host, props.editor.get, (focus) => {
|
|
95
165
|
editorFocused = focus;
|
|
96
166
|
});
|
|
97
167
|
let prevSelection;
|
|
98
|
-
useEditorUpdateEvent(host, editor, (view) => {
|
|
168
|
+
useEditorUpdateEvent(host, props.editor.get, (view) => {
|
|
99
169
|
if (!editorFocused && host.contains(host.ownerDocument.activeElement)) return;
|
|
100
170
|
const { selection } = view.state;
|
|
101
|
-
|
|
171
|
+
if (prevSelection?.eq(selection)) return;
|
|
102
172
|
prevSelection = selection;
|
|
103
|
-
|
|
104
|
-
|
|
173
|
+
const reference = getVirtualSelectionElement(view);
|
|
174
|
+
store.setAnchorElement(reference);
|
|
175
|
+
if (reference && props.defaultOpen.get()) store.requestOpenChange(true);
|
|
176
|
+
else if (!reference) store.requestOpenChange(false);
|
|
105
177
|
});
|
|
106
|
-
|
|
178
|
+
useKeymap(host, props.editor.get, { Escape: () => {
|
|
179
|
+
if (!props.dismissOnEscape.get() || !store.getIsOpen()) return false;
|
|
180
|
+
store.requestOpenChange(false);
|
|
181
|
+
return true;
|
|
182
|
+
} });
|
|
107
183
|
}
|
|
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
|
-
});
|
|
184
|
+
const InlinePopoverRootElementBase = defineCustomElement(setupInlinePopoverRoot, InlinePopoverRootPropsDeclaration);
|
|
185
|
+
/**
|
|
186
|
+
* @public
|
|
187
|
+
*/
|
|
188
|
+
var InlinePopoverRootElement = class extends InlinePopoverRootElementBase {};
|
|
124
189
|
/** @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);
|
|
190
|
+
function registerInlinePopoverRootElement() {
|
|
191
|
+
registerCustomElement("prosekit-inline-popover-root", InlinePopoverRootElement);
|
|
192
|
+
}
|
|
138
193
|
//#endregion
|
|
139
|
-
export {
|
|
194
|
+
export { InlinePopoverPopupElement, InlinePopoverPopupPropsDeclaration, InlinePopoverPositionerElement, InlinePopoverPositionerPropsDeclaration, InlinePopoverRootElement, InlinePopoverRootPropsDeclaration, OpenChangeEvent, registerInlinePopoverPopupElement, registerInlinePopoverPositionerElement, registerInlinePopoverRootElement, setupInlinePopoverPopup, setupInlinePopoverPositioner, setupInlinePopoverRoot };
|
|
140
195
|
|
|
141
196
|
//# sourceMappingURL=prosekit-web-inline-popover.js.map
|