Skip to content

Commit

Permalink
Do not consider Bold, Italic and Underline from ContentModelDocument …
Browse files Browse the repository at this point in the history
…when retrieving the FormatState (#2081)

* init

* fix test
  • Loading branch information
BryanValverdeU authored Sep 21, 2023
1 parent f8e3096 commit e808fbf
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 e808fbf

Please sign in to comment.