Issue #107
This commit is contained in:
parent
e7d7cd1948
commit
9657769e42
|
@ -11,6 +11,7 @@ export default class Selection {
|
||||||
|
|
||||||
constructor(target, body) {
|
constructor(target, body) {
|
||||||
this.underlying = {
|
this.underlying = {
|
||||||
|
'@context': 'http://www.w3.org/ns/anno.jsonld',
|
||||||
type: 'Selection',
|
type: 'Selection',
|
||||||
body: body || [],
|
body: body || [],
|
||||||
target
|
target
|
||||||
|
@ -29,6 +30,10 @@ export default class Selection {
|
||||||
return cloned;
|
return cloned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get context() {
|
||||||
|
return this.underlying['@context'];
|
||||||
|
}
|
||||||
|
|
||||||
get type() {
|
get type() {
|
||||||
return this.underlying.type;
|
return this.underlying.type;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +92,6 @@ 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',
|
|
||||||
'type': 'Annotation',
|
'type': 'Annotation',
|
||||||
'id': `#${uuid()}`
|
'id': `#${uuid()}`
|
||||||
});
|
});
|
||||||
|
|
|
@ -51,6 +51,10 @@ export default class WebAnnotation {
|
||||||
return this.underlying.id;
|
return this.underlying.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get context() {
|
||||||
|
return this.underlying['@context'];
|
||||||
|
}
|
||||||
|
|
||||||
get type() {
|
get type() {
|
||||||
return this.underlying.type;
|
return this.underlying.type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,6 +260,20 @@ export default class Editor extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a URI to the context field
|
||||||
|
*/
|
||||||
|
onAddContext = uri => {
|
||||||
|
const { currentAnnotation } = this.state;
|
||||||
|
const context = Array.isArray(currentAnnotation.context) ?
|
||||||
|
currentAnnotation.context : [ currentAnnotation.context ];
|
||||||
|
|
||||||
|
if (context.indexOf(uri) < 0) {
|
||||||
|
context.push(uri);
|
||||||
|
this.updateCurrentAnnotation({ '@context': context });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onCancel = () =>
|
onCancel = () =>
|
||||||
this.props.onCancel(this.props.annotation);
|
this.props.onCancel(this.props.annotation);
|
||||||
|
|
||||||
|
@ -335,6 +349,7 @@ export default class Editor extends Component {
|
||||||
onUpsertBody: this.onUpsertBody,
|
onUpsertBody: this.onUpsertBody,
|
||||||
onBatchModify: this.onBatchModify,
|
onBatchModify: this.onBatchModify,
|
||||||
onSetProperty: this.onSetProperty,
|
onSetProperty: this.onSetProperty,
|
||||||
|
onAddContext: this.onAddContext,
|
||||||
onSaveAndClose: this.onOk
|
onSaveAndClose: this.onOk
|
||||||
})
|
})
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -19,6 +19,7 @@ export default class WrappedWidget extends Component {
|
||||||
onRemoveBody: (body, saveImmediately) => props.onRemoveBody(body, saveImmediately),
|
onRemoveBody: (body, saveImmediately) => props.onRemoveBody(body, saveImmediately),
|
||||||
onBatchModify: (diffs, saveImmediately) => props.onBatchModify(diffs, saveImmediately),
|
onBatchModify: (diffs, saveImmediately) => props.onBatchModify(diffs, saveImmediately),
|
||||||
onSetProperty: (property, value) => props.onSetProperty(property, value),
|
onSetProperty: (property, value) => props.onSetProperty(property, value),
|
||||||
|
onAddContext: uri => props.onAddContext(uri),
|
||||||
onSaveAndClose: () => props.onSaveAndClose()
|
onSaveAndClose: () => props.onSaveAndClose()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue