You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
407 B
17 lines
407 B
import { Editor } from 'slate'
|
|
|
|
export const toggleMark = (editor: Editor, format: any) => {
|
|
const isActive = isMarkActive(editor, format)
|
|
|
|
if (isActive) {
|
|
Editor.removeMark(editor, format)
|
|
} else {
|
|
Editor.addMark(editor, format, true)
|
|
}
|
|
}
|
|
|
|
export const isMarkActive = (editor: Editor, format: any) => {
|
|
const marks = Editor.marks(editor)
|
|
return marks ? marks[format] === true : false
|
|
}
|