diff --git a/packages/tiptap/src/Plugins/FloatingMenu.js b/packages/tiptap/src/Plugins/FloatingMenu.js index d262acbd7..e56e394a9 100644 --- a/packages/tiptap/src/Plugins/FloatingMenu.js +++ b/packages/tiptap/src/Plugins/FloatingMenu.js @@ -14,6 +14,9 @@ class Menu { this.isActive = false this.top = 0 + // the mousedown event is fired before blur so we can prevent it + this.options.element.addEventListener('mousedown', this.handleClick) + this.options.editor.on('focus', ({ view }) => { this.update(view) }) @@ -22,6 +25,10 @@ class Menu { }) } + handleClick(event) { + event.preventDefault() + } + update(view, lastState) { const { state } = view @@ -72,6 +79,10 @@ class Menu { this.sendUpdate() } + destroy() { + this.options.element.removeEventListener('mousedown', this.handleClick) + } + } export default function (options) { diff --git a/packages/tiptap/src/Plugins/MenuBubble.js b/packages/tiptap/src/Plugins/MenuBubble.js index 1540ee9a0..9243a1756 100644 --- a/packages/tiptap/src/Plugins/MenuBubble.js +++ b/packages/tiptap/src/Plugins/MenuBubble.js @@ -67,6 +67,9 @@ class Menu { this.left = 0 this.bottom = 0 + // the mousedown event is fired before blur so we can prevent it + this.options.element.addEventListener('mousedown', this.handleClick) + this.options.editor.on('focus', ({ view }) => { this.update(view) }) @@ -75,6 +78,10 @@ class Menu { }) } + handleClick(event) { + event.preventDefault() + } + update(view, lastState) { const { state } = view @@ -132,6 +139,10 @@ class Menu { this.sendUpdate() } + destroy() { + this.options.element.removeEventListener('mousedown', this.handleClick) + } + } export default function (options) {