revert: remove 'whenNotEditable' as option for openOnClick" (#5040)

This reverts commit 0f41e389b3.

Co-authored-by: Nick Perez <nicholas.perez@tiptap.dev>
This commit is contained in:
Benjamin Kroeger 2024-05-24 16:58:58 +02:00 committed by GitHub
parent e95140c889
commit ef635db6c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 2 additions and 15 deletions

View File

@ -65,14 +65,6 @@ Link.configure({
})
```
If set to `'whenNotEditable'`, links will be opened on click only when editor is not editable.
```js
Link.configure({
openOnClick: 'whenNotEditable',
})
```
### linkOnPaste
Adds a link to the current selection if the pasted content only contains an url.

View File

@ -3,8 +3,7 @@ import { MarkType } from '@tiptap/pm/model'
import { Plugin, PluginKey } from '@tiptap/pm/state'
type ClickHandlerOptions = {
type: MarkType,
whenNotEditable: boolean,
type: MarkType
}
export function clickHandler(options: ClickHandlerOptions): Plugin {
@ -12,9 +11,6 @@ export function clickHandler(options: ClickHandlerOptions): Plugin {
key: new PluginKey('handleClickLink'),
props: {
handleClick: (view, pos, event) => {
if (options.whenNotEditable && view.editable) {
return false
}
if (event.button !== 0) {
return false
}

View File

@ -48,7 +48,7 @@ export interface LinkOptions {
* @example false
* @example 'whenNotEditable'
*/
openOnClick: boolean | 'whenNotEditable'
openOnClick: boolean
/**
* Adds a link to the current selection if the pasted content only contains an url.
* @default true
@ -264,7 +264,6 @@ export const Link = Mark.create<LinkOptions>({
plugins.push(
clickHandler({
type: this.type,
whenNotEditable: this.options.openOnClick === 'whenNotEditable',
}),
)
}