tiptap/packages/core/src/commands/setNodeAttributes.ts

15 lines
345 B
TypeScript
Raw Normal View History

2020-11-05 05:38:52 +08:00
import { Command } from '../Editor'
export default (attributes: {}): Command => ({ tr, state, dispatch }) => {
const { selection } = tr
const { from, to } = selection
state.doc.nodesBetween(from, to, (node, pos) => {
if (!node.type.isText && dispatch) {
tr.setNodeMarkup(pos, undefined, attributes)
}
})
return true
}