Skip to content

Commit

Permalink
Fix cursor stuck at list issue (#303)
Browse files Browse the repository at this point in the history
* Fix cursor stuck at list issue

* fix build
  • Loading branch information
JiuqingSong committed May 30, 2019
1 parent deb6cf7 commit 5834321
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
@@ -1,4 +1,5 @@
import contains from '../utils/contains';
import getTagOfNode from '../utils/getTagOfNode';
import isNodeEmpty from '../utils/isNodeEmpty';
import { NodePosition } from 'roosterjs-editor-types';

Expand Down Expand Up @@ -27,7 +28,7 @@ export default function isPositionAtBeginningOf(position: NodePosition, targetNo
function areAllPrevousNodesEmpty(node: Node): boolean {
while (node.previousSibling) {
node = node.previousSibling;
if (!isNodeEmpty(node)) {
if (getTagOfNode(node) == 'BR' || !isNodeEmpty(node)) {
return false;
}
}
Expand Down
Expand Up @@ -111,6 +111,16 @@ describe('isPositionAtBeginningOf()', () => {
true
);
});

it('There is a BR before the position', () => {
runTest(
'<div id=id1><br><span id=span1></div>',
() => $('span1'),
0,
() => $('id1'),
false
);
});
});

function $(id: string) {
Expand Down

0 comments on commit 5834321

Please sign in to comment.