Skip to content

Instantly share code, notes, and snippets.

@nedrocks
Created February 10, 2016 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nedrocks/d9384a536a49ccd4b915 to your computer and use it in GitHub Desktop.
Save nedrocks/d9384a536a49ccd4b915 to your computer and use it in GitHub Desktop.
Guardian/Scribe selection appears to change when logging
To show the issue, add an event listener for the scribe event in a plugin (e.g.):
scribe.el.addEventListener('keydown', function(evt) {
var lastSelection = new scribe.api.Selection();
console.log(lastSelection.range.collapsed);
console.log(lastSelection.range);
});
Now, select a block of text within the same span (1 or more characters) and type any key that modifies the state
(i.e. forces an input event to fire.) Note that the output should looks something like:
false <---- this is lastSelection.range.collapsed, which is correct
{
collapsed: true <----- Wait what???
commonAncestorContainer: text
endContainer: text
endOffset: 6
startContainer: text
startOffset: 6
...
}
It's still a little unclear if this is a browser issue or whether this is a scribe issue. Needless to say this
will get confusing when debugging so be careful!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment