Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1x 1x 1x 38x 36x 36x 36x 20x 20x 20x 20x 20x | import { mutateBlock } from 'roosterjs-content-model-dom';
import { splitParagraph } from '../utils/splitParagraph';
import type { DeleteSelectionStep } from 'roosterjs-content-model-types';
/**
* @internal
*/
export const handleEnterOnParagraph: (
formatsToPreserveOnMerge: string[]
) => DeleteSelectionStep = formatsToPreserveOnMerge => context => {
const { paragraph, path } = context.insertPoint;
const paraIndex = path[0]?.blocks.indexOf(paragraph) ?? -1;
if (context.deleteResult == 'notDeleted' && paraIndex >= 0) {
const newPara = splitParagraph(
context.insertPoint,
false /* removeImplicitParagraph */,
formatsToPreserveOnMerge
);
mutateBlock(path[0]).blocks.splice(paraIndex + 1, 0, newPara);
context.deleteResult = 'range';
context.lastParagraph = newPara;
context.insertPoint.paragraph = newPara;
}
};
|