Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected changeState(effect: Function, state: any, action: ActionResponseHandle | ActionNormalHandle): any {
if (isDraftable(state)) {
const draft = createDraft(state);
const responseDraft = effect(draft, action);
if (responseDraft === undefined) {
state = finishDraft(draft);
} else if (isDraft(responseDraft)) {
state = finishDraft(responseDraft);
} else {
state = responseDraft;
}
} else {
state = effect(state, action);
if (state === undefined) {
throw new StateReturnRequiredError(action.type);
}
}
return state;
}
}
parent.children.splice(index + 1, 0, newNode)
if (selection) {
for (const [point, key] of Range.points(selection)) {
selection[key] = Point.transform(point, op)!
}
}
break
}
}
editor.children = finishDraft(editor.children) as Node[]
if (selection) {
editor.selection = isDraft(selection)
? (finishDraft(selection) as Range)
: selection
} else {
editor.selection = null
}
},
}
parent.children.splice(index + 1, 0, newNode)
if (selection) {
for (const [point, key] of Range.points(selection)) {
selection[key] = Point.transform(point, op)!
}
}
break
}
}
editor.children = finishDraft(editor.children) as Node[]
if (selection) {
editor.selection = isDraft(selection)
? (finishDraft(selection) as Range)
: selection
} else {
editor.selection = null
}
},