Welcome to mirror list, hosted at ThFree Co, Russian Federation.

link.js « plugins « src - github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1a656362e4e442c76d46814e5940c4c532b6cedc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { Plugin, PluginKey } from 'prosemirror-state'

const clickHandler = ({ editor, type, onClick }) => {
	return new Plugin({
		props: {
			key: new PluginKey('textLink'),
			handleClick: (view, pos, event) => {
				const attrs = editor.getAttributes(type)
				const link = event.target.closest('a')
				if (link && attrs.href && onClick) {
					return onClick(event, attrs)
				}
				return false
			},
		},
	})
}

export { clickHandler }