@prosekit/web 0.7.11 → 0.7.13

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 (113) hide show
  1. package/dist/{get-default-state-BzBimBWi.js → get-default-state.js} +2 -3
  2. package/dist/get-default-state.js.map +1 -0
  3. package/dist/{get-safe-editor-view-Dt9Amrcn.js → get-safe-editor-view.js} +2 -2
  4. package/dist/get-safe-editor-view.js.map +1 -0
  5. package/dist/prosekit-web-autocomplete.d.ts.map +1 -1
  6. package/dist/prosekit-web-autocomplete.js +8 -23
  7. package/dist/prosekit-web-autocomplete.js.map +1 -1
  8. package/dist/prosekit-web-block-handle.js +53 -80
  9. package/dist/prosekit-web-block-handle.js.map +1 -1
  10. package/dist/prosekit-web-drop-indicator.js +3 -6
  11. package/dist/prosekit-web-drop-indicator.js.map +1 -1
  12. package/dist/prosekit-web-inline-popover.js +2 -9
  13. package/dist/prosekit-web-inline-popover.js.map +1 -1
  14. package/dist/prosekit-web-popover.js +1 -4
  15. package/dist/prosekit-web-popover.js.map +1 -1
  16. package/dist/prosekit-web-resizable.d.ts.map +1 -1
  17. package/dist/prosekit-web-resizable.js +30 -13
  18. package/dist/prosekit-web-resizable.js.map +1 -1
  19. package/dist/prosekit-web-table-handle.js +76 -48
  20. package/dist/prosekit-web-table-handle.js.map +1 -1
  21. package/dist/prosekit-web-tooltip.js +1 -4
  22. package/dist/prosekit-web-tooltip.js.map +1 -1
  23. package/dist/prosekit-web.js +1 -1
  24. package/dist/prosekit-web.js.map +1 -1
  25. package/dist/{use-editor-extension-B2WuUfnd.js → use-editor-extension.js} +2 -3
  26. package/dist/use-editor-extension.js.map +1 -0
  27. package/dist/{use-scrolling-BjVzAkiZ.js → use-scrolling.js} +2 -4
  28. package/dist/use-scrolling.js.map +1 -0
  29. package/package.json +11 -10
  30. package/src/components/autocomplete/autocomplete-empty/element.gen.ts +2 -2
  31. package/src/components/autocomplete/autocomplete-item/element.gen.ts +2 -2
  32. package/src/components/autocomplete/autocomplete-item/setup.ts +2 -2
  33. package/src/components/autocomplete/autocomplete-list/element.gen.ts +2 -2
  34. package/src/components/autocomplete/autocomplete-list/setup.ts +6 -5
  35. package/src/components/autocomplete/autocomplete-popover/element.gen.ts +2 -2
  36. package/src/components/autocomplete/autocomplete-popover/helpers.spec.ts +1 -1
  37. package/src/components/autocomplete/autocomplete-popover/helpers.ts +2 -2
  38. package/src/components/autocomplete/autocomplete-popover/setup.ts +8 -8
  39. package/src/components/autocomplete/index.gen.ts +12 -12
  40. package/src/components/block-handle/block-handle-add/element.gen.ts +2 -2
  41. package/src/components/block-handle/block-handle-add/setup.ts +2 -2
  42. package/src/components/block-handle/block-handle-draggable/element.gen.ts +2 -2
  43. package/src/components/block-handle/block-handle-draggable/set-drag-preview.ts +12 -13
  44. package/src/components/block-handle/block-handle-draggable/setup.ts +9 -14
  45. package/src/components/block-handle/block-handle-popover/element.gen.ts +2 -2
  46. package/src/components/block-handle/block-handle-popover/pointer-move.ts +4 -12
  47. package/src/components/block-handle/block-handle-popover/setup.ts +6 -8
  48. package/src/components/block-handle/index.gen.ts +9 -9
  49. package/src/components/drop-indicator/drop-indicator/element.gen.ts +2 -2
  50. package/src/components/drop-indicator/drop-indicator/setup.ts +4 -4
  51. package/src/components/drop-indicator/index.gen.ts +3 -3
  52. package/src/components/inline-popover/index.gen.ts +3 -3
  53. package/src/components/inline-popover/inline-popover/element.gen.ts +2 -2
  54. package/src/components/inline-popover/inline-popover/setup.ts +5 -5
  55. package/src/components/popover/index.gen.ts +9 -9
  56. package/src/components/popover/popover-content/element.gen.ts +2 -2
  57. package/src/components/popover/popover-root/element.gen.ts +2 -2
  58. package/src/components/popover/popover-trigger/element.gen.ts +2 -2
  59. package/src/components/resizable/index.gen.ts +6 -6
  60. package/src/components/resizable/resizable-handle/calc-resize.spec.ts +1 -1
  61. package/src/components/resizable/resizable-handle/calc-resize.ts +1 -1
  62. package/src/components/resizable/resizable-handle/element.gen.ts +2 -2
  63. package/src/components/resizable/resizable-handle/setup.ts +11 -4
  64. package/src/components/resizable/resizable-root/element.gen.ts +2 -2
  65. package/src/components/resizable/resizable-root/setup.ts +11 -4
  66. package/src/components/resizable/resizable-root/types.ts +37 -3
  67. package/src/components/table-handle/context.ts +1 -1
  68. package/src/components/table-handle/dnd.ts +3 -3
  69. package/src/components/table-handle/hooks/use-drop.ts +2 -2
  70. package/src/components/table-handle/index.gen.ts +27 -27
  71. package/src/components/table-handle/table-handle-column-root/element.gen.ts +2 -2
  72. package/src/components/table-handle/table-handle-column-root/setup.ts +4 -4
  73. package/src/components/table-handle/table-handle-column-trigger/element.gen.ts +2 -2
  74. package/src/components/table-handle/table-handle-column-trigger/setup.ts +3 -3
  75. package/src/components/table-handle/table-handle-drag-preview/element.gen.ts +2 -2
  76. package/src/components/table-handle/table-handle-drag-preview/render-preview.ts +5 -5
  77. package/src/components/table-handle/table-handle-drag-preview/setup.ts +5 -5
  78. package/src/components/table-handle/table-handle-drag-preview/updater.ts +4 -4
  79. package/src/components/table-handle/table-handle-drop-indicator/element.gen.ts +2 -2
  80. package/src/components/table-handle/table-handle-drop-indicator/setup.ts +4 -4
  81. package/src/components/table-handle/table-handle-drop-indicator/updater.ts +5 -5
  82. package/src/components/table-handle/table-handle-popover-content/element.gen.ts +2 -2
  83. package/src/components/table-handle/table-handle-popover-content/setup.ts +3 -3
  84. package/src/components/table-handle/table-handle-popover-item/element.gen.ts +2 -2
  85. package/src/components/table-handle/table-handle-popover-item/setup.ts +1 -1
  86. package/src/components/table-handle/table-handle-root/element.gen.ts +2 -2
  87. package/src/components/table-handle/table-handle-root/setup.ts +8 -8
  88. package/src/components/table-handle/table-handle-row-root/element.gen.ts +2 -2
  89. package/src/components/table-handle/table-handle-row-root/setup.ts +4 -4
  90. package/src/components/table-handle/table-handle-row-trigger/element.gen.ts +2 -2
  91. package/src/components/table-handle/table-handle-row-trigger/setup.ts +3 -3
  92. package/src/components/tooltip/index.gen.ts +9 -9
  93. package/src/components/tooltip/tooltip-content/element.gen.ts +2 -2
  94. package/src/components/tooltip/tooltip-root/element.gen.ts +2 -2
  95. package/src/components/tooltip/tooltip-trigger/element.gen.ts +2 -2
  96. package/src/constants.ts +1 -0
  97. package/src/hooks/use-editor-focus-event.ts +1 -1
  98. package/src/hooks/use-editor-typing.ts +1 -1
  99. package/src/hooks/use-editor-update-event.ts +1 -1
  100. package/src/hooks/use-keymap.ts +1 -1
  101. package/src/hooks/use-selecting.ts +1 -1
  102. package/src/index.ts +1 -1
  103. package/src/utils/fade-color.ts +1 -1
  104. package/src/utils/get-client-rect.ts +47 -9
  105. package/src/utils/get-default-state.spec.ts +1 -1
  106. package/dist/get-default-state-BzBimBWi.js.map +0 -1
  107. package/dist/get-safe-editor-view-Dt9Amrcn.js.map +0 -1
  108. package/dist/inject-style-BaFaVQvj.js +0 -76
  109. package/dist/inject-style-BaFaVQvj.js.map +0 -1
  110. package/dist/use-editor-extension-B2WuUfnd.js.map +0 -1
  111. package/dist/use-scrolling-BjVzAkiZ.js.map +0 -1
  112. package/src/utils/get-box-element.ts +0 -20
  113. package/src/utils/throttle.ts +0 -17
@@ -1,7 +1,7 @@
1
1
  import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
2
2
 
3
- import { useAutocompleteItem } from "./setup"
4
- import { autocompleteItemEvents, autocompleteItemProps, type AutocompleteItemEvents, type AutocompleteItemProps } from "./types"
3
+ import { useAutocompleteItem } from "./setup.ts"
4
+ import { autocompleteItemEvents, autocompleteItemProps, type AutocompleteItemEvents, type AutocompleteItemProps } from "./types.ts"
5
5
 
6
6
  const AutocompleteItemElementBase: BaseElementConstructor<AutocompleteItemProps> = defineCustomElement<
7
7
  AutocompleteItemProps,
@@ -1,9 +1,9 @@
1
1
  import { useEffect, useEventListener, type ConnectableElement, type SetupOptions } from '@aria-ui/core'
2
2
  import { useListboxItem } from '@aria-ui/listbox/elements'
3
3
 
4
- import { openContext } from '../context'
4
+ import { openContext } from '../context.ts'
5
5
 
6
- import type { AutocompleteItemEvents, AutocompleteItemProps } from './types'
6
+ import type { AutocompleteItemEvents, AutocompleteItemProps } from './types.ts'
7
7
 
8
8
  /**
9
9
  * @internal
@@ -1,7 +1,7 @@
1
1
  import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
2
2
 
3
- import { useAutocompleteList } from "./setup"
4
- import { autocompleteListEvents, autocompleteListProps, type AutocompleteListEvents, type AutocompleteListProps } from "./types"
3
+ import { useAutocompleteList } from "./setup.ts"
4
+ import { autocompleteListEvents, autocompleteListProps, type AutocompleteListEvents, type AutocompleteListProps } from "./types.ts"
5
5
 
6
6
  const AutocompleteListElementBase: BaseElementConstructor<AutocompleteListProps> = defineCustomElement<
7
7
  AutocompleteListProps,
@@ -7,12 +7,13 @@ import {
7
7
  type TypedEventTarget,
8
8
  } from '@aria-ui/core'
9
9
  import { listboxProps, useListbox, type ListboxProps } from '@aria-ui/listbox/elements'
10
- import { defineDOMEventHandler, Priority, withPriority, type Editor } from '@prosekit/core'
10
+ import type { Priority } from '@prosekit/core'
11
+ import { defineDOMEventHandler, withPriority, type Editor } from '@prosekit/core'
11
12
 
12
- import { getStateWithDefaults } from '../../../utils/get-default-state'
13
- import { onSubmitContext, openContext, queryContext } from '../context'
13
+ import { getStateWithDefaults } from '../../../utils/get-default-state.ts'
14
+ import { onSubmitContext, openContext, queryContext } from '../context.ts'
14
15
 
15
- import type { AutocompleteListEvents, AutocompleteListProps } from './types'
16
+ import type { AutocompleteListEvents, AutocompleteListProps } from './types.ts'
16
17
 
17
18
  /**
18
19
  * @internal
@@ -103,7 +104,7 @@ function useKeyDownTarget(
103
104
  },
104
105
  )
105
106
 
106
- return editorValue.use(withPriority(extension, Priority.highest))
107
+ return editorValue.use(withPriority(extension, 4 satisfies typeof Priority.highest))
107
108
  })
108
109
 
109
110
  return {
@@ -1,7 +1,7 @@
1
1
  import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
2
2
 
3
- import { useAutocompletePopover } from "./setup"
4
- import { autocompletePopoverEvents, autocompletePopoverProps, type AutocompletePopoverEvents, type AutocompletePopoverProps } from "./types"
3
+ import { useAutocompletePopover } from "./setup.ts"
4
+ import { autocompletePopoverEvents, autocompletePopoverProps, type AutocompletePopoverEvents, type AutocompletePopoverProps } from "./types.ts"
5
5
 
6
6
  const AutocompletePopoverElementBase: BaseElementConstructor<AutocompletePopoverProps> = defineCustomElement<
7
7
  AutocompletePopoverProps,
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
 
3
- import { defaultQueryBuilder } from './helpers'
3
+ import { defaultQueryBuilder } from './helpers.ts'
4
4
 
5
5
  describe('defaultQueryBuilder', () => {
6
6
  it('can remove extra spaces', () => {
@@ -1,7 +1,7 @@
1
1
  export function defaultQueryBuilder(match: RegExpExecArray): string {
2
2
  return match[0]
3
3
  .toLowerCase()
4
- .replace(/[!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]/g, '')
5
- .replace(/\s\s+/g, ' ')
4
+ .replaceAll(/[!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]/g, '')
5
+ .replaceAll(/\s\s+/g, ' ')
6
6
  .trim()
7
7
  }
@@ -11,16 +11,16 @@ import {
11
11
  } from '@aria-ui/core'
12
12
  import { useOverlayPositionerState } from '@aria-ui/overlay/elements'
13
13
  import { usePresence } from '@aria-ui/presence'
14
- import { defineKeymap, Priority, withPriority, type Editor } from '@prosekit/core'
14
+ import { defineKeymap, withPriority, type Editor, type Priority } from '@prosekit/core'
15
15
  import { AutocompleteRule, defineAutocomplete, type MatchHandler } from '@prosekit/extensions/autocomplete'
16
16
 
17
- import { useEditorExtension } from '../../../hooks/use-editor-extension'
18
- import { useFirstRendering } from '../../../hooks/use-first-rendering'
19
- import { getSafeEditorView } from '../../../utils/get-safe-editor-view'
20
- import { onSubmitContext, openContext, queryContext } from '../context'
17
+ import { useEditorExtension } from '../../../hooks/use-editor-extension.ts'
18
+ import { useFirstRendering } from '../../../hooks/use-first-rendering.ts'
19
+ import { getSafeEditorView } from '../../../utils/get-safe-editor-view.ts'
20
+ import { onSubmitContext, openContext, queryContext } from '../context.ts'
21
21
 
22
- import { defaultQueryBuilder } from './helpers'
23
- import type { AutocompletePopoverEvents, AutocompletePopoverProps } from './types'
22
+ import { defaultQueryBuilder } from './helpers.ts'
23
+ import type { AutocompletePopoverEvents, AutocompletePopoverProps } from './types.ts'
24
24
 
25
25
  /**
26
26
  * @internal
@@ -164,6 +164,6 @@ function useEscapeKeydown(
164
164
  handler: () => boolean,
165
165
  ): void {
166
166
  const keymap = { Escape: handler }
167
- const extension = withPriority(defineKeymap(keymap), Priority.highest)
167
+ const extension = withPriority(defineKeymap(keymap), 4 satisfies typeof Priority.highest)
168
168
  useEditorExtension(host, editor, extension)
169
169
  }
@@ -1,17 +1,17 @@
1
1
  // This file is generated by packages/dev/src/gen-components.ts
2
2
 
3
- export { AutocompleteEmptyElement } from './autocomplete-empty/element.gen'
4
- export { autocompleteEmptyEvents, autocompleteEmptyProps, type AutocompleteEmptyEvents, type AutocompleteEmptyProps } from './autocomplete-empty/types'
5
- export { useAutocompleteEmpty } from './autocomplete-empty/setup'
3
+ export { AutocompleteEmptyElement } from './autocomplete-empty/element.gen.ts'
4
+ export { autocompleteEmptyEvents, autocompleteEmptyProps, type AutocompleteEmptyEvents, type AutocompleteEmptyProps } from './autocomplete-empty/types.ts'
5
+ export { useAutocompleteEmpty } from './autocomplete-empty/setup.ts'
6
6
 
7
- export { AutocompleteItemElement } from './autocomplete-item/element.gen'
8
- export { autocompleteItemEvents, autocompleteItemProps, type AutocompleteItemEvents, type AutocompleteItemProps } from './autocomplete-item/types'
9
- export { useAutocompleteItem } from './autocomplete-item/setup'
7
+ export { AutocompleteItemElement } from './autocomplete-item/element.gen.ts'
8
+ export { autocompleteItemEvents, autocompleteItemProps, type AutocompleteItemEvents, type AutocompleteItemProps } from './autocomplete-item/types.ts'
9
+ export { useAutocompleteItem } from './autocomplete-item/setup.ts'
10
10
 
11
- export { AutocompleteListElement } from './autocomplete-list/element.gen'
12
- export { autocompleteListEvents, autocompleteListProps, type AutocompleteListEvents, type AutocompleteListProps } from './autocomplete-list/types'
13
- export { useAutocompleteList } from './autocomplete-list/setup'
11
+ export { AutocompleteListElement } from './autocomplete-list/element.gen.ts'
12
+ export { autocompleteListEvents, autocompleteListProps, type AutocompleteListEvents, type AutocompleteListProps } from './autocomplete-list/types.ts'
13
+ export { useAutocompleteList } from './autocomplete-list/setup.ts'
14
14
 
15
- export { AutocompletePopoverElement } from './autocomplete-popover/element.gen'
16
- export { autocompletePopoverEvents, autocompletePopoverProps, type AutocompletePopoverEvents, type AutocompletePopoverProps } from './autocomplete-popover/types'
17
- export { useAutocompletePopover } from './autocomplete-popover/setup'
15
+ export { AutocompletePopoverElement } from './autocomplete-popover/element.gen.ts'
16
+ export { autocompletePopoverEvents, autocompletePopoverProps, type AutocompletePopoverEvents, type AutocompletePopoverProps } from './autocomplete-popover/types.ts'
17
+ export { useAutocompletePopover } from './autocomplete-popover/setup.ts'
@@ -1,7 +1,7 @@
1
1
  import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
2
2
 
3
- import { useBlockHandleAdd } from "./setup"
4
- import { blockHandleAddEvents, blockHandleAddProps, type BlockHandleAddEvents, type BlockHandleAddProps } from "./types"
3
+ import { useBlockHandleAdd } from "./setup.ts"
4
+ import { blockHandleAddEvents, blockHandleAddProps, type BlockHandleAddEvents, type BlockHandleAddProps } from "./types.ts"
5
5
 
6
6
  const BlockHandleAddElementBase: BaseElementConstructor<BlockHandleAddProps> = defineCustomElement<
7
7
  BlockHandleAddProps,
@@ -1,9 +1,9 @@
1
1
  import { useEventListener, type ConnectableElement, type SignalState } from '@aria-ui/core'
2
2
  import { insertDefaultBlock } from '@prosekit/core'
3
3
 
4
- import { blockPopoverContext } from '../context'
4
+ import { blockPopoverContext } from '../context.ts'
5
5
 
6
- import type { BlockHandleAddProps } from './types'
6
+ import type { BlockHandleAddProps } from './types.ts'
7
7
 
8
8
  /**
9
9
  * @internal
@@ -1,7 +1,7 @@
1
1
  import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
2
2
 
3
- import { useBlockHandleDraggable } from "./setup"
4
- import { blockHandleDraggableEvents, blockHandleDraggableProps, type BlockHandleDraggableEvents, type BlockHandleDraggableProps } from "./types"
3
+ import { useBlockHandleDraggable } from "./setup.ts"
4
+ import { blockHandleDraggableEvents, blockHandleDraggableProps, type BlockHandleDraggableEvents, type BlockHandleDraggableProps } from "./types.ts"
5
5
 
6
6
  const BlockHandleDraggableElementBase: BaseElementConstructor<BlockHandleDraggableProps> = defineCustomElement<
7
7
  BlockHandleDraggableProps,
@@ -1,8 +1,7 @@
1
- import { assignStyles } from '../../../utils/assign-styles'
2
- import { deepCloneElement } from '../../../utils/clone-element'
3
- import { getClientRect } from '../../../utils/get-client-rect'
4
- import { injectStyle } from '../../../utils/inject-style'
5
- import { maxZIndex } from '../../../utils/max-z-index'
1
+ import { DRAGGING_CLASS_NAME } from '../../../constants.ts'
2
+ import { assignStyles } from '../../../utils/assign-styles.ts'
3
+ import { getClientRect } from '../../../utils/get-client-rect.ts'
4
+ import { maxZIndex } from '../../../utils/max-z-index.ts'
6
5
 
7
6
  /**
8
7
  * Sets a drag preview image for the given element and ensures the preview position
@@ -16,7 +15,7 @@ import { maxZIndex } from '../../../utils/max-z-index'
16
15
  * - Removes the container from the document body after the next frame.
17
16
  */
18
17
  export function setDragPreview(event: DragEvent, element: HTMLElement): void {
19
- const { top, bottom, left, right } = getClientRect(element)
18
+ const { top, bottom, left, right } = getClientRect(element, { left: true, right: true, top: true, bottom: true })
20
19
  const width = right - left
21
20
  const height = bottom - top
22
21
  const elementX = left
@@ -28,6 +27,10 @@ export function setDragPreview(event: DragEvent, element: HTMLElement): void {
28
27
 
29
28
  const container = document.createElement('div')
30
29
 
30
+ // Add some class names so that all styles applied to
31
+ // given class names can also be applied to the drag preview.
32
+ container.classList.add('ProseMirror', DRAGGING_CLASS_NAME)
33
+
31
34
  // If outsideX is positive, the point is at the left side of the element.
32
35
  const outsideX = Math.round(elementX - clientX)
33
36
  // If outsideY is positive, the point is above the element.
@@ -66,19 +69,15 @@ export function setDragPreview(event: DragEvent, element: HTMLElement): void {
66
69
  height: `${height + borderY}px`,
67
70
  })
68
71
 
69
- const [clonedElement, styleText] = deepCloneElement(element, true)
72
+ const clonedElement = element.cloneNode(true) as HTMLElement
70
73
 
71
74
  // A hardcoded opacity.
72
- clonedElement.style.setProperty('opacity', '0.5', 'important')
73
- // The bounding client rect doesn't include the margin, so we need to remove
74
- // the margin too from the cloned element so that it can fit the container.
75
- clonedElement.style.setProperty('margin', '0', 'important')
75
+ clonedElement.style.setProperty('opacity', '0.8', 'important')
76
76
  // Hide the outline of the cloned element.
77
77
  clonedElement.style.setProperty('outline-color', 'transparent', 'important')
78
78
 
79
- document.body.appendChild(container)
80
79
  container.appendChild(clonedElement)
81
- injectStyle(container, styleText)
80
+ document.body.appendChild(container)
82
81
 
83
82
  event.dataTransfer?.setDragImage(container, Math.max(-outsideX, 0), Math.max(-outsideY, 0))
84
83
 
@@ -6,12 +6,12 @@ import { Fragment, Slice } from '@prosekit/pm/model'
6
6
  import { NodeSelection } from '@prosekit/pm/state'
7
7
  import type { EditorView } from '@prosekit/pm/view'
8
8
 
9
- import { getBoxElement } from '../../../utils/get-box-element'
10
- import { getSafeEditorView } from '../../../utils/get-safe-editor-view'
11
- import { blockPopoverContext, draggingContext, type BlockPopoverContext, type HoverState } from '../context'
9
+ import { DRAGGING_CLASS_NAME } from '../../../constants.ts'
10
+ import { getSafeEditorView } from '../../../utils/get-safe-editor-view.ts'
11
+ import { blockPopoverContext, draggingContext, type BlockPopoverContext, type HoverState } from '../context.ts'
12
12
 
13
- import { setDragPreview } from './set-drag-preview'
14
- import type { BlockHandleDraggableProps } from './types'
13
+ import { setDragPreview } from './set-drag-preview.ts'
14
+ import type { BlockHandleDraggableProps } from './types.ts'
15
15
 
16
16
  /**
17
17
  * @internal
@@ -36,7 +36,7 @@ export function useBlockHandleDraggable(
36
36
  const hoverState = context.get()
37
37
 
38
38
  if (view && hoverState) {
39
- view.dom.classList.add('prosekit-dragging')
39
+ view.dom.classList.add(DRAGGING_CLASS_NAME)
40
40
  createDraggingPreview(view, hoverState, event)
41
41
  setViewDragging(view, hoverState)
42
42
  }
@@ -47,7 +47,7 @@ export function useBlockHandleDraggable(
47
47
 
48
48
  const view = getSafeEditorView(state.editor.get())
49
49
  if (view) {
50
- view.dom.classList.remove('prosekit-dragging')
50
+ view.dom.classList.remove(DRAGGING_CLASS_NAME)
51
51
  }
52
52
  })
53
53
 
@@ -92,15 +92,10 @@ function createDraggingPreview(view: EditorView, hoverState: HoverState, event:
92
92
  return
93
93
  }
94
94
 
95
- const boxElement = getBoxElement(element)
96
- if (!boxElement || !isHTMLElement(boxElement)) {
97
- return
98
- }
99
-
100
95
  event.dataTransfer.clearData()
101
- event.dataTransfer.setData('text/html', boxElement.outerHTML)
96
+ event.dataTransfer.setData('text/html', element.outerHTML)
102
97
  event.dataTransfer.effectAllowed = 'copyMove'
103
- setDragPreview(event, boxElement)
98
+ setDragPreview(event, element)
104
99
 
105
100
  return
106
101
  }
@@ -1,7 +1,7 @@
1
1
  import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
2
2
 
3
- import { useBlockHandlePopover } from "./setup"
4
- import { blockHandlePopoverEvents, blockHandlePopoverProps, type BlockHandlePopoverEvents, type BlockHandlePopoverProps } from "./types"
3
+ import { useBlockHandlePopover } from "./setup.ts"
4
+ import { blockHandlePopoverEvents, blockHandlePopoverProps, type BlockHandlePopoverEvents, type BlockHandlePopoverProps } from "./types.ts"
5
5
 
6
6
  const BlockHandlePopoverElementBase: BaseElementConstructor<BlockHandlePopoverProps> = defineCustomElement<
7
7
  BlockHandlePopoverProps,
@@ -1,12 +1,11 @@
1
1
  import type { VirtualElement } from '@floating-ui/dom'
2
- import { isElement, isHTMLElement, isTextNode } from '@ocavue/utils'
2
+ import { isElement, isHTMLElement, isTextNode, throttle } from '@ocavue/utils'
3
3
  import { defineDOMEventHandler, union, type PlainExtension } from '@prosekit/core'
4
4
  import type { ProseMirrorNode } from '@prosekit/pm/model'
5
5
  import type { EditorView } from '@prosekit/pm/view'
6
6
 
7
- import { getClientRect } from '../../../utils/get-client-rect'
8
- import { throttle } from '../../../utils/throttle'
9
- import type { HoverState } from '../context'
7
+ import { getClientRect } from '../../../utils/get-client-rect.ts'
8
+ import type { HoverState } from '../context.ts'
10
9
 
11
10
  export type ElementHoverHandler = (
12
11
  reference: VirtualElement | null,
@@ -186,14 +185,7 @@ function findOuterRect(node: Node): Rect | undefined {
186
185
  return
187
186
  }
188
187
 
189
- const rect = getClientRect(node)
190
- const style = node.ownerDocument.defaultView?.getComputedStyle(node)
191
- const marginLeft = style && Number.parseInt(style.marginLeft, 10) || 0
192
- const marginRight = style && Number.parseInt(style.marginRight, 10) || 0
193
- const left = rect.left - marginLeft
194
- const right = rect.right + marginRight
195
-
196
- return { top: rect.top, bottom: rect.bottom, left, right }
188
+ return getClientRect(node, { left: true, right: true })
197
189
  }
198
190
 
199
191
  function findFirstLineRectInNode(node: Node): Rect | undefined {
@@ -4,12 +4,12 @@ import { usePresence } from '@aria-ui/presence'
4
4
  import type { VirtualElement } from '@floating-ui/dom'
5
5
  import type { Editor } from '@prosekit/core'
6
6
 
7
- import { useEditorExtension } from '../../../hooks/use-editor-extension'
8
- import { useScrolling } from '../../../hooks/use-scrolling'
9
- import { blockPopoverContext, draggingContext, type BlockPopoverContext, type HoverState } from '../context'
7
+ import { useEditorExtension } from '../../../hooks/use-editor-extension.ts'
8
+ import { useScrolling } from '../../../hooks/use-scrolling.ts'
9
+ import { blockPopoverContext, draggingContext, type BlockPopoverContext, type HoverState } from '../context.ts'
10
10
 
11
- import { defineElementHoverHandler, type ElementHoverHandler } from './pointer-move'
12
- import type { BlockHandlePopoverEvents, BlockHandlePopoverProps } from './types'
11
+ import { defineElementHoverHandler, type ElementHoverHandler } from './pointer-move.ts'
12
+ import type { BlockHandlePopoverEvents, BlockHandlePopoverProps } from './types.ts'
13
13
 
14
14
  /**
15
15
  * @internal
@@ -64,7 +64,5 @@ function useHoverExtension(
64
64
  }
65
65
 
66
66
  function isHoverStateEqual(a: HoverState | null, b: HoverState | null) {
67
- if (!a && !b) return true
68
- if (!a || !b) return false
69
- return a.pos === b.pos && a.node.eq(b.node)
67
+ return (!a && !b) || (a && b && a.pos === b.pos && a.node.eq(b.node))
70
68
  }
@@ -1,13 +1,13 @@
1
1
  // This file is generated by packages/dev/src/gen-components.ts
2
2
 
3
- export { BlockHandleAddElement } from './block-handle-add/element.gen'
4
- export { blockHandleAddEvents, blockHandleAddProps, type BlockHandleAddEvents, type BlockHandleAddProps } from './block-handle-add/types'
5
- export { useBlockHandleAdd } from './block-handle-add/setup'
3
+ export { BlockHandleAddElement } from './block-handle-add/element.gen.ts'
4
+ export { blockHandleAddEvents, blockHandleAddProps, type BlockHandleAddEvents, type BlockHandleAddProps } from './block-handle-add/types.ts'
5
+ export { useBlockHandleAdd } from './block-handle-add/setup.ts'
6
6
 
7
- export { BlockHandleDraggableElement } from './block-handle-draggable/element.gen'
8
- export { blockHandleDraggableEvents, blockHandleDraggableProps, type BlockHandleDraggableEvents, type BlockHandleDraggableProps } from './block-handle-draggable/types'
9
- export { useBlockHandleDraggable } from './block-handle-draggable/setup'
7
+ export { BlockHandleDraggableElement } from './block-handle-draggable/element.gen.ts'
8
+ export { blockHandleDraggableEvents, blockHandleDraggableProps, type BlockHandleDraggableEvents, type BlockHandleDraggableProps } from './block-handle-draggable/types.ts'
9
+ export { useBlockHandleDraggable } from './block-handle-draggable/setup.ts'
10
10
 
11
- export { BlockHandlePopoverElement } from './block-handle-popover/element.gen'
12
- export { blockHandlePopoverEvents, blockHandlePopoverProps, type BlockHandlePopoverEvents, type BlockHandlePopoverProps } from './block-handle-popover/types'
13
- export { useBlockHandlePopover } from './block-handle-popover/setup'
11
+ export { BlockHandlePopoverElement } from './block-handle-popover/element.gen.ts'
12
+ export { blockHandlePopoverEvents, blockHandlePopoverProps, type BlockHandlePopoverEvents, type BlockHandlePopoverProps } from './block-handle-popover/types.ts'
13
+ export { useBlockHandlePopover } from './block-handle-popover/setup.ts'
@@ -1,7 +1,7 @@
1
1
  import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
2
2
 
3
- import { useDropIndicator } from "./setup"
4
- import { dropIndicatorEvents, dropIndicatorProps, type DropIndicatorEvents, type DropIndicatorProps } from "./types"
3
+ import { useDropIndicator } from "./setup.ts"
4
+ import { dropIndicatorEvents, dropIndicatorProps, type DropIndicatorEvents, type DropIndicatorProps } from "./types.ts"
5
5
 
6
6
  const DropIndicatorElementBase: BaseElementConstructor<DropIndicatorProps> = defineCustomElement<
7
7
  DropIndicatorProps,
@@ -2,11 +2,11 @@ import { createComputed, createSignal, useEffect, type ConnectableElement, type
2
2
  import { usePresence } from '@aria-ui/presence'
3
3
  import { defineDropIndicator, type ShowHandlerOptions } from '@prosekit/extensions/drop-indicator'
4
4
 
5
- import { useEditorExtension } from '../../../hooks/use-editor-extension'
6
- import { useScrolling } from '../../../hooks/use-scrolling'
7
- import { assignStyles } from '../../../utils/assign-styles'
5
+ import { useEditorExtension } from '../../../hooks/use-editor-extension.ts'
6
+ import { useScrolling } from '../../../hooks/use-scrolling.ts'
7
+ import { assignStyles } from '../../../utils/assign-styles.ts'
8
8
 
9
- import type { DropIndicatorEvents, DropIndicatorProps } from './types'
9
+ import type { DropIndicatorEvents, DropIndicatorProps } from './types.ts'
10
10
 
11
11
  /**
12
12
  * @internal
@@ -1,5 +1,5 @@
1
1
  // This file is generated by packages/dev/src/gen-components.ts
2
2
 
3
- export { DropIndicatorElement } from './drop-indicator/element.gen'
4
- export { dropIndicatorEvents, dropIndicatorProps, type DropIndicatorEvents, type DropIndicatorProps } from './drop-indicator/types'
5
- export { useDropIndicator } from './drop-indicator/setup'
3
+ export { DropIndicatorElement } from './drop-indicator/element.gen.ts'
4
+ export { dropIndicatorEvents, dropIndicatorProps, type DropIndicatorEvents, type DropIndicatorProps } from './drop-indicator/types.ts'
5
+ export { useDropIndicator } from './drop-indicator/setup.ts'
@@ -1,5 +1,5 @@
1
1
  // This file is generated by packages/dev/src/gen-components.ts
2
2
 
3
- export { InlinePopoverElement } from './inline-popover/element.gen'
4
- export { inlinePopoverEvents, inlinePopoverProps, type InlinePopoverEvents, type InlinePopoverProps } from './inline-popover/types'
5
- export { useInlinePopover } from './inline-popover/setup'
3
+ export { InlinePopoverElement } from './inline-popover/element.gen.ts'
4
+ export { inlinePopoverEvents, inlinePopoverProps, type InlinePopoverEvents, type InlinePopoverProps } from './inline-popover/types.ts'
5
+ export { useInlinePopover } from './inline-popover/setup.ts'
@@ -1,7 +1,7 @@
1
1
  import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
2
2
 
3
- import { useInlinePopover } from "./setup"
4
- import { inlinePopoverEvents, inlinePopoverProps, type InlinePopoverEvents, type InlinePopoverProps } from "./types"
3
+ import { useInlinePopover } from "./setup.ts"
4
+ import { inlinePopoverEvents, inlinePopoverProps, type InlinePopoverEvents, type InlinePopoverProps } from "./types.ts"
5
5
 
6
6
  const InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps> = defineCustomElement<
7
7
  InlinePopoverProps,
@@ -13,12 +13,12 @@ import type { ReferenceElement } from '@floating-ui/dom'
13
13
  import type { Editor } from '@prosekit/core'
14
14
  import type { Selection } from '@prosekit/pm/state'
15
15
 
16
- import { useEditorFocusChangeEvent } from '../../../hooks/use-editor-focus-event'
17
- import { useEditorUpdateEvent } from '../../../hooks/use-editor-update-event'
18
- import { useKeymap } from '../../../hooks/use-keymap'
16
+ import { useEditorFocusChangeEvent } from '../../../hooks/use-editor-focus-event.ts'
17
+ import { useEditorUpdateEvent } from '../../../hooks/use-editor-update-event.ts'
18
+ import { useKeymap } from '../../../hooks/use-keymap.ts'
19
19
 
20
- import type { InlinePopoverEvents, InlinePopoverProps } from './types'
21
- import { getVirtualSelectionElement } from './virtual-selection-element'
20
+ import type { InlinePopoverEvents, InlinePopoverProps } from './types.ts'
21
+ import { getVirtualSelectionElement } from './virtual-selection-element.ts'
22
22
 
23
23
  /**
24
24
  * @internal
@@ -1,13 +1,13 @@
1
1
  // This file is generated by packages/dev/src/gen-components.ts
2
2
 
3
- export { PopoverContentElement } from './popover-content/element.gen'
4
- export { popoverContentEvents, popoverContentProps, type PopoverContentEvents, type PopoverContentProps } from './popover-content/types'
5
- export { usePopoverContent } from './popover-content/setup'
3
+ export { PopoverContentElement } from './popover-content/element.gen.ts'
4
+ export { popoverContentEvents, popoverContentProps, type PopoverContentEvents, type PopoverContentProps } from './popover-content/types.ts'
5
+ export { usePopoverContent } from './popover-content/setup.ts'
6
6
 
7
- export { PopoverRootElement } from './popover-root/element.gen'
8
- export { popoverRootEvents, popoverRootProps, type PopoverRootEvents, type PopoverRootProps } from './popover-root/types'
9
- export { usePopoverRoot } from './popover-root/setup'
7
+ export { PopoverRootElement } from './popover-root/element.gen.ts'
8
+ export { popoverRootEvents, popoverRootProps, type PopoverRootEvents, type PopoverRootProps } from './popover-root/types.ts'
9
+ export { usePopoverRoot } from './popover-root/setup.ts'
10
10
 
11
- export { PopoverTriggerElement } from './popover-trigger/element.gen'
12
- export { popoverTriggerEvents, popoverTriggerProps, type PopoverTriggerEvents, type PopoverTriggerProps } from './popover-trigger/types'
13
- export { usePopoverTrigger } from './popover-trigger/setup'
11
+ export { PopoverTriggerElement } from './popover-trigger/element.gen.ts'
12
+ export { popoverTriggerEvents, popoverTriggerProps, type PopoverTriggerEvents, type PopoverTriggerProps } from './popover-trigger/types.ts'
13
+ export { usePopoverTrigger } from './popover-trigger/setup.ts'
@@ -1,7 +1,7 @@
1
1
  import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
2
2
 
3
- import { usePopoverContent } from "./setup"
4
- import { popoverContentEvents, popoverContentProps, type PopoverContentEvents, type PopoverContentProps } from "./types"
3
+ import { usePopoverContent } from "./setup.ts"
4
+ import { popoverContentEvents, popoverContentProps, type PopoverContentEvents, type PopoverContentProps } from "./types.ts"
5
5
 
6
6
  const PopoverContentElementBase: BaseElementConstructor<PopoverContentProps> = defineCustomElement<
7
7
  PopoverContentProps,
@@ -1,7 +1,7 @@
1
1
  import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
2
2
 
3
- import { usePopoverRoot } from "./setup"
4
- import { popoverRootEvents, popoverRootProps, type PopoverRootEvents, type PopoverRootProps } from "./types"
3
+ import { usePopoverRoot } from "./setup.ts"
4
+ import { popoverRootEvents, popoverRootProps, type PopoverRootEvents, type PopoverRootProps } from "./types.ts"
5
5
 
6
6
  const PopoverRootElementBase: BaseElementConstructor<PopoverRootProps> = defineCustomElement<
7
7
  PopoverRootProps,
@@ -1,7 +1,7 @@
1
1
  import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
2
2
 
3
- import { usePopoverTrigger } from "./setup"
4
- import { popoverTriggerEvents, popoverTriggerProps, type PopoverTriggerEvents, type PopoverTriggerProps } from "./types"
3
+ import { usePopoverTrigger } from "./setup.ts"
4
+ import { popoverTriggerEvents, popoverTriggerProps, type PopoverTriggerEvents, type PopoverTriggerProps } from "./types.ts"
5
5
 
6
6
  const PopoverTriggerElementBase: BaseElementConstructor<PopoverTriggerProps> = defineCustomElement<
7
7
  PopoverTriggerProps,
@@ -1,9 +1,9 @@
1
1
  // This file is generated by packages/dev/src/gen-components.ts
2
2
 
3
- export { ResizableHandleElement } from './resizable-handle/element.gen'
4
- export { resizableHandleEvents, resizableHandleProps, type ResizableHandleEvents, type ResizableHandleProps } from './resizable-handle/types'
5
- export { useResizableHandle } from './resizable-handle/setup'
3
+ export { ResizableHandleElement } from './resizable-handle/element.gen.ts'
4
+ export { resizableHandleEvents, resizableHandleProps, type ResizableHandleEvents, type ResizableHandleProps } from './resizable-handle/types.ts'
5
+ export { useResizableHandle } from './resizable-handle/setup.ts'
6
6
 
7
- export { ResizableRootElement } from './resizable-root/element.gen'
8
- export { resizableRootEvents, resizableRootProps, type ResizableRootEvents, type ResizableRootProps } from './resizable-root/types'
9
- export { useResizableRoot } from './resizable-root/setup'
7
+ export { ResizableRootElement } from './resizable-root/element.gen.ts'
8
+ export { resizableRootEvents, resizableRootProps, type ResizableRootEvents, type ResizableRootProps } from './resizable-root/types.ts'
9
+ export { useResizableRoot } from './resizable-root/setup.ts'
@@ -1,6 +1,6 @@
1
1
  import { expect, test } from 'vitest'
2
2
 
3
- import { calcResize } from './calc-resize'
3
+ import { calcResize } from './calc-resize.ts'
4
4
 
5
5
  test('calcBottomRightResize', () => {
6
6
  const testIncrease = (dx: number, dy: number) => {
@@ -1,4 +1,4 @@
1
- import { isFinitePositiveNumber } from '../../../utils/is-finite-positive-number'
1
+ import { isFinitePositiveNumber } from '../../../utils/is-finite-positive-number.ts'
2
2
 
3
3
  export function calcResize(
4
4
  position:
@@ -1,7 +1,7 @@
1
1
  import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from "@aria-ui/core"
2
2
 
3
- import { useResizableHandle } from "./setup"
4
- import { resizableHandleEvents, resizableHandleProps, type ResizableHandleEvents, type ResizableHandleProps } from "./types"
3
+ import { useResizableHandle } from "./setup.ts"
4
+ import { resizableHandleEvents, resizableHandleProps, type ResizableHandleEvents, type ResizableHandleProps } from "./types.ts"
5
5
 
6
6
  const ResizableHandleElementBase: BaseElementConstructor<ResizableHandleProps> = defineCustomElement<
7
7
  ResizableHandleProps,
@@ -1,10 +1,17 @@
1
1
  import { createSignal, useEffect, type ConnectableElement, type ReadonlySignal, type SignalState } from '@aria-ui/core'
2
2
  import { getWindow } from '@ocavue/utils'
3
3
 
4
- import { onResizeContext, onResizeEndContext, onResizeStartContext, type OnResize, type OnResizeEnd, type OnResizeStart } from '../context'
5
-
6
- import { calcResize } from './calc-resize'
7
- import type { ResizableHandleProps } from './types'
4
+ import {
5
+ onResizeContext,
6
+ onResizeEndContext,
7
+ onResizeStartContext,
8
+ type OnResize,
9
+ type OnResizeEnd,
10
+ type OnResizeStart,
11
+ } from '../context.ts'
12
+
13
+ import { calcResize } from './calc-resize.ts'
14
+ import type { ResizableHandleProps } from './types.ts'
8
15
 
9
16
  /**
10
17
  * @internal