import { Link } from "@tiptap/extension-link";
export default Link.extend({
addOptions() {
return {
...this.parent?.(),
// prevent a second autolink plugin from being added
autolink: false,
linkOnPaste: false,
};
},
addAttributes() {
return {
// Preserve any existing attributes from the parent Link extension:
...this.parent?.(),
// Define a new 'class' attribute for link marks:
class: {
default: null,
parseHTML: (element) => element.getAttribute("class"),
renderHTML: (attributes) => {
// Only include the class attribute if it’s set
if (!attributes.class) return {};
return { class: attributes.class };
},
},
};
},
});
import { Link } from "@tiptap/extension-link";
export default Link.extend({
addOptions() {
return {
...this.parent?.(),
// prevent a second autolink plugin from being added
autolink: false,
linkOnPaste: false,
};
},
addAttributes() {
return {
// Preserve any existing attributes from the parent Link extension:
...this.parent?.(),
// Define a new 'class' attribute for link marks:
class: {
default: null,
parseHTML: (element) => element.getAttribute("class"),
renderHTML: (attributes) => {
// Only include the class attribute if it’s set
if (!attributes.class) return {};
return { class: attributes.class };
},
},
};
},
});