Skip to content

Commit

Permalink
Merge pull request #2535 from microsoft/u/juliaroldi/backspace
Browse files Browse the repository at this point in the history
Unlist after backspace
  • Loading branch information
juliaroldi authored Mar 27, 2024
2 parents fc9d8b7 + 9b855ff commit 0ce1dc2
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ export const deleteList: DeleteSelectionStep = context => {
item &&
index >= 0 &&
paragraph.segments[0] == marker &&
item.blockGroupType == 'ListItem' &&
(paragraph.segments.length == 1 ||
(paragraph.segments.length == 2 && paragraph.segments[1].segmentType == 'Br'))
item.blockGroupType == 'ListItem'
) {
item.levels = [];
context.deleteResult = 'range';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,4 +455,79 @@ describe('deleteList', () => {
});
expect(result.deleteResult).toEqual('range');
});

it('delete list if the cursor is before text', () => {
const model: ContentModelDocument = {
blockGroupType: 'Document',
blocks: [
{
blockType: 'BlockGroup',
blockGroupType: 'ListItem',
format: {
listStyleType: '"1. "',
},
blocks: [
{
blockType: 'Paragraph',
format: {},
segments: [
{
segmentType: 'SelectionMarker',
format: {},
isSelected: true,
},
{
segmentType: 'Text',
text: 'text',
format: {},
},
{
segmentType: 'Br',
format: {},
},
],
isImplicit: true,
},
],
levels: [
{
listType: 'OL',
format: {},
dataset: {},
},
],
formatHolder: {
segmentType: 'SelectionMarker',
isSelected: true,
format: {},
},
},
],
};
const result = deleteSelection(model, [deleteList]);
normalizeContentModel(model);
expect(result.deleteResult).toEqual('range');
expect(model).toEqual({
blockGroupType: 'Document',
blocks: [
{
blockType: 'Paragraph',
segments: [
{
segmentType: 'SelectionMarker',
isSelected: true,
format: {},
},
{
segmentType: 'Text',
text: 'text',
format: {},
},
],
format: {},
isImplicit: false,
},
],
});
});
});

0 comments on commit 0ce1dc2

Please sign in to comment.