mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-18 00:10:43 +08:00
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:
parent
e95140c889
commit
ef635db6c0
@ -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.
|
||||||
|
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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',
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user