@recogito/recogito-client-core
Advanced tools
Comparing version 0.1.8 to 0.1.9
{ | ||
"name": "@recogito/recogito-client-core", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "Core functions, classes and components for RecogitoJS", | ||
@@ -52,4 +52,4 @@ "main": "src/index.js", | ||
"tiny-emitter": "^2.1.0", | ||
"uuid": "^8.2.0" | ||
"uuid": "^8.3.0" | ||
} | ||
} |
@@ -13,3 +13,3 @@ import Connection from './Connection'; | ||
this.connections = []; | ||
this.connections = []; | ||
@@ -19,3 +19,3 @@ this.contentEl = contentEl; | ||
this.svg = document.createElementNS(CONST.NAMESPACE, 'svg'); | ||
this.svg.classList.add('r6o-relations-layer'); | ||
this.svg.setAttribute('class', 'r6o-relations-layer'); | ||
this.contentEl.appendChild(this.svg); | ||
@@ -38,3 +38,3 @@ | ||
const c = new Connection(this.contentEl, this.svg, annotation); | ||
// Forward click event as selection, unless we're read-only | ||
@@ -68,5 +68,5 @@ c.on('click', relation => this.emit('selectRelation', relation)); | ||
} | ||
addOrUpdateRelation = (relation, maybePrevious) => { | ||
const previous = maybePrevious ? | ||
const previous = maybePrevious ? | ||
this.connections.find(c => c.matchesRelation(relation)) : null; | ||
@@ -159,7 +159,7 @@ | ||
if (readOnly) | ||
this.svg.classList.add('readonly'); | ||
this.svg.setAttribute('class', 'r6o-relations-layer readonly'); | ||
else | ||
this.svg.classList.remove('readonly'); | ||
this.svg.setAttribute('class', 'r6o-relations-layer'); | ||
} | ||
} |
import { trimRange, rangeToSelection, enableTouch, getExactOverlaps } from './SelectionUtils'; | ||
import { isInternetExplorer } from '../utils'; | ||
import EventEmitter from 'tiny-emitter'; | ||
@@ -6,2 +7,20 @@ | ||
const IS_INTERNET_EXPLORER = | ||
window?.navigator.userAgent.match(/(MSIE|Trident)/); | ||
/** Tests whether maybeChildEl is contained in containerEl **/ | ||
const contains = (containerEl, maybeChildEl) => { | ||
if (IS_INTERNET_EXPLORER) { | ||
// In IE, .contains returns false for text nodes | ||
// https://stackoverflow.com/questions/44140712/ie-acting-strange-with-node-contains-and-text-nodes | ||
if (maybeChildEl.nodeType == Node.TEXT_NODE) | ||
return containerEl === maybeChildEl.parentNode || containerEl.contains(maybeChildEl.parentNode); | ||
else | ||
return containerEl.contains(maybeChildEl); | ||
} else { | ||
// Things can be so simple, unless you're in IE | ||
return containerEl.contains(maybeChildEl); | ||
} | ||
} | ||
export default class SelectionHandler extends EventEmitter { | ||
@@ -58,3 +77,3 @@ | ||
if (this.el.contains(commonAncestorContainer)) { | ||
if (contains(this.el, commonAncestorContainer)) { | ||
const stub = rangeToSelection(selectedRange, this.el); | ||
@@ -61,0 +80,0 @@ |
@@ -38,3 +38,8 @@ import I18n from '../i18n'; | ||
const deflatedChildren = deflateOne(parent); | ||
parent.innerHTML = ''; | ||
// This would be easier, but breaks on IE11 | ||
// parent.innerHTML = ''; | ||
while (parent.firstChild) | ||
parent.removeChild(parent.lastChild); | ||
deflatedChildren.forEach(node => parent.appendChild(node)); | ||
@@ -41,0 +46,0 @@ }); |
1207668
2569
Updateduuid@^8.3.0