Skip to content

Commit aa426ec

Browse files
committed
feat(selection-watcher): introducing new method
1 parent 54e0536 commit aa426ec

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/selection-watcher.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,19 @@ export default class SelectionWatcher {
2222
this.currentRange = undefined
2323
}
2424

25+
/**
26+
* Updates the internal selection pointer to the current rangy selection.
27+
*/
28+
syncSelection () {
29+
this.rangySelection = rangy.getSelection(this.win)
30+
}
31+
2532
/**
2633
* Return a RangeContainer if the current selection is within an editable
2734
* otherwise return an empty RangeContainer
2835
*/
2936
getRangeContainer () {
30-
this.rangySelection = rangy.getSelection(this.win)
37+
this.syncSelection()
3138

3239
// rangeCount is 0 or 1 in all browsers except firefox
3340
// firefox can work with multiple ranges

0 commit comments

Comments
 (0)