@harvard-lts/mirador-annotations-auth-plugin 0.0.1 → 0.0.2
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 +143 -94
- package/package.json +1 -1
package/dist/es/index.js
CHANGED
|
@@ -430,10 +430,10 @@ var AnnotationsAuthSidePanel = /*#__PURE__*/function (_Component) {
|
|
|
430
430
|
_this.handleAnnotationBlur = _this.handleAnnotationBlur.bind(_this);
|
|
431
431
|
var _this$props = _this.props,
|
|
432
432
|
windowId = _this$props.windowId,
|
|
433
|
-
|
|
433
|
+
canvasAnnotationPages = _this$props.canvasAnnotationPages;
|
|
434
434
|
_this.state = {
|
|
435
435
|
windowId: windowId,
|
|
436
|
-
|
|
436
|
+
canvasAnnotationPages: canvasAnnotationPages
|
|
437
437
|
};
|
|
438
438
|
return _this;
|
|
439
439
|
}
|
|
@@ -479,38 +479,71 @@ var AnnotationsAuthSidePanel = /*#__PURE__*/function (_Component) {
|
|
|
479
479
|
}, {
|
|
480
480
|
key: "componentDidMount",
|
|
481
481
|
value: function () {
|
|
482
|
-
var _componentDidMount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
483
|
-
var
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
while (1) switch (_context.prev = _context.next) {
|
|
482
|
+
var _componentDidMount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
483
|
+
var canvasAnnotationPages, promises, results;
|
|
484
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
485
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
487
486
|
case 0:
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
487
|
+
canvasAnnotationPages = this.state.canvasAnnotationPages;
|
|
488
|
+
promises = [];
|
|
489
|
+
canvasAnnotationPages.forEach(function (annotationPage, index) {
|
|
490
|
+
var promise = new Promise(/*#__PURE__*/function () {
|
|
491
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve, reject) {
|
|
492
|
+
var result;
|
|
493
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
494
|
+
while (1) switch (_context.prev = _context.next) {
|
|
495
|
+
case 0:
|
|
496
|
+
_context.prev = 0;
|
|
497
|
+
_context.next = 3;
|
|
498
|
+
return fetch(annotationPage, {
|
|
499
|
+
method: 'get',
|
|
500
|
+
credentials: 'include'
|
|
501
|
+
});
|
|
502
|
+
case 3:
|
|
503
|
+
result = _context.sent;
|
|
504
|
+
resolve(result.json());
|
|
505
|
+
_context.next = 10;
|
|
506
|
+
break;
|
|
507
|
+
case 7:
|
|
508
|
+
_context.prev = 7;
|
|
509
|
+
_context.t0 = _context["catch"](0);
|
|
510
|
+
reject('Network response was not ok');
|
|
511
|
+
case 10:
|
|
512
|
+
case "end":
|
|
513
|
+
return _context.stop();
|
|
514
|
+
}
|
|
515
|
+
}, _callee, null, [[0, 7]]);
|
|
516
|
+
}));
|
|
517
|
+
return function (_x, _x2) {
|
|
518
|
+
return _ref.apply(this, arguments);
|
|
519
|
+
};
|
|
520
|
+
}());
|
|
521
|
+
promises.push(promise);
|
|
508
522
|
});
|
|
509
|
-
|
|
523
|
+
_context2.prev = 3;
|
|
524
|
+
_context2.next = 6;
|
|
525
|
+
return Promise.all(promises);
|
|
526
|
+
case 6:
|
|
527
|
+
results = _context2.sent;
|
|
528
|
+
this.setState({
|
|
529
|
+
annotationData: results,
|
|
530
|
+
loading: false
|
|
531
|
+
});
|
|
532
|
+
_context2.next = 14;
|
|
533
|
+
break;
|
|
534
|
+
case 10:
|
|
535
|
+
_context2.prev = 10;
|
|
536
|
+
_context2.t0 = _context2["catch"](3);
|
|
537
|
+
console.error('There was a problem receiving the annotation:', _context2.t0);
|
|
538
|
+
this.setState({
|
|
539
|
+
loading: false,
|
|
540
|
+
error: _context2.t0.message
|
|
541
|
+
});
|
|
542
|
+
case 14:
|
|
510
543
|
case "end":
|
|
511
|
-
return
|
|
544
|
+
return _context2.stop();
|
|
512
545
|
}
|
|
513
|
-
},
|
|
546
|
+
}, _callee2, this, [[3, 10]]);
|
|
514
547
|
}));
|
|
515
548
|
function componentDidMount() {
|
|
516
549
|
return _componentDidMount.apply(this, arguments);
|
|
@@ -520,7 +553,7 @@ var AnnotationsAuthSidePanel = /*#__PURE__*/function (_Component) {
|
|
|
520
553
|
}, {
|
|
521
554
|
key: "render",
|
|
522
555
|
value: function render() {
|
|
523
|
-
var
|
|
556
|
+
var _this2 = this;
|
|
524
557
|
var _this$props5 = this.props,
|
|
525
558
|
classes = _this$props5.classes,
|
|
526
559
|
containerRef = _this$props5.containerRef,
|
|
@@ -545,67 +578,71 @@ var AnnotationsAuthSidePanel = /*#__PURE__*/function (_Component) {
|
|
|
545
578
|
}), error && /*#__PURE__*/jsxs("p", {
|
|
546
579
|
children: ["Error: ", error]
|
|
547
580
|
})]
|
|
548
|
-
}), /*#__PURE__*/jsx(
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
581
|
+
}), annotationData && /*#__PURE__*/jsx(Fragment, {
|
|
582
|
+
children: annotationData.map(function (annotation, i) {
|
|
583
|
+
return /*#__PURE__*/jsx(MenuList, {
|
|
584
|
+
autoFocusItem: true,
|
|
585
|
+
variant: "selectedMenu",
|
|
586
|
+
children: /*#__PURE__*/jsx(ScrollTo, {
|
|
587
|
+
containerRef: containerRef,
|
|
588
|
+
offsetTop: 96 // offset for the height of the form above
|
|
589
|
+
,
|
|
590
|
+
scrollTo: selectedAnnotationId === {
|
|
591
|
+
annotation: annotation
|
|
592
|
+
}.id,
|
|
593
|
+
children: /*#__PURE__*/jsx(MenuItem, {
|
|
594
|
+
button: true,
|
|
595
|
+
component: listContainerComponent,
|
|
596
|
+
className: clsx(classes.annotationListItem, _defineProperty({}, classes.hovered, hoveredAnnotationIds.includes({
|
|
597
|
+
annotation: annotation
|
|
598
|
+
}.id))),
|
|
599
|
+
annotationid: {
|
|
600
|
+
annotation: annotation
|
|
601
|
+
}.id,
|
|
602
|
+
selected: selectedAnnotationId === {
|
|
603
|
+
annotation: annotation
|
|
604
|
+
}.id,
|
|
605
|
+
onClick: function onClick(e) {
|
|
606
|
+
return _this2.handleClick(e, {
|
|
607
|
+
annotation: annotation
|
|
608
|
+
});
|
|
609
|
+
},
|
|
610
|
+
onFocus: function onFocus() {
|
|
611
|
+
return _this2.handleAnnotationHover({
|
|
612
|
+
annotation: annotation
|
|
613
|
+
});
|
|
614
|
+
},
|
|
615
|
+
onBlur: _this2.handleAnnotationBlur,
|
|
616
|
+
onMouseEnter: function onMouseEnter() {
|
|
617
|
+
return _this2.handleAnnotationHover({
|
|
618
|
+
annotation: annotation
|
|
619
|
+
});
|
|
620
|
+
},
|
|
621
|
+
onMouseLeave: _this2.handleAnnotationBlur,
|
|
622
|
+
children: /*#__PURE__*/jsx(ListItemText, {
|
|
623
|
+
primaryTypographyProps: {
|
|
624
|
+
variant: 'body2'
|
|
625
|
+
},
|
|
626
|
+
children: /*#__PURE__*/jsx(SanitizedHtml, {
|
|
627
|
+
ruleSet: htmlSanitizationRuleSet,
|
|
628
|
+
htmlString: annotation.resources[0].resource.chars
|
|
629
|
+
})
|
|
630
|
+
})
|
|
631
|
+
}, {
|
|
632
|
+
annotation: annotation
|
|
633
|
+
}.id)
|
|
634
|
+
}, "".concat({
|
|
635
|
+
annotation: annotation
|
|
636
|
+
}.id, "-scroll"))
|
|
637
|
+
});
|
|
638
|
+
})
|
|
602
639
|
})]
|
|
603
640
|
});
|
|
604
641
|
}
|
|
605
642
|
}]);
|
|
606
643
|
}(Component);
|
|
607
644
|
AnnotationsAuthSidePanel.propTypes = {
|
|
608
|
-
|
|
645
|
+
canvasAnnotationPages: PropTypes.arrayOf(PropTypes.string),
|
|
609
646
|
canvasLabel: PropTypes.string,
|
|
610
647
|
classes: PropTypes.objectOf(PropTypes.string),
|
|
611
648
|
htmlSanitizationRuleSet: PropTypes.string,
|
|
@@ -617,7 +654,7 @@ AnnotationsAuthSidePanel.propTypes = {
|
|
|
617
654
|
windowId: PropTypes.string.isRequired
|
|
618
655
|
};
|
|
619
656
|
AnnotationsAuthSidePanel.defaultProps = {
|
|
620
|
-
|
|
657
|
+
canvasAnnotationPages: [],
|
|
621
658
|
canvasLabel: null,
|
|
622
659
|
classes: {},
|
|
623
660
|
htmlSanitizationRuleSet: 'iiif',
|
|
@@ -648,29 +685,41 @@ var styles = function styles(theme) {
|
|
|
648
685
|
};
|
|
649
686
|
|
|
650
687
|
/** */
|
|
651
|
-
function
|
|
652
|
-
var
|
|
688
|
+
function getAnnotationPages(canvases, canvasIds) {
|
|
689
|
+
var annotationPagesArray = [];
|
|
690
|
+
var annotationPages = [];
|
|
653
691
|
for (var i = 0; i < canvases.length; i++) {
|
|
654
692
|
if (canvases[i].id === canvasIds[0]) {
|
|
655
693
|
if (canvases[i].__jsonld.otherContent !== undefined) {
|
|
656
694
|
// Version 2 Annotation Page
|
|
657
|
-
|
|
695
|
+
canvases[i].__jsonld.otherContent[0]["@id"];
|
|
696
|
+
annotationPagesArray = canvases[i].__jsonld.otherContent;
|
|
697
|
+
for (var j = 0; j < annotationPagesArray.length; j++) {
|
|
698
|
+
if (annotationPagesArray[j]["@type"] === "sc:AnnotationList") {
|
|
699
|
+
annotationPages[j] = annotationPagesArray[j]["@id"];
|
|
700
|
+
}
|
|
701
|
+
}
|
|
658
702
|
}
|
|
659
703
|
if (canvases[i].__jsonld.annotations !== undefined) {
|
|
660
704
|
// Version 3 Annotation Page
|
|
661
|
-
|
|
705
|
+
canvases[i].__jsonld.annotations[0].id;
|
|
706
|
+
annotationPagesArray = canvases[i].__jsonld.annotations;
|
|
707
|
+
for (var _j = 0; _j < annotationPagesArray.length; _j++) {
|
|
708
|
+
if (annotationPagesArray[_j].type === "AnnotationPage") {
|
|
709
|
+
annotationPages[_j] = annotationPagesArray[_j].id;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
662
712
|
}
|
|
663
713
|
break;
|
|
664
714
|
}
|
|
665
715
|
}
|
|
666
|
-
|
|
667
|
-
return annotationPage;
|
|
716
|
+
return annotationPages;
|
|
668
717
|
}
|
|
669
718
|
var mapStateToProps = function mapStateToProps(state, _ref) {
|
|
670
719
|
var canvasId = _ref.canvasId,
|
|
671
720
|
windowId = _ref.windowId;
|
|
672
721
|
return {
|
|
673
|
-
|
|
722
|
+
canvasAnnotationPages: getAnnotationPages(getCanvases(state, {
|
|
674
723
|
windowId: windowId
|
|
675
724
|
}), getVisibleCanvasIds(state, {
|
|
676
725
|
windowId: windowId
|