Skip to content

Commit

Permalink
revert: remove 'whenNotEditable' as option for openOnClick" (#5040)
Browse files Browse the repository at this point in the history
This reverts commit 0f41e38.

Co-authored-by: Nick Perez <nicholas.perez@tiptap.dev>
  • Loading branch information
benkroeger and nperez0111 committed May 24, 2024
1 parent e95140c commit ef635db
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 15 deletions.
8 changes: 0 additions & 8 deletions docs/api/marks/link.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 1 addition & 5 deletions packages/extension-link/src/helpers/clickHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ 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 {
return new Plugin({
key: new PluginKey('handleClickLink'),
props: {
handleClick: (view, pos, event) => {
if (options.whenNotEditable && view.editable) {
return false
}
if (event.button !== 0) {
return false
}
Expand Down
3 changes: 1 addition & 2 deletions packages/extension-link/src/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -264,7 +264,6 @@ export const Link = Mark.create<LinkOptions>({
plugins.push(
clickHandler({
type: this.type,
whenNotEditable: this.options.openOnClick === 'whenNotEditable',
}),
)
}
Expand Down

0 comments on commit ef635db

Please sign in to comment.