Closes #8
This commit is contained in:
parent
6ca6d8e969
commit
a66df4950c
|
@ -49,17 +49,23 @@ export default class SelectionHandler extends EventEmitter {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const selectedRange = trimRange(selection.getRangeAt(0));
|
const selectedRange = trimRange(selection.getRangeAt(0));
|
||||||
const stub = rangeToSelection(selectedRange, this.el);
|
|
||||||
|
|
||||||
const spans = this.highlighter.wrapRange(selectedRange);
|
// Make sure the selection is entirely inside this.el
|
||||||
spans.forEach(span => span.className = 'r6o-selection');
|
const { commonAncestorContainer } = selectedRange;
|
||||||
|
|
||||||
this._clearNativeSelection();
|
if (this.el.contains(commonAncestorContainer)) {
|
||||||
|
const stub = rangeToSelection(selectedRange, this.el);
|
||||||
|
|
||||||
this.emit('select', {
|
const spans = this.highlighter.wrapRange(selectedRange);
|
||||||
selection: stub,
|
spans.forEach(span => span.className = 'r6o-selection');
|
||||||
element: selectedRange
|
|
||||||
});
|
this._clearNativeSelection();
|
||||||
|
|
||||||
|
this.emit('select', {
|
||||||
|
selection: stub,
|
||||||
|
element: selectedRange
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue