@harvard-lts/mirador-annotations-auth-plugin 0.0.1
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/LICENSE +201 -0
- package/README.md +43 -0
- package/dist/es/index.js +694 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Mirador annotations authentication plugin
|
|
2
|
+
|
|
3
|
+
A Mirador 3 plugin for including authentication cookies for annotations.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- [NVM](https://github.com/nvm-sh/nvm)
|
|
8
|
+
|
|
9
|
+
## Setup
|
|
10
|
+
|
|
11
|
+
1. Run `nvm use` to ensure your version of matches that in the `.nvmrc` file
|
|
12
|
+
2. Run `npm i` to install dependencies
|
|
13
|
+
3. Use one of the [NPM scripts](#npm-scripts) to perform the actions described below.
|
|
14
|
+
|
|
15
|
+
## NPM scripts
|
|
16
|
+
|
|
17
|
+
The following are some useful scripts can be ran using `npm run <script>`. A full list can be seen in [package.json](./package.json)
|
|
18
|
+
|
|
19
|
+
| Script | Description |
|
|
20
|
+
| ------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
21
|
+
| `clean` | Removes the `dist` directories |
|
|
22
|
+
| `build` | Builds the source files into the `./dist` directory |
|
|
23
|
+
| `serve` | Runs a local web server where the plugin can be viewed in a vanilla Mirador instance (helpful for testing and development) |
|
|
24
|
+
| `test` | Runs the automated test suites
|
|
25
|
+
|
|
26
|
+
## Installing in Mirador
|
|
27
|
+
|
|
28
|
+
The `mirador-annotations-auth-plugin` requires an instance of Mirador 3. Visit the [Mirador wiki](https://github.com/ProjectMirador/mirador/wiki) to learn how to [install an existing plugin](https://github.com/ProjectMirador/mirador/wiki/Mirador-3-plugins#installing-an-existing-plugin) and for additional information about plugins.
|
|
29
|
+
|
|
30
|
+
Package you will need to install:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm i @harvard-lts/mirador-annotations-auth-plugin
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Contribute
|
|
37
|
+
Mirador's development, design, and maintenance is driven by community needs and ongoing feedback and discussion. Join us at our regularly scheduled community calls, on [IIIF slack #mirador](http://bit.ly/iiif-slack), or the [mirador-tech](https://groups.google.com/forum/#!forum/mirador-tech) and [iiif-discuss](https://groups.google.com/forum/#!forum/iiif-discuss) mailing lists. To suggest features, report bugs, and clarify usage, please submit a GitHub issue.
|
|
38
|
+
|
|
39
|
+
[build-badge]: https://img.shields.io/travis/projectmirador/mirador-annotations-auth-plugin/master.png?style=flat-square
|
|
40
|
+
[build]: https://travis-ci.org/projectmirador/mirador-annotations-auth-plugin
|
|
41
|
+
|
|
42
|
+
[npm-badge]: https://img.shields.io/npm/v/mirador-annotations-auth-plugin.png?style=flat-square
|
|
43
|
+
[npm]: https://www.npmjs.org/package/mirador-annotations-auth-plugin
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
import { compose } from 'redux';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import React, { Component } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import Typography from '@material-ui/core/Typography';
|
|
7
|
+
import MenuList from '@material-ui/core/MenuList';
|
|
8
|
+
import MenuItem from '@material-ui/core/MenuItem';
|
|
9
|
+
import ListItemText from '@material-ui/core/ListItemText';
|
|
10
|
+
import { ScrollTo } from 'mirador/dist/es/src/components/ScrollTo';
|
|
11
|
+
import SanitizedHtml from 'mirador/dist/es/src/containers/SanitizedHtml';
|
|
12
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
13
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
14
|
+
import { withTranslation } from 'react-i18next';
|
|
15
|
+
import { getVisibleCanvasIds, getCanvases, getCanvasLabel } from 'mirador/dist/es/src/state/selectors';
|
|
16
|
+
|
|
17
|
+
function _assertThisInitialized(e) {
|
|
18
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
19
|
+
return e;
|
|
20
|
+
}
|
|
21
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
22
|
+
try {
|
|
23
|
+
var i = n[a](c),
|
|
24
|
+
u = i.value;
|
|
25
|
+
} catch (n) {
|
|
26
|
+
return void e(n);
|
|
27
|
+
}
|
|
28
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
29
|
+
}
|
|
30
|
+
function _asyncToGenerator(n) {
|
|
31
|
+
return function () {
|
|
32
|
+
var t = this,
|
|
33
|
+
e = arguments;
|
|
34
|
+
return new Promise(function (r, o) {
|
|
35
|
+
var a = n.apply(t, e);
|
|
36
|
+
function _next(n) {
|
|
37
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
38
|
+
}
|
|
39
|
+
function _throw(n) {
|
|
40
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
41
|
+
}
|
|
42
|
+
_next(void 0);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function _callSuper(t, o, e) {
|
|
47
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
48
|
+
}
|
|
49
|
+
function _classCallCheck(a, n) {
|
|
50
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
51
|
+
}
|
|
52
|
+
function _defineProperties(e, r) {
|
|
53
|
+
for (var t = 0; t < r.length; t++) {
|
|
54
|
+
var o = r[t];
|
|
55
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function _createClass(e, r, t) {
|
|
59
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
60
|
+
writable: !1
|
|
61
|
+
}), e;
|
|
62
|
+
}
|
|
63
|
+
function _defineProperty(e, r, t) {
|
|
64
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
65
|
+
value: t,
|
|
66
|
+
enumerable: !0,
|
|
67
|
+
configurable: !0,
|
|
68
|
+
writable: !0
|
|
69
|
+
}) : e[r] = t, e;
|
|
70
|
+
}
|
|
71
|
+
function _getPrototypeOf(t) {
|
|
72
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
73
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
74
|
+
}, _getPrototypeOf(t);
|
|
75
|
+
}
|
|
76
|
+
function _inherits(t, e) {
|
|
77
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
78
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
79
|
+
constructor: {
|
|
80
|
+
value: t,
|
|
81
|
+
writable: !0,
|
|
82
|
+
configurable: !0
|
|
83
|
+
}
|
|
84
|
+
}), Object.defineProperty(t, "prototype", {
|
|
85
|
+
writable: !1
|
|
86
|
+
}), e && _setPrototypeOf(t, e);
|
|
87
|
+
}
|
|
88
|
+
function _isNativeReflectConstruct() {
|
|
89
|
+
try {
|
|
90
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
91
|
+
} catch (t) {}
|
|
92
|
+
return (_isNativeReflectConstruct = function () {
|
|
93
|
+
return !!t;
|
|
94
|
+
})();
|
|
95
|
+
}
|
|
96
|
+
function _possibleConstructorReturn(t, e) {
|
|
97
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
98
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
99
|
+
return _assertThisInitialized(t);
|
|
100
|
+
}
|
|
101
|
+
function _regeneratorRuntime() {
|
|
102
|
+
_regeneratorRuntime = function () {
|
|
103
|
+
return e;
|
|
104
|
+
};
|
|
105
|
+
var t,
|
|
106
|
+
e = {},
|
|
107
|
+
r = Object.prototype,
|
|
108
|
+
n = r.hasOwnProperty,
|
|
109
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
110
|
+
t[e] = r.value;
|
|
111
|
+
},
|
|
112
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
113
|
+
a = i.iterator || "@@iterator",
|
|
114
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
115
|
+
u = i.toStringTag || "@@toStringTag";
|
|
116
|
+
function define(t, e, r) {
|
|
117
|
+
return Object.defineProperty(t, e, {
|
|
118
|
+
value: r,
|
|
119
|
+
enumerable: !0,
|
|
120
|
+
configurable: !0,
|
|
121
|
+
writable: !0
|
|
122
|
+
}), t[e];
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
define({}, "");
|
|
126
|
+
} catch (t) {
|
|
127
|
+
define = function (t, e, r) {
|
|
128
|
+
return t[e] = r;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function wrap(t, e, r, n) {
|
|
132
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
133
|
+
a = Object.create(i.prototype),
|
|
134
|
+
c = new Context(n || []);
|
|
135
|
+
return o(a, "_invoke", {
|
|
136
|
+
value: makeInvokeMethod(t, r, c)
|
|
137
|
+
}), a;
|
|
138
|
+
}
|
|
139
|
+
function tryCatch(t, e, r) {
|
|
140
|
+
try {
|
|
141
|
+
return {
|
|
142
|
+
type: "normal",
|
|
143
|
+
arg: t.call(e, r)
|
|
144
|
+
};
|
|
145
|
+
} catch (t) {
|
|
146
|
+
return {
|
|
147
|
+
type: "throw",
|
|
148
|
+
arg: t
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
e.wrap = wrap;
|
|
153
|
+
var h = "suspendedStart",
|
|
154
|
+
l = "suspendedYield",
|
|
155
|
+
f = "executing",
|
|
156
|
+
s = "completed",
|
|
157
|
+
y = {};
|
|
158
|
+
function Generator() {}
|
|
159
|
+
function GeneratorFunction() {}
|
|
160
|
+
function GeneratorFunctionPrototype() {}
|
|
161
|
+
var p = {};
|
|
162
|
+
define(p, a, function () {
|
|
163
|
+
return this;
|
|
164
|
+
});
|
|
165
|
+
var d = Object.getPrototypeOf,
|
|
166
|
+
v = d && d(d(values([])));
|
|
167
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
168
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
169
|
+
function defineIteratorMethods(t) {
|
|
170
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
171
|
+
define(t, e, function (t) {
|
|
172
|
+
return this._invoke(e, t);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function AsyncIterator(t, e) {
|
|
177
|
+
function invoke(r, o, i, a) {
|
|
178
|
+
var c = tryCatch(t[r], t, o);
|
|
179
|
+
if ("throw" !== c.type) {
|
|
180
|
+
var u = c.arg,
|
|
181
|
+
h = u.value;
|
|
182
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
183
|
+
invoke("next", t, i, a);
|
|
184
|
+
}, function (t) {
|
|
185
|
+
invoke("throw", t, i, a);
|
|
186
|
+
}) : e.resolve(h).then(function (t) {
|
|
187
|
+
u.value = t, i(u);
|
|
188
|
+
}, function (t) {
|
|
189
|
+
return invoke("throw", t, i, a);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
a(c.arg);
|
|
193
|
+
}
|
|
194
|
+
var r;
|
|
195
|
+
o(this, "_invoke", {
|
|
196
|
+
value: function (t, n) {
|
|
197
|
+
function callInvokeWithMethodAndArg() {
|
|
198
|
+
return new e(function (e, r) {
|
|
199
|
+
invoke(t, n, e, r);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function makeInvokeMethod(e, r, n) {
|
|
207
|
+
var o = h;
|
|
208
|
+
return function (i, a) {
|
|
209
|
+
if (o === f) throw Error("Generator is already running");
|
|
210
|
+
if (o === s) {
|
|
211
|
+
if ("throw" === i) throw a;
|
|
212
|
+
return {
|
|
213
|
+
value: t,
|
|
214
|
+
done: !0
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
for (n.method = i, n.arg = a;;) {
|
|
218
|
+
var c = n.delegate;
|
|
219
|
+
if (c) {
|
|
220
|
+
var u = maybeInvokeDelegate(c, n);
|
|
221
|
+
if (u) {
|
|
222
|
+
if (u === y) continue;
|
|
223
|
+
return u;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
227
|
+
if (o === h) throw o = s, n.arg;
|
|
228
|
+
n.dispatchException(n.arg);
|
|
229
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
230
|
+
o = f;
|
|
231
|
+
var p = tryCatch(e, r, n);
|
|
232
|
+
if ("normal" === p.type) {
|
|
233
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
234
|
+
return {
|
|
235
|
+
value: p.arg,
|
|
236
|
+
done: n.done
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
function maybeInvokeDelegate(e, r) {
|
|
244
|
+
var n = r.method,
|
|
245
|
+
o = e.iterator[n];
|
|
246
|
+
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
247
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
248
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
249
|
+
var a = i.arg;
|
|
250
|
+
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
251
|
+
}
|
|
252
|
+
function pushTryEntry(t) {
|
|
253
|
+
var e = {
|
|
254
|
+
tryLoc: t[0]
|
|
255
|
+
};
|
|
256
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
257
|
+
}
|
|
258
|
+
function resetTryEntry(t) {
|
|
259
|
+
var e = t.completion || {};
|
|
260
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
261
|
+
}
|
|
262
|
+
function Context(t) {
|
|
263
|
+
this.tryEntries = [{
|
|
264
|
+
tryLoc: "root"
|
|
265
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
266
|
+
}
|
|
267
|
+
function values(e) {
|
|
268
|
+
if (e || "" === e) {
|
|
269
|
+
var r = e[a];
|
|
270
|
+
if (r) return r.call(e);
|
|
271
|
+
if ("function" == typeof e.next) return e;
|
|
272
|
+
if (!isNaN(e.length)) {
|
|
273
|
+
var o = -1,
|
|
274
|
+
i = function next() {
|
|
275
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
276
|
+
return next.value = t, next.done = !0, next;
|
|
277
|
+
};
|
|
278
|
+
return i.next = i;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
282
|
+
}
|
|
283
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
284
|
+
value: GeneratorFunctionPrototype,
|
|
285
|
+
configurable: !0
|
|
286
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
287
|
+
value: GeneratorFunction,
|
|
288
|
+
configurable: !0
|
|
289
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
290
|
+
var e = "function" == typeof t && t.constructor;
|
|
291
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
292
|
+
}, e.mark = function (t) {
|
|
293
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
294
|
+
}, e.awrap = function (t) {
|
|
295
|
+
return {
|
|
296
|
+
__await: t
|
|
297
|
+
};
|
|
298
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
299
|
+
return this;
|
|
300
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
301
|
+
void 0 === i && (i = Promise);
|
|
302
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
303
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
304
|
+
return t.done ? t.value : a.next();
|
|
305
|
+
});
|
|
306
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
307
|
+
return this;
|
|
308
|
+
}), define(g, "toString", function () {
|
|
309
|
+
return "[object Generator]";
|
|
310
|
+
}), e.keys = function (t) {
|
|
311
|
+
var e = Object(t),
|
|
312
|
+
r = [];
|
|
313
|
+
for (var n in e) r.push(n);
|
|
314
|
+
return r.reverse(), function next() {
|
|
315
|
+
for (; r.length;) {
|
|
316
|
+
var t = r.pop();
|
|
317
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
318
|
+
}
|
|
319
|
+
return next.done = !0, next;
|
|
320
|
+
};
|
|
321
|
+
}, e.values = values, Context.prototype = {
|
|
322
|
+
constructor: Context,
|
|
323
|
+
reset: function (e) {
|
|
324
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
325
|
+
},
|
|
326
|
+
stop: function () {
|
|
327
|
+
this.done = !0;
|
|
328
|
+
var t = this.tryEntries[0].completion;
|
|
329
|
+
if ("throw" === t.type) throw t.arg;
|
|
330
|
+
return this.rval;
|
|
331
|
+
},
|
|
332
|
+
dispatchException: function (e) {
|
|
333
|
+
if (this.done) throw e;
|
|
334
|
+
var r = this;
|
|
335
|
+
function handle(n, o) {
|
|
336
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
337
|
+
}
|
|
338
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
339
|
+
var i = this.tryEntries[o],
|
|
340
|
+
a = i.completion;
|
|
341
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
342
|
+
if (i.tryLoc <= this.prev) {
|
|
343
|
+
var c = n.call(i, "catchLoc"),
|
|
344
|
+
u = n.call(i, "finallyLoc");
|
|
345
|
+
if (c && u) {
|
|
346
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
347
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
348
|
+
} else if (c) {
|
|
349
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
350
|
+
} else {
|
|
351
|
+
if (!u) throw Error("try statement without catch or finally");
|
|
352
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
abrupt: function (t, e) {
|
|
358
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
359
|
+
var o = this.tryEntries[r];
|
|
360
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
361
|
+
var i = o;
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
366
|
+
var a = i ? i.completion : {};
|
|
367
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
368
|
+
},
|
|
369
|
+
complete: function (t, e) {
|
|
370
|
+
if ("throw" === t.type) throw t.arg;
|
|
371
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
372
|
+
},
|
|
373
|
+
finish: function (t) {
|
|
374
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
375
|
+
var r = this.tryEntries[e];
|
|
376
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
catch: function (t) {
|
|
380
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
381
|
+
var r = this.tryEntries[e];
|
|
382
|
+
if (r.tryLoc === t) {
|
|
383
|
+
var n = r.completion;
|
|
384
|
+
if ("throw" === n.type) {
|
|
385
|
+
var o = n.arg;
|
|
386
|
+
resetTryEntry(r);
|
|
387
|
+
}
|
|
388
|
+
return o;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
throw Error("illegal catch attempt");
|
|
392
|
+
},
|
|
393
|
+
delegateYield: function (e, r, n) {
|
|
394
|
+
return this.delegate = {
|
|
395
|
+
iterator: values(e),
|
|
396
|
+
resultName: r,
|
|
397
|
+
nextLoc: n
|
|
398
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
399
|
+
}
|
|
400
|
+
}, e;
|
|
401
|
+
}
|
|
402
|
+
function _setPrototypeOf(t, e) {
|
|
403
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
404
|
+
return t.__proto__ = e, t;
|
|
405
|
+
}, _setPrototypeOf(t, e);
|
|
406
|
+
}
|
|
407
|
+
function _toPrimitive(t, r) {
|
|
408
|
+
if ("object" != typeof t || !t) return t;
|
|
409
|
+
var e = t[Symbol.toPrimitive];
|
|
410
|
+
if (void 0 !== e) {
|
|
411
|
+
var i = e.call(t, r || "default");
|
|
412
|
+
if ("object" != typeof i) return i;
|
|
413
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
414
|
+
}
|
|
415
|
+
return ("string" === r ? String : Number)(t);
|
|
416
|
+
}
|
|
417
|
+
function _toPropertyKey(t) {
|
|
418
|
+
var i = _toPrimitive(t, "string");
|
|
419
|
+
return "symbol" == typeof i ? i : i + "";
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
var AnnotationsAuthSidePanel = /*#__PURE__*/function (_Component) {
|
|
423
|
+
function AnnotationsAuthSidePanel(props) {
|
|
424
|
+
var _this;
|
|
425
|
+
_classCallCheck(this, AnnotationsAuthSidePanel);
|
|
426
|
+
_this = _callSuper(this, AnnotationsAuthSidePanel, [props]);
|
|
427
|
+
_this.containerRef = /*#__PURE__*/React.createRef();
|
|
428
|
+
_this.handleClick = _this.handleClick.bind(_this);
|
|
429
|
+
_this.handleAnnotationHover = _this.handleAnnotationHover.bind(_this);
|
|
430
|
+
_this.handleAnnotationBlur = _this.handleAnnotationBlur.bind(_this);
|
|
431
|
+
var _this$props = _this.props,
|
|
432
|
+
windowId = _this$props.windowId,
|
|
433
|
+
canvasAnnotationPage = _this$props.canvasAnnotationPage;
|
|
434
|
+
_this.state = {
|
|
435
|
+
windowId: windowId,
|
|
436
|
+
canvasAnnotationPage: canvasAnnotationPage
|
|
437
|
+
};
|
|
438
|
+
return _this;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Handle click event of an annotation.
|
|
443
|
+
*/
|
|
444
|
+
_inherits(AnnotationsAuthSidePanel, _Component);
|
|
445
|
+
return _createClass(AnnotationsAuthSidePanel, [{
|
|
446
|
+
key: "handleClick",
|
|
447
|
+
value: function handleClick(event, annotation) {
|
|
448
|
+
var _this$props2 = this.props,
|
|
449
|
+
deselectAnnotation = _this$props2.deselectAnnotation,
|
|
450
|
+
selectAnnotation = _this$props2.selectAnnotation,
|
|
451
|
+
selectedAnnotationId = _this$props2.selectedAnnotationId,
|
|
452
|
+
windowId = _this$props2.windowId;
|
|
453
|
+
if (selectedAnnotationId === annotation.id) {
|
|
454
|
+
deselectAnnotation(windowId, annotation.id);
|
|
455
|
+
} else {
|
|
456
|
+
selectAnnotation(windowId, annotation.id);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/** */
|
|
461
|
+
}, {
|
|
462
|
+
key: "handleAnnotationHover",
|
|
463
|
+
value: function handleAnnotationHover(annotation) {
|
|
464
|
+
var _this$props3 = this.props,
|
|
465
|
+
hoverAnnotation = _this$props3.hoverAnnotation,
|
|
466
|
+
windowId = _this$props3.windowId;
|
|
467
|
+
hoverAnnotation(windowId, [annotation.id]);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/** */
|
|
471
|
+
}, {
|
|
472
|
+
key: "handleAnnotationBlur",
|
|
473
|
+
value: function handleAnnotationBlur() {
|
|
474
|
+
var _this$props4 = this.props,
|
|
475
|
+
hoverAnnotation = _this$props4.hoverAnnotation,
|
|
476
|
+
windowId = _this$props4.windowId;
|
|
477
|
+
hoverAnnotation(windowId, []);
|
|
478
|
+
}
|
|
479
|
+
}, {
|
|
480
|
+
key: "componentDidMount",
|
|
481
|
+
value: function () {
|
|
482
|
+
var _componentDidMount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
483
|
+
var _this2 = this;
|
|
484
|
+
var canvasAnnotationPage;
|
|
485
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
486
|
+
while (1) switch (_context.prev = _context.next) {
|
|
487
|
+
case 0:
|
|
488
|
+
canvasAnnotationPage = this.state.canvasAnnotationPage;
|
|
489
|
+
fetch(canvasAnnotationPage, {
|
|
490
|
+
method: 'get',
|
|
491
|
+
credentials: 'include'
|
|
492
|
+
}).then(function (response) {
|
|
493
|
+
if (!response.ok) {
|
|
494
|
+
throw new Error('Network response was not ok');
|
|
495
|
+
}
|
|
496
|
+
return response.json();
|
|
497
|
+
}).then(function (annotationData) {
|
|
498
|
+
_this2.setState({
|
|
499
|
+
annotationData: annotationData,
|
|
500
|
+
loading: false
|
|
501
|
+
});
|
|
502
|
+
})["catch"](function (error) {
|
|
503
|
+
console.error('There was a problem receiving the annotation:', error);
|
|
504
|
+
_this2.setState({
|
|
505
|
+
loading: false,
|
|
506
|
+
error: error.message
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
case 2:
|
|
510
|
+
case "end":
|
|
511
|
+
return _context.stop();
|
|
512
|
+
}
|
|
513
|
+
}, _callee, this);
|
|
514
|
+
}));
|
|
515
|
+
function componentDidMount() {
|
|
516
|
+
return _componentDidMount.apply(this, arguments);
|
|
517
|
+
}
|
|
518
|
+
return componentDidMount;
|
|
519
|
+
}()
|
|
520
|
+
}, {
|
|
521
|
+
key: "render",
|
|
522
|
+
value: function render() {
|
|
523
|
+
var _this3 = this;
|
|
524
|
+
var _this$props5 = this.props,
|
|
525
|
+
classes = _this$props5.classes,
|
|
526
|
+
containerRef = _this$props5.containerRef,
|
|
527
|
+
canvasLabel = _this$props5.canvasLabel,
|
|
528
|
+
selectedAnnotationId = _this$props5.selectedAnnotationId,
|
|
529
|
+
listContainerComponent = _this$props5.listContainerComponent,
|
|
530
|
+
hoveredAnnotationIds = _this$props5.hoveredAnnotationIds,
|
|
531
|
+
htmlSanitizationRuleSet = _this$props5.htmlSanitizationRuleSet;
|
|
532
|
+
var _this$state = this.state,
|
|
533
|
+
annotationData = _this$state.annotationData,
|
|
534
|
+
loading = _this$state.loading,
|
|
535
|
+
error = _this$state.error;
|
|
536
|
+
if ({
|
|
537
|
+
annotationData: annotationData
|
|
538
|
+
}.length === 0) return /*#__PURE__*/jsx(Fragment, {});
|
|
539
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
540
|
+
children: [/*#__PURE__*/jsxs(Typography, {
|
|
541
|
+
className: classes.sectionHeading,
|
|
542
|
+
variant: "overline",
|
|
543
|
+
children: [canvasLabel, loading && /*#__PURE__*/jsx("p", {
|
|
544
|
+
children: "Loading..."
|
|
545
|
+
}), error && /*#__PURE__*/jsxs("p", {
|
|
546
|
+
children: ["Error: ", error]
|
|
547
|
+
})]
|
|
548
|
+
}), /*#__PURE__*/jsx(MenuList, {
|
|
549
|
+
autoFocusItem: true,
|
|
550
|
+
variant: "selectedMenu",
|
|
551
|
+
children: /*#__PURE__*/jsx(ScrollTo, {
|
|
552
|
+
containerRef: containerRef,
|
|
553
|
+
offsetTop: 96 // offset for the height of the form above
|
|
554
|
+
,
|
|
555
|
+
scrollTo: selectedAnnotationId === {
|
|
556
|
+
annotationData: annotationData
|
|
557
|
+
}.id,
|
|
558
|
+
children: /*#__PURE__*/jsx(MenuItem, {
|
|
559
|
+
button: true,
|
|
560
|
+
component: listContainerComponent,
|
|
561
|
+
className: clsx(classes.annotationListItem, _defineProperty({}, classes.hovered, hoveredAnnotationIds.includes({
|
|
562
|
+
annotationData: annotationData
|
|
563
|
+
}.id))),
|
|
564
|
+
annotationid: {
|
|
565
|
+
annotationData: annotationData
|
|
566
|
+
}.id,
|
|
567
|
+
selected: selectedAnnotationId === {
|
|
568
|
+
annotationData: annotationData
|
|
569
|
+
}.id,
|
|
570
|
+
onClick: function onClick(e) {
|
|
571
|
+
return _this3.handleClick(e, {
|
|
572
|
+
annotationData: annotationData
|
|
573
|
+
});
|
|
574
|
+
},
|
|
575
|
+
onFocus: function onFocus() {
|
|
576
|
+
return _this3.handleAnnotationHover({
|
|
577
|
+
annotationData: annotationData
|
|
578
|
+
});
|
|
579
|
+
},
|
|
580
|
+
onBlur: this.handleAnnotationBlur,
|
|
581
|
+
onMouseEnter: function onMouseEnter() {
|
|
582
|
+
return _this3.handleAnnotationHover({
|
|
583
|
+
annotationData: annotationData
|
|
584
|
+
});
|
|
585
|
+
},
|
|
586
|
+
onMouseLeave: this.handleAnnotationBlur,
|
|
587
|
+
children: /*#__PURE__*/jsx(ListItemText, {
|
|
588
|
+
primaryTypographyProps: {
|
|
589
|
+
variant: 'body2'
|
|
590
|
+
},
|
|
591
|
+
children: annotationData && /*#__PURE__*/jsx(SanitizedHtml, {
|
|
592
|
+
ruleSet: htmlSanitizationRuleSet,
|
|
593
|
+
htmlString: annotationData.resources[0].resource.chars
|
|
594
|
+
})
|
|
595
|
+
})
|
|
596
|
+
}, {
|
|
597
|
+
annotationData: annotationData
|
|
598
|
+
}.id)
|
|
599
|
+
}, "".concat({
|
|
600
|
+
annotationData: annotationData
|
|
601
|
+
}.id, "-scroll"))
|
|
602
|
+
})]
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
}]);
|
|
606
|
+
}(Component);
|
|
607
|
+
AnnotationsAuthSidePanel.propTypes = {
|
|
608
|
+
canvasAnnotationPage: PropTypes.string,
|
|
609
|
+
canvasLabel: PropTypes.string,
|
|
610
|
+
classes: PropTypes.objectOf(PropTypes.string),
|
|
611
|
+
htmlSanitizationRuleSet: PropTypes.string,
|
|
612
|
+
hoverAnnotation: PropTypes.func.isRequired,
|
|
613
|
+
hoveredAnnotationIds: PropTypes.arrayOf(PropTypes.string),
|
|
614
|
+
listContainerComponent: PropTypes.elementType,
|
|
615
|
+
selectAnnotation: PropTypes.func.isRequired,
|
|
616
|
+
selectedAnnotationId: PropTypes.string,
|
|
617
|
+
windowId: PropTypes.string.isRequired
|
|
618
|
+
};
|
|
619
|
+
AnnotationsAuthSidePanel.defaultProps = {
|
|
620
|
+
canvasAnnotationPage: null,
|
|
621
|
+
canvasLabel: null,
|
|
622
|
+
classes: {},
|
|
623
|
+
htmlSanitizationRuleSet: 'iiif',
|
|
624
|
+
hoverAnnotation: function hoverAnnotation() {},
|
|
625
|
+
hoveredAnnotationIds: [],
|
|
626
|
+
listContainerComponent: 'li',
|
|
627
|
+
selectAnnotation: function selectAnnotation() {},
|
|
628
|
+
selectedAnnotationId: undefined,
|
|
629
|
+
windowId: null
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
var styles = function styles(theme) {
|
|
633
|
+
return {
|
|
634
|
+
section: {
|
|
635
|
+
borderBottom: ".5px solid ".concat(theme.palette.section_divider),
|
|
636
|
+
paddingBottom: theme.spacing(1),
|
|
637
|
+
paddingLeft: theme.spacing(2),
|
|
638
|
+
paddingRight: theme.spacing(1),
|
|
639
|
+
paddingTop: theme.spacing(2)
|
|
640
|
+
},
|
|
641
|
+
citationIntro: {
|
|
642
|
+
paddingBottom: theme.spacing(1),
|
|
643
|
+
paddingLeft: theme.spacing(2),
|
|
644
|
+
paddingRight: theme.spacing(1),
|
|
645
|
+
paddingTop: theme.spacing(2)
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
/** */
|
|
651
|
+
function getAnnotationPage(canvases, canvasIds) {
|
|
652
|
+
var annotationPage = null;
|
|
653
|
+
for (var i = 0; i < canvases.length; i++) {
|
|
654
|
+
if (canvases[i].id === canvasIds[0]) {
|
|
655
|
+
if (canvases[i].__jsonld.otherContent !== undefined) {
|
|
656
|
+
// Version 2 Annotation Page
|
|
657
|
+
annotationPage = canvases[i].__jsonld.otherContent[0]["@id"];
|
|
658
|
+
}
|
|
659
|
+
if (canvases[i].__jsonld.annotations !== undefined) {
|
|
660
|
+
// Version 3 Annotation Page
|
|
661
|
+
annotationPage = canvases[i].__jsonld.annotations[0].id;
|
|
662
|
+
}
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
console.log('annotationPage', annotationPage);
|
|
667
|
+
return annotationPage;
|
|
668
|
+
}
|
|
669
|
+
var mapStateToProps = function mapStateToProps(state, _ref) {
|
|
670
|
+
var canvasId = _ref.canvasId,
|
|
671
|
+
windowId = _ref.windowId;
|
|
672
|
+
return {
|
|
673
|
+
canvasAnnotationPage: getAnnotationPage(getCanvases(state, {
|
|
674
|
+
windowId: windowId
|
|
675
|
+
}), getVisibleCanvasIds(state, {
|
|
676
|
+
windowId: windowId
|
|
677
|
+
})),
|
|
678
|
+
canvasLabel: getCanvasLabel(state, {
|
|
679
|
+
canvasId: canvasId,
|
|
680
|
+
windowId: windowId
|
|
681
|
+
}),
|
|
682
|
+
windowId: windowId
|
|
683
|
+
};
|
|
684
|
+
};
|
|
685
|
+
var enhance = compose(withTranslation(), withStyles(styles), connect(mapStateToProps));
|
|
686
|
+
var AnnotationsAuthPanel = {
|
|
687
|
+
target: 'CanvasAnnotations',
|
|
688
|
+
mode: 'wrap',
|
|
689
|
+
component: enhance(AnnotationsAuthSidePanel)
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
var index = [AnnotationsAuthPanel];
|
|
693
|
+
|
|
694
|
+
export { AnnotationsAuthPanel, index as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@harvard-lts/mirador-annotations-auth-plugin",
|
|
3
|
+
"license": "Apache-2.0",
|
|
4
|
+
"repository": "https://github.com/harvard-lts/mirador-annotations-auth-plugin.git",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react-component"
|
|
7
|
+
],
|
|
8
|
+
"version": "0.0.1",
|
|
9
|
+
"description": "A Mirador 3 plugin for including authentication cookies for annotations.",
|
|
10
|
+
"module": "dist/es/index.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"clean": "rm -rf ./dist && rm -rf ./demo/dist",
|
|
16
|
+
"prebuild": "npm run clean",
|
|
17
|
+
"prepublishOnly": "npm run build",
|
|
18
|
+
"build": "run-p build:es",
|
|
19
|
+
"build:es": "rollup -c",
|
|
20
|
+
"serve": "webpack serve --mode development --open",
|
|
21
|
+
"test": "jest",
|
|
22
|
+
"test:coverage": "jest --coverage",
|
|
23
|
+
"test:watch": "jest --watch"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@babel/cli": "^7.26.4",
|
|
27
|
+
"@babel/core": "^7.26.0",
|
|
28
|
+
"@babel/preset-env": "^7.21.4",
|
|
29
|
+
"@babel/preset-react": "^7.18.6",
|
|
30
|
+
"@material-ui/core": "^4.12.4",
|
|
31
|
+
"@material-ui/icons": "^4.11.2",
|
|
32
|
+
"@rollup/plugin-babel": "^6.0.3",
|
|
33
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
34
|
+
"@testing-library/react": "^12.0.0",
|
|
35
|
+
"babel-jest": "^29.7.0",
|
|
36
|
+
"babel-loader": "^9.1.2",
|
|
37
|
+
"jest": "^29.7.0",
|
|
38
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
39
|
+
"mirador": "^3.4.3",
|
|
40
|
+
"npm-run-all": "^4.1.5",
|
|
41
|
+
"rollup": "^3.29.5",
|
|
42
|
+
"url": "^0.11.0",
|
|
43
|
+
"webpack": "^5.94.0",
|
|
44
|
+
"webpack-cli": "^5.1.4",
|
|
45
|
+
"webpack-dev-server": "^5.2.0",
|
|
46
|
+
"webpack-node-externals": "^3.0.0",
|
|
47
|
+
"whatwg-fetch": "^3.6.2"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"jquery": "^3.7.0",
|
|
51
|
+
"prop-types": "^15.8.1",
|
|
52
|
+
"react": "^16.14.0",
|
|
53
|
+
"react-dom": "^16.14.0"
|
|
54
|
+
}
|
|
55
|
+
}
|