Bugfix
This commit is contained in:
parent
b875f99be7
commit
7e32f62a93
|
@ -9,7 +9,7 @@ import { v4 as uuid } from 'uuid';
|
||||||
export default class Selection {
|
export default class Selection {
|
||||||
|
|
||||||
constructor(target) {
|
constructor(target) {
|
||||||
this._underlying = {
|
this.underlying = {
|
||||||
type: 'Selection',
|
type: 'Selection',
|
||||||
body: [],
|
body: [],
|
||||||
target
|
target
|
||||||
|
@ -19,25 +19,25 @@ export default class Selection {
|
||||||
/** Creates a copy of this selection **/
|
/** Creates a copy of this selection **/
|
||||||
clone = opt_props => {
|
clone = opt_props => {
|
||||||
// Deep-clone target
|
// Deep-clone target
|
||||||
const clonedTarget = JSON.parse(JSON.stringify(this._underlying.target));
|
const clonedTarget = JSON.parse(JSON.stringify(this.underlying.target));
|
||||||
const cloned = new Selection(clonedTarget);
|
const cloned = new Selection(clonedTarget);
|
||||||
|
|
||||||
if (opt_props)
|
if (opt_props)
|
||||||
cloned._underlying = { ...cloned._underlying, ...opt_props };
|
cloned.underlying = { ...cloned.underlying, ...opt_props };
|
||||||
|
|
||||||
return cloned;
|
return cloned;
|
||||||
}
|
}
|
||||||
|
|
||||||
get type() {
|
get type() {
|
||||||
return this._underlying.type;
|
return this.underlying.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
get body() {
|
get body() {
|
||||||
return this._underlying.body;
|
return this.underlying.body;
|
||||||
}
|
}
|
||||||
|
|
||||||
get target() {
|
get target() {
|
||||||
return this._underlying.target;
|
return this.underlying.target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For consistency with WebAnnotation **/
|
/** For consistency with WebAnnotation **/
|
||||||
|
@ -45,16 +45,16 @@ export default class Selection {
|
||||||
if (!other) {
|
if (!other) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return this._underlying === other._underlying;
|
return this.underlying === other.underlying;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get bodies() {
|
get bodies() {
|
||||||
return this._underlying.body;
|
return this.underlying.body;
|
||||||
}
|
}
|
||||||
|
|
||||||
selector = type => {
|
selector = type => {
|
||||||
const { target } = this._underlying;
|
const { target } = this.underlying;
|
||||||
|
|
||||||
if (target.selector) {
|
if (target.selector) {
|
||||||
// Normalize to array
|
// Normalize to array
|
||||||
|
@ -79,7 +79,7 @@ export default class Selection {
|
||||||
}
|
}
|
||||||
|
|
||||||
toAnnotation = () => {
|
toAnnotation = () => {
|
||||||
const a = Object.assign({}, this._underlying, {
|
const a = Object.assign({}, this.underlying, {
|
||||||
'@context': 'http://www.w3.org/ns/anno.jsonld',
|
'@context': 'http://www.w3.org/ns/anno.jsonld',
|
||||||
'type': 'Annotation',
|
'type': 'Annotation',
|
||||||
'id': `#${uuid()}`
|
'id': `#${uuid()}`
|
||||||
|
|
Loading…
Reference in New Issue