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

Fix cursor stuck at list issue #303

Merged
merged 2 commits into from
May 30, 2019
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
@@ -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)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is BR the only tag type that may show up prior to the text?

Copy link
Collaborator Author

@JiuqingSong JiuqingSong May 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other visible tags like TABLE, IMG, ... are already handled.

return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
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