Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -475,6 +476,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

Expand Down
2 changes: 2 additions & 0 deletions plugins/text-editor-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand Down
Loading