mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-06 15:35:28 +00:00
UBERF-8545: fix links in readonly documents (#8050)
Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
This commit is contained in:
parent
c2d8a31534
commit
cae76abb8a
@ -56,7 +56,7 @@ export const DefaultKit = Extension.create<DefaultKitOptions>({
|
|||||||
}),
|
}),
|
||||||
Typography.configure({}),
|
Typography.configure({}),
|
||||||
Link.extend({ inclusive: false }).configure({
|
Link.extend({ inclusive: false }).configure({
|
||||||
openOnClick: true,
|
openOnClick: false,
|
||||||
HTMLAttributes: { class: 'cursor-pointer', rel: 'noopener noreferrer', target: '_blank' }
|
HTMLAttributes: { class: 'cursor-pointer', rel: 'noopener noreferrer', target: '_blank' }
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
import { showPopup } from '@hcengineering/ui'
|
import { showPopup } from '@hcengineering/ui'
|
||||||
import { Extension } from '@tiptap/core'
|
import { Extension } from '@tiptap/core'
|
||||||
|
import { type MarkType } from '@tiptap/pm/model'
|
||||||
|
import { Plugin, PluginKey } from '@tiptap/pm/state'
|
||||||
import LinkPopup from '../LinkPopup.svelte'
|
import LinkPopup from '../LinkPopup.svelte'
|
||||||
|
|
||||||
export const LinkUtilsExtension = Extension.create<any>({
|
export const LinkUtilsExtension = Extension.create<any>({
|
||||||
@ -42,6 +44,28 @@ export const LinkUtilsExtension = Extension.create<any>({
|
|||||||
},
|
},
|
||||||
|
|
||||||
addProseMirrorPlugins () {
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -62,7 +62,7 @@ export const DefaultKit = Extension.create<DefaultKitOptions>({
|
|||||||
}),
|
}),
|
||||||
Typography.configure({}),
|
Typography.configure({}),
|
||||||
Link.extend({ inclusive: false }).configure({
|
Link.extend({ inclusive: false }).configure({
|
||||||
openOnClick: true,
|
openOnClick: false,
|
||||||
HTMLAttributes: { class: 'cursor-pointer', rel: 'noopener noreferrer', target: '_blank' }
|
HTMLAttributes: { class: 'cursor-pointer', rel: 'noopener noreferrer', target: '_blank' }
|
||||||
}),
|
}),
|
||||||
CodeBlockHighlighExtension.configure(codeBlockHighlightOptions)
|
CodeBlockHighlighExtension.configure(codeBlockHighlightOptions)
|
||||||
|
Loading…
Reference in New Issue
Block a user