mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-10 05:58:13 +08:00
29 lines
539 B
TypeScript
29 lines
539 B
TypeScript
import { Editor } from '../Editor'
|
|
|
|
declare module '../Editor' {
|
|
interface Editor {
|
|
removeMarks(): Editor,
|
|
}
|
|
}
|
|
|
|
export default function removeMarks(next: Function, editor: Editor): void {
|
|
const { state, view, schema } = editor
|
|
const { selection, tr } = state
|
|
const { from, to, empty } = selection
|
|
let transaction = tr
|
|
|
|
if (empty) {
|
|
next()
|
|
return
|
|
}
|
|
|
|
Object
|
|
.entries(schema.marks)
|
|
.forEach(([name, mark]) => {
|
|
transaction.removeMark(from, to, mark)
|
|
})
|
|
|
|
view.dispatch(transaction)
|
|
next()
|
|
}
|