From 0f0100660665ad0ac752656180b367f21d73f3c6 Mon Sep 17 00:00:00 2001 From: Takagi <1103069291@qq.com> Date: Fri, 5 Jul 2024 18:29:07 +0800 Subject: [PATCH] fix: bubble menu not appearing when crossing lines in editor (#6268) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind bug /area editor /milestone 2.18.x #### What this PR does / why we need it: 在默认编辑器中,选中一个跨多个节点的 text 时,selection 会变为 RangeSelection,此时冒泡菜单将不会出现。 此 RP 将 RangeSelection 添加至 text 的冒泡菜单验证中,使得冒泡菜单可以出现。 #### How to test it? 测试跨行选中多个无序列表时,是否出现冒泡菜单。 #### Which issue(s) this PR fixes: Fixes #6267 #### Does this PR introduce a user-facing change? ```release-note 修复默认编辑器中跨行选择节点时冒泡菜单无法出现的问题 ``` --- ui/packages/editor/src/extensions/text/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/packages/editor/src/extensions/text/index.ts b/ui/packages/editor/src/extensions/text/index.ts index b3d0a3889..0d41fc388 100644 --- a/ui/packages/editor/src/extensions/text/index.ts +++ b/ui/packages/editor/src/extensions/text/index.ts @@ -1,6 +1,7 @@ import ColorBubbleItem from "@/extensions/color/ColorBubbleItem.vue"; import HighlightBubbleItem from "@/extensions/highlight/HighlightBubbleItem.vue"; import LinkBubbleButton from "@/extensions/link/LinkBubbleButton.vue"; +import { RangeSelection } from "@/extensions/range-selection"; import { i18n } from "@/locales"; import type { EditorState } from "@/tiptap/pm"; import { isActive, isTextSelection } from "@/tiptap/vue-3"; @@ -56,7 +57,10 @@ const Text = TiptapText.extend({ return false; } - if (!isTextSelection(selection)) { + if ( + !isTextSelection(selection) && + !(selection instanceof RangeSelection) + ) { return false; }