From 0cc18dfca2d893fc4a7d959b0a3f1591b46b0959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Sat, 8 Jun 2019 22:38:26 +0200 Subject: [PATCH] refactoring --- packages/tiptap/src/Components/EditorFloatingMenu.js | 1 + packages/tiptap/src/Components/EditorMenuBubble.js | 1 + packages/tiptap/src/Plugins/FloatingMenu.js | 6 +----- packages/tiptap/src/Plugins/MenuBubble.js | 6 +----- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/tiptap/src/Components/EditorFloatingMenu.js b/packages/tiptap/src/Components/EditorFloatingMenu.js index c281c89ca..45479bd05 100644 --- a/packages/tiptap/src/Components/EditorFloatingMenu.js +++ b/packages/tiptap/src/Components/EditorFloatingMenu.js @@ -26,6 +26,7 @@ export default { if (editor) { this.$nextTick(() => { editor.registerPlugin(FloatingMenu({ + editor, element: this.$el, onUpdate: menu => { this.menu = menu diff --git a/packages/tiptap/src/Components/EditorMenuBubble.js b/packages/tiptap/src/Components/EditorMenuBubble.js index 3d5e67f49..d55ad0bb2 100644 --- a/packages/tiptap/src/Components/EditorMenuBubble.js +++ b/packages/tiptap/src/Components/EditorMenuBubble.js @@ -30,6 +30,7 @@ export default { if (editor) { this.$nextTick(() => { editor.registerPlugin(MenuBubble({ + editor, element: this.$el, keepInBounds: this.keepInBounds, onUpdate: menu => { diff --git a/packages/tiptap/src/Plugins/FloatingMenu.js b/packages/tiptap/src/Plugins/FloatingMenu.js index c2c59c063..04f647ebb 100644 --- a/packages/tiptap/src/Plugins/FloatingMenu.js +++ b/packages/tiptap/src/Plugins/FloatingMenu.js @@ -14,7 +14,7 @@ class Menu { this.isActive = false this.top = 0 - this.editorView.dom.addEventListener('blur', this.hide.bind(this)) + this.options.editor.on('blur', this.hide.bind(this)) } update(view, lastState) { @@ -67,10 +67,6 @@ class Menu { this.sendUpdate() } - destroy() { - this.editorView.dom.removeEventListener('blur', this.hide) - } - } export default function (options) { diff --git a/packages/tiptap/src/Plugins/MenuBubble.js b/packages/tiptap/src/Plugins/MenuBubble.js index 3873d9ccf..244424e00 100644 --- a/packages/tiptap/src/Plugins/MenuBubble.js +++ b/packages/tiptap/src/Plugins/MenuBubble.js @@ -67,7 +67,7 @@ class Menu { this.left = 0 this.bottom = 0 - this.editorView.dom.addEventListener('blur', this.hide.bind(this)) + this.options.editor.on('blur', this.hide.bind(this)) } update(view, lastState) { @@ -127,10 +127,6 @@ class Menu { this.sendUpdate() } - destroy() { - this.editorView.dom.removeEventListener('blur', this.hide) - } - } export default function (options) {