@prosekit/web 0.8.0-beta.6 → 0.8.0
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/autocomplete.d.ts +9 -2
- package/dist/autocomplete.d.ts.map +1 -1
- package/dist/autocomplete.js +14 -11
- package/dist/autocomplete.js.map +1 -1
- package/dist/block-handle.d.ts.map +1 -1
- package/dist/block-handle.js +16 -10
- package/dist/block-handle.js.map +1 -1
- package/dist/drop-indicator.js.map +1 -1
- package/dist/inline-popover.js +4 -11
- package/dist/inline-popover.js.map +1 -1
- package/dist/table-handle.js +11 -22
- package/dist/table-handle.js.map +1 -1
- package/dist/use-editor-update-event.js +11 -0
- package/dist/use-editor-update-event.js.map +1 -0
- package/package.json +11 -11
- package/src/components/autocomplete/autocomplete-positioner.ts +13 -4
- package/src/components/autocomplete/autocomplete-root.ts +3 -3
- package/src/components/block-handle/block-handle-add.ts +1 -1
- package/src/components/block-handle/block-handle-draggable.ts +1 -1
- package/src/components/block-handle/block-handle-positioner.ts +1 -1
- package/src/components/block-handle/block-handle-root.ts +5 -2
- package/src/components/block-handle/use-has-text-selection.ts +13 -0
- package/src/components/inline-popover/inline-popover-positioner.ts +1 -1
- package/src/components/inline-popover/inline-popover-root.ts +1 -1
- package/src/components/table-handle/shared.ts +6 -6
- package/src/components/table-handle/table-handle-column-menu-trigger.ts +1 -1
- package/src/components/table-handle/table-handle-drag-preview.ts +1 -1
- package/src/components/table-handle/table-handle-drop-indicator.ts +1 -1
- package/src/components/table-handle/table-handle-root.ts +1 -1
- package/src/components/table-handle/table-handle-row-menu-trigger.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosekit/web",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.8.0
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "A collection of web components for ProseKit",
|
|
7
7
|
"author": {
|
|
@@ -73,24 +73,24 @@
|
|
|
73
73
|
],
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@aria-ui/core": "^0.2.0",
|
|
76
|
-
"@aria-ui/elements": "^0.1.
|
|
76
|
+
"@aria-ui/elements": "^0.1.9",
|
|
77
77
|
"@aria-ui/utils": "^0.1.5",
|
|
78
78
|
"@floating-ui/dom": "^1.7.6",
|
|
79
79
|
"@ocavue/utils": "^1.6.0",
|
|
80
80
|
"prosemirror-tables": "^1.8.5",
|
|
81
|
-
"@prosekit/core": "^0.12.0
|
|
82
|
-
"@prosekit/extensions": "^0.16.0
|
|
83
|
-
"@prosekit/pm": "^0.1.16
|
|
81
|
+
"@prosekit/core": "^0.12.0",
|
|
82
|
+
"@prosekit/extensions": "^0.16.0",
|
|
83
|
+
"@prosekit/pm": "^0.1.16"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@aria-ui/cli": "^0.1.
|
|
87
|
-
"tsdown": "^0.21.
|
|
88
|
-
"type-fest": "^5.
|
|
86
|
+
"@aria-ui/cli": "^0.1.8",
|
|
87
|
+
"tsdown": "^0.21.10",
|
|
88
|
+
"type-fest": "^5.6.0",
|
|
89
89
|
"typescript": "~5.9.3",
|
|
90
|
-
"vitest": "^4.1.
|
|
91
|
-
"@prosekit/config-
|
|
90
|
+
"vitest": "^4.1.5",
|
|
91
|
+
"@prosekit/config-ts": "0.0.0",
|
|
92
92
|
"@prosekit/config-vitest": "0.0.0",
|
|
93
|
-
"@prosekit/config-
|
|
93
|
+
"@prosekit/config-tsdown": "0.0.0"
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
96
96
|
"build:tsc": "tsc -b tsconfig.json",
|
|
@@ -26,12 +26,20 @@ export interface AutocompletePositionerProps extends OverlayPositionerProps {
|
|
|
26
26
|
placement: OverlayPositionerProps['placement']
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* The distance between the popover and the
|
|
29
|
+
* The distance between the popover and the text selection.
|
|
30
30
|
*
|
|
31
|
-
* @default 4
|
|
31
|
+
* @default { mainAxis: 8, crossAxis: -4 }
|
|
32
32
|
*/
|
|
33
33
|
offset: OverlayPositionerProps['offset']
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Whether to hide the floating element when the reference element or the
|
|
37
|
+
* floating element is fully clipped.
|
|
38
|
+
*
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
hide: OverlayPositionerProps['hide']
|
|
42
|
+
|
|
35
43
|
/**
|
|
36
44
|
* @default true
|
|
37
45
|
*/
|
|
@@ -64,11 +72,12 @@ export const AutocompletePositionerPropsDeclaration: PropsDeclaration<Autocomple
|
|
|
64
72
|
>({
|
|
65
73
|
...OverlayPositionerPropsDeclaration,
|
|
66
74
|
placement: { default: 'bottom-start', attribute: 'placement', type: 'string' },
|
|
67
|
-
offset: { default:
|
|
75
|
+
offset: { default: { mainAxis: 8, crossAxis: -4 }, attribute: false },
|
|
76
|
+
hide: { default: true, attribute: 'hide', type: 'boolean' },
|
|
68
77
|
inline: { default: true, attribute: 'inline', type: 'boolean' },
|
|
69
78
|
hoist: { default: true, attribute: 'hoist', type: 'boolean' },
|
|
70
79
|
fitViewport: { default: true, attribute: 'fit-viewport', type: 'boolean' },
|
|
71
|
-
boundary: { default: defaultBoundary, attribute: false
|
|
80
|
+
boundary: { default: defaultBoundary, attribute: false },
|
|
72
81
|
overflowPadding: { default: 8, attribute: 'overflow-padding', type: 'number' },
|
|
73
82
|
})
|
|
74
83
|
|
|
@@ -54,9 +54,9 @@ export interface AutocompleteRootProps {
|
|
|
54
54
|
export const AutocompleteRootPropsDeclaration: PropsDeclaration<AutocompleteRootProps> = /* @__PURE__ */ defineProps<
|
|
55
55
|
AutocompleteRootProps
|
|
56
56
|
>({
|
|
57
|
-
editor: { default: null, attribute: false
|
|
58
|
-
regex: { default: null, attribute: false
|
|
59
|
-
filter: { default: defaultItemFilter, attribute: false
|
|
57
|
+
editor: { default: null, attribute: false },
|
|
58
|
+
regex: { default: null, attribute: false },
|
|
59
|
+
filter: { default: defaultItemFilter, attribute: false },
|
|
60
60
|
})
|
|
61
61
|
|
|
62
62
|
/**
|
|
@@ -24,7 +24,7 @@ export interface BlockHandleAddProps {
|
|
|
24
24
|
|
|
25
25
|
/** @internal */
|
|
26
26
|
export const BlockHandleAddPropsDeclaration: PropsDeclaration<BlockHandleAddProps> = /* @__PURE__ */ defineProps<BlockHandleAddProps>({
|
|
27
|
-
editor: { default: null, attribute: false
|
|
27
|
+
editor: { default: null, attribute: false },
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -37,7 +37,7 @@ export interface BlockHandleDraggableProps {
|
|
|
37
37
|
export const BlockHandleDraggablePropsDeclaration: PropsDeclaration<BlockHandleDraggableProps> = /* @__PURE__ */ defineProps<
|
|
38
38
|
BlockHandleDraggableProps
|
|
39
39
|
>({
|
|
40
|
-
editor: { default: null, attribute: false
|
|
40
|
+
editor: { default: null, attribute: false },
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -59,7 +59,7 @@ export const BlockHandlePositionerPropsDeclaration: PropsDeclaration<BlockHandle
|
|
|
59
59
|
// Enabling `hoist` will cause the popover to have a small delay when
|
|
60
60
|
// scrolling the page.
|
|
61
61
|
hoist: { default: false, attribute: 'hoist', type: 'boolean' },
|
|
62
|
-
flip: { default: false, attribute: false
|
|
62
|
+
flip: { default: false, attribute: false },
|
|
63
63
|
shift: { default: false, attribute: 'shift', type: 'boolean' },
|
|
64
64
|
hide: { default: true, attribute: 'hide', type: 'boolean' },
|
|
65
65
|
})
|
|
@@ -18,6 +18,7 @@ import type { ProseMirrorNode } from '@prosekit/pm/model'
|
|
|
18
18
|
import { useScrolling } from '../../hooks/use-scrolling.ts'
|
|
19
19
|
|
|
20
20
|
import { blockHandleOverlayStoreContext, BlockHandleStore, blockHandleStoreContext } from './context.ts'
|
|
21
|
+
import { useHasTextSelection } from './use-has-text-selection.ts'
|
|
21
22
|
import { useHoverExtension } from './use-hover-extension.ts'
|
|
22
23
|
|
|
23
24
|
export interface BlockHandleRootProps {
|
|
@@ -34,7 +35,7 @@ export interface BlockHandleRootProps {
|
|
|
34
35
|
export const BlockHandleRootPropsDeclaration: PropsDeclaration<BlockHandleRootProps> = /* @__PURE__ */ defineProps<
|
|
35
36
|
BlockHandleRootProps
|
|
36
37
|
>({
|
|
37
|
-
editor: { default: null, attribute: false
|
|
38
|
+
editor: { default: null, attribute: false },
|
|
38
39
|
})
|
|
39
40
|
|
|
40
41
|
/**
|
|
@@ -75,8 +76,10 @@ export function setupBlockHandleRoot(
|
|
|
75
76
|
|
|
76
77
|
const reference = createSignal<VirtualElement | undefined>(undefined)
|
|
77
78
|
const getScrolling = useScrolling(host)
|
|
79
|
+
// Hide the block handle when there is a text selection to avoid the block handle overlapping with inline menu
|
|
80
|
+
const getHasTextSelection = useHasTextSelection(host, getEditor)
|
|
78
81
|
|
|
79
|
-
const getOpen = computed(() => !!store.hoverState.get() && !getScrolling())
|
|
82
|
+
const getOpen = computed(() => !!store.hoverState.get() && !getScrolling() && !getHasTextSelection())
|
|
80
83
|
|
|
81
84
|
const overlayStore = createOverlayStore(
|
|
82
85
|
getOpen,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createSignal, type HostElement } from '@aria-ui/core'
|
|
2
|
+
import { isTextSelection, type Editor } from '@prosekit/core'
|
|
3
|
+
|
|
4
|
+
import { useEditorUpdateEvent } from '../../hooks/use-editor-update-event.ts'
|
|
5
|
+
|
|
6
|
+
export function useHasTextSelection(host: HostElement, getEditor: () => Editor | null): () => boolean {
|
|
7
|
+
const state = createSignal(false)
|
|
8
|
+
useEditorUpdateEvent(host, getEditor, (view) => {
|
|
9
|
+
const { selection } = view.state
|
|
10
|
+
state.set(!selection.empty && isTextSelection(selection))
|
|
11
|
+
})
|
|
12
|
+
return state.get
|
|
13
|
+
}
|
|
@@ -86,7 +86,7 @@ export const InlinePopoverPositionerPropsDeclaration: PropsDeclaration<InlinePop
|
|
|
86
86
|
>({
|
|
87
87
|
...OverlayPositionerPropsDeclaration,
|
|
88
88
|
placement: { default: 'top', attribute: 'placement', type: 'string' },
|
|
89
|
-
offset: { default: 12, attribute: false
|
|
89
|
+
offset: { default: 12, attribute: false },
|
|
90
90
|
hide: { default: true, attribute: 'hide', type: 'boolean' },
|
|
91
91
|
hoist: { default: false, attribute: 'hoist', type: 'boolean' },
|
|
92
92
|
overlap: { default: true, attribute: 'overlap', type: 'boolean' },
|
|
@@ -53,7 +53,7 @@ export const InlinePopoverRootPropsDeclaration: PropsDeclaration<InlinePopoverRo
|
|
|
53
53
|
InlinePopoverRootProps
|
|
54
54
|
>({
|
|
55
55
|
...OverlayRootPropsDeclaration,
|
|
56
|
-
editor: { default: null, attribute: false
|
|
56
|
+
editor: { default: null, attribute: false },
|
|
57
57
|
defaultOpen: { default: true, attribute: 'default-open', type: 'boolean' },
|
|
58
58
|
dismissOnEscape: { default: true, attribute: 'dismiss-on-escape', type: 'boolean' },
|
|
59
59
|
})
|
|
@@ -52,10 +52,10 @@ export const SharedTableHandlePositionerPropsDeclaration: PropsDeclaration<Share
|
|
|
52
52
|
SharedTableHandlePositionerProps
|
|
53
53
|
>({
|
|
54
54
|
...OverlayPositionerPropsDeclaration,
|
|
55
|
-
editor: { default: null, attribute: false
|
|
56
|
-
hoist: { default: false, attribute: false
|
|
57
|
-
flip: { default: false, attribute: false
|
|
58
|
-
shift: { default: false, attribute: false
|
|
59
|
-
hide: { default: true, attribute: false
|
|
60
|
-
offset: { default: 0, attribute: false
|
|
55
|
+
editor: { default: null, attribute: false },
|
|
56
|
+
hoist: { default: false, attribute: false },
|
|
57
|
+
flip: { default: false, attribute: false },
|
|
58
|
+
shift: { default: false, attribute: false },
|
|
59
|
+
hide: { default: true, attribute: false },
|
|
60
|
+
offset: { default: 0, attribute: false },
|
|
61
61
|
})
|
|
@@ -31,7 +31,7 @@ export interface TableHandleColumnMenuTriggerProps {
|
|
|
31
31
|
export const TableHandleColumnMenuTriggerPropsDeclaration: PropsDeclaration<TableHandleColumnMenuTriggerProps> = defineProps<
|
|
32
32
|
TableHandleColumnMenuTriggerProps
|
|
33
33
|
>({
|
|
34
|
-
editor: { default: null, attribute: false
|
|
34
|
+
editor: { default: null, attribute: false },
|
|
35
35
|
})
|
|
36
36
|
|
|
37
37
|
/** @internal */
|
|
@@ -30,7 +30,7 @@ export interface TableHandleDragPreviewProps {
|
|
|
30
30
|
export const TableHandleDragPreviewPropsDeclaration: PropsDeclaration<TableHandleDragPreviewProps> = defineProps<
|
|
31
31
|
TableHandleDragPreviewProps
|
|
32
32
|
>({
|
|
33
|
-
editor: { default: null, attribute: false
|
|
33
|
+
editor: { default: null, attribute: false },
|
|
34
34
|
})
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -35,7 +35,7 @@ export interface TableHandleDropIndicatorProps {
|
|
|
35
35
|
export const TableHandleDropIndicatorPropsDeclaration: PropsDeclaration<TableHandleDropIndicatorProps> = defineProps<
|
|
36
36
|
TableHandleDropIndicatorProps
|
|
37
37
|
>({
|
|
38
|
-
editor: { default: null, attribute: false
|
|
38
|
+
editor: { default: null, attribute: false },
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -33,7 +33,7 @@ export interface TableHandleRootProps {
|
|
|
33
33
|
|
|
34
34
|
/** @internal */
|
|
35
35
|
export const TableHandleRootPropsDeclaration: PropsDeclaration<TableHandleRootProps> = defineProps<TableHandleRootProps>({
|
|
36
|
-
editor: { default: null, attribute: false
|
|
36
|
+
editor: { default: null, attribute: false },
|
|
37
37
|
})
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -31,7 +31,7 @@ export interface TableHandleRowMenuTriggerProps {
|
|
|
31
31
|
export const TableHandleRowMenuTriggerPropsDeclaration: PropsDeclaration<TableHandleRowMenuTriggerProps> = defineProps<
|
|
32
32
|
TableHandleRowMenuTriggerProps
|
|
33
33
|
>({
|
|
34
|
-
editor: { default: null, attribute: false
|
|
34
|
+
editor: { default: null, attribute: false },
|
|
35
35
|
})
|
|
36
36
|
|
|
37
37
|
/** @internal */
|