From 6747131e23fd42e929ae9fd1d2f6db47c38d24ea Mon Sep 17 00:00:00 2001 From: Artyom Savchenko Date: Mon, 27 Apr 2026 15:55:53 +0700 Subject: [PATCH] Fix link action (#10793) * Fix link action Signed-off-by: Artem Savchenko * Clean up Signed-off-by: Artem Savchenko --------- Signed-off-by: Artem Savchenko --- .../src/components/extension/inlineComment.ts | 2 ++ .../src/components/extension/note.ts | 2 ++ .../src/components/extension/shortcuts/linkKeymap.ts | 3 +++ .../src/components/extension/toolbar/toolbar.ts | 9 +++++++++ plugins/text-editor-resources/src/utils.ts | 2 ++ 5 files changed, 18 insertions(+) diff --git a/plugins/text-editor-resources/src/components/extension/inlineComment.ts b/plugins/text-editor-resources/src/components/extension/inlineComment.ts index ca312793a5..6bd502ee43 100644 --- a/plugins/text-editor-resources/src/components/extension/inlineComment.ts +++ b/plugins/text-editor-resources/src/components/extension/inlineComment.ts @@ -34,6 +34,7 @@ import tippy, { type Instance } from 'tippy.js' import 'tippy.js/animations/shift-toward.css' import { type Doc as YDoc, type Map as YMap } from 'yjs' import { SvelteRenderer } from '../node-view' +import { hideTextEditorToolbar } from './toolbar/toolbar' export interface InlineCommentExtensionOptions { boundary?: HTMLElement @@ -946,6 +947,7 @@ function getReferenceRect (view: EditorView, from: number, to: number): DOMRect } export async function createInlineComment (editor: Editor, event: MouseEvent): Promise { + hideTextEditorToolbar(editor) editor.view.dispatch(setMeta(editor.state.tr, { newCommentRequested: true })) } diff --git a/plugins/text-editor-resources/src/components/extension/note.ts b/plugins/text-editor-resources/src/components/extension/note.ts index 28d1a1874d..65ec85e16f 100644 --- a/plugins/text-editor-resources/src/components/extension/note.ts +++ b/plugins/text-editor-resources/src/components/extension/note.ts @@ -7,6 +7,7 @@ import { NoteBaseExtension, type NoteKind, name as noteName } from '@hcengineeri import ConfigureNotePopup from '../note/ConfigureNotePopup.svelte' import DisplayNotePopup from '../note/DisplayNotePopup.svelte' +import { hideTextEditorToolbar } from './toolbar/toolbar' export interface NoteOptions { readonly: boolean @@ -195,6 +196,7 @@ export function displayNote (text: string, event: MouseEvent): void { } export async function configureNote (editor: Editor, event: MouseEvent): Promise { + hideTextEditorToolbar(editor) const attributes = editor.getAttributes(noteName) const text = attributes.title const kind = attributes.kind diff --git a/plugins/text-editor-resources/src/components/extension/shortcuts/linkKeymap.ts b/plugins/text-editor-resources/src/components/extension/shortcuts/linkKeymap.ts index 30e2aacf88..2dda211bb9 100644 --- a/plugins/text-editor-resources/src/components/extension/shortcuts/linkKeymap.ts +++ b/plugins/text-editor-resources/src/components/extension/shortcuts/linkKeymap.ts @@ -15,6 +15,8 @@ import { showPopup } from '@hcengineering/ui' import { Extension } from '@tiptap/core' + +import { hideTextEditorToolbar } from '../toolbar/toolbar' import { type MarkType } from '@tiptap/pm/model' import { Plugin, PluginKey } from '@tiptap/pm/state' import LinkPopup from '../../LinkPopup.svelte' @@ -30,6 +32,7 @@ export const LinkKeymapExtension = Extension.create({ const link = this.editor.getAttributes('link').href + hideTextEditorToolbar(this.editor) showPopup(LinkPopup, { link }, undefined, undefined, (newLink) => { if (newLink === '') { this.editor.chain().focus().extendMarkRange('link').unsetLink().run() diff --git a/plugins/text-editor-resources/src/components/extension/toolbar/toolbar.ts b/plugins/text-editor-resources/src/components/extension/toolbar/toolbar.ts index 30e63c3b37..136ac9adbd 100644 --- a/plugins/text-editor-resources/src/components/extension/toolbar/toolbar.ts +++ b/plugins/text-editor-resources/src/components/extension/toolbar/toolbar.ts @@ -475,6 +475,15 @@ export function getToolbarCursor (editorState: EditorState): ToolbarCursor return state?.cursor ?? null } +/** Dismiss the floating text toolbar (e.g. before opening a popup so it does not cover it). */ +export function hideTextEditorToolbar (editor: Editor): void { + const pluginState = getToolbarControlPluginState(editor.state) + if (pluginState?.cursor == null) { + return + } + editor.view.dispatch(updateCursor(editor.state.tr, null, pluginState, 'hide-for-popup')) +} + function resolveCursor (props: ResolveCursorProps): ToolbarCursor | null { const providers = props.state.providers diff --git a/plugins/text-editor-resources/src/utils.ts b/plugins/text-editor-resources/src/utils.ts index e01ea34e1d..8e0373d4a4 100644 --- a/plugins/text-editor-resources/src/utils.ts +++ b/plugins/text-editor-resources/src/utils.ts @@ -17,6 +17,7 @@ import { SelectPopup, showPopup, type PopupAlignment } from '@hcengineering/ui' import { type Editor, type Attribute } from '@tiptap/core' import { type ActionContext } from '@hcengineering/text-editor' +import { hideTextEditorToolbar } from './components/extension/toolbar/toolbar' import { mInsertTable } from './components/extensions' import LinkPopup from './components/LinkPopup.svelte' @@ -76,6 +77,7 @@ export async function isHeadingVisible (editor: Editor, ctx: ActionContext): Pro } export async function formatLink (editor: Editor): Promise { + hideTextEditorToolbar(editor) const link = editor.getAttributes('link').href // give editor some time to handle blur event