add HTMLAttributes to defaultoptions
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import {
|
||||
Command, createMark, markPasteRule, mergeAttributes,
|
||||
Command,
|
||||
createMark,
|
||||
markPasteRule,
|
||||
mergeAttributes,
|
||||
} from '@tiptap/core'
|
||||
import { Plugin, PluginKey } from 'prosemirror-state'
|
||||
|
||||
export interface LinkOptions {
|
||||
openOnClick: boolean,
|
||||
target: string,
|
||||
rel: string,
|
||||
HTMLAttributes: {
|
||||
[key: string]: any
|
||||
},
|
||||
}
|
||||
|
||||
export const pasteRegex = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%._+~#=?!&/()]*)/gi
|
||||
@@ -18,8 +22,10 @@ const Link = createMark({
|
||||
|
||||
defaultOptions: <LinkOptions>{
|
||||
openOnClick: true,
|
||||
target: '_blank',
|
||||
rel: 'noopener noreferrer nofollow',
|
||||
HTMLAttributes: {
|
||||
target: '_blank',
|
||||
rel: 'noopener noreferrer nofollow',
|
||||
},
|
||||
},
|
||||
|
||||
addAttributes() {
|
||||
@@ -28,7 +34,7 @@ const Link = createMark({
|
||||
default: null,
|
||||
},
|
||||
target: {
|
||||
default: this.options.target,
|
||||
default: this.options.HTMLAttributes.target,
|
||||
},
|
||||
}
|
||||
},
|
||||
@@ -40,7 +46,7 @@ const Link = createMark({
|
||||
},
|
||||
|
||||
renderHTML({ HTMLAttributes }) {
|
||||
return ['a', mergeAttributes(HTMLAttributes, { rel: this.options.rel }), 0]
|
||||
return ['a', mergeAttributes(HTMLAttributes, { rel: this.options.HTMLAttributes.rel }), 0]
|
||||
},
|
||||
|
||||
addCommands() {
|
||||
|
||||
Reference in New Issue
Block a user