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