add color support
This commit is contained in:
@@ -13,12 +13,25 @@ declare module '@tiptap/core/src/Editor' {
|
||||
export default new Mark()
|
||||
.name('highlight')
|
||||
.schema(() => ({
|
||||
attrs: {
|
||||
color: {
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
parseDOM: [
|
||||
{
|
||||
tag: 'mark',
|
||||
getAttrs: node => {
|
||||
return {
|
||||
color: (node as HTMLElement).style.backgroundColor,
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
toDOM: () => ['mark', 0],
|
||||
toDOM: node => ['mark', {
|
||||
...node.attrs,
|
||||
style: node.attrs.color && `background-color: ${node.attrs.color};`,
|
||||
}, 0],
|
||||
}))
|
||||
.commands(({ name }) => ({
|
||||
highlight: () => ({ commands }) => {
|
||||
|
||||
Reference in New Issue
Block a user