I create Mark by the tiptap Mark.create({})
. I don’t want users to select this Mark
. How can I do that? The Mark code is below:
import { Mark, mergeAttributes } from '@tiptap/core';
const TextColor = Mark.create({
name: 'textColor',
addOptions() {
return { HTMLAttributes: {} };
},
addAttributes() {
return {
attrs: {
default: { color: 'gray' },
parseHTML: (element) => element.getAttribute('data-text-color'),
renderHTML: ({ attrs }) => {
if (!attrs || !attrs.color) {
return {};
}
const { color, ...leftAttrs } = attrs;
if (!leftAttrs.style || typeof leftAttrs.style !== 'string') {
leftAttrs.style = '';
}
leftAttrs.style = `color: ${color}; ${leftAttrs.style}`;
return {
'data-text-color': color,
...leftAttrs,
};
},
},
};
},
parseHTML() {
return [{ tag: 'span' }];
},
renderHTML({ HTMLAttributes }) {
return [
'span',
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
0,
];
},
});
export default TextColor;