@prosekit/web 0.8.0-beta.5 → 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.
Files changed (78) hide show
  1. package/dist/{prosekit-web-autocomplete.d.ts → autocomplete.d.ts} +10 -3
  2. package/dist/autocomplete.d.ts.map +1 -0
  3. package/dist/{prosekit-web-autocomplete.js → autocomplete.js} +15 -12
  4. package/dist/autocomplete.js.map +1 -0
  5. package/dist/{prosekit-web-block-handle.d.ts → block-handle.d.ts} +1 -1
  6. package/dist/block-handle.d.ts.map +1 -0
  7. package/dist/{prosekit-web-block-handle.js → block-handle.js} +17 -11
  8. package/dist/block-handle.js.map +1 -0
  9. package/dist/{prosekit-web-drop-indicator.d.ts → drop-indicator.d.ts} +1 -1
  10. package/dist/drop-indicator.d.ts.map +1 -0
  11. package/dist/{prosekit-web-drop-indicator.js → drop-indicator.js} +1 -1
  12. package/dist/drop-indicator.js.map +1 -0
  13. package/dist/{prosekit-web.d.ts → index.d.ts} +1 -1
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/{prosekit-web.js → index.js} +1 -1
  16. package/dist/index.js.map +1 -0
  17. package/dist/{prosekit-web-inline-popover.d.ts → inline-popover.d.ts} +1 -1
  18. package/dist/inline-popover.d.ts.map +1 -0
  19. package/dist/{prosekit-web-inline-popover.js → inline-popover.js} +5 -12
  20. package/dist/inline-popover.js.map +1 -0
  21. package/dist/{prosekit-web-menu.d.ts → menu.d.ts} +1 -1
  22. package/dist/menu.d.ts.map +1 -0
  23. package/dist/{prosekit-web-menu.js → menu.js} +1 -1
  24. package/dist/menu.js.map +1 -0
  25. package/dist/{prosekit-web-popover.d.ts → popover.d.ts} +1 -1
  26. package/dist/popover.d.ts.map +1 -0
  27. package/dist/{prosekit-web-popover.js → popover.js} +1 -1
  28. package/dist/popover.js.map +1 -0
  29. package/dist/{prosekit-web-resizable.d.ts → resizable.d.ts} +1 -1
  30. package/dist/resizable.d.ts.map +1 -0
  31. package/dist/{prosekit-web-resizable.js → resizable.js} +1 -1
  32. package/dist/resizable.js.map +1 -0
  33. package/dist/{prosekit-web-table-handle.d.ts → table-handle.d.ts} +1 -1
  34. package/dist/table-handle.d.ts.map +1 -0
  35. package/dist/{prosekit-web-table-handle.js → table-handle.js} +12 -23
  36. package/dist/table-handle.js.map +1 -0
  37. package/dist/{prosekit-web-tooltip.d.ts → tooltip.d.ts} +1 -1
  38. package/dist/tooltip.d.ts.map +1 -0
  39. package/dist/{prosekit-web-tooltip.js → tooltip.js} +1 -1
  40. package/dist/tooltip.js.map +1 -0
  41. package/dist/use-editor-update-event.js +11 -0
  42. package/dist/use-editor-update-event.js.map +1 -0
  43. package/package.json +44 -61
  44. package/src/components/autocomplete/autocomplete-positioner.ts +13 -4
  45. package/src/components/autocomplete/autocomplete-root.ts +3 -3
  46. package/src/components/block-handle/block-handle-add.ts +1 -1
  47. package/src/components/block-handle/block-handle-draggable.ts +1 -1
  48. package/src/components/block-handle/block-handle-positioner.ts +1 -1
  49. package/src/components/block-handle/block-handle-root.ts +5 -2
  50. package/src/components/block-handle/use-has-text-selection.ts +13 -0
  51. package/src/components/inline-popover/inline-popover-positioner.ts +1 -1
  52. package/src/components/inline-popover/inline-popover-root.ts +1 -1
  53. package/src/components/table-handle/shared.ts +6 -6
  54. package/src/components/table-handle/table-handle-column-menu-trigger.ts +1 -1
  55. package/src/components/table-handle/table-handle-drag-preview.ts +1 -1
  56. package/src/components/table-handle/table-handle-drop-indicator.ts +1 -1
  57. package/src/components/table-handle/table-handle-root.ts +1 -1
  58. package/src/components/table-handle/table-handle-row-menu-trigger.ts +1 -1
  59. package/dist/prosekit-web-autocomplete.d.ts.map +0 -1
  60. package/dist/prosekit-web-autocomplete.js.map +0 -1
  61. package/dist/prosekit-web-block-handle.d.ts.map +0 -1
  62. package/dist/prosekit-web-block-handle.js.map +0 -1
  63. package/dist/prosekit-web-drop-indicator.d.ts.map +0 -1
  64. package/dist/prosekit-web-drop-indicator.js.map +0 -1
  65. package/dist/prosekit-web-inline-popover.d.ts.map +0 -1
  66. package/dist/prosekit-web-inline-popover.js.map +0 -1
  67. package/dist/prosekit-web-menu.d.ts.map +0 -1
  68. package/dist/prosekit-web-menu.js.map +0 -1
  69. package/dist/prosekit-web-popover.d.ts.map +0 -1
  70. package/dist/prosekit-web-popover.js.map +0 -1
  71. package/dist/prosekit-web-resizable.d.ts.map +0 -1
  72. package/dist/prosekit-web-resizable.js.map +0 -1
  73. package/dist/prosekit-web-table-handle.d.ts.map +0 -1
  74. package/dist/prosekit-web-table-handle.js.map +0 -1
  75. package/dist/prosekit-web-tooltip.d.ts.map +0 -1
  76. package/dist/prosekit-web-tooltip.js.map +0 -1
  77. package/dist/prosekit-web.d.ts.map +0 -1
  78. package/dist/prosekit-web.js.map +0 -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-beta.5",
4
+ "version": "0.8.0",
5
5
  "private": false,
6
6
  "description": "A collection of web components for ProseKit",
7
7
  "author": {
@@ -23,48 +23,48 @@
23
23
  "ProseMirror"
24
24
  ],
25
25
  "sideEffects": true,
26
- "main": "./dist/prosekit-web.js",
27
- "module": "./dist/prosekit-web.js",
26
+ "main": "./dist/index.js",
27
+ "module": "./dist/index.js",
28
28
  "exports": {
29
29
  ".": {
30
- "types": "./dist/prosekit-web.d.ts",
31
- "default": "./dist/prosekit-web.js"
30
+ "types": "./dist/index.d.ts",
31
+ "default": "./dist/index.js"
32
32
  },
33
33
  "./autocomplete": {
34
- "types": "./dist/prosekit-web-autocomplete.d.ts",
35
- "default": "./dist/prosekit-web-autocomplete.js"
34
+ "types": "./dist/autocomplete.d.ts",
35
+ "default": "./dist/autocomplete.js"
36
36
  },
37
37
  "./block-handle": {
38
- "types": "./dist/prosekit-web-block-handle.d.ts",
39
- "default": "./dist/prosekit-web-block-handle.js"
38
+ "types": "./dist/block-handle.d.ts",
39
+ "default": "./dist/block-handle.js"
40
40
  },
41
41
  "./drop-indicator": {
42
- "types": "./dist/prosekit-web-drop-indicator.d.ts",
43
- "default": "./dist/prosekit-web-drop-indicator.js"
42
+ "types": "./dist/drop-indicator.d.ts",
43
+ "default": "./dist/drop-indicator.js"
44
44
  },
45
45
  "./inline-popover": {
46
- "types": "./dist/prosekit-web-inline-popover.d.ts",
47
- "default": "./dist/prosekit-web-inline-popover.js"
46
+ "types": "./dist/inline-popover.d.ts",
47
+ "default": "./dist/inline-popover.js"
48
48
  },
49
49
  "./menu": {
50
- "types": "./dist/prosekit-web-menu.d.ts",
51
- "default": "./dist/prosekit-web-menu.js"
50
+ "types": "./dist/menu.d.ts",
51
+ "default": "./dist/menu.js"
52
52
  },
53
53
  "./popover": {
54
- "types": "./dist/prosekit-web-popover.d.ts",
55
- "default": "./dist/prosekit-web-popover.js"
54
+ "types": "./dist/popover.d.ts",
55
+ "default": "./dist/popover.js"
56
56
  },
57
57
  "./resizable": {
58
- "types": "./dist/prosekit-web-resizable.d.ts",
59
- "default": "./dist/prosekit-web-resizable.js"
58
+ "types": "./dist/resizable.d.ts",
59
+ "default": "./dist/resizable.js"
60
60
  },
61
61
  "./table-handle": {
62
- "types": "./dist/prosekit-web-table-handle.d.ts",
63
- "default": "./dist/prosekit-web-table-handle.js"
62
+ "types": "./dist/table-handle.d.ts",
63
+ "default": "./dist/table-handle.js"
64
64
  },
65
65
  "./tooltip": {
66
- "types": "./dist/prosekit-web-tooltip.d.ts",
67
- "default": "./dist/prosekit-web-tooltip.js"
66
+ "types": "./dist/tooltip.d.ts",
67
+ "default": "./dist/tooltip.js"
68
68
  }
69
69
  },
70
70
  "files": [
@@ -73,79 +73,62 @@
73
73
  ],
74
74
  "dependencies": {
75
75
  "@aria-ui/core": "^0.2.0",
76
- "@aria-ui/elements": "^0.1.8",
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-beta.0",
82
- "@prosekit/pm": "^0.1.15",
83
- "@prosekit/extensions": "^0.16.0-beta.0"
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.6",
87
- "tsdown": "^0.21.8",
88
- "type-fest": "^5.5.0",
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.4",
90
+ "vitest": "^4.1.5",
91
91
  "@prosekit/config-ts": "0.0.0",
92
- "@prosekit/config-tsdown": "0.0.0",
93
- "@prosekit/config-vitest": "0.0.0"
94
- },
95
- "publishConfig": {
96
- "dev": {}
97
- },
98
- "dev": {
99
- "entry": {
100
- "prosekit-web": "./src/index.ts",
101
- "prosekit-web-autocomplete": "./src/components/autocomplete/index.ts",
102
- "prosekit-web-block-handle": "./src/components/block-handle/index.ts",
103
- "prosekit-web-drop-indicator": "./src/components/drop-indicator/index.ts",
104
- "prosekit-web-inline-popover": "./src/components/inline-popover/index.ts",
105
- "prosekit-web-menu": "./src/components/menu/index.ts",
106
- "prosekit-web-popover": "./src/components/popover/index.ts",
107
- "prosekit-web-resizable": "./src/components/resizable/index.ts",
108
- "prosekit-web-table-handle": "./src/components/table-handle/index.ts",
109
- "prosekit-web-tooltip": "./src/components/tooltip/index.ts"
110
- }
92
+ "@prosekit/config-vitest": "0.0.0",
93
+ "@prosekit/config-tsdown": "0.0.0"
111
94
  },
112
95
  "scripts": {
113
96
  "build:tsc": "tsc -b tsconfig.json",
114
97
  "build:tsdown": "tsdown",
115
98
  "build:aria-ui": "node build.mjs"
116
99
  },
117
- "types": "./dist/prosekit-web.d.ts",
100
+ "types": "./dist/index.d.ts",
118
101
  "typesVersions": {
119
102
  "*": {
120
103
  ".": [
121
- "./dist/prosekit-web.d.ts"
104
+ "./dist/index.d.ts"
122
105
  ],
123
106
  "autocomplete": [
124
- "./dist/prosekit-web-autocomplete.d.ts"
107
+ "./dist/autocomplete.d.ts"
125
108
  ],
126
109
  "block-handle": [
127
- "./dist/prosekit-web-block-handle.d.ts"
110
+ "./dist/block-handle.d.ts"
128
111
  ],
129
112
  "drop-indicator": [
130
- "./dist/prosekit-web-drop-indicator.d.ts"
113
+ "./dist/drop-indicator.d.ts"
131
114
  ],
132
115
  "inline-popover": [
133
- "./dist/prosekit-web-inline-popover.d.ts"
116
+ "./dist/inline-popover.d.ts"
134
117
  ],
135
118
  "menu": [
136
- "./dist/prosekit-web-menu.d.ts"
119
+ "./dist/menu.d.ts"
137
120
  ],
138
121
  "popover": [
139
- "./dist/prosekit-web-popover.d.ts"
122
+ "./dist/popover.d.ts"
140
123
  ],
141
124
  "resizable": [
142
- "./dist/prosekit-web-resizable.d.ts"
125
+ "./dist/resizable.d.ts"
143
126
  ],
144
127
  "table-handle": [
145
- "./dist/prosekit-web-table-handle.d.ts"
128
+ "./dist/table-handle.d.ts"
146
129
  ],
147
130
  "tooltip": [
148
- "./dist/prosekit-web-tooltip.d.ts"
131
+ "./dist/tooltip.d.ts"
149
132
  ]
150
133
  }
151
134
  }
@@ -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 hovered block.
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: 4, attribute: false, type: 'json' },
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, type: 'json' },
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, type: 'json' },
58
- regex: { default: null, attribute: false, type: 'json' },
59
- filter: { default: defaultItemFilter, attribute: false, type: 'json' },
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, type: 'json' },
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, type: 'json' },
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, type: 'json' },
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, type: 'json' },
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, type: 'json' },
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, type: 'json' },
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, type: 'json' },
56
- hoist: { default: false, attribute: false, type: 'boolean' },
57
- flip: { default: false, attribute: false, type: 'json' },
58
- shift: { default: false, attribute: false, type: 'boolean' },
59
- hide: { default: true, attribute: false, type: 'boolean' },
60
- offset: { default: 0, attribute: false, type: 'json' },
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, type: 'json' },
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, type: 'json' },
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, type: 'json' },
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, type: 'json' },
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, type: 'json' },
34
+ editor: { default: null, attribute: false },
35
35
  })
36
36
 
37
37
  /** @internal */
@@ -1 +0,0 @@
1
- {"version":3,"file":"prosekit-web-autocomplete.d.ts","names":[],"sources":["../src/components/autocomplete/autocomplete-empty.ts","../src/components/autocomplete/autocomplete-item.ts","../src/components/autocomplete/autocomplete-popup.ts","../src/components/autocomplete/autocomplete-positioner.ts","../src/components/autocomplete/autocomplete-root.ts"],"mappings":";;;;UAWiB,sBAAA,SAA+B,iBAAA;;cAGnC,iCAAA,EAAmC,gBAAA,CAAiB,sBAAA;;;;iBAOjD,sBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,sBAAA;AAAA,cAKT,4BAAA,EAA8B,sBAAA,CAAuB,sBAAA;;;;;AAP3D;cAiBa,wBAAA,SAAiC,4BAAA;;iBAG9B,gCAAA,CAAA;AAAA,UCzBC,qBAAA,SAA8B,gBAAA;;ADL/C;;;;;AAGA;ECUE,KAAA;AAAA;;cAIW,gCAAA,EAAkC,gBAAA,CAAiB,qBAAA;AAAA,UAO/C,sBAAA,SAA+B,iBAAA;;;;iBAKhC,qBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,qBAAA;AAAA,cAST,2BAAA,EAA6B,sBAAA,CAAuB,qBAAA;;;;;;;;;ADzBzD;;;;;cC2CY,uBAAA,SAAgC,2BAAA;;iBAG7B,+BAAA,CAAA;;;AD7DhB;UEiBiB,sBAAA,SAA+B,iBAAA;;;AFdhD;UEmBiB,uBAAA,SAAgC,iBAAA;;cAGpC,iCAAA,EAAmC,gBAAA,CAAiB,sBAAA;AFfjE;AAAA,iBEoBgB,sBAAA,CACd,IAAA,EAAM,WAAA,EACN,MAAA,EAAQ,KAAA,CAAM,sBAAA;AAAA,cAsCV,4BAAA,EAA8B,sBAAA,CAAuB,sBAAA;;;;;;;;;;;;;AFvD1D;cEyEY,wBAAA,SAAiC,4BAAA;;iBAG9B,gCAAA,CAAA;;;;UCnFC,2BAAA,SAAoC,sBAAA;EHRb;;;;AAGxC;EGWE,SAAA,EAAW,sBAAA;;;;AHJb;;EGWE,MAAA,EAAQ,sBAAA;EHVF;;;EGeN,MAAA,EAAQ,sBAAA;EHdI;;;EGmBZ,KAAA,EAAO,sBAAA;EHnBM;;;EGwBb,WAAA,EAAa,sBAAA;EHnBT;;;EGwBJ,QAAA,EAAU,sBAAA;EHxBqE;AAUjF;;EGmBE,eAAA,EAAiB,sBAAA;AAAA;;cAIN,sCAAA,EAAwC,gBAAA,CAAiB,2BAAA;;iBActD,2BAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,2BAAA;AAAA,cAOT,iCAAA,EAAmC,sBAAA,CAAuB,2BAAA;;;AFpEhE;;;;;AAYA;;;;;AAOA;;;;;AAKA;;cEoEa,6BAAA,SAAsC,iCAAA;;iBAGnC,qCAAA,CAAA;AAAA,UCpFC,qBAAA;EJhBuB;;;;AAGxC;;EIoBE,MAAA,EAAQ,MAAA;EJpBsC;;AAOhD;;;EIoBE,KAAA,EAAO,MAAA;EJlBM;;;;;;EI0Bb,MAAA,EAAQ,UAAA;AAAA;;cAIG,gCAAA,EAAkC,gBAAA,CAAiB,qBAAA;;AJ3B/D;;cIsCY,gBAAA,SAAyB,KAAA;EJpCF;;AAUpC;EAVoC,SIwCzB,MAAA;cAEG,KAAA;AAAA;;AJ7Bd;;UIsCiB,sBAAA,SAA+B,iBAAA;EJtCA;;;EI0C9C,UAAA,EAAY,eAAA;EHnEyB;;;EGwErC,WAAA,EAAa,gBAAA;AAAA;;;;iBAkBC,qBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,qBAAA;AAAA,cA8JT,2BAAA,EAA6B,sBAAA,CAAuB,qBAAA;;;;;AHlO1D;;;cG8Oa,uBAAA,SAAgC,2BAAA;;iBAG7B,+BAAA,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"prosekit-web-autocomplete.js","names":[],"sources":["../src/components/autocomplete/autocomplete-empty.ts","../src/utils/prevent-default.ts","../src/components/autocomplete/autocomplete-item.ts","../src/utils/lazy-signal.ts","../src/utils/use-no-focus.ts","../src/components/autocomplete/context.ts","../src/components/autocomplete/autocomplete-popup.ts","../src/components/autocomplete/autocomplete-positioner.ts","../src/utils/event.ts","../src/components/autocomplete/helpers.ts","../src/components/autocomplete/autocomplete-root.ts"],"sourcesContent":["import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { setupListboxEmpty, type ListboxEmptyProps } from '@aria-ui/elements/listbox'\n\nexport interface AutocompleteEmptyProps extends ListboxEmptyProps {}\n\n/** @internal */\nexport const AutocompleteEmptyPropsDeclaration: PropsDeclaration<AutocompleteEmptyProps> = /* @__PURE__ */ defineProps<\n AutocompleteEmptyProps\n>({})\n\n/**\n * @internal\n */\nexport function setupAutocompleteEmpty(\n host: HostElement,\n props: State<AutocompleteEmptyProps>,\n): void {\n setupListboxEmpty(host, props)\n}\n\nconst AutocompleteEmptyElementBase: HostElementConstructor<AutocompleteEmptyProps> = defineCustomElement(\n setupAutocompleteEmpty,\n AutocompleteEmptyPropsDeclaration,\n)\n\n/**\n * `<prosekit-autocomplete-empty>` custom element.\n *\n * Properties: {@link AutocompleteEmptyProps}\n */\nexport class AutocompleteEmptyElement extends AutocompleteEmptyElementBase {}\n\n/** @internal */\nexport function registerAutocompleteEmptyElement(): void {\n registerCustomElement('prosekit-autocomplete-empty', AutocompleteEmptyElement)\n}\n","export function preventDefault(event: Event): void {\n event.preventDefault()\n}\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { SelectEvent, setupListboxItem, type ListboxItemEvents, type ListboxItemProps } from '@aria-ui/elements/listbox'\nimport { useEventListener } from '@aria-ui/utils'\n\nimport { preventDefault } from '../../utils/prevent-default.ts'\n\nexport { SelectEvent }\n\nexport interface AutocompleteItemProps extends ListboxItemProps {\n /**\n * The value of the item, which will be matched against the query.\n *\n * If not provided, the value is the item's text content.\n *\n * @default \"\"\n */\n value: string\n}\n\n/** @internal */\nexport const AutocompleteItemPropsDeclaration: PropsDeclaration<AutocompleteItemProps> = /* @__PURE__ */ defineProps<AutocompleteItemProps>(\n {\n value: { default: '', attribute: 'value', type: 'string' },\n disabled: { default: false, attribute: 'disabled', type: 'boolean' },\n },\n)\n\nexport interface AutocompleteItemEvents extends ListboxItemEvents {}\n\n/**\n * @internal\n */\nexport function setupAutocompleteItem(\n host: HostElement,\n props: State<AutocompleteItemProps>,\n): void {\n setupListboxItem(host, props)\n\n // Prevent the editor from losing focus\n useEventListener(host, 'pointerdown', preventDefault)\n useEventListener(host, 'mousedown', preventDefault)\n}\n\nconst AutocompleteItemElementBase: HostElementConstructor<AutocompleteItemProps> = defineCustomElement(\n setupAutocompleteItem,\n AutocompleteItemPropsDeclaration,\n)\n\n/**\n * `<prosekit-autocomplete-item>` custom element.\n *\n * Properties: {@link AutocompleteItemProps}\n *\n * Events: {@link AutocompleteItemEvents}\n *\n * Data attributes:\n *\n * | Attribute | Description |\n * | --- | --- |\n * | `data-highlighted` | Present when the item is the currently highlighted option |\n */\nexport class AutocompleteItemElement extends AutocompleteItemElementBase {}\n\n/** @internal */\nexport function registerAutocompleteItemElement(): void {\n registerCustomElement('prosekit-autocomplete-item', AutocompleteItemElement)\n}\n","import type { Signal } from '@aria-ui/core'\n\nexport function createLazySignal<T>(\n getRemote: () => Signal<T> | undefined,\n fallback: T,\n): Signal<T> {\n return {\n get: (): T => {\n const remote = getRemote()\n return remote ? remote.get() : fallback\n },\n set: (value: T): void => {\n const remote = getRemote()\n if (remote) remote.set(value)\n },\n }\n}\n","import { onMount, type HostElement } from '@aria-ui/core'\n\nexport function useNoFocus(host: HostElement): void {\n onMount(host, () => {\n host.tabIndex = -1\n })\n}\n","import { createContext, type Context, type Signal } from '@aria-ui/core'\nimport type { ItemFilter } from '@aria-ui/elements/listbox'\nimport type { OverlayStore } from '@aria-ui/elements/overlay'\n\n/**\n * @internal\n */\nexport interface AutocompleteStore {\n overlayStore: OverlayStore\n query: Signal<string>\n eventTarget: Signal<EventTarget | null>\n filter: Signal<ItemFilter | null>\n}\n\n/**\n * @internal\n */\nexport const autocompleteStoreContext: Context<AutocompleteStore> = createContext<AutocompleteStore>('prosekit-autocomplete-store')\n","import {\n createSignal,\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type Signal,\n type State,\n} from '@aria-ui/core'\nimport {\n defaultItemFilter,\n setupListboxRoot,\n type ItemFilter,\n type ListboxRootEvents,\n type ListboxRootProps,\n} from '@aria-ui/elements/listbox'\nimport { OverlayPopupPropsDeclaration, setupOverlayPopup, type OverlayPopupProps } from '@aria-ui/elements/overlay'\n\nimport { createLazySignal } from '../../utils/lazy-signal.ts'\nimport { useNoFocus } from '../../utils/use-no-focus.ts'\n\nimport { autocompleteStoreContext } from './context.ts'\n\n/**\n * @public\n */\nexport interface AutocompletePopupProps extends OverlayPopupProps {}\n\n/**\n * @public\n */\nexport interface AutocompletePopupEvents extends ListboxRootEvents {}\n\n/** @internal */\nexport const AutocompletePopupPropsDeclaration: PropsDeclaration<AutocompletePopupProps> = /* @__PURE__ */ defineProps<\n AutocompletePopupProps\n>(OverlayPopupPropsDeclaration)\n\n/** @internal */\nexport function setupAutocompletePopup(\n host: HostElement,\n _props: State<AutocompletePopupProps>,\n): void {\n const getStore = autocompleteStoreContext.consume(host)\n const getOverlayStore = () => getStore()?.overlayStore\n\n setupOverlayPopup(host, getOverlayStore)\n\n const query = createLazySignal<string>(() => getStore()?.query, ' ')\n const eventTarget = createLazySignal<EventTarget | null>(() => getStore()?.eventTarget, null)\n const filter = createLazySignal<ItemFilter | null>(() => getStore()?.filter, defaultItemFilter)\n const getDisabled = () => (!(getOverlayStore()?.getIsOpen?.()))\n const disabled: Signal<boolean> = { get: getDisabled, set: () => {} }\n const listboxProps = createPopupListboxProps(filter, query, eventTarget, disabled)\n\n setupListboxRoot(host, listboxProps)\n useNoFocus(host)\n}\n\nfunction createPopupListboxProps(\n filter: Signal<ItemFilter | null>,\n query: Signal<string>,\n eventTarget: Signal<EventTarget | null>,\n disabled: Signal<boolean>,\n): State<ListboxRootProps> {\n return {\n value: createSignal(''),\n values: createSignal<string[]>([]),\n multiple: createSignal(false),\n disabled,\n orientation: createSignal<'vertical' | 'horizontal'>('vertical'),\n loop: createSignal(false),\n autoHighlight: createSignal(true),\n query,\n eventTarget,\n filter,\n }\n}\n\nconst AutocompletePopupElementBase: HostElementConstructor<AutocompletePopupProps> = defineCustomElement(\n setupAutocompletePopup,\n AutocompletePopupPropsDeclaration,\n)\n\n/**\n * `<prosekit-autocomplete-popup>` custom element.\n *\n * Properties: {@link AutocompletePopupProps}\n *\n * Events: {@link AutocompletePopupEvents}\n *\n * Data attributes:\n *\n * | Attribute | Description |\n * | --- | --- |\n * | `data-state` | `\"open\"` when the autocomplete is visible, `\"closed\"` otherwise |\n */\nexport class AutocompletePopupElement extends AutocompletePopupElementBase {}\n\n/** @internal */\nexport function registerAutocompletePopupElement(): void {\n registerCustomElement('prosekit-autocomplete-popup', AutocompletePopupElement)\n}\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { OverlayPositionerPropsDeclaration, setupOverlayPositioner, type OverlayPositionerProps } from '@aria-ui/elements/overlay'\n\nimport { autocompleteStoreContext } from './context.ts'\n\nconst body = typeof document !== 'undefined' && document.querySelector('body')\nconst defaultBoundary = body || 'clippingAncestors'\n\n/**\n * @public\n */\nexport interface AutocompletePositionerProps extends OverlayPositionerProps {\n /**\n * The placement of the popover, relative to the text cursor.\n *\n * @default \"bottom-start\"\n */\n placement: OverlayPositionerProps['placement']\n\n /**\n * The distance between the popover and the hovered block.\n *\n * @default 4\n */\n offset: OverlayPositionerProps['offset']\n\n /**\n * @default true\n */\n inline: OverlayPositionerProps['inline']\n\n /**\n * @default true\n */\n hoist: OverlayPositionerProps['hoist']\n\n /**\n * @default true\n */\n fitViewport: OverlayPositionerProps['fitViewport']\n\n /**\n * @default \"The body element\"\n */\n boundary: OverlayPositionerProps['boundary']\n\n /**\n * @default 8\n */\n overflowPadding: OverlayPositionerProps['overflowPadding']\n}\n\n/** @internal */\nexport const AutocompletePositionerPropsDeclaration: PropsDeclaration<AutocompletePositionerProps> = /* @__PURE__ */ defineProps<\n AutocompletePositionerProps\n>({\n ...OverlayPositionerPropsDeclaration,\n placement: { default: 'bottom-start', attribute: 'placement', type: 'string' },\n offset: { default: 4, attribute: false, type: 'json' },\n inline: { default: true, attribute: 'inline', type: 'boolean' },\n hoist: { default: true, attribute: 'hoist', type: 'boolean' },\n fitViewport: { default: true, attribute: 'fit-viewport', type: 'boolean' },\n boundary: { default: defaultBoundary, attribute: false, type: 'json' },\n overflowPadding: { default: 8, attribute: 'overflow-padding', type: 'number' },\n})\n\n/** @internal */\nexport function setupAutocompletePositioner(\n host: HostElement,\n props: State<AutocompletePositionerProps>,\n): void {\n const getStore = autocompleteStoreContext.consume(host)\n const getOverlayStore = () => getStore()?.overlayStore\n setupOverlayPositioner(host, props as unknown as State<OverlayPositionerProps>, getOverlayStore)\n}\n\nconst AutocompletePositionerElementBase: HostElementConstructor<AutocompletePositionerProps> = defineCustomElement(\n setupAutocompletePositioner,\n AutocompletePositionerPropsDeclaration,\n)\n\n/**\n * `<prosekit-autocomplete-positioner>` custom element.\n *\n * Properties: {@link AutocompletePositionerProps}\n *\n * Data attributes:\n *\n * | Attribute | Description |\n * | --- | --- |\n * | `data-state` | `\"open\"` when the autocomplete is visible, `\"closed\"` otherwise |\n * | `data-side` | The side of the anchor element the positioner is on |\n * | `data-align` | The alignment of the positioner relative to the anchor element |\n *\n * CSS variables:\n *\n * | Variable | Description |\n * | --- | --- |\n * | `--transform-origin` | The coordinates that this element is anchored to. Useful for scale animations. |\n */\nexport class AutocompletePositionerElement extends AutocompletePositionerElementBase {}\n\n/** @internal */\nexport function registerAutocompletePositionerElement(): void {\n registerCustomElement('prosekit-autocomplete-positioner', AutocompletePositionerElement)\n}\n","function cloneKeyboardEvent(source: KeyboardEvent): KeyboardEvent {\n return new KeyboardEvent(source.type, {\n code: source.code,\n key: source.key,\n location: source.location,\n repeat: source.repeat,\n altKey: source.altKey,\n ctrlKey: source.ctrlKey,\n metaKey: source.metaKey,\n shiftKey: source.shiftKey,\n\n view: source.view,\n // internal bridge target; events don't need to bubble\"\n bubbles: false,\n cancelable: true,\n })\n}\n\nexport class KeyboardEventTarget extends EventTarget {\n override dispatchEvent(event: KeyboardEvent): boolean {\n const newEvent = cloneKeyboardEvent(event)\n const result: boolean = super.dispatchEvent(newEvent)\n if (newEvent.defaultPrevented) {\n event.preventDefault()\n }\n return result\n }\n}\n","export function defaultQueryBuilder(match: RegExpExecArray): string {\n return match[0]\n .toLowerCase()\n .replaceAll(/[!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~]/g, '')\n .replaceAll(/\\s\\s+/g, ' ')\n .trim()\n}\n","import {\n createSignal,\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEffect,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type Signal,\n type State,\n} from '@aria-ui/core'\nimport { defaultItemFilter, type ItemFilter, type ListboxRootEvents } from '@aria-ui/elements/listbox'\nimport { createOverlayStore, OpenChangeEvent, type OverlayStore } from '@aria-ui/elements/overlay'\nimport { useEventListener } from '@aria-ui/utils'\nimport { defineDOMEventHandler, defineKeymap, withPriority, type Editor, type Extension, type Priority } from '@prosekit/core'\nimport { AutocompleteRule, defineAutocomplete, type MatchHandler } from '@prosekit/extensions/autocomplete'\n\nimport { useEditorExtension } from '../../hooks/use-editor-extension.ts'\nimport { KeyboardEventTarget } from '../../utils/event.ts'\nimport { getSafeEditorView } from '../../utils/get-safe-editor-view.ts'\n\nimport { autocompleteStoreContext, type AutocompleteStore } from './context.ts'\nimport { defaultQueryBuilder } from './helpers.ts'\n\nexport { OpenChangeEvent }\n\nexport interface AutocompleteRootProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * The regular expression to match the query text to autocomplete.\n *\n * @default null\n */\n regex: RegExp | null\n\n /**\n * The filter function to determine if an item should be shown in the\n * listbox.\n *\n * @default defaultItemFilter\n */\n filter: ItemFilter | null\n}\n\n/** @internal */\nexport const AutocompleteRootPropsDeclaration: PropsDeclaration<AutocompleteRootProps> = /* @__PURE__ */ defineProps<\n AutocompleteRootProps\n>({\n editor: { default: null, attribute: false, type: 'json' },\n regex: { default: null, attribute: false, type: 'json' },\n filter: { default: defaultItemFilter, attribute: false, type: 'json' },\n})\n\n/**\n * @public\n */\nexport class QueryChangeEvent extends Event {\n /**\n * The current query string.\n */\n readonly detail: string\n\n constructor(query: string) {\n super('queryChange', { bubbles: true })\n this.detail = query\n }\n}\n\n/**\n * @public\n */\nexport interface AutocompleteRootEvents extends ListboxRootEvents {\n /**\n * Fired when the open state changes.\n */\n openChange: OpenChangeEvent\n\n /**\n * Fired when the query changes.\n */\n queryChange: QueryChangeEvent\n}\n\ninterface RuleHandlers {\n submit?: VoidFunction\n dismiss?: VoidFunction\n}\n\ninterface AutocompleteRuleDeps {\n reference: Signal<Element | undefined>\n handlers: RuleHandlers\n setQuery: (next: string) => void\n requestOpenChange: (open: boolean) => void\n}\n\n/**\n * @internal\n */\nexport function setupAutocompleteRoot(\n host: HostElement,\n props: State<AutocompleteRootProps>,\n): void {\n const getEditor = props.editor.get\n\n const reference = createSignal<Element | undefined>(undefined)\n const open = createSignal(false)\n const query = createSignal('')\n const keyboardTarget = new KeyboardEventTarget()\n const eventTarget = createSignal<EventTarget | null>(keyboardTarget)\n const handlers: RuleHandlers = {}\n\n // Create overlay store for positioning. The open state is managed by the\n // overlay store via requestOpenChange(), which dispatches OpenChangeEvent and\n // updates the open signal.\n const overlayStore: OverlayStore = createOverlayStore(\n open.get,\n open.set,\n () => false,\n () => false,\n (event) => host.dispatchEvent(event),\n )\n\n useEffect(host, () => {\n overlayStore.setAnchorElement(reference.get())\n })\n\n const autocompleteStore: AutocompleteStore = {\n overlayStore,\n query,\n eventTarget,\n filter: props.filter,\n }\n\n autocompleteStoreContext.provide(host, autocompleteStore)\n\n useEventListener(host, 'valueChange', () => {\n handlers.submit?.()\n })\n\n useKeyboardBridge(host, getEditor, open.get, keyboardTarget)\n\n useEscapeKeydown(host, getEditor, () => {\n if (!open.get() || !handlers.dismiss) return false\n handlers.dismiss()\n return true\n })\n\n const setQuery = (next: string): void => {\n if (query.get() === next) return\n query.set(next)\n host.dispatchEvent(new QueryChangeEvent(next))\n }\n\n useAutocompleteExtension(host, getEditor, props.regex.get, {\n reference,\n handlers,\n setQuery,\n requestOpenChange: (open) => overlayStore.requestOpenChange(open),\n })\n}\n\nconst EVENT_KEYS = [\n 'ArrowDown',\n 'ArrowRight',\n 'ArrowUp',\n 'ArrowLeft',\n 'Home',\n 'End',\n 'Enter',\n] as const\n\nfunction useKeyboardBridge(\n host: HostElement,\n getEditor: () => Editor | null,\n getOpen: () => boolean,\n target: EventTarget,\n): void {\n const extension: Extension = defineDOMEventHandler('keydown', (view, event): boolean => {\n if (\n view.composing\n || event.defaultPrevented\n || !getOpen()\n || !EVENT_KEYS.includes(event.key as (typeof EVENT_KEYS)[number])\n ) {\n return false\n }\n target.dispatchEvent(event)\n return event.defaultPrevented\n })\n useEditorExtension(host, getEditor, withPriority(extension, 4 satisfies typeof Priority.highest))\n}\n\nfunction useAutocompleteExtension(\n host: HostElement,\n getEditor: () => Editor | null,\n getRegex: () => RegExp | null,\n deps: AutocompleteRuleDeps,\n) {\n useEffect(host, () => {\n const editor = getEditor()\n const regex = getRegex()\n\n if (!editor || !regex) {\n return\n }\n\n const rule = createAutocompleteRule(editor, regex, deps)\n const extension = defineAutocomplete(rule)\n return editor.use(extension)\n })\n}\n\nfunction createAutocompleteRule(\n editor: Editor,\n regex: RegExp,\n deps: AutocompleteRuleDeps,\n) {\n const { reference, handlers, setQuery, requestOpenChange } = deps\n\n const handleEnter: MatchHandler = (options) => {\n const view = getSafeEditorView(editor)\n const span = view?.dom.querySelector('.prosekit-autocomplete-match')\n\n if (span) {\n reference.set(span)\n }\n\n handlers.submit = options.deleteMatch\n handlers.dismiss = options.ignoreMatch\n setQuery(defaultQueryBuilder(options.match))\n requestOpenChange(true)\n }\n\n const handleLeave = () => {\n reference.set(undefined)\n setQuery('')\n handlers.submit = undefined\n handlers.dismiss = undefined\n requestOpenChange(false)\n }\n\n return new AutocompleteRule({\n regex,\n onEnter: handleEnter,\n onLeave: handleLeave,\n })\n}\n\nfunction useEscapeKeydown(\n host: HostElement,\n getEditor: () => Editor | null,\n handler: () => boolean,\n): void {\n const keymap = { Escape: handler }\n const extension = withPriority(defineKeymap(keymap), 4 satisfies typeof Priority.highest)\n useEditorExtension(host, getEditor, extension)\n}\n\nconst AutocompleteRootElementBase: HostElementConstructor<AutocompleteRootProps> = defineCustomElement(\n setupAutocompleteRoot,\n AutocompleteRootPropsDeclaration,\n)\n\n/**\n * `<prosekit-autocomplete-root>` custom element.\n *\n * Properties: {@link AutocompleteRootProps}\n *\n * Events: {@link AutocompleteRootEvents}\n */\nexport class AutocompleteRootElement extends AutocompleteRootElementBase {}\n\n/** @internal */\nexport function registerAutocompleteRootElement(): void {\n registerCustomElement('prosekit-autocomplete-root', AutocompleteRootElement)\n}\n"],"mappings":";;;;;;;;;AAcA,MAAa,oCAA8F,4BAEzG,EAAE,CAAC;;;;AAKL,SAAgB,uBACd,MACA,OACM;AACN,mBAAkB,MAAM,MAAM;;AAGhC,MAAM,+BAA+E,oBACnF,wBACA,kCACD;;;;;;AAOD,IAAa,2BAAb,cAA8C,6BAA6B;;AAG3E,SAAgB,mCAAyC;AACvD,uBAAsB,+BAA+B,yBAAyB;;AC1ChF,SAAgB,eAAe,OAAoB;AACjD,OAAM,gBAAgB;;;AC2BxB,MAAa,mCAA4F,4B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E7C,MAAM,OADO,kBAAkB,OAAO,EACnB,IAAI,cAAc,+BAA+B;AAEpE,MAAI,KACF,WAAU,IAAI,KAAK;AAGrB,WAAS,SAAS,QAAQ;AAC1B,WAAS,UAAU,QAAQ;AAC3B,WAAS,oBAAoB,QAAQ,MAAM,CAAC;AAC5C,oBAAkB,KAAK;;CAGzB,MAAM,oBAAoB;AACxB,YAAU,IAAI,KAAA,EAAU;AACxB,WAAS,GAAG;AACZ,WAAS,SAAS,KAAA;AAClB,WAAS,UAAU,KAAA;AACnB,oBAAkB,MAAM;;AAG1B,QAAO,IAAI,iBAAiB;EAC1B;EACA,SAAS;EACT,SAAS;EACV,CAAC;;AAGJ,SAAS,iBACP,MACA,WACA,SACM;AAGN,oBAAmB,MAAM,WADP,aAAa,aADhB,EAAE,QAAQ,SAAS,CACiB,EAAE,EAAoC,CAC3C;;AAGhD,MAAM,8BAA6E,oBACjF,uBACA,iCACD;;;;;;;;AASD,IAAa,0BAAb,cAA6C,4BAA4B;;AAGzE,SAAgB,kCAAwC;AACtD,uBAAsB,8BAA8B,wBAAwB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"prosekit-web-block-handle.d.ts","names":[],"sources":["../src/components/block-handle/block-handle-add.ts","../src/components/block-handle/block-handle-draggable.ts","../src/components/block-handle/block-handle-popup.ts","../src/components/block-handle/block-handle-positioner.ts","../src/components/block-handle/block-handle-root.ts"],"mappings":";;;;;UAciB,mBAAA;;;;AAAjB;;;EAOE,MAAA,EAAQ,MAAA;AAAA;AAIV;AAAA,cAAa,8BAAA,EAAgC,gBAAA,CAAiB,mBAAA;;;;iBAO9C,mBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,mBAAA;AAAA,cAuBT,yBAAA,EAA2B,sBAAA,CAAuB,mBAAA;;;;;;cAU3C,qBAAA,SAA8B,yBAAA;;iBAG3B,6BAAA,CAAA;AAAA,UC7CC,yBAAA;;;;ADXjB;;;ECkBE,MAAA,EAAQ,M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AAS,IAAA,EAAM,eAAA;IAAiB,GAAA;EAAA;AAAA;;AJQ7C;;UICgB,qBAAA;EJCgB;;AAUjC;EIPE,WAAA,EAAa,2BAAA;AAAA;;;AJUf;iBIJgB,oBAAA,CACd,IAAA,EAAM,WAAA,EACN,KAAA,EAAO,KAAA,CAAM,oBAAA;AAAA,cAkCT,0BAAA,EAA4B,sBAAA,CAAuB,oBAAA;;;;AH7EzD;;;;cGyFa,sBAAA,SAA+B,0BAAA;;iBAG5B,8BAAA,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"prosekit-web-block-handle.js","names":[],"sources":["../src/components/block-handle/context.ts","../src/components/block-handle/block-handle-add.ts","../src/constants.ts","../src/utils/get-client-rect.ts","../src/utils/max-z-index.ts","../src/components/block-handle/set-drag-preview.ts","../src/components/block-handle/block-handle-draggable.ts","../src/components/block-handle/block-handle-popup.ts","../src/components/block-handle/block-handle-positioner.ts","../src/utils/prefers-reduced-motion.ts","../src/components/block-handle/hover-state.ts","../src/components/block-handle/pointer-move.ts","../src/components/block-handle/use-hover-extension.ts","../src/components/block-handle/block-handle-root.ts"],"sourcesContent":["import { createContext, createSignal, type Context, type Signal } from '@aria-ui/core'\nimport type { OverlayStore } from '@aria-ui/elements/overlay'\n\nimport type { HoverState } from './hover-state.ts'\n\n/**\n * @internal\n */\nexport class BlockHandleStore {\n readonly hoverState: Signal<HoverState | undefined> = createSignal<HoverState | undefined>(undefined)\n readonly dragging: Signal<boolean> = createSignal(false)\n}\n\n/**\n * @internal\n */\nexport const blockHandleStoreContext: Context<BlockHandleStore> = createContext<BlockHandleStore>('prosekit-block-handle-store')\n\n/**\n * @internal\n */\nexport const blockHandleOverlayStoreContext: Context<OverlayStore> = createContext<OverlayStore>('prosekit-block-handle-overlay-store')\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { useEventListener } from '@aria-ui/utils'\nimport { insertDefaultBlock, type Editor } from '@prosekit/core'\n\nimport { blockHandleStoreContext } from './context.ts'\n\nexport interface BlockHandleAddProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const BlockHandleAddPropsDeclaration: PropsDeclaration<BlockHandleAddProps> = /* @__PURE__ */ defineProps<BlockHandleAddProps>({\n editor: { default: null, attribute: false, type: 'json' },\n})\n\n/**\n * @internal\n */\nexport function setupBlockHandleAdd(\n host: HostElement,\n props: State<BlockHandleAddProps>,\n): void {\n const getStore = blockHandleStoreContext.consume(host)\n\n useEventListener(host, 'pointerdown', (event) => {\n event.preventDefault()\n\n const store = getStore()\n const editor = props.editor.get()\n const hoverState = store?.hoverState.get()\n if (!editor || !hoverState) {\n return\n }\n\n const { node, pos } = hoverState\n editor.exec(insertDefaultBlock({ pos: pos + node.nodeSize }))\n editor.focus()\n\n // Hide the drag handle\n store?.hoverState.set(undefined)\n })\n}\n\nconst BlockHandleAddElementBase: HostElementConstructor<BlockHandleAddProps> = defineCustomElement(\n setupBlockHandleAdd,\n BlockHandleAddPropsDeclaration,\n)\n\n/**\n * `<prosekit-block-handle-add>` custom element.\n *\n * Properties: {@link BlockHandleAddProps}\n */\nexport class BlockHandleAddElement extends BlockHandleAddElementBase {}\n\n/** @internal */\nexport function registerBlockHandleAddElement(): void {\n registerCustomElement('prosekit-block-handle-add', BlockHandleAddElement)\n}\n","export const DRAGGING_CLASS_NAME = 'prosekit-dragging'\n","interface Rect {\n top: number\n bottom: number\n right: number\n left: number\n}\n\ninterface IncludeExtraOptions {\n top?: boolean\n bottom?: boolean\n right?: boolean\n left?: boolean\n}\n\n/**\n * Similar to `element.getBoundingClientRect`, but handles `display: contents` CSS\n * property and optionally includes margins and outlines.\n */\nexport function getClientRect(element: Element, includeExtra?: IncludeExtraOptions | false): Rect {\n const rect = element.getBoundingClientRect()\n if (rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0) {\n // Suspiciously rect, probably an element with `display: contents`, in\n // which case `element.getClientRects()` will return an empty array.\n if (element.getClientRects().length === 0) {\n const children = [...element.children]\n const rects = children.map(child => getClientRect(child, includeExtra))\n if (rects.length === 0) {\n return rect\n }\n if (rects.length === 1) {\n return rects[0]\n }\n let { top, bottom, left, right } = rects[0]\n for (let i = 1; i < rects.length; i++) {\n const r = rects[i]\n if (r.top < top) top = r.top\n if (r.bottom > bottom) bottom = r.bottom\n if (r.left < left) left = r.left\n if (r.right > right) right = r.right\n }\n return { top, bottom, left, right }\n }\n }\n return includeExtra ? addExtra(element, rect, includeExtra) : rect\n}\n\nfunction addExtra(element: Element, rect: Rect, options: IncludeExtraOptions): Rect {\n const view = element.ownerDocument?.defaultView\n if (!view) {\n return rect\n }\n\n const style = view.getComputedStyle(element)\n const marginTop = options.top ? Number.parseFloat(style.marginTop) || 0 : 0\n const marginBottom = options.bottom ? Number.parseFloat(style.marginBottom) || 0 : 0\n const marginRight = options.right ? Number.parseFloat(style.marginRight) || 0 : 0\n const marginLeft = options.left ? Number.parseFloat(style.marginLeft) || 0 : 0\n\n const outlineWidth = Number.parseFloat(style.outlineWidth) || 0\n const outlineOffset = Number.parseFloat(style.outlineOffset) || 0\n const outline = Math.max(outlineWidth + outlineOffset, 0)\n const outlineTop = options.top ? outline : 0\n const outlineBottom = options.bottom ? outline : 0\n const outlineRight = options.right ? outline : 0\n const outlineLeft = options.left ? outline : 0\n\n return {\n top: rect.top - Math.max(marginTop, outlineTop),\n bottom: rect.bottom + Math.max(marginBottom, outlineBottom),\n right: rect.right + Math.max(marginRight, outlineRight),\n left: rect.left - Math.max(marginLeft, outlineLeft),\n }\n}\n","// Maximum possible z-index\n// https://stackoverflow.com/questions/491052/minimum-and-maximum-value-of-z-index\nexport const maxZIndex = '2147483647'\n","import { DRAGGING_CLASS_NAME } from '../../constants.ts'\nimport { assignStyles } from '../../utils/assign-styles.ts'\nimport { getClientRect } from '../../utils/get-client-rect.ts'\nimport { maxZIndex } from '../../utils/max-z-index.ts'\n\n/**\n * Sets a drag preview image for the given element and ensures the preview position\n * relative to the pointer is correct.\n *\n * This function does the following:\n *\n * - Creates a temporary container element.\n * - Puts the container at the end of the document body.\n * - Sets event's drag image.\n * - Removes the container from the document body after the next frame.\n */\nexport function setDragPreview(event: DragEvent, element: HTMLElement): void {\n const { top, bottom, left, right } = getClientRect(element, { left: true, right: true, top: true, bottom: true })\n const width = right - left\n const height = bottom - top\n const elementX = left\n const elementY = top\n\n const { clientX, clientY } = event\n\n const document = element.ownerDocument\n\n const container = document.createElement('div')\n\n // Add some class names so that all styles applied to\n // given class names can also be applied to the drag preview.\n container.classList.add('ProseMirror', DRAGGING_CLASS_NAME)\n\n // If outsideX is positive, the point is at the left side of the element.\n const outsideX = Math.round(elementX - clientX)\n // If outsideY is positive, the point is above the element.\n const outsideY = Math.round(elementY - clientY)\n\n const borderX = Math.max(outsideX, 0)\n const borderY = Math.max(outsideY, 0)\n assignStyles(container, {\n // Ensuring we don't cause reflow when adding the element to the page using\n // `position:fixed` rather than `position:absolute` so we are positioned on\n // the current viewport. `position:fixed` also creates a new stacking\n // context, so we don't need to do that here.\n // https://github.com/atlassian/pragmatic-drag-and-drop/blob/56276552/packages/core/src/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.ts#L60\n position: 'fixed',\n\n // The element is positioned off-screen to avoid capturing the content of\n // the page on Safari when the dragging element has a transparent background\n // on Safari. See https://github.com/prosekit/prosekit/issues/1153 for more\n // details.\n top: '-1000vh',\n left: '-1000vw',\n\n // The element should not be interactive.\n pointerEvents: 'none',\n\n zIndex: maxZIndex,\n\n // Only reliable cross browser technique found to push a drag preview away\n // from the cursor is to use transparent borders on the container.\n // https://github.com/atlassian/pragmatic-drag-and-drop/blob/56276552/packages/core/src/public-utils/element/custom-native-drag-preview/pointer-outside-of-preview.ts#L13-L18\n borderLeft: `${borderX}px solid transparent`,\n borderTop: `${borderY}px solid transparent`,\n\n boxSizing: 'border-box',\n width: `${width + borderX}px`,\n height: `${height + borderY}px`,\n })\n\n const clonedElement = element.cloneNode(true) as HTMLElement\n\n // A hardcoded opacity.\n clonedElement.style.setProperty('opacity', '0.8', 'important')\n // Hide the outline of the cloned element.\n clonedElement.style.setProperty('outline-color', 'transparent', 'important')\n\n container.appendChild(clonedElement)\n document.body.appendChild(container)\n\n event.dataTransfer?.setDragImage(container, Math.max(-outsideX, 0), Math.max(-outsideY, 0))\n\n requestAnimationFrame(() => {\n container.remove()\n })\n}\n","import {\n defineCustomElement,\n defineProps,\n onMount,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { useAttribute, useEventListener } from '@aria-ui/utils'\nimport { isHTMLElement } from '@ocavue/utils'\nimport type { Editor } from '@prosekit/core'\nimport type { ViewDragging } from '@prosekit/extensions/drop-indicator'\nimport { Fragment, Slice } from '@prosekit/pm/model'\nimport { NodeSelection } from '@prosekit/pm/state'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { DRAGGING_CLASS_NAME } from '../../constants.ts'\nimport { getSafeEditorView } from '../../utils/get-safe-editor-view.ts'\n\nimport { blockHandleStoreContext } from './context.ts'\nimport type { HoverState } from './hover-state.ts'\nimport { setDragPreview } from './set-drag-preview.ts'\n\nexport interface BlockHandleDraggableProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const BlockHandleDraggablePropsDeclaration: PropsDeclaration<BlockHandleDraggableProps> = /* @__PURE__ */ defineProps<\n BlockHandleDraggableProps\n>({\n editor: { default: null, attribute: false, type: 'json' },\n})\n\n/**\n * @internal\n */\nexport function setupBlockHandleDraggable(\n host: HostElement,\n props: State<BlockHandleDraggableProps>,\n): void {\n const getStore = blockHandleStoreContext.consume(host)\n\n onMount(host, () => {\n host.draggable = true\n })\n\n usePointerDownHandler(host, () => getStore()?.hoverState.get() ?? null, props.editor.get)\n\n useEventListener(host, 'dragstart', (event) => {\n const store = getStore()\n store?.dragging.set(true)\n\n const view = getSafeEditorView(props.editor.get())\n const hoverState = store?.hoverState.get()\n\n if (view && hoverState) {\n view.dom.classList.add(DRAGGING_CLASS_NAME)\n createDraggingPreview(view, hoverState, event)\n setViewDragging(view, hoverState)\n }\n })\n\n useEventListener(host, 'dragend', () => {\n const store = getStore()\n store?.dragging.set(false)\n\n const view = getSafeEditorView(props.editor.get())\n if (view) {\n view.dom.classList.remove(DRAGGING_CLASS_NAME)\n }\n })\n\n useAttribute(host, 'data-dragging', () => (getStore()?.dragging.get() ? '' : undefined))\n}\n\nfunction usePointerDownHandler(\n host: HostElement,\n getHoverState: () => HoverState | null,\n getEditor: () => Editor | null,\n) {\n useEventListener(host, 'pointerdown', () => {\n const hoverState = getHoverState()\n const editor = getEditor()\n\n if (hoverState?.pos == null || !editor?.view) {\n return\n }\n\n const { view } = editor\n view.dispatch(\n view.state.tr.setSelection(NodeSelection.create(view.state.doc, hoverState.pos)),\n )\n\n // Clicking the handle will blur the editor, so we need to focus it again.\n // We cannot call `event.preventDefault()` here to prevent the blur\n // because it will prevent the drag event from firing.\n requestAnimationFrame(() => {\n view.focus()\n })\n })\n}\n\nfunction createDraggingPreview(view: EditorView, hoverState: HoverState, event: DragEvent): void {\n if (!event.dataTransfer) {\n return\n }\n\n const { pos } = hoverState\n\n const element = view.nodeDOM(pos)\n if (!element || !isHTMLElement(element)) {\n return\n }\n\n event.dataTransfer.clearData()\n event.dataTransfer.setData('text/html', element.outerHTML)\n event.dataTransfer.effectAllowed = 'copyMove'\n setDragPreview(event, element)\n\n return\n}\n\nfunction setViewDragging(view: EditorView, hoverState: HoverState): void {\n const { node, pos } = hoverState\n\n const dragging: ViewDragging = {\n slice: new Slice(Fragment.from(node), 0, 0),\n move: true,\n node: NodeSelection.create(view.state.doc, pos),\n }\n\n view.dragging = dragging\n}\n\nconst BlockHandleDraggableElementBase: HostElementConstructor<BlockHandleDraggableProps> = defineCustomElement(\n setupBlockHandleDraggable,\n BlockHandleDraggablePropsDeclaration,\n)\n\n/**\n * `<prosekit-block-handle-draggable>` custom element.\n *\n * Properties: {@link BlockHandleDraggableProps}\n *\n * Data attributes:\n *\n * | Attribute | Description |\n * | --- | --- |\n * | `data-dragging` | Present when the element is being dragged |\n */\nexport class BlockHandleDraggableElement extends BlockHandleDraggableElementBase {}\n\n/** @internal */\nexport function registerBlockHandleDraggableElement(): void {\n registerCustomElement('prosekit-block-handle-draggable', BlockHandleDraggableElement)\n}\n","import {\n defineCustomElement,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { OverlayPopupPropsDeclaration, setupOverlayPopup, type OverlayPopupProps } from '@aria-ui/elements/overlay'\n\nimport { blockHandleOverlayStoreContext } from './context.ts'\n\n/**\n * @public\n */\nexport interface BlockHandlePopupProps extends OverlayPopupProps {}\n\n/** @internal */\nexport const BlockHandlePopupPropsDeclaration: PropsDeclaration<BlockHandlePopupProps> = OverlayPopupPropsDeclaration\n\n/** @internal */\nexport function setupBlockHandlePopup(\n host: HostElement,\n _props: State<BlockHandlePopupProps>,\n): void {\n const getOverlayStore = blockHandleOverlayStoreContext.consume(host)\n setupOverlayPopup(host, getOverlayStore)\n}\n\nconst BlockHandlePopupElementBase: HostElementConstructor<BlockHandlePopupProps> = defineCustomElement(\n setupBlockHandlePopup,\n BlockHandlePopupPropsDeclaration,\n)\n\n/**\n * `<prosekit-block-handle-popup>` custom element.\n *\n * Properties: {@link BlockHandlePopupProps}\n *\n * Data attributes:\n *\n * | Attribute | Description |\n * | --- | --- |\n * | `data-state` | `\"open\"` when the block handle is visible, `\"closed\"` otherwise |\n */\nexport class BlockHandlePopupElement extends BlockHandlePopupElementBase {}\n\n/** @internal */\nexport function registerBlockHandlePopupElement(): void {\n registerCustomElement('prosekit-block-handle-popup', BlockHandlePopupElement)\n}\n","import {\n defineCustomElement,\n defineProps,\n registerCustomElement,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { OverlayPositionerPropsDeclaration, setupOverlayPositioner, type OverlayPositionerProps } from '@aria-ui/elements/overlay'\nimport type { Placement } from '@floating-ui/dom'\n\nimport { blockHandleOverlayStoreContext } from './context.ts'\n\n/**\n * @public\n */\nexport interface BlockHandlePositionerProps extends Omit<OverlayPositionerProps, 'placement' | 'hoist' | 'flip' | 'shift' | 'hide'> {\n /**\n * The placement of the popover, relative to the hovered block.\n *\n * @default \"left\"\n */\n placement: Placement\n\n /**\n * Whether to use the browser [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)\n * to place the floating element on top of other page content.\n *\n * @default false\n */\n hoist: boolean\n\n /**\n * @default false\n * @hidden\n */\n flip: boolean\n\n /**\n * @default false\n * @hidden\n */\n shift: boolean\n\n /**\n * @default true\n * @hidden\n */\n hide: boolean\n}\n\n/** @internal */\nexport const BlockHandlePositionerPropsDeclaration: PropsDeclaration<BlockHandlePositionerProps> = /* @__PURE__ */ defineProps<\n BlockHandlePositionerProps\n>({\n ...OverlayPositionerPropsDeclaration,\n placement: { default: 'left', attribute: 'placement', type: 'string' },\n // Enabling `hoist` will cause the popover to have a small delay when\n // scrolling the page.\n hoist: { default: false, attribute: 'hoist', type: 'boolean' },\n flip: { default: false, attribute: false, type: 'json' },\n shift: { default: false, attribute: 'shift', type: 'boolean' },\n hide: { default: true, attribute: 'hide', type: 'boolean' },\n})\n\n/** @internal */\nexport function setupBlockHandlePositioner(\n host: HostElement,\n props: State<BlockHandlePositionerProps>,\n): void {\n const getOverlayStore = blockHandleOverlayStoreContext.consume(host)\n setupOverlayPositioner(host, props as unknown as State<OverlayPositionerProps>, getOverlayStore)\n}\n\nconst BlockHandlePositionerElementBase: HostElementConstructor<BlockHandlePositionerProps> = defineCustomElement(\n setupBlockHandlePositioner,\n BlockHandlePositionerPropsDeclaration,\n)\n\n/**\n * `<prosekit-block-handle-positioner>` custom element.\n *\n * Properties: {@link BlockHandlePositionerProps}\n *\n * Data attributes:\n *\n * | Attribute | Description |\n * | --- | --- |\n * | `data-state` | `\"open\"` when the block handle is visible, `\"closed\"` otherwise |\n * | `data-side` | The side of the anchor element the positioner is on |\n * | `data-align` | The alignment of the positioner relative to the anchor element |\n *\n * CSS variables:\n *\n * | Variable | Description |\n * | --- | --- |\n * | `--transform-origin` | The coordinates that this element is anchored to. Useful for scale animations. |\n */\nexport class BlockHandlePositionerElement extends BlockHandlePositionerElementBase {}\n\n/** @internal */\nexport function registerBlockHandlePositionerElement(): void {\n registerCustomElement('prosekit-block-handle-positioner', BlockHandlePositionerElement)\n}\n","export function prefersReducedMotion(): boolean {\n if (typeof window === 'undefined') {\n return false\n }\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches\n}\n","import type { ProseMirrorNode } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport interface HoverState {\n node: ProseMirrorNode\n pos: number\n}\n\n/**\n * @internal\n */\nexport function isHoverStateEqual(a: HoverState, b: HoverState): boolean {\n return a.pos === b.pos && a.node.eq(b.node)\n}\n","import type { VirtualElement } from '@floating-ui/dom'\nimport { isElement, isHTMLElement, isTextNode, throttle } from '@ocavue/utils'\nimport { defineDOMEventHandler, union, type PlainExtension } from '@prosekit/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { getClientRect } from '../../utils/get-client-rect.ts'\n\nimport type { HoverState } from './hover-state.ts'\n\nexport type ElementHoverHandler = (\n reference?: VirtualElement,\n hoverState?: HoverState,\n) => void\n\nexport function defineElementHoverHandler(handler: ElementHoverHandler): PlainExtension {\n const handleElement = (\n node: ProseMirrorNode,\n pos: number,\n element: HTMLElement,\n parentElement?: Node | null,\n ) => {\n const reference: VirtualElement = {\n contextElement: element,\n\n getBoundingClientRect: () => {\n const rect = findFirstLineRect(parentElement, element)\n return rect ? fulfillRect(rect) : fallbackRect\n },\n }\n\n handler(reference, { node, pos })\n }\n\n let lastX = -1\n let lastY = -1\n let lastTime = -1\n\n const handlePointerEvent = (view: EditorView, event: PointerEvent) => {\n const { x, y } = event\n\n // Simple performance optimization. If the pointer is not moving, we don't\n // want to recalculate the block handle position within a short period of\n // time window.\n if (lastX === x && lastY === y) {\n const now = Date.now()\n if (now - lastTime < 100) {\n return\n }\n lastTime = now\n }\n lastX = x\n lastY = y\n\n const block = findBlockByCoords(view, x, y)\n if (!block) {\n handler()\n return\n }\n\n const { node, pos } = block\n const element = view.nodeDOM(pos)\n if (!element || !isHTMLElement(element)) {\n handler()\n return\n }\n\n // If `node` is the first child of another non-doc block node, for example a\n // list node or a blockquote node, we want to put the block handle agains\n // the parent node.\n const $pos = view.state.doc.resolve(pos)\n if ($pos.depth > 0 && $pos.index($pos.depth) === 0) {\n const parentPos = $pos.before($pos.depth)\n const parentNode = $pos.parent\n const parentElement = view.nodeDOM(parentPos)\n handleElement(parentNode, parentPos, element, parentElement)\n } else {\n handleElement(node, pos, element)\n }\n }\n\n return union(\n defineDOMEventHandler('pointermove', throttle(handlePointerEvent, 200)),\n defineDOMEventHandler('pointerenter', handlePointerEvent),\n defineDOMEventHandler('pointerout', handlePointerEvent),\n defineDOMEventHandler('keypress', () => handler()),\n )\n}\n\nfunction findBlockByCoords(view: EditorView, x: number, y: number): { node: ProseMirrorNode; pos: number } | undefined {\n const rect = getClientRect(view.dom)\n if (!isWithinRect(rect, x, y)) {\n return\n }\n\n let parent: ProseMirrorNode | undefined = view.state.doc\n let pos = -1\n\n while (parent) {\n if (parent.isBlock && (parent.isTextblock || parent.isAtom || parent.type.spec.isolating)) {\n return { node: parent, pos }\n }\n\n // Collect all children and their positions\n const children: ProseMirrorNode[] = []\n const positions: number[] = []\n parent.forEach((child, offset) => {\n children.push(child)\n positions.push(offset + pos + 1)\n })\n\n let lo = 0\n let hi = children.length - 1\n\n while (lo <= hi) {\n const i = hi - ((hi - lo) >> 1)\n const childDOM = view.nodeDOM(positions[i])\n const childRect = getNodeRect(childDOM)\n if (!childRect) {\n console.warn(`[prosekit] Unable to get rect at position: ${positions[i]}`)\n return\n }\n if (childRect.top > y) {\n hi = i - 1\n } else if (childRect.bottom < y) {\n lo = i + 1\n } else {\n lo = i\n break\n }\n }\n\n if (lo > hi) {\n return\n }\n\n parent = children[lo]\n pos = positions[lo]\n }\n}\n\nfunction getNodeRect(node: Node | null | undefined): Rect | undefined {\n if (node && isElement(node) && node.isConnected) {\n return getClientRect(node)\n }\n}\n\nfunction isWithinRect(rect: Rect, x: number, y: number) {\n return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom\n}\n\ninterface Rect {\n top: number\n right: number\n bottom: number\n left: number\n}\n\nfunction findFirstLineRect(outer?: Node | null, inner?: Node | null): Rect | undefined {\n if (outer && !outer.isConnected) {\n return\n }\n if (inner && !inner.isConnected) {\n return\n }\n\n if (outer && inner) {\n const outerRect = findOuterRect(outer)\n const innerRect = findFirstLineRectInNode(inner)\n if (outerRect && innerRect) {\n const { top, bottom } = innerRect\n const { left, right } = outerRect\n return { top, bottom, left, right }\n } else {\n return outerRect || innerRect\n }\n } else if (outer) {\n return findFirstLineRectInNode(outer)\n } else if (inner) {\n return findFirstLineRectInNode(inner)\n }\n}\n\nfunction findOuterRect(node: Node): Rect | undefined {\n if (!isElement(node)) {\n return\n }\n\n return getClientRect(node, { left: true, right: true })\n}\n\nfunction findFirstLineRectInNode(node: Node): Rect | undefined {\n if (isElement(node)) {\n return findFirstLineRectInElement(node)\n } else if (isTextNode(node)) {\n return findFirstLineRectInTextNode(node)\n }\n}\n\nfunction findFirstLineRectInTextNode(node: Text): Rect | undefined {\n const ownerDocument = node.ownerDocument\n if (!ownerDocument) {\n return\n }\n const range = ownerDocument.createRange()\n range.setStart(node, 0)\n range.setEnd(node, 0)\n const rects = range.getClientRects()\n return rects[0]\n}\n\nfunction findFirstLineRectInElement(element: Element): Rect | undefined {\n if (element.nodeName === 'BR') {\n return element.getBoundingClientRect()\n }\n\n const rect = getClientRect(element)\n const style = element.ownerDocument.defaultView?.getComputedStyle(element)\n const marginLeft = style && Number.parseInt(style.marginLeft, 10) || 0\n const marginRight = style && Number.parseInt(style.marginRight, 10) || 0\n const left = rect.left - marginLeft\n const right = rect.right + marginRight\n\n const lineHeight = style && Number.parseInt(style.lineHeight, 10) || 24\n const paddingTop = style && Number.parseInt(style.paddingTop, 10) || 0\n const borderTop = style && Number.parseInt(style.borderTopWidth, 10) || 0\n const top = rect.top + paddingTop + borderTop\n const bottom = top + lineHeight\n\n return { top, bottom, left, right }\n}\n\nfunction fulfillRect({ top, right, bottom, left }: Rect) {\n return { top, right, bottom, left, width: right - left, height: bottom - top, x: left, y: top }\n}\n\n// A fallback rect that is far away from the screen. It should not be used through.\nconst fallbackRect = Object.freeze({\n top: -9999,\n right: -9999,\n bottom: -9999,\n left: -9999,\n width: 0,\n height: 0,\n x: -9999,\n y: -9999,\n})\n","import type { HostElement } from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nimport { useEditorExtension } from '../../hooks/use-editor-extension.ts'\nimport { prefersReducedMotion } from '../../utils/prefers-reduced-motion.ts'\n\nimport { isHoverStateEqual, type HoverState } from './hover-state.ts'\nimport { defineElementHoverHandler, type ElementHoverHandler } from './pointer-move.ts'\n\nexport function useHoverExtension(\n host: HostElement,\n getEditor: () => Editor | null,\n handler: ElementHoverHandler,\n): void {\n const invalidTimeoutMs = prefersReducedMotion() ? 0 : 180\n\n let invalidTimeoutId: ReturnType<typeof setTimeout> | undefined\n\n let prevHoverState: HoverState | undefined\n\n const callHandler: ElementHoverHandler = (reference, hoverState) => {\n prevHoverState = hoverState\n handler(reference, hoverState)\n }\n\n const extension = defineElementHoverHandler((reference, hoverState) => {\n if (hoverState && invalidTimeoutId != null) {\n clearTimeout(invalidTimeoutId)\n invalidTimeoutId = undefined\n }\n\n if (prevHoverState && hoverState) {\n if (isHoverStateEqual(prevHoverState, hoverState)) {\n return\n }\n callHandler(reference, hoverState)\n return\n }\n\n if (!prevHoverState && !hoverState) {\n return\n }\n\n if (!prevHoverState && hoverState) {\n callHandler(reference, hoverState)\n return\n }\n\n if (prevHoverState && !hoverState) {\n if (invalidTimeoutId != null) {\n return\n }\n\n // Wait for a short period of time before invalidating the hover state.\n // This ensures smoother animation when the pointer moves between two\n // blocks with a small gap.\n invalidTimeoutId = setTimeout(() => {\n callHandler(reference, undefined)\n invalidTimeoutId = undefined\n }, invalidTimeoutMs)\n }\n })\n\n useEditorExtension(host, getEditor, extension)\n}\n","import {\n computed,\n createSignal,\n defineCustomElement,\n defineProps,\n registerCustomElement,\n useEffect,\n type HostElement,\n type HostElementConstructor,\n type PropsDeclaration,\n type State,\n} from '@aria-ui/core'\nimport { createOverlayStore } from '@aria-ui/elements/overlay'\nimport type { VirtualElement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\n\nimport { useScrolling } from '../../hooks/use-scrolling.ts'\n\nimport { blockHandleOverlayStoreContext, BlockHandleStore, blockHandleStoreContext } from './context.ts'\nimport { useHoverExtension } from './use-hover-extension.ts'\n\nexport interface BlockHandleRootProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n}\n\n/** @internal */\nexport const BlockHandleRootPropsDeclaration: PropsDeclaration<BlockHandleRootProps> = /* @__PURE__ */ defineProps<\n BlockHandleRootProps\n>({\n editor: { default: null, attribute: false, type: 'json' },\n})\n\n/**\n * @public\n */\nexport class BlockHandleStateChangeEvent extends Event {\n /**\n * The currently hovered block's node and position, or `null` if no block is hovered.\n */\n detail: { node: ProseMirrorNode; pos: number } | null\n constructor(state: { node: ProseMirrorNode; pos: number } | null) {\n super('stateChange', { bubbles: true })\n this.detail = state\n }\n}\n\n/**\n * @public\n */\nexport interface BlockHandleRootEvents {\n /**\n * Fired when the hovered block changes.\n */\n stateChange: BlockHandleStateChangeEvent\n}\n\n/**\n * @internal\n */\nexport function setupBlockHandleRoot(\n host: HostElement,\n props: State<BlockHandleRootProps>,\n): void {\n const getEditor = props.editor.get\n\n const store = new BlockHandleStore()\n blockHandleStoreContext.provide(host, store)\n\n const reference = createSignal<VirtualElement | undefined>(undefined)\n const getScrolling = useScrolling(host)\n\n const getOpen = computed(() => !!store.hoverState.get() && !getScrolling())\n\n const overlayStore = createOverlayStore(\n getOpen,\n () => {},\n () => true,\n () => false,\n (event) => host.dispatchEvent(event),\n )\n\n useHoverExtension(host, getEditor, (ref, hoverState) => {\n reference.set(ref ?? undefined)\n store.hoverState.set(hoverState)\n const state = hoverState ? { node: hoverState.node, pos: hoverState.pos } : null\n host.dispatchEvent(new BlockHandleStateChangeEvent(state))\n })\n\n useEffect(host, () => {\n overlayStore.setAnchorElement(reference.get())\n })\n\n blockHandleOverlayStoreContext.provide(host, overlayStore)\n}\n\nconst BlockHandleRootElementBase: HostElementConstructor<BlockHandleRootProps> = defineCustomElement(\n setupBlockHandleRoot,\n BlockHandleRootPropsDeclaration,\n)\n\n/**\n * `<prosekit-block-handle-root>` custom element.\n *\n * Properties: {@link BlockHandleRootProps}\n *\n * Events: {@link BlockHandleRootEvents}\n */\nexport class BlockHandleRootElement extends BlockHandleRootElementBase {}\n\n/** @internal */\nexport function registerBlockHandleRootElement(): void {\n registerCustomElement('prosekit-block-handle-root', BlockHandleRootElement)\n}\n"],"mappings":";;;;;;;;;;;;;AAQA,IAAa,mBAAb,MAA8B;;oBAC0B,aAAqC,KAAA,EAAU;kBAChE,aAAa,MAAM;;;;;;AAM1D,MAAa,0BAAqD,cAAgC,8BAA8B;;;;AAKhI,MAAa,iCAAwD,cAA4B,sCAAsC;;ACIvI,MAAa,iCAAwF,4BAAiC,EACpI,QAAQ;CAAE,SAAS;CAAM,WAAW;CAAO,MAAM;CAAQ,EAC1D,CAAC;;;;AAKF,SAAgB,oBACd,MACA,OACM;CACN,MAAM,WAAW,wBAAwB,QAAQ,KAAK;AAEtD,kBAAiB,MAAM,gBAAgB,UAAU;AAC/C,QAAM,gBAAgB;EAEtB,MAAM,QAAQ,UAAU;EACxB,MAAM,S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pC,yBAAwB,QAAQ,MAAM,MAAM;CAE5C,MAAM,YAAY,aAAyC,KAAA,EAAU;CACrE,MAAM,eAAe,aAAa,KAAK;CAIvC,MAAM,eAAe,mBAFL,eAAe,CAAC,CAAC,MAAM,WAAW,KAAK,IAAI,CAAC,cAAc,CAAC,QAInE,UACA,YACA,QACL,UAAU,KAAK,cAAc,MAAM,CACrC;AAED,mBAAkB,MAAM,YAAY,KAAK,eAAe;AACtD,YAAU,IAAI,OAAO,KAAA,EAAU;AAC/B,QAAM,WAAW,IAAI,WAAW;EAChC,MAAM,QAAQ,aAAa;GAAE,MAAM,WAAW;GAAM,KAAK,WAAW;GAAK,GAAG;AAC5E,OAAK,cAAc,IAAI,4BAA4B,MAAM,CAAC;GAC1D;AAEF,WAAU,YAAY;AACpB,eAAa,iBAAiB,UAAU,KAAK,CAAC;GAC9C;AAEF,gCAA+B,QAAQ,MAAM,aAAa;;AAG5D,MAAM,6BAA2E,oBAC/E,sBACA,gCACD;;;;;;;;AASD,IAAa,yBAAb,cAA4C,2BAA2B;;AAGvE,SAAgB,iCAAuC;AACrD,uBAAsB,8BAA8B,uBAAuB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"prosekit-web-drop-indicator.d.ts","names":[],"sources":["../src/components/drop-indicator/drop-indicator.ts"],"mappings":";;UAoBiB,kBAAA;EAAA;;;;;;EAOf,MAAA,EAAQ,MAAA;EAOH;;AAIP;;;EAJE,KAAA;AAAA;AAoBF;AAAA,cAhBa,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;;;;;;cAU1C,oBAAA,SAA6B,wBAAA;;AAZzC;;iBAiBe,4BAAA,CAAA"}
@@ -1 +0,0 @@
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 * `<prosekit-drop-indicator>` custom element.\n *\n * Properties: {@link DropIndicatorProps}\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;;;;;;AAOD,IAAa,uBAAb,cAA0C,yBAAyB;;;;AAKnE,SAAgB,+BAAqC;AACnD,uBAAsB,2BAA2B,qBAAqB"}
@@ -1 +0,0 @@
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":";;;;;AAkBA;UAAiB,uBAAA,SAAgC,iBAAA;;cAGpC,kCAAA,EAAoC,gBAAA,CAAiB,uBAAA;AAAlE;AAAA,iBAGgB,uBAAA,CACd,IAAA,EAAM,WAAA,EACN,MAAA,EAAQ,KAAA,CAAM,uBAAA;AAAA,cAYV,6BAAA,EAA+B,sBAAA,CAAuB,uBAAA;;;AAd5D;;;;;;;;;cA8Ba,yBAAA,SAAkC,6BAAA;;iBAG/B,iCAAA,CAAA;;;AAvChB;UCFiB,4BAAA,SACf,IAAA,CACE,sBAAA;;;;ADGJ;;ECYE,SAAA,EAAW,sBAAA;EDZoC;;AAGjD;;;ECgBE,MAAA,EAAQ,sBAAA;EDdM;;;;;;ECsBd,IAAA,EAAM,sBAAA;EDtBQ;;;;AAUf;;ECoBC,KAAA;EDlBmC;;AAgBrC;;;;ECUE,OAAA,EAAS,sBAAA;EDPK;;;;;;ECed,MA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