add color parameter to highlight command
This commit is contained in:
@@ -3,7 +3,7 @@ import { MarkType } from 'prosemirror-model'
|
||||
import { Command } from '../Editor'
|
||||
import getMarkType from '../utils/getMarkType'
|
||||
|
||||
type ToggleMarkCommand = (typeOrName: string | MarkType) => Command
|
||||
type ToggleMarkCommand = (typeOrName: string | MarkType, attrs?: {}) => Command
|
||||
|
||||
declare module '../Editor' {
|
||||
interface Commands {
|
||||
@@ -11,8 +11,8 @@ declare module '../Editor' {
|
||||
}
|
||||
}
|
||||
|
||||
export const toggleMark: ToggleMarkCommand = typeOrName => ({ state, dispatch }) => {
|
||||
export const toggleMark: ToggleMarkCommand = (typeOrName, attrs) => ({ state, dispatch }) => {
|
||||
const type = getMarkType(typeOrName, state.schema)
|
||||
|
||||
return originalToggleMark(type)(state, dispatch)
|
||||
return originalToggleMark(type, attrs)(state, dispatch)
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ export default new Mark()
|
||||
}, 0],
|
||||
}))
|
||||
.commands(({ name }) => ({
|
||||
highlight: () => ({ commands }) => {
|
||||
return commands.toggleMark(name)
|
||||
highlight: attrs => ({ commands }) => {
|
||||
return commands.toggleMark(name, attrs)
|
||||
},
|
||||
}))
|
||||
.keys(({ editor }) => ({
|
||||
|
||||
Reference in New Issue
Block a user