@harvard-lts/mirador-annotations-auth-plugin 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/index.js +60 -18
- package/package.json +1 -1
package/dist/es/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
|
13
13
|
import { withStyles } from '@material-ui/core/styles';
|
|
14
14
|
import { withTranslation } from 'react-i18next';
|
|
15
15
|
import { getVisibleCanvasIds, getCanvases, getCanvasLabel } from 'mirador/dist/es/src/state/selectors';
|
|
16
|
+
import AnnotationFactory from 'mirador/dist/es/src/lib/AnnotationFactory';
|
|
16
17
|
|
|
17
18
|
function _OverloadYield(e, d) {
|
|
18
19
|
this.v = e, this.k = d;
|
|
@@ -373,10 +374,12 @@ var AnnotationsAuthSidePanel = /*#__PURE__*/function (_Component) {
|
|
|
373
374
|
_this.handleAnnotationBlur = _this.handleAnnotationBlur.bind(_this);
|
|
374
375
|
var _this$props = _this.props,
|
|
375
376
|
windowId = _this$props.windowId,
|
|
376
|
-
canvasAnnotationPages = _this$props.canvasAnnotationPages
|
|
377
|
+
canvasAnnotationPages = _this$props.canvasAnnotationPages,
|
|
378
|
+
canvasAnnotationList = _this$props.canvasAnnotationList;
|
|
377
379
|
_this.state = {
|
|
378
380
|
windowId: windowId,
|
|
379
|
-
canvasAnnotationPages: canvasAnnotationPages
|
|
381
|
+
canvasAnnotationPages: canvasAnnotationPages,
|
|
382
|
+
canvasAnnotationList: canvasAnnotationList
|
|
380
383
|
};
|
|
381
384
|
return _this;
|
|
382
385
|
}
|
|
@@ -423,11 +426,25 @@ var AnnotationsAuthSidePanel = /*#__PURE__*/function (_Component) {
|
|
|
423
426
|
key: "componentDidMount",
|
|
424
427
|
value: function () {
|
|
425
428
|
var _componentDidMount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
426
|
-
var canvasAnnotationPages, promises, results;
|
|
429
|
+
var _this$state, canvasAnnotationPages, canvasAnnotationList, promises, results;
|
|
427
430
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
428
431
|
while (1) switch (_context2.prev = _context2.next) {
|
|
429
432
|
case 0:
|
|
430
|
-
|
|
433
|
+
_this$state = this.state, canvasAnnotationPages = _this$state.canvasAnnotationPages, canvasAnnotationList = _this$state.canvasAnnotationList;
|
|
434
|
+
if (!(canvasAnnotationList.json !== undefined)) {
|
|
435
|
+
_context2.next = 5;
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
if (!(canvasAnnotationList.json[0].items !== undefined)) {
|
|
439
|
+
_context2.next = 5;
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
this.setState({
|
|
443
|
+
annotationData: canvasAnnotationList.json[0].items,
|
|
444
|
+
loading: false
|
|
445
|
+
});
|
|
446
|
+
return _context2.abrupt("return");
|
|
447
|
+
case 5:
|
|
431
448
|
promises = [];
|
|
432
449
|
canvasAnnotationPages.forEach(function (annotationPage, index) {
|
|
433
450
|
var promise = new Promise(/*#__PURE__*/function () {
|
|
@@ -463,30 +480,30 @@ var AnnotationsAuthSidePanel = /*#__PURE__*/function (_Component) {
|
|
|
463
480
|
}());
|
|
464
481
|
promises.push(promise);
|
|
465
482
|
});
|
|
466
|
-
_context2.prev =
|
|
467
|
-
_context2.next =
|
|
483
|
+
_context2.prev = 7;
|
|
484
|
+
_context2.next = 10;
|
|
468
485
|
return Promise.all(promises);
|
|
469
|
-
case
|
|
486
|
+
case 10:
|
|
470
487
|
results = _context2.sent;
|
|
471
488
|
this.setState({
|
|
472
489
|
annotationData: results,
|
|
473
490
|
loading: false
|
|
474
491
|
});
|
|
475
|
-
_context2.next =
|
|
492
|
+
_context2.next = 18;
|
|
476
493
|
break;
|
|
477
|
-
case
|
|
478
|
-
_context2.prev =
|
|
479
|
-
_context2.t0 = _context2["catch"](
|
|
494
|
+
case 14:
|
|
495
|
+
_context2.prev = 14;
|
|
496
|
+
_context2.t0 = _context2["catch"](7);
|
|
480
497
|
console.error('There was a problem receiving the annotation:', _context2.t0);
|
|
481
498
|
this.setState({
|
|
482
499
|
loading: false,
|
|
483
500
|
error: _context2.t0.message
|
|
484
501
|
});
|
|
485
|
-
case
|
|
502
|
+
case 18:
|
|
486
503
|
case "end":
|
|
487
504
|
return _context2.stop();
|
|
488
505
|
}
|
|
489
|
-
}, _callee2, this, [[
|
|
506
|
+
}, _callee2, this, [[7, 14]]);
|
|
490
507
|
}));
|
|
491
508
|
function componentDidMount() {
|
|
492
509
|
return _componentDidMount.apply(this, arguments);
|
|
@@ -505,10 +522,10 @@ var AnnotationsAuthSidePanel = /*#__PURE__*/function (_Component) {
|
|
|
505
522
|
listContainerComponent = _this$props5.listContainerComponent,
|
|
506
523
|
hoveredAnnotationIds = _this$props5.hoveredAnnotationIds,
|
|
507
524
|
htmlSanitizationRuleSet = _this$props5.htmlSanitizationRuleSet;
|
|
508
|
-
var _this$
|
|
509
|
-
annotationData = _this$
|
|
510
|
-
loading = _this$
|
|
511
|
-
error = _this$
|
|
525
|
+
var _this$state2 = this.state,
|
|
526
|
+
annotationData = _this$state2.annotationData,
|
|
527
|
+
loading = _this$state2.loading,
|
|
528
|
+
error = _this$state2.error;
|
|
512
529
|
if ({
|
|
513
530
|
annotationData: annotationData
|
|
514
531
|
}.length === 0) return /*#__PURE__*/jsx(Fragment, {});
|
|
@@ -523,6 +540,7 @@ var AnnotationsAuthSidePanel = /*#__PURE__*/function (_Component) {
|
|
|
523
540
|
})]
|
|
524
541
|
}), annotationData && /*#__PURE__*/jsx(Fragment, {
|
|
525
542
|
children: annotationData.map(function (annotation, i) {
|
|
543
|
+
var _annotation$body, _annotation$resources;
|
|
526
544
|
return /*#__PURE__*/jsx(MenuList, {
|
|
527
545
|
autoFocusItem: true,
|
|
528
546
|
variant: "selectedMenu",
|
|
@@ -568,7 +586,7 @@ var AnnotationsAuthSidePanel = /*#__PURE__*/function (_Component) {
|
|
|
568
586
|
},
|
|
569
587
|
children: /*#__PURE__*/jsx(SanitizedHtml, {
|
|
570
588
|
ruleSet: htmlSanitizationRuleSet,
|
|
571
|
-
htmlString: annotation.resources[0].resource.chars
|
|
589
|
+
htmlString: ((_annotation$body = annotation.body) === null || _annotation$body === void 0 ? void 0 : _annotation$body.value) || ((_annotation$resources = annotation.resources) === null || _annotation$resources === void 0 || (_annotation$resources = _annotation$resources[0]) === null || _annotation$resources === void 0 || (_annotation$resources = _annotation$resources.resource) === null || _annotation$resources === void 0 ? void 0 : _annotation$resources.chars) || ''
|
|
572
590
|
})
|
|
573
591
|
})
|
|
574
592
|
}, {
|
|
@@ -586,6 +604,7 @@ var AnnotationsAuthSidePanel = /*#__PURE__*/function (_Component) {
|
|
|
586
604
|
}(Component);
|
|
587
605
|
AnnotationsAuthSidePanel.propTypes = {
|
|
588
606
|
canvasAnnotationPages: PropTypes.arrayOf(PropTypes.string),
|
|
607
|
+
canvasAnnotationList: PropTypes.arrayOf(PropTypes.object),
|
|
589
608
|
canvasLabel: PropTypes.string,
|
|
590
609
|
classes: PropTypes.objectOf(PropTypes.string),
|
|
591
610
|
htmlSanitizationRuleSet: PropTypes.string,
|
|
@@ -598,6 +617,7 @@ AnnotationsAuthSidePanel.propTypes = {
|
|
|
598
617
|
};
|
|
599
618
|
AnnotationsAuthSidePanel.defaultProps = {
|
|
600
619
|
canvasAnnotationPages: [],
|
|
620
|
+
canvasAnnotationList: [],
|
|
601
621
|
canvasLabel: null,
|
|
602
622
|
classes: {},
|
|
603
623
|
htmlSanitizationRuleSet: 'iiif',
|
|
@@ -658,6 +678,23 @@ function getAnnotationPages(canvases, canvasIds) {
|
|
|
658
678
|
}
|
|
659
679
|
return annotationPages;
|
|
660
680
|
}
|
|
681
|
+
function getAnnotationList(canvases, canvasIds) {
|
|
682
|
+
var annotationList = [];
|
|
683
|
+
for (var i = 0; i < canvases.length; i++) {
|
|
684
|
+
if (canvases[i].id === canvasIds[0]) {
|
|
685
|
+
if (canvases[i].__jsonld.otherContent !== undefined) {
|
|
686
|
+
// Version 2 Annotation Page
|
|
687
|
+
annotationList = AnnotationFactory.determineAnnotation(canvases[i].__jsonld.otherContent);
|
|
688
|
+
}
|
|
689
|
+
if (canvases[i].__jsonld.annotations !== undefined) {
|
|
690
|
+
// Version 3 Annotation Page
|
|
691
|
+
annotationList = AnnotationFactory.determineAnnotation(canvases[i].__jsonld.annotations);
|
|
692
|
+
}
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
return annotationList;
|
|
697
|
+
}
|
|
661
698
|
var mapStateToProps = function mapStateToProps(state, _ref) {
|
|
662
699
|
var canvasId = _ref.canvasId,
|
|
663
700
|
windowId = _ref.windowId;
|
|
@@ -667,6 +704,11 @@ var mapStateToProps = function mapStateToProps(state, _ref) {
|
|
|
667
704
|
}), getVisibleCanvasIds(state, {
|
|
668
705
|
windowId: windowId
|
|
669
706
|
})),
|
|
707
|
+
canvasAnnotationList: getAnnotationList(getCanvases(state, {
|
|
708
|
+
windowId: windowId
|
|
709
|
+
}), getVisibleCanvasIds(state, {
|
|
710
|
+
windowId: windowId
|
|
711
|
+
})),
|
|
670
712
|
canvasLabel: getCanvasLabel(state, {
|
|
671
713
|
canvasId: canvasId,
|
|
672
714
|
windowId: windowId
|