Merge branch 'staging' into develop

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2025-02-19 14:12:43 +07:00
14 changed files with 140 additions and 64 deletions
@@ -15,6 +15,8 @@
import { showPopup } from '@hcengineering/ui'
import { Extension } from '@tiptap/core'
import { type MarkType } from '@tiptap/pm/model'
import { Plugin, PluginKey } from '@tiptap/pm/state'
import LinkPopup from '../LinkPopup.svelte'
export const LinkUtilsExtension = Extension.create<any>({
@@ -42,6 +44,28 @@ export const LinkUtilsExtension = Extension.create<any>({
},
addProseMirrorPlugins () {
return []
return [LinkClickHandlerPlugin({ type: this.editor.schema.marks.link })]
}
})
interface LinkClickHandlerOptions {
type: MarkType
}
export function LinkClickHandlerPlugin (options: LinkClickHandlerOptions): Plugin {
return new Plugin({
key: new PluginKey('handleClickLink'),
props: {
handleClick: (view, pos, event) => {
const $pos = view.state.doc.resolve(pos)
const link = options.type.isInSet($pos.marks())
if (typeof link?.attrs.href === 'string') {
window.open(link.attrs.href, link.attrs.target)
return true
}
return false
}
}
})
}
@@ -363,7 +363,7 @@ export async function getReferenceFromUrl (text: string): Promise<ReferenceNodeP
const _id: Ref<Doc> | undefined =
linkProvider !== undefined ? (await (await getResource(linkProvider.decode))(id)) ?? id : id
const label = await getReferenceLabel(objectclass, id)
const label = await getReferenceLabel(objectclass, _id)
if (label === '') return
return {