@tiptap/extension-floating-menu
Advanced tools
Comparing version 2.0.0-beta.46 to 2.0.0-beta.47
@@ -16,3 +16,3 @@ 'use strict'; | ||
this.preventHide = false; | ||
this.shouldShow = ({ state }) => { | ||
this.shouldShow = ({ view, state }) => { | ||
const { selection } = state; | ||
@@ -24,3 +24,6 @@ const { $anchor, empty } = selection; | ||
&& !$anchor.parent.textContent; | ||
if (!empty || !isRootDepth || !isEmptyTextBlock) { | ||
if (!view.hasFocus() | ||
|| !empty | ||
|| !isRootDepth | ||
|| !isEmptyTextBlock) { | ||
return false; | ||
@@ -79,2 +82,8 @@ } | ||
}); | ||
// maybe we have to hide tippy on its own blur event as well | ||
if (this.tippy.popper.firstChild) { | ||
this.tippy.popper.firstChild.addEventListener('blur', event => { | ||
this.blurHandler({ event }); | ||
}); | ||
} | ||
} | ||
@@ -81,0 +90,0 @@ update(view, oldState) { |
@@ -8,3 +8,3 @@ import { posToDOMRect, Extension } from '@tiptap/core'; | ||
this.preventHide = false; | ||
this.shouldShow = ({ state }) => { | ||
this.shouldShow = ({ view, state }) => { | ||
const { selection } = state; | ||
@@ -16,3 +16,6 @@ const { $anchor, empty } = selection; | ||
&& !$anchor.parent.textContent; | ||
if (!empty || !isRootDepth || !isEmptyTextBlock) { | ||
if (!view.hasFocus() | ||
|| !empty | ||
|| !isRootDepth | ||
|| !isEmptyTextBlock) { | ||
return false; | ||
@@ -71,2 +74,8 @@ } | ||
}); | ||
// maybe we have to hide tippy on its own blur event as well | ||
if (this.tippy.popper.firstChild) { | ||
this.tippy.popper.firstChild.addEventListener('blur', event => { | ||
this.blurHandler({ event }); | ||
}); | ||
} | ||
} | ||
@@ -73,0 +82,0 @@ update(view, oldState) { |
@@ -14,3 +14,3 @@ (function (global, factory) { | ||
this.preventHide = false; | ||
this.shouldShow = ({ state }) => { | ||
this.shouldShow = ({ view, state }) => { | ||
const { selection } = state; | ||
@@ -22,3 +22,6 @@ const { $anchor, empty } = selection; | ||
&& !$anchor.parent.textContent; | ||
if (!empty || !isRootDepth || !isEmptyTextBlock) { | ||
if (!view.hasFocus() | ||
|| !empty | ||
|| !isRootDepth | ||
|| !isEmptyTextBlock) { | ||
return false; | ||
@@ -77,2 +80,8 @@ } | ||
}); | ||
// maybe we have to hide tippy on its own blur event as well | ||
if (this.tippy.popper.firstChild) { | ||
this.tippy.popper.firstChild.addEventListener('blur', event => { | ||
this.blurHandler({ event }); | ||
}); | ||
} | ||
} | ||
@@ -79,0 +88,0 @@ update(view, oldState) { |
{ | ||
"name": "@tiptap/extension-floating-menu", | ||
"description": "floating-menu extension for tiptap", | ||
"version": "2.0.0-beta.46", | ||
"version": "2.0.0-beta.47", | ||
"homepage": "https://tiptap.dev", | ||
@@ -36,3 +36,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "6360278660d9c1e256975699d911a55dfa943d5d" | ||
"gitHead": "56cbf99f9f636930f77840d6e69dd1d8d2063e37" | ||
} |
@@ -36,3 +36,3 @@ import { Editor, posToDOMRect } from '@tiptap/core' | ||
public shouldShow: Exclude<FloatingMenuPluginProps['shouldShow'], null> = ({ state }) => { | ||
public shouldShow: Exclude<FloatingMenuPluginProps['shouldShow'], null> = ({ view, state }) => { | ||
const { selection } = state | ||
@@ -45,3 +45,8 @@ const { $anchor, empty } = selection | ||
if (!empty || !isRootDepth || !isEmptyTextBlock) { | ||
if ( | ||
!view.hasFocus() | ||
|| !empty | ||
|| !isRootDepth | ||
|| !isEmptyTextBlock | ||
) { | ||
return false | ||
@@ -121,2 +126,9 @@ } | ||
}) | ||
// maybe we have to hide tippy on its own blur event as well | ||
if (this.tippy.popper.firstChild) { | ||
(this.tippy.popper.firstChild as HTMLElement).addEventListener('blur', event => { | ||
this.blurHandler({ event }) | ||
}) | ||
} | ||
} | ||
@@ -123,0 +135,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
58257
711