Skip to content

Commit b01a3c1

Browse files
committed
Merge branch 'develop' of github.com:ueberdosis/tiptap
2 parents 6c44032 + 8838e57 commit b01a3c1

File tree

15 files changed

+291
-71
lines changed

15 files changed

+291
-71
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tiptap/vue-3": patch
3+
---
4+
5+
Fix attribute forwarding for BubbleMenu and FloatingMenu Vue 3 components to allow setting z-index and other HTML attributes
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@tiptap/extension-hard-break': patch
3+
---
4+
5+
Ensure that markdown hard breaks (two spaces followed by a newline) are parsed so they render as line breaks (`<br>`) in the editor when using `contentType: 'markdown'`.
6+
7+
Fixes #7107
8+
9+

.changeset/nine-eyes-call.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tiptap/extension-unique-id': minor
3+
---
4+
5+
Add `updateDocument` option to disable document updates caused by the Unique ID extension.

.changeset/rare-pumpkins-shave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tiptap/core': patch
3+
---
4+
5+
Only remove injected CSS on unmount if no other editors are in the document (fixes #6836)

.changeset/ready-rings-fall.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@tiptap/extension-drag-handle': patch
3+
---
4+
5+
Replace DOM traversal with browser's native elementsFromPoint for better performance.
6+
7+
- Use elementsFromPoint instead of querySelectorAll
8+
- Add clampToContent helper for coordinate boundary validation
9+
- Add findClosestTopLevelBlock helper for efficient block lookup
10+
- Future-proof for root-level mousemove listeners

.changeset/two-moles-learn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tiptap/react': patch
3+
---
4+
5+
Prevent Bubble Menu plugin from re-loading every time the BubbleMenu component re-renders. Reverts a regression introduced in v3.6.3, in PR #7028.

packages/core/src/Editor.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export class Editor extends EventEmitter<EditorEvents> {
5757

5858
private css: HTMLStyleElement | null = null
5959

60+
private className = 'tiptap'
61+
6062
public schema!: Schema
6163

6264
private editorView: EditorView | null = null
@@ -193,7 +195,8 @@ export class Editor extends EventEmitter<EditorEvents> {
193195
this.isInitialized = false
194196

195197
// Safely remove CSS element with fallback for test environments
196-
if (this.css) {
198+
// Only remove CSS if no other editors exist in the document after unmount
199+
if (this.css && !document.querySelectorAll(`.${this.className}`).length) {
197200
try {
198201
if (typeof this.css.remove === 'function') {
199202
this.css.remove()
@@ -556,7 +559,7 @@ export class Editor extends EventEmitter<EditorEvents> {
556559
* Prepend class name to element.
557560
*/
558561
public prependClass(): void {
559-
this.view.dom.className = `tiptap ${this.view.dom.className}`
562+
this.view.dom.className = `${this.className} ${this.view.dom.className}`
560563
}
561564

562565
public isCapturingTransaction = false

packages/extension-drag-handle-vue-2/src/DragHandle.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,24 @@ export const DragHandle = Vue.extend({
3838
default: null,
3939
},
4040

41+
onElementDragStart: {
42+
type: Function as PropType<DragHandleProps['onElementDragStart']>,
43+
default: null,
44+
},
45+
46+
onElementDragEnd: {
47+
type: Function as PropType<DragHandleProps['onElementDragEnd']>,
48+
default: null,
49+
},
50+
4151
class: {
4252
type: String as PropType<DragHandleProps['class']>,
4353
default: 'drag-handle',
4454
},
4555
},
4656

4757
mounted() {
48-
const { editor, pluginKey, onNodeChange } = this.$props
58+
const { editor, pluginKey, onNodeChange, onElementDragStart, onElementDragEnd } = this.$props
4959

5060
editor.registerPlugin(
5161
DragHandlePlugin({
@@ -54,6 +64,8 @@ export const DragHandle = Vue.extend({
5464
pluginKey,
5565
computePositionConfig: { ...defaultComputePositionConfig, ...this.computePositionConfig },
5666
onNodeChange,
67+
onElementDragStart,
68+
onElementDragEnd,
5769
}).plugin,
5870
)
5971
},

packages/extension-drag-handle-vue-3/src/DragHandle.ts

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import {
44
DragHandlePlugin,
55
dragHandlePluginDefaultKey,
66
} from '@tiptap/extension-drag-handle'
7+
import type { Node } from '@tiptap/pm/model'
8+
import type { Plugin, PluginKey } from '@tiptap/pm/state'
79
import type { Editor } from '@tiptap/vue-3'
810
import type { PropType } from 'vue'
9-
import { defineComponent, h, onBeforeUnmount, onMounted, ref } from 'vue'
11+
import { defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref, shallowRef } from 'vue'
1012

1113
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
1214

@@ -20,7 +22,7 @@ export const DragHandle = defineComponent({
2022

2123
props: {
2224
pluginKey: {
23-
type: [String, Object] as PropType<DragHandleProps['pluginKey']>,
25+
type: [String, Object] as PropType<PluginKey | string>,
2426
default: dragHandlePluginDefaultKey,
2527
},
2628

@@ -39,6 +41,16 @@ export const DragHandle = defineComponent({
3941
default: null,
4042
},
4143

44+
onElementDragStart: {
45+
type: Function as PropType<DragHandleProps['onElementDragStart']>,
46+
default: null,
47+
},
48+
49+
onElementDragEnd: {
50+
type: Function as PropType<DragHandleProps['onElementDragEnd']>,
51+
default: null,
52+
},
53+
4254
class: {
4355
type: String as PropType<DragHandleProps['class']>,
4456
default: 'drag-handle',
@@ -47,25 +59,45 @@ export const DragHandle = defineComponent({
4759

4860
setup(props, { slots }) {
4961
const root = ref<HTMLElement | null>(null)
62+
const pluginHandle = shallowRef<{ plugin: Plugin; unbind: () => void } | null>(null)
5063

51-
onMounted(() => {
52-
const { editor, pluginKey, onNodeChange, computePositionConfig } = props
53-
54-
editor.registerPlugin(
55-
DragHandlePlugin({
56-
editor,
57-
element: root.value as HTMLElement,
58-
pluginKey,
59-
computePositionConfig: { ...defaultComputePositionConfig, ...computePositionConfig },
60-
onNodeChange,
61-
}).plugin,
62-
)
64+
onMounted(async () => {
65+
await nextTick()
66+
67+
const { editor, pluginKey, onNodeChange, onElementDragEnd, onElementDragStart, computePositionConfig } = props
68+
69+
if (!root.value) {
70+
return
71+
}
72+
if (!props.editor || props.editor.isDestroyed) {
73+
return
74+
}
75+
76+
const init = DragHandlePlugin({
77+
editor,
78+
element: root.value,
79+
pluginKey,
80+
computePositionConfig: { ...defaultComputePositionConfig, ...computePositionConfig },
81+
onNodeChange,
82+
onElementDragStart,
83+
onElementDragEnd,
84+
})
85+
86+
pluginHandle.value = init
87+
props.editor.registerPlugin(init.plugin)
6388
})
6489

6590
onBeforeUnmount(() => {
66-
const { pluginKey, editor } = props
91+
if (!pluginHandle.value) {
92+
return
93+
}
94+
95+
if (props.editor && !props.editor.isDestroyed) {
96+
props.editor.unregisterPlugin(props.pluginKey)
97+
}
6798

68-
editor.unregisterPlugin(pluginKey as string)
99+
pluginHandle.value.unbind?.()
100+
pluginHandle.value = null
69101
})
70102

71103
return () =>

packages/extension-drag-handle/src/drag-handle.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ export interface DragHandleOptions {
3232
* Returns a node or null when a node is hovered over
3333
*/
3434
onNodeChange?: (options: { node: Node | null; editor: Editor }) => void
35+
/**
36+
* The callback function that will be called when drag start.
37+
*/
38+
onElementDragStart?: (e: DragEvent) => void
39+
/**
40+
* The callback function that will be called when drag end.
41+
*/
42+
onElementDragEnd?: (e: DragEvent) => void
3543
}
3644

3745
declare module '@tiptap/core' {
@@ -70,6 +78,8 @@ export const DragHandle = Extension.create<DragHandleOptions>({
7078
onNodeChange: () => {
7179
return null
7280
},
81+
onElementDragStart: undefined,
82+
onElementDragEnd: undefined,
7383
}
7484
},
7585

@@ -106,6 +116,8 @@ export const DragHandle = Extension.create<DragHandleOptions>({
106116
element,
107117
editor: this.editor,
108118
onNodeChange: this.options.onNodeChange,
119+
onElementDragStart: this.options.onElementDragStart,
120+
onElementDragEnd: this.options.onElementDragEnd,
109121
}).plugin,
110122
]
111123
},

0 commit comments

Comments
 (0)