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