Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated isModelEmptyFast to consider changed indentation as not empty string #2625

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export function isModelEmptyFast(model: ContentModelDocument): boolean {
)
) {
return false; // Has meaningful segments, it is not empty
} else if (
(firstBlock.format.marginRight && parseFloat(firstBlock.format.marginRight) > 0) ||
(firstBlock.format.marginLeft && parseFloat(firstBlock.format.marginLeft) > 0)
) {
return false; // Has margin (indentation is changed), it is not empty
} else {
return firstBlock.segments.filter(x => x.segmentType == 'Br').length <= 1; // If there are more than one BR, it is not empty, otherwise it is empty
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,32 @@ describe('isModelEmptyFast', () => {
expect(result).toBeTrue();
});

it('Single Paragraph block - right margin 10px', () => {
const model = createContentModelDocument();
const para = createParagraph();
para.format.marginRight = '10px';

para.segments.push(createBr());
model.blocks.push(para);

const result = isModelEmptyFast(model);

expect(result).toBeFalse();
});

it('Single Paragraph block - left margin 0.25rem', () => {
const model = createContentModelDocument();
const para = createParagraph();
para.format.marginLeft = '0.25rem';

para.segments.push(createBr());
model.blocks.push(para);

const result = isModelEmptyFast(model);

expect(result).toBeFalse();
});

it('Single Paragraph block - two BR segment', () => {
const model = createContentModelDocument();
const para = createParagraph();
Expand Down
Loading