From 112136ec79a881206f18603265ce414c6f926efd Mon Sep 17 00:00:00 2001 From: Artem Savchenko Date: Wed, 22 Apr 2026 12:37:38 +0700 Subject: [PATCH] Fix link action 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 | 12 +++++++++++- plugins/text-editor-resources/src/utils.ts | 2 ++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/plugins/text-editor-resources/src/components/extension/inlineComment.ts b/plugins/text-editor-resources/src/components/extension/inlineComment.ts index ca312793a5c..6bd502ee43a 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 28d1a1874da..65ec85e16ff 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 30e2aacf884..2dda211bb97 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 30e63c3b37f..e1246c70a7a 100644 --- a/plugins/text-editor-resources/src/components/extension/toolbar/toolbar.ts +++ b/plugins/text-editor-resources/src/components/extension/toolbar/toolbar.ts @@ -267,7 +267,8 @@ export function ToolbarControlPlugin (editor: Editor, options: ToolbarOptions): placement: viewOptions?.placement, hideOnClick: 'toggle', appendTo: viewOptions?.floating !== true ? (options.popupContainer ?? document.body) : document.body, - zIndex: 10001, + // Stay below application popups (base z-index 10000 in packages/ui Popup.svelte) so Link, Note, etc. are usable. + zIndex: 9999, offset: viewOptions?.offset, popperOptions: { modifiers: [ @@ -475,6 +476,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 e01ea34e1df..8e0373d4a49 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