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

@@ -5,7 +5,7 @@ import { createExtension } from '../Extension'
export const ClearNodes = createExtension({
addCommands() {
return {
clearNodes: (): Command => ({ state, tr }) => {
clearNodes: (): Command => ({ state, tr, dispatch }) => {
const { selection } = tr
const { from, to } = selection
@@ -18,11 +18,11 @@ export const ClearNodes = createExtension({
if (nodeRange) {
const targetLiftDepth = liftTarget(nodeRange)
if (node.type.isTextblock) {
if (node.type.isTextblock && dispatch) {
tr.setNodeMarkup(nodeRange.start, state.schema.nodes.paragraph)
}
if (targetLiftDepth || targetLiftDepth === 0) {
if ((targetLiftDepth || targetLiftDepth === 0) && dispatch) {
tr.lift(nodeRange, targetLiftDepth)
}
}