@prosekit/web 0.3.4 → 0.3.6
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.
|
@@ -22,7 +22,6 @@ import { PopoverTriggerProps } from '@aria-ui/popover';
|
|
|
22
22
|
import type { ProseMirrorNode } from '@prosekit/pm/model';
|
|
23
23
|
import { ReadonlySignal } from '@aria-ui/core';
|
|
24
24
|
import type { ReferenceElement } from '@floating-ui/dom';
|
|
25
|
-
import type { Selection as Selection_2 } from '@prosekit/pm/state';
|
|
26
25
|
import { SignalState } from '@aria-ui/core';
|
|
27
26
|
import type { TooltipContentProps } from '@aria-ui/tooltip';
|
|
28
27
|
import { TooltipRootProps } from '@aria-ui/tooltip';
|
|
@@ -414,7 +413,7 @@ Commands: never;
|
|
|
414
413
|
|
|
415
414
|
export declare type ElementHoverHandler = (reference: VirtualElement | null, element: HTMLElement | null, node: ProseMirrorNode | null, pos: number | null) => void;
|
|
416
415
|
|
|
417
|
-
export declare function getVirtualSelectionElement(view: EditorView): ReferenceElement |
|
|
416
|
+
export declare function getVirtualSelectionElement(view: EditorView): ReferenceElement | undefined;
|
|
418
417
|
|
|
419
418
|
declare class InlinePopoverElement extends InlinePopoverElement_base {
|
|
420
419
|
}
|
|
@@ -503,8 +502,6 @@ export { InlinePopoverProps as InlinePopoverProps_alias_1 }
|
|
|
503
502
|
|
|
504
503
|
export declare function isFinitePositiveNumber(value: unknown): value is number;
|
|
505
504
|
|
|
506
|
-
export declare function isInCodeBlock(selection: Selection_2): boolean | undefined;
|
|
507
|
-
|
|
508
505
|
export declare function omit<T extends Record<string, unknown>, K extends keyof T>(object: T, keys: K[]): Omit<T, K>;
|
|
509
506
|
|
|
510
507
|
/**
|
|
@@ -64,38 +64,33 @@ function useKeymap(host, editor, keymap) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
// src/components/inline-popover/inline-popover/virtual-selection-element.ts
|
|
67
|
-
import {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return type.spec.code && type.isBlock;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// src/components/inline-popover/inline-popover/virtual-selection-element.ts
|
|
67
|
+
import {
|
|
68
|
+
containsInlineNode,
|
|
69
|
+
isInCodeBlock,
|
|
70
|
+
isTextSelection
|
|
71
|
+
} from "@prosekit/core";
|
|
76
72
|
function getVirtualSelectionElement(view) {
|
|
77
73
|
if (typeof window === "undefined" || view.isDestroyed) {
|
|
78
|
-
return
|
|
74
|
+
return;
|
|
79
75
|
}
|
|
80
76
|
const selection = view.state.selection;
|
|
81
|
-
if (!selection.empty && !isInCodeBlock(selection) && isTextSelection(selection)) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
77
|
+
if (!selection.empty && !isInCodeBlock(selection) && isTextSelection(selection) && containsInlineNode(view.state.doc, selection.from, selection.to)) {
|
|
78
|
+
return getDomDecoration(view) || getInlineDecoration(view);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function getDomDecoration(view) {
|
|
82
|
+
const range = getDomRange(view);
|
|
83
|
+
if (range) {
|
|
84
|
+
return {
|
|
85
|
+
contextElement: view.dom,
|
|
86
|
+
getBoundingClientRect: () => range.getBoundingClientRect(),
|
|
87
|
+
getClientRects: () => range.getClientRects()
|
|
88
|
+
};
|
|
94
89
|
}
|
|
95
|
-
return null;
|
|
96
90
|
}
|
|
97
|
-
function getDomRange() {
|
|
98
|
-
const
|
|
91
|
+
function getDomRange(view) {
|
|
92
|
+
const win = view.dom.ownerDocument.defaultView;
|
|
93
|
+
const selection = win == null ? void 0 : win.getSelection();
|
|
99
94
|
if (!selection || selection.isCollapsed) {
|
|
100
95
|
return;
|
|
101
96
|
}
|
|
@@ -170,7 +165,7 @@ function useInlinePopoverReference(host, editor) {
|
|
|
170
165
|
if (isPopoverFocused) {
|
|
171
166
|
return;
|
|
172
167
|
}
|
|
173
|
-
reference.set(getVirtualSelectionElement(view));
|
|
168
|
+
reference.set(getVirtualSelectionElement(view) || null);
|
|
174
169
|
});
|
|
175
170
|
return reference;
|
|
176
171
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosekit/web",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.6",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "ocavue",
|
|
@@ -72,16 +72,16 @@
|
|
|
72
72
|
"@aria-ui/popover": "^0.0.19",
|
|
73
73
|
"@aria-ui/presence": "^0.0.13",
|
|
74
74
|
"@aria-ui/tooltip": "^0.0.21",
|
|
75
|
-
"@floating-ui/dom": "^1.6.
|
|
76
|
-
"@zag-js/dom-query": "^0.
|
|
77
|
-
"@prosekit/core": "^0.7.
|
|
78
|
-
"@prosekit/
|
|
79
|
-
"@prosekit/
|
|
75
|
+
"@floating-ui/dom": "^1.6.8",
|
|
76
|
+
"@zag-js/dom-query": "^0.62.0",
|
|
77
|
+
"@prosekit/core": "^0.7.5",
|
|
78
|
+
"@prosekit/pm": "^0.1.7",
|
|
79
|
+
"@prosekit/extensions": "^0.7.6"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"tsup": "^8.
|
|
82
|
+
"tsup": "^8.2.2",
|
|
83
83
|
"typescript": "^5.5.3",
|
|
84
|
-
"vitest": "^2.0.
|
|
84
|
+
"vitest": "^2.0.4",
|
|
85
85
|
"@prosekit/dev": "0.0.0"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|