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 ### linkOnPaste
Adds a link to the current selection if the pasted content only contains an url. 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' import { Plugin, PluginKey } from '@tiptap/pm/state'
type ClickHandlerOptions = { type ClickHandlerOptions = {
type: MarkType, type: MarkType
whenNotEditable: boolean,
} }
export function clickHandler(options: ClickHandlerOptions): Plugin { export function clickHandler(options: ClickHandlerOptions): Plugin {
@ -12,9 +11,6 @@ export function clickHandler(options: ClickHandlerOptions): Plugin {
key: new PluginKey('handleClickLink'), key: new PluginKey('handleClickLink'),
props: { props: {
handleClick: (view, pos, event) => { handleClick: (view, pos, event) => {
if (options.whenNotEditable && view.editable) {
return false
}
if (event.button !== 0) { if (event.button !== 0) {
return false return false
} }

View File

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