Tweaked readOnly mode
This commit is contained in:
parent
a2599a9237
commit
71f390b316
|
@ -39,7 +39,7 @@ export default class TextAnnotator extends Component {
|
|||
componentDidMount() {
|
||||
this.highlighter = new Highlighter(this.props.contentEl, this.props.formatter);
|
||||
|
||||
this.selectionHandler = new SelectionHandler(this.props.contentEl, this.highlighter);
|
||||
this.selectionHandler = new SelectionHandler(this.props.contentEl, this.highlighter, this.props.readOnly);
|
||||
this.selectionHandler.on('select', this.handleSelect);
|
||||
|
||||
this.relationsLayer = new RelationsLayer(this.props.contentEl);
|
||||
|
|
|
@ -5,11 +5,12 @@ const IS_TOUCH = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|||
|
||||
export default class SelectionHandler extends EventEmitter {
|
||||
|
||||
constructor(element, highlighter) {
|
||||
constructor(element, highlighter, readOnly) {
|
||||
super();
|
||||
|
||||
this.el = element;
|
||||
this.highlighter = highlighter;
|
||||
this.readOnly = readOnly;
|
||||
|
||||
this.isEnabled = true;
|
||||
|
||||
|
@ -47,7 +48,7 @@ export default class SelectionHandler extends EventEmitter {
|
|||
// De-select
|
||||
this.emit('select', {});
|
||||
}
|
||||
} else {
|
||||
} else if (!this.readOnly) {
|
||||
const selectedRange = trimRange(selection.getRangeAt(0));
|
||||
|
||||
// Make sure the selection is entirely inside this.el
|
||||
|
|
Loading…
Reference in New Issue