fix: add way to cancel inputrules and pasterules (#2368)
Co-authored-by: Philipp Kühn <philippkuehn@MacBook-Pro-von-Philipp.local>
This commit is contained in:
@@ -24,7 +24,7 @@ export function markInputRule(config: {
|
||||
const attributes = callOrReturn(config.getAttributes, undefined, match)
|
||||
|
||||
if (attributes === false || attributes === null) {
|
||||
return
|
||||
return null
|
||||
}
|
||||
|
||||
const { tr } = state
|
||||
@@ -64,6 +64,8 @@ export function markInputRule(config: {
|
||||
|
||||
tr.removeStoredMark(config.type)
|
||||
}
|
||||
|
||||
return tr
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ export function nodeInputRule(config: {
|
||||
} else if (match[0]) {
|
||||
tr.replaceWith(start, end, config.type.create(attributes))
|
||||
}
|
||||
|
||||
return tr
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,7 +29,11 @@ export function textInputRule(config: {
|
||||
}
|
||||
}
|
||||
|
||||
state.tr.insertText(insert, start, end)
|
||||
const { tr } = state
|
||||
|
||||
tr.insertText(insert, start, end)
|
||||
|
||||
return tr
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,9 +29,12 @@ export function textblockTypeInputRule(config: {
|
||||
return null
|
||||
}
|
||||
|
||||
state.tr
|
||||
.delete(range.from, range.to)
|
||||
const { tr } = state
|
||||
|
||||
tr.delete(range.from, range.to)
|
||||
.setBlockType(range.from, range.from, config.type, attributes)
|
||||
|
||||
return tr
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ export function wrappingInputRule(config: {
|
||||
) {
|
||||
tr.join(range.from - 1)
|
||||
}
|
||||
|
||||
return tr
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user