Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mappedStep.from + mappedStep.slice.content.size,
schema.marks.strong.create(),
),
);
tr.step(step);
} else {
/* If it's a deletion */
const mappedStep = step.map(mapping);
const invertedStep = mappedStep.invert(tr.doc);
console.log('----');
console.log(JSON.stringify(mappedStep.toJSON()));
console.log(JSON.stringify(invertedStep.toJSON()));
newSteps.push(mappedStep);
newSteps.push(invertedStep);
newSteps.push(
new AddMarkStep(
invertedStep.from,
invertedStep.from + invertedStep.slice.content.size,
schema.marks.strike.create(),
),
);
mapping.appendMap(invertedStep.getMap());
tr.step(mappedStep);
tr.step(invertedStep);
}
});
return newSteps;
if (child.marks.some((mark) => mark.type.name === 'addition')) {
sliceIsAddition = true;
}
});
if (step instanceof ReplaceStep) {
if (sliceIsAddition) {
return [];
}
// Invert the replacement...
const deletionSize = step.to - step.from;
const additionSize = step.slice.size;
const addReplacedStep = new ReplaceStep(step.from, step.from, docSlice);
const addDeletionMark = new AddMarkStep(step.from, step.to, schema.marks.deletion.create());
const addAdditionMark =
additionSize &&
new AddMarkStep(
step.from + deletionSize,
step.to + additionSize + deletionSize,
schema.marks.addition.create(),
);
return [addReplacedStep, addDeletionMark, addAdditionMark];
}
if (step instanceof ReplaceAroundStep) {
throw new Error("Can't handle this step yet");
}
return [];
};
const docSlice = doc.slice(step.from, step.to);
let sliceIsAddition = false;
docSlice.content.forEach((child) => {
if (child.marks.some((mark) => mark.type.name === 'addition')) {
sliceIsAddition = true;
}
});
if (step instanceof ReplaceStep) {
if (sliceIsAddition) {
return [];
}
// Invert the replacement...
const deletionSize = step.to - step.from;
const additionSize = step.slice.size;
const addReplacedStep = new ReplaceStep(step.from, step.from, docSlice);
const addDeletionMark = new AddMarkStep(step.from, step.to, schema.marks.deletion.create());
const addAdditionMark =
additionSize &&
new AddMarkStep(
step.from + deletionSize,
step.to + additionSize + deletionSize,
schema.marks.addition.create(),
);
return [addReplacedStep, addDeletionMark, addAdditionMark];
}
if (step instanceof ReplaceAroundStep) {
throw new Error("Can't handle this step yet");
}
return [];
};