Files
tiptap/packages/core/src/commands/removeMarks.ts
2020-11-04 22:38:52 +01:00

21 lines
372 B
TypeScript

import { Command } from '../Editor'
export default (): Command => ({ tr, state, dispatch }) => {
const { selection } = tr
const { from, to, empty } = selection
if (empty) {
return true
}
if (dispatch) {
Object
.entries(state.schema.marks)
.forEach(([, mark]) => {
tr.removeMark(from, to, mark as any)
})
}
return true
}