move commands again
This commit is contained in:
14
packages/core/src/commands/setNodeAttributes.ts
Normal file
14
packages/core/src/commands/setNodeAttributes.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user