Reputation: 511
The below code snippet is working well for all browsers except Microsoft Edge.
$rootScope.highlights = $window.rangy.createHighlighter();
$rootScope.highlights.addClassApplier($window.rangy.createClassApplier('commented-text'));
$rootScope.highlights.highlightSelection('commented-text');
$window.getSelection().collapseToStart();
Is there anything we need to specifically add for Edge?
Upvotes: 0
Views: 231
Reputation: 602
There is an open issue on the rangy github https://github.com/timdown/rangy/issues/368 with some kind of possible solution proposed.
Commenting out the method on line 2277 of rangy-core.js
Maybe this can help you as well?
Upvotes: 1
Reputation: 511
After a lot of research, came to solution that rangy.createHighlighter() without any parameters won't work for Edge.
You need to specify the "TextRange" additional parameter (see below).
The default is "textContent".
$rootScope.highlights = rangy.createHighlighter(window.document, "TextRange");
Reference: https://github.com/timdown/rangy/wiki/Highlighter-Module
Upvotes: 1