Skip to content

Commit

Permalink
Merge branch 'u/jisong/2078' of https://github.com/microsoft/roosterjs
Browse files Browse the repository at this point in the history
…into u/jisong/2078
  • Loading branch information
JiuqingSong committed Sep 21, 2023
2 parents 574f107 + 5afa9c5 commit b18e05a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@ export function retrieveModelFormatState(
// Segment formats
segments?.forEach(segment => {
if (isFirstSegment || segment.segmentType != 'SelectionMarker') {
const modelFormat = Object.assign({}, model.format);
delete modelFormat?.italic;
delete modelFormat?.underline;
delete modelFormat?.fontWeight;

retrieveSegmentFormat(
formatState,
isFirst,
Object.assign(
{},
model.format,
modelFormat,
block.format,
block.decorator?.format,
segment.format,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,41 @@ describe('retrieveModelFormatState', () => {
});
});

it('With default format and other different format', () => {
const model = createContentModelDocument({
fontFamily: 'Arial',
fontSize: '12px',
underline: true,
fontWeight: 'bold',
italic: true,
});
const result: ContentModelFormatState = {};
const para = createParagraph();
const text1 = createText('test1', { fontFamily: 'Tahoma', fontSize: '15px' });
para.segments.push(text1);

text1.isSelected = true;

spyOn(iterateSelections, 'iterateSelections').and.callFake((path, callback) => {
callback(path, undefined, para, [text1]);
return false;
});

retrieveModelFormatState(model, null, result);

expect(result).toEqual({
isBlockQuote: false,
isBold: false,
isSuperscript: false,
isSubscript: false,
fontSize: '11.25pt',
isCodeInline: false,
canUnlink: false,
canAddImageAltText: false,
fontName: 'Tahoma',
});
});

it('With default format and other different format', () => {
const model = createContentModelDocument({
fontFamily: 'Arial',
Expand Down

0 comments on commit b18e05a

Please sign in to comment.