Skip to content

Commit

Permalink
Fix 300391: [Mail] The numbers will become a continuous sequence afte…
Browse files Browse the repository at this point in the history
…r typing enter at the last line of the numbering above (#2782)

Co-authored-by: Bryan Valverde U <[email protected]>
  • Loading branch information
JiuqingSong and BryanValverdeU authored Sep 4, 2024
1 parent f496042 commit a419832
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export const handleEnterOnList: DeleteSelectionStep = context => {
nextListItem.levels[0]
) {
nextListItem.levels.forEach(level => {
level.format.startNumberOverride = undefined;
// Remove startNumberOverride so that next list item can join current list, unless it is 1.
// List start with 1 means it should be an explicit new list and should never join another list before it
if (level.format.startNumberOverride !== 1) {
level.format.startNumberOverride = undefined;
}
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2439,6 +2439,118 @@ describe('handleEnterOnList - keyboardEnter', () => {
runTest(input, true, expected, false, 1);
});

it('Two separate lists, Enter on first one', () => {
const model: ContentModelDocument = {
blockGroupType: 'Document',
blocks: [
{
blockType: 'BlockGroup',
blockGroupType: 'ListItem',
levels: [{ listType: 'OL', format: { startNumberOverride: 1 }, dataset: {} }],
blocks: [
{
blockType: 'Paragraph',
format: {},
segments: [
{ segmentType: 'Text', text: 'test', format: {} },
{ segmentType: 'SelectionMarker', format: {}, isSelected: true },
],
},
],
format: {},
formatHolder: { segmentType: 'SelectionMarker', format: {} },
},
{
blockType: 'BlockGroup',
blockGroupType: 'ListItem',
levels: [{ listType: 'OL', format: { startNumberOverride: 1 }, dataset: {} }],
blocks: [
{
blockType: 'Paragraph',
format: {},
segments: [{ segmentType: 'Br', format: {} }],
},
],
format: {},
formatHolder: {
segmentType: 'SelectionMarker',
format: {},
},
},
],
};

const expectedModel: ContentModelDocument = {
blockGroupType: 'Document',
blocks: [
{
blockType: 'BlockGroup',
blockGroupType: 'ListItem',
levels: [{ listType: 'OL', format: { startNumberOverride: 1 }, dataset: {} }],
blocks: [
{
blockType: 'Paragraph',
format: {},
segments: [{ segmentType: 'Text', text: 'test', format: {} }],
},
],
format: {},
formatHolder: { segmentType: 'SelectionMarker', format: {} },
},
{
blockType: 'BlockGroup',
blockGroupType: 'ListItem',
levels: [
{
listType: 'OL',
format: {
startNumberOverride: undefined,
displayForDummyItem: undefined,
},
dataset: {},
},
],
blocks: [
{
blockType: 'Paragraph',
format: {},
segments: [
{ segmentType: 'SelectionMarker', format: {}, isSelected: true },
{ segmentType: 'Br', format: {} },
],
},
],
format: {},
formatHolder: { segmentType: 'SelectionMarker', format: {}, isSelected: false },
},
{
blockType: 'BlockGroup',
blockGroupType: 'ListItem',
blocks: [
{
blockType: 'Paragraph',
segments: [{ segmentType: 'Br', format: {} }],
format: {},
},
],
levels: [
{
listType: 'OL',
format: {
startNumberOverride: 1,
},
dataset: {},
},
],
formatHolder: { segmentType: 'SelectionMarker', format: {} },
format: {},
},
],
};

runTest(model, false, expectedModel, false, 1);
});

it('List item contains multiple blocks', () => {
const model: ContentModelDocument = {
blockGroupType: 'Document',
Expand Down

0 comments on commit a419832

Please sign in to comment.