Skip to content

Commit

Permalink
Empty line should be preserved when clearBlockFormat (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuqingSong authored Dec 12, 2018
1 parent a7c9886 commit 6a18e9e
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 331 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "roosterjs",
"version": "6.19.0",
"version": "6.19.1",
"description": "Framework-independent javascript editor",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function clearNodeFormat(
tagsToStopUnwrap: string[],
attributesToPreserve: string[]
): boolean {
if (node.nodeType != NodeType.Element) {
if (node.nodeType != NodeType.Element || getTagOfNode(node) == 'BR') {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as TestHelper from '../TestHelper';
import clearBlockFormat from '../../format/clearBlockFormat';
import { Editor } from 'roosterjs-editor-core';

describe('clearFormat()', () => {
describe('clearBlockFormat()', () => {
let testID = 'clearFormat';
let editor: Editor;

Expand All @@ -26,6 +26,10 @@ describe('clearFormat()', () => {
runTest('', '');
});

it('Empty line', () => {
runTest('<div><br></div><!--{"start":[0],"end":[0]}-->', '<div><br></div>');
});

it('BIU', () => {
// The selection path like {"start":[0,1,1,0,0],"end":[0,2,0,5]} is generated from the "Take snapshot" functionality of sample site
runTest(
Expand Down Expand Up @@ -58,7 +62,7 @@ describe('clearFormat()', () => {
it('Multi lines', () => {
runTest(
'<div>This</div><div>is<br>a</div><div>test</div><!--{"start":[0,0,0],"end":[2,0,4]}-->',
'<div>This</div><div>is</div><div>a</div><div>test</div>'
'<div>This</div><div>is<br></div><div>a</div><div>test</div>'
);
});

Expand Down Expand Up @@ -86,7 +90,7 @@ describe('clearFormat()', () => {
it('List in table - select cross cell', () => {
runTest(
'<div><table><tbody><tr><td>This</td><td>is<br><ul><li>a</li><ul><li>test</li></ul></ul></td></tr></tbody></table><br></div><!--{"start":[0,0,0,0,0,0,2],"end":[0,0,0,0,1,2,0,0,1]}-->',
'<div><table><tbody><tr><td>This</td><td><div>is</div><div>a</div><ul><ul><li>test</li></ul></ul></td></tr></tbody></table><br></div>'
'<div><table><tbody><tr><td>This</td><td><div>is<br></div><div>a</div><ul><ul><li>test</li></ul></ul></td></tr></tbody></table><br></div>'
);
});

Expand Down
Loading

0 comments on commit 6a18e9e

Please sign in to comment.