Skip to content

Commit e23577a

Browse files
committed
Keep list item color after outdent
1 parent febf50f commit e23577a

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed

packages/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteList.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const deleteList: DeleteSelectionStep = context => {
6767
if (mutableList.levels.length > 1) {
6868
const newListItem = createListItem(
6969
mutableList.levels.slice(0, -1),
70-
mutableList.format
70+
mutableList.formatHolder.format
7171
);
7272

7373
newListItem.blocks = removedBlocks.map(

packages/roosterjs-content-model-plugins/test/edit/deleteSteps/deleteListTest.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,85 @@ describe('deleteList', () => {
672672
expect(result.deleteResult).toBe('range');
673673
});
674674

675+
it('Delete at beginning of list item with list item format', () => {
676+
const list = createListItem([createListLevel('UL'), createListLevel('OL')], {
677+
textColor: 'red',
678+
});
679+
const paragraph = createParagraph();
680+
const SelectionMarker = createSelectionMarker();
681+
const model = createContentModelDocument();
682+
683+
paragraph.segments.push(SelectionMarker);
684+
list.blocks.push(paragraph);
685+
model.blocks.push(list);
686+
687+
const result = deleteSelection(model, [deleteList]);
688+
689+
expect(model).toEqual({
690+
blockGroupType: 'Document',
691+
blocks: [
692+
{
693+
blockType: 'BlockGroup',
694+
blockGroupType: 'ListItem',
695+
blocks: [],
696+
levels: [
697+
{
698+
listType: 'UL',
699+
format: {},
700+
dataset: {},
701+
},
702+
{
703+
listType: 'OL',
704+
format: {},
705+
dataset: {},
706+
},
707+
],
708+
formatHolder: {
709+
segmentType: 'SelectionMarker',
710+
isSelected: false,
711+
format: {
712+
textColor: 'red',
713+
},
714+
},
715+
format: {},
716+
},
717+
{
718+
blockType: 'BlockGroup',
719+
blockGroupType: 'ListItem',
720+
blocks: [
721+
{
722+
blockType: 'Paragraph',
723+
segments: [
724+
{
725+
segmentType: 'SelectionMarker',
726+
isSelected: true,
727+
format: {},
728+
},
729+
],
730+
format: {},
731+
},
732+
],
733+
levels: [
734+
{
735+
listType: 'UL',
736+
format: {},
737+
dataset: {},
738+
},
739+
],
740+
formatHolder: {
741+
segmentType: 'SelectionMarker',
742+
isSelected: false,
743+
format: {
744+
textColor: 'red',
745+
},
746+
},
747+
format: {},
748+
},
749+
],
750+
});
751+
expect(result.deleteResult).toBe('range');
752+
});
753+
675754
it('Delete at beginning of list item with previous list item', () => {
676755
const list1 = createListItem([createListLevel('UL')]);
677756
const paragraph1 = createParagraph();

0 commit comments

Comments
 (0)