refactoring

This commit is contained in:
Philipp Kühn
2020-11-02 16:23:43 +01:00
parent eed82a57b6
commit 389937c32f
15 changed files with 61 additions and 40 deletions

View File

@@ -4,12 +4,12 @@ import { createExtension } from '../Extension'
export const SetNodeAttributes = createExtension({
addCommands() {
return {
setNodeAttributes: (attributes: {}): Command => ({ tr, state }) => {
setNodeAttributes: (attributes: {}): Command => ({ tr, state, dispatch }) => {
const { selection } = tr
const { from, to } = selection
state.doc.nodesBetween(from, to, (node, pos) => {
if (!node.type.isText) {
if (!node.type.isText && dispatch) {
tr.setNodeMarkup(pos, undefined, attributes)
}
})