rename unsetMarks to unsetAllMarks
This commit is contained in:
23
packages/core/src/commands/unsetAllMarks.ts
Normal file
23
packages/core/src/commands/unsetAllMarks.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Command } from '../types'
|
||||
|
||||
/**
|
||||
* Remove all marks in the current selection.
|
||||
*/
|
||||
export const unsetAllMarks = (): 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
|
||||
}
|
||||
Reference in New Issue
Block a user