mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-08 18:57:42 +02:00
Fix link action (#10793)
* Fix link action Signed-off-by: Artem Savchenko <armisav@gmail.com> * Clean up Signed-off-by: Artem Savchenko <armisav@gmail.com> --------- Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
@@ -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<void> {
|
||||
hideTextEditorToolbar(editor)
|
||||
editor.view.dispatch(setMeta(editor.state.tr, { newCommentRequested: true }))
|
||||
}
|
||||
|
||||
|
||||
@@ -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<void> {
|
||||
hideTextEditorToolbar(editor)
|
||||
const attributes = editor.getAttributes(noteName)
|
||||
const text = attributes.title
|
||||
const kind = attributes.kind
|
||||
|
||||
@@ -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<any>({
|
||||
|
||||
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()
|
||||
|
||||
@@ -475,6 +475,15 @@ export function getToolbarCursor<T> (editorState: EditorState): ToolbarCursor<T>
|
||||
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<any> | null {
|
||||
const providers = props.state.providers
|
||||
|
||||
|
||||
@@ -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<void> {
|
||||
hideTextEditorToolbar(editor)
|
||||
const link = editor.getAttributes('link').href
|
||||
|
||||
// give editor some time to handle blur event
|
||||
|
||||
Reference in New Issue
Block a user