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

Always setRange in toggleMarkup and toggleSection #291

Merged
merged 1 commit into from
Jan 11, 2016

Conversation

bantic
Copy link
Collaborator

@bantic bantic commented Jan 11, 2016

This helps prevent a situation where the editor element has a selection
but it is not the active element. Typing while another element (like a
button) is focused (active) but the editor element has the selection is
problematic: The browser refocuses on the editor element and starts
inserting text, but it handles the input before it has focused, which
means the key* handlers do not fire.

cc @mixonic

Fixes #285

@@ -63,6 +63,10 @@ const Position = class Position {
return this.markerPosition.offset;
}

get isBlank() {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not a property set inside the constructor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No particular reason; I can change it. FWIW I don't think that defining a getter using get X() versus setting it on this in the constructor changes the shape of the object, in case that is a concern. I'll put it in the constructor for clarity, though.

This helps prevent a situation where the editor element has a selection
but it is not the active element. Typing while another element (like a
button) is focused (active) but the editor element has the selection is
problematic: The browser refocuses on the editor element and starts
inserting text, but it handles the input before it has focused, which
means the key* handlers do not fire.

Also renamed Position#emptyPosition and Range#emptyRange ->
blankPosition, blankRange. Adds `isBlank` property to Position and
Range.

Defensively avoid attempting to render a cursor when the range is blank.

When cursor contains non-markerable, toggleMarkup is no-op

Fixes #285
Fixes #287
@bantic bantic force-pushed the fix-toggle-section-marker-285 branch from d777d7d to 5ae07ee Compare January 11, 2016 22:43
mixonic added a commit that referenced this pull request Jan 11, 2016
Always `setRange` in `toggleMarkup` and `toggleSection`
@mixonic mixonic merged commit 3a22d87 into master Jan 11, 2016
@mixonic mixonic deleted the fix-toggle-section-marker-285 branch January 11, 2016 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants