add multicolor option to highlight
This commit is contained in:
@@ -64,7 +64,7 @@ export default {
|
||||
Document,
|
||||
Paragraph,
|
||||
Text,
|
||||
Highlight,
|
||||
Highlight.configure({ multicolor: true }),
|
||||
],
|
||||
content: `
|
||||
<p>This isn’t highlighted.</s></p>
|
||||
|
||||
@@ -13,9 +13,10 @@ yarn add @tiptap/extension-highlight
|
||||
```
|
||||
|
||||
## Settings
|
||||
| Option | Type | Default | Description |
|
||||
| -------------- | -------- | ------- | --------------------------------------------------------------------- |
|
||||
| HTMLAttributes | `Object` | `{}` | Custom HTML attributes that should be added to the rendered HTML tag. |
|
||||
| Option | Type | Default | Description |
|
||||
| -------------- | --------- | ------- | --------------------------------------------------------------------- |
|
||||
| multicolor | `Boolean` | `false` | Add support for multiple colors. |
|
||||
| HTMLAttributes | `Object` | `{}` | Custom HTML attributes that should be added to the rendered HTML tag. |
|
||||
|
||||
## Commands
|
||||
| Command | Options | Description |
|
||||
|
||||
@@ -19,7 +19,7 @@ export interface ExtensionConfig<Options = any, Commands = {}> {
|
||||
*/
|
||||
addGlobalAttributes?: (this: {
|
||||
options: Options,
|
||||
}) => GlobalAttributes,
|
||||
}) => GlobalAttributes | {},
|
||||
|
||||
/**
|
||||
* Commands
|
||||
|
||||
@@ -60,7 +60,7 @@ export interface MarkConfig<Options = any, Commands = {}> extends Overwrite<Exte
|
||||
this: {
|
||||
options: Options,
|
||||
},
|
||||
) => Attributes,
|
||||
) => Attributes | {},
|
||||
|
||||
/**
|
||||
* Commands
|
||||
|
||||
@@ -95,7 +95,7 @@ export interface NodeConfig<Options = any, Commands = {}> extends Overwrite<Exte
|
||||
this: {
|
||||
options: Options,
|
||||
},
|
||||
) => Attributes,
|
||||
) => Attributes | {},
|
||||
|
||||
/**
|
||||
* Commands
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
} from '@tiptap/core'
|
||||
|
||||
export interface HighlightOptions {
|
||||
multicolor: boolean,
|
||||
HTMLAttributes: {
|
||||
[key: string]: any
|
||||
},
|
||||
@@ -19,10 +20,15 @@ const Highlight = Mark.create({
|
||||
name: 'highlight',
|
||||
|
||||
defaultOptions: <HighlightOptions>{
|
||||
multicolor: false,
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
addAttributes() {
|
||||
if (!this.options.multicolor) {
|
||||
return {}
|
||||
}
|
||||
|
||||
return {
|
||||
color: {
|
||||
default: null,
|
||||
|
||||
Reference in New Issue
Block a user