Skip to content

Commit

Permalink
Fix #2857 (#2858)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuqingSong authored Nov 4, 2024
1 parent fad8ec6 commit c2051c7
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const createNewListItem = (
const levels = createNewListLevel(listItem);
const newListItem: ShallowMutableContentModelListItem = createListItem(
levels,
insertPoint.marker.format
listItem.formatHolder.format
);

newListItem.blocks.push(newParagraph);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,108 @@ describe('handleEnterOnList', () => {
};
runTest(model, expectedModel, 'range', listItem);
});

it('Selection Marker has styles from previous list item', () => {
const model: ContentModelDocument = {
blockGroupType: 'Document',
blocks: [
{
blockType: 'BlockGroup',
blockGroupType: 'ListItem',
blocks: [
{
blockType: 'Paragraph',
segments: [
{
segmentType: 'SelectionMarker',
isSelected: true,
format: { fontSize: '20pt', fontWeight: 'bold' },
},
{
segmentType: 'Text',
text: 'test',
format: { fontWeight: 'bold' },
},
],
format: {},
},
],
format: {},
formatHolder: {
segmentType: 'SelectionMarker',
format: { fontSize: '10pt' },
},
levels: [{ listType: 'UL', format: {}, dataset: {} }],
},
],
};
const listItem: ContentModelListItem = {
blockType: 'BlockGroup',
blockGroupType: 'ListItem',
blocks: [
{
blockType: 'Paragraph',
segments: [
{
segmentType: 'SelectionMarker',
isSelected: true,
format: { fontSize: '20pt', fontWeight: 'bold' },
},
{
segmentType: 'Text',
text: 'test',
format: { fontWeight: 'bold' },
},
],
format: {},
},
],
levels: [
{
listType: 'UL',
format: {
startNumberOverride: undefined,
displayForDummyItem: undefined,
},
dataset: {},
},
],
formatHolder: {
segmentType: 'SelectionMarker',
isSelected: false,
format: { fontSize: '10pt' },
},
format: {},
};
const expectedModel: ContentModelDocument = {
blockGroupType: 'Document',
blocks: [
{
blockType: 'BlockGroup',
blockGroupType: 'ListItem',
blocks: [
{
blockType: 'Paragraph',
segments: [
{
segmentType: 'Br',
format: { fontSize: '20pt', fontWeight: 'bold' },
},
],
format: {},
segmentFormat: { fontSize: '20pt' },
},
],
format: {},
formatHolder: { segmentType: 'SelectionMarker', format: { fontSize: '10pt' } },
levels: [{ listType: 'UL', format: {}, dataset: {} }],
},
listItem,
],
};

runTest(model, expectedModel, 'range', listItem);
});
});

describe('handleEnterOnList - keyboardEnter', () => {
Expand Down

0 comments on commit c2051c7

Please sign in to comment.