Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "extension/link: adds 'whenNotEditable' as option for openOnClick" #5040

Merged
merged 2 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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