@tiptap/extension-floating-menu
Advanced tools
Comparing version 2.10.4 to 2.11.0
@@ -52,2 +52,3 @@ import { Editor } from '@tiptap/core'; | ||
tippyOptions?: Partial<Props>; | ||
private getTextContent; | ||
shouldShow: Exclude<FloatingMenuPluginProps['shouldShow'], null>; | ||
@@ -54,0 +55,0 @@ constructor({ editor, element, view, tippyOptions, shouldShow, }: FloatingMenuViewProps); |
@@ -1,2 +0,2 @@ | ||
import { posToDOMRect, Extension } from '@tiptap/core'; | ||
import { getText, getTextSerializersFromSchema, posToDOMRect, Extension } from '@tiptap/core'; | ||
import { Plugin, PluginKey } from '@tiptap/pm/state'; | ||
@@ -6,2 +6,5 @@ import tippy from 'tippy.js'; | ||
class FloatingMenuView { | ||
getTextContent(node) { | ||
return getText(node, { textSerializers: getTextSerializersFromSchema(this.editor.schema) }); | ||
} | ||
constructor({ editor, element, view, tippyOptions = {}, shouldShow, }) { | ||
@@ -13,3 +16,3 @@ this.preventHide = false; | ||
const isRootDepth = $anchor.depth === 1; | ||
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent; | ||
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent); | ||
if (!view.hasFocus() | ||
@@ -16,0 +19,0 @@ || !empty |
@@ -8,2 +8,5 @@ (function (global, factory) { | ||
class FloatingMenuView { | ||
getTextContent(node) { | ||
return core.getText(node, { textSerializers: core.getTextSerializersFromSchema(this.editor.schema) }); | ||
} | ||
constructor({ editor, element, view, tippyOptions = {}, shouldShow, }) { | ||
@@ -15,3 +18,3 @@ this.preventHide = false; | ||
const isRootDepth = $anchor.depth === 1; | ||
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent; | ||
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent); | ||
if (!view.hasFocus() | ||
@@ -18,0 +21,0 @@ || !empty |
{ | ||
"name": "@tiptap/extension-floating-menu", | ||
"description": "floating-menu extension for tiptap", | ||
"version": "2.10.4", | ||
"version": "2.11.0", | ||
"homepage": "https://tiptap.dev", | ||
@@ -32,4 +32,4 @@ "keywords": [ | ||
"devDependencies": { | ||
"@tiptap/core": "^2.10.4", | ||
"@tiptap/pm": "^2.10.4" | ||
"@tiptap/core": "^2.11.0", | ||
"@tiptap/pm": "^2.11.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "peerDependencies": { |
@@ -1,2 +0,5 @@ | ||
import { Editor, posToDOMRect } from '@tiptap/core' | ||
import { | ||
Editor, getText, getTextSerializersFromSchema, posToDOMRect, | ||
} from '@tiptap/core' | ||
import { Node as ProseMirrorNode } from '@tiptap/pm/model' | ||
import { EditorState, Plugin, PluginKey } from '@tiptap/pm/state' | ||
@@ -67,2 +70,6 @@ import { EditorView } from '@tiptap/pm/view' | ||
private getTextContent(node:ProseMirrorNode) { | ||
return getText(node, { textSerializers: getTextSerializersFromSchema(this.editor.schema) }) | ||
} | ||
public shouldShow: Exclude<FloatingMenuPluginProps['shouldShow'], null> = ({ view, state }) => { | ||
@@ -72,4 +79,5 @@ const { selection } = state | ||
const isRootDepth = $anchor.depth === 1 | ||
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent | ||
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent) | ||
if ( | ||
@@ -76,0 +84,0 @@ !view.hasFocus() |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72184
821