dbf-mirador 4.2.3
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 +203 -0
- package/README.md +133 -0
- package/dist/CommentSharp-B0J_-jEq.js +325 -0
- package/dist/CommentSharp-B0J_-jEq.js.map +1 -0
- package/dist/FailedImageContext-aQXnWSHN.js +318 -0
- package/dist/FailedImageContext-aQXnWSHN.js.map +1 -0
- package/dist/PluginHook-CFw_6P5c.js +54 -0
- package/dist/PluginHook-CFw_6P5c.js.map +1 -0
- package/dist/WindowCanvasNavigationControls-CUX723BQ.js +242 -0
- package/dist/WindowCanvasNavigationControls-CUX723BQ.js.map +1 -0
- package/dist/action-types-DjIbTE-A.js +74 -0
- package/dist/action-types-DjIbTE-A.js.map +1 -0
- package/dist/canvas-C8oHvXFN.js +41 -0
- package/dist/canvas-C8oHvXFN.js.map +1 -0
- package/dist/canvases-gRqhr-IH.js +3154 -0
- package/dist/canvases-gRqhr-IH.js.map +1 -0
- package/dist/createSvgIcon-Cwt8YPfm.js +2 -0
- package/dist/getters-COus7Mvg.js +2066 -0
- package/dist/getters-COus7Mvg.js.map +1 -0
- package/dist/index.module-CbBRf_R8.js +403 -0
- package/dist/index.module-CbBRf_R8.js.map +1 -0
- package/dist/mirador.es.js +39600 -0
- package/dist/mirador.es.js.map +1 -0
- package/dist/mirador.min.js +334 -0
- package/dist/mirador.min.js.map +1 -0
- package/dist/react-error-boundary.esm-B_pT-oCS.js +67 -0
- package/dist/react-error-boundary.esm-B_pT-oCS.js.map +1 -0
- package/dist/visuallyHidden-DmYvwNdU.js +98 -0
- package/dist/visuallyHidden-DmYvwNdU.js.map +1 -0
- package/dist/window-zelwU7wz.js +138 -0
- package/dist/window-zelwU7wz.js.map +1 -0
- package/package.json +138 -0
- package/src/components/AccessTokenSender.jsx +34 -0
- package/src/components/AnnotationSettings.jsx +31 -0
- package/src/components/AnnotationsOverlay.jsx +328 -0
- package/src/components/App.jsx +34 -0
- package/src/components/AppProviders.jsx +129 -0
- package/src/components/AttributionPanel.jsx +78 -0
- package/src/components/AudioViewer.jsx +39 -0
- package/src/components/BackgroundPluginArea.jsx +9 -0
- package/src/components/Branding.jsx +33 -0
- package/src/components/CanvasAnnotations.jsx +125 -0
- package/src/components/CanvasInfo.jsx +46 -0
- package/src/components/CanvasLayers.jsx +367 -0
- package/src/components/ChangeThemeDialog.jsx +65 -0
- package/src/components/CollapsibleSection.jsx +53 -0
- package/src/components/CollectionDialog.jsx +236 -0
- package/src/components/CollectionInfo.jsx +48 -0
- package/src/components/CompanionArea.jsx +140 -0
- package/src/components/CompanionWindow.jsx +228 -0
- package/src/components/CompanionWindowFactory.jsx +38 -0
- package/src/components/CompanionWindowSection.jsx +11 -0
- package/src/components/CustomPanel.jsx +22 -0
- package/src/components/ErrorContent.jsx +65 -0
- package/src/components/ErrorDialog.jsx +47 -0
- package/src/components/FullScreenButton.jsx +47 -0
- package/src/components/GalleryView.jsx +36 -0
- package/src/components/GalleryViewThumbnail.jsx +160 -0
- package/src/components/IIIFAuthentication.jsx +144 -0
- package/src/components/IIIFDropTarget.jsx +168 -0
- package/src/components/IIIFIFrameCommunication.jsx +45 -0
- package/src/components/IIIFResourceLabel.jsx +26 -0
- package/src/components/IIIFThumbnail.jsx +214 -0
- package/src/components/ImageFailureMessage.jsx +42 -0
- package/src/components/LabelValueMetadata.jsx +46 -0
- package/src/components/LanguageSettings.jsx +46 -0
- package/src/components/LayersPanel.jsx +24 -0
- package/src/components/LocalePicker.jsx +56 -0
- package/src/components/ManifestForm.jsx +79 -0
- package/src/components/ManifestInfo.jsx +67 -0
- package/src/components/ManifestListItem.jsx +209 -0
- package/src/components/ManifestListItemError.jsx +53 -0
- package/src/components/ManifestRelatedLinks.jsx +154 -0
- package/src/components/MinimalWindow.jsx +104 -0
- package/src/components/MiradorMenuButton.jsx +71 -0
- package/src/components/MosaicRenderPreview.jsx +16 -0
- package/src/components/NestedMenu.jsx +42 -0
- package/src/components/NewBrowserWindow.jsx +34 -0
- package/src/components/OpenSeadragonComponent.jsx +258 -0
- package/src/components/OpenSeadragonTileSource.jsx +105 -0
- package/src/components/OpenSeadragonViewer.jsx +161 -0
- package/src/components/PluginHook.jsx +27 -0
- package/src/components/PrimaryWindow.jsx +115 -0
- package/src/components/SanitizedHtml.jsx +37 -0
- package/src/components/ScrollIndicatedDialogContent.jsx +60 -0
- package/src/components/ScrollTo.jsx +61 -0
- package/src/components/SearchHit.jsx +220 -0
- package/src/components/SearchPanel.jsx +80 -0
- package/src/components/SearchPanelControls.jsx +174 -0
- package/src/components/SearchPanelNavigation.jsx +84 -0
- package/src/components/SearchResults.jsx +138 -0
- package/src/components/SelectCollection.jsx +44 -0
- package/src/components/SidebarIndexItem.jsx +11 -0
- package/src/components/SidebarIndexList.jsx +73 -0
- package/src/components/SidebarIndexTableOfContents.jsx +170 -0
- package/src/components/SidebarIndexThumbnail.jsx +22 -0
- package/src/components/TextViewer.jsx +37 -0
- package/src/components/ThumbnailCanvasGrouping.jsx +122 -0
- package/src/components/ThumbnailNavigation.jsx +231 -0
- package/src/components/VideoViewer.jsx +35 -0
- package/src/components/ViewerInfo.jsx +55 -0
- package/src/components/ViewerNavigation.jsx +72 -0
- package/src/components/Window.jsx +150 -0
- package/src/components/WindowAuthenticationBar.jsx +176 -0
- package/src/components/WindowCanvasNavigationControls.jsx +91 -0
- package/src/components/WindowList.jsx +71 -0
- package/src/components/WindowListButton.jsx +57 -0
- package/src/components/WindowSideBar.jsx +48 -0
- package/src/components/WindowSideBarAnnotationsPanel.jsx +51 -0
- package/src/components/WindowSideBarButtons.jsx +151 -0
- package/src/components/WindowSideBarCanvasPanel.jsx +165 -0
- package/src/components/WindowSideBarCollectionPanel.jsx +179 -0
- package/src/components/WindowSideBarInfoPanel.jsx +67 -0
- package/src/components/WindowThumbnailSettings.jsx +130 -0
- package/src/components/WindowTopBar.jsx +125 -0
- package/src/components/WindowTopBarPluginArea.jsx +8 -0
- package/src/components/WindowTopBarPluginMenu.jsx +78 -0
- package/src/components/WindowTopBarTitle.jsx +73 -0
- package/src/components/WindowTopMenu.jsx +81 -0
- package/src/components/WindowTopMenuButton.jsx +49 -0
- package/src/components/WindowViewSettings.jsx +95 -0
- package/src/components/WindowViewer.jsx +26 -0
- package/src/components/Workspace.jsx +124 -0
- package/src/components/WorkspaceAdd.jsx +221 -0
- package/src/components/WorkspaceAddButton.jsx +73 -0
- package/src/components/WorkspaceArea.jsx +66 -0
- package/src/components/WorkspaceControlPanel.jsx +85 -0
- package/src/components/WorkspaceControlPanelButtons.jsx +20 -0
- package/src/components/WorkspaceDialog.jsx +11 -0
- package/src/components/WorkspaceElastic.jsx +88 -0
- package/src/components/WorkspaceElasticWindow.jsx +79 -0
- package/src/components/WorkspaceExport.jsx +99 -0
- package/src/components/WorkspaceImport.jsx +89 -0
- package/src/components/WorkspaceMenu.jsx +126 -0
- package/src/components/WorkspaceMenuButton.jsx +42 -0
- package/src/components/WorkspaceMosaic.jsx +149 -0
- package/src/components/WorkspaceOptionsButton.jsx +35 -0
- package/src/components/WorkspaceOptionsMenu.jsx +112 -0
- package/src/components/WorkspaceSelectionDialog.jsx +165 -0
- package/src/components/ZoomControls.jsx +57 -0
- package/src/components/icons/BookViewIcon.jsx +14 -0
- package/src/components/icons/CanvasIndexIcon.jsx +14 -0
- package/src/components/icons/GalleryViewIcon.jsx +17 -0
- package/src/components/icons/MiradorIcon.jsx +14 -0
- package/src/components/icons/RestoreZoomIcon.jsx +15 -0
- package/src/components/icons/ThumbnailNavigationBottomIcon.jsx +15 -0
- package/src/components/icons/ThumbnailNavigationRightIcon.jsx +16 -0
- package/src/components/icons/WindowMaxIcon.jsx +15 -0
- package/src/components/icons/WindowMinIcon.jsx +15 -0
- package/src/components/icons/WindowOptionsIcon.jsx +16 -0
- package/src/components/icons/WorkspaceTypeElasticIcon.jsx +157 -0
- package/src/components/icons/WorkspaceTypeMosaicIcon.jsx +162 -0
- package/src/components/icons/index.js +27 -0
- package/src/components/index.js +108 -0
- package/src/config/css-ns.js +10 -0
- package/src/config/index.js +2 -0
- package/src/config/settings.js +607 -0
- package/src/containers/AnnotationSettings.js +27 -0
- package/src/containers/AnnotationsOverlay.js +51 -0
- package/src/containers/AppProviders.js +20 -0
- package/src/containers/AttributionPanel.js +20 -0
- package/src/containers/AudioViewer.js +16 -0
- package/src/containers/BackgroundPluginArea.js +4 -0
- package/src/containers/Branding.js +4 -0
- package/src/containers/CanvasAnnotations.js +32 -0
- package/src/containers/CanvasInfo.js +20 -0
- package/src/containers/CanvasLayers.js +25 -0
- package/src/containers/ChangeThemeDialog.js +29 -0
- package/src/containers/CollapsibleSection.js +3 -0
- package/src/containers/CollectionDialog.js +48 -0
- package/src/containers/CollectionInfo.js +29 -0
- package/src/containers/CompanionArea.js +22 -0
- package/src/containers/CompanionWindow.js +40 -0
- package/src/containers/CompanionWindowFactory.js +23 -0
- package/src/containers/CustomPanel.js +13 -0
- package/src/containers/ErrorContent.js +20 -0
- package/src/containers/ErrorDialog.js +28 -0
- package/src/containers/FullScreenButton.js +22 -0
- package/src/containers/GalleryView.js +23 -0
- package/src/containers/GalleryViewThumbnail.js +51 -0
- package/src/containers/IIIFAuthentication.js +86 -0
- package/src/containers/IIIFThumbnail.js +17 -0
- package/src/containers/LabelValueMetadata.js +14 -0
- package/src/containers/LanguageSettings.js +26 -0
- package/src/containers/LayersPanel.js +16 -0
- package/src/containers/LocalePicker.js +3 -0
- package/src/containers/ManifestForm.js +16 -0
- package/src/containers/ManifestInfo.js +29 -0
- package/src/containers/ManifestListItem.js +52 -0
- package/src/containers/ManifestListItemError.js +15 -0
- package/src/containers/ManifestRelatedLinks.js +28 -0
- package/src/containers/MinimalWindow.js +25 -0
- package/src/containers/MiradorMenuButton.js +7 -0
- package/src/containers/MosaicRenderPreview.js +14 -0
- package/src/containers/OpenSeadragonViewer.js +59 -0
- package/src/containers/PrimaryWindow.js +27 -0
- package/src/containers/SanitizedHtml.js +3 -0
- package/src/containers/ScrollIndicatedDialogContent.js +3 -0
- package/src/containers/SearchHit.js +71 -0
- package/src/containers/SearchPanel.js +23 -0
- package/src/containers/SearchPanelControls.js +36 -0
- package/src/containers/SearchPanelNavigation.js +39 -0
- package/src/containers/SearchResults.js +38 -0
- package/src/containers/SelectCollection.js +24 -0
- package/src/containers/SidebarIndexItem.js +8 -0
- package/src/containers/SidebarIndexList.js +28 -0
- package/src/containers/SidebarIndexTableOfContents.js +31 -0
- package/src/containers/SidebarIndexThumbnail.js +18 -0
- package/src/containers/TextViewer.js +19 -0
- package/src/containers/ThumbnailCanvasGrouping.js +29 -0
- package/src/containers/ThumbnailNavigation.js +48 -0
- package/src/containers/VideoViewer.js +16 -0
- package/src/containers/ViewerInfo.js +30 -0
- package/src/containers/ViewerNavigation.js +31 -0
- package/src/containers/Window.js +45 -0
- package/src/containers/WindowAuthenticationBar.js +7 -0
- package/src/containers/WindowCanvasNavigationControls.js +15 -0
- package/src/containers/WindowList.js +30 -0
- package/src/containers/WindowListButton.js +15 -0
- package/src/containers/WindowSideBar.js +20 -0
- package/src/containers/WindowSideBarAnnotationsPanel.js +23 -0
- package/src/containers/WindowSideBarButtons.js +75 -0
- package/src/containers/WindowSideBarCanvasPanel.js +50 -0
- package/src/containers/WindowSideBarCollectionPanel.js +48 -0
- package/src/containers/WindowSideBarInfoPanel.js +35 -0
- package/src/containers/WindowThumbnailSettings.js +31 -0
- package/src/containers/WindowTopBar.js +39 -0
- package/src/containers/WindowTopBarPluginArea.js +8 -0
- package/src/containers/WindowTopBarPluginMenu.js +7 -0
- package/src/containers/WindowTopBarTitle.js +17 -0
- package/src/containers/WindowTopMenu.js +28 -0
- package/src/containers/WindowTopMenuButton.js +7 -0
- package/src/containers/WindowViewSettings.js +30 -0
- package/src/containers/WindowViewer.js +10 -0
- package/src/containers/Workspace.js +36 -0
- package/src/containers/WorkspaceAdd.js +27 -0
- package/src/containers/WorkspaceAddButton.js +30 -0
- package/src/containers/WorkspaceArea.js +21 -0
- package/src/containers/WorkspaceControlPanel.js +10 -0
- package/src/containers/WorkspaceControlPanelButtons.js +7 -0
- package/src/containers/WorkspaceElastic.js +41 -0
- package/src/containers/WorkspaceElasticWindow.js +36 -0
- package/src/containers/WorkspaceExport.js +18 -0
- package/src/containers/WorkspaceImport.js +19 -0
- package/src/containers/WorkspaceMenu.js +30 -0
- package/src/containers/WorkspaceMenuButton.js +10 -0
- package/src/containers/WorkspaceMosaic.js +32 -0
- package/src/containers/WorkspaceOptionsButton.js +7 -0
- package/src/containers/WorkspaceOptionsMenu.js +3 -0
- package/src/containers/WorkspaceSelectionDialog.js +26 -0
- package/src/containers/ZoomControls.js +26 -0
- package/src/containers/index.js +94 -0
- package/src/contexts/FailedImageContext.js +8 -0
- package/src/contexts/FailedImageProvider.jsx +34 -0
- package/src/contexts/FullScreenContext.js +5 -0
- package/src/contexts/LocaleContext.js +5 -0
- package/src/contexts/OpenSeadragonViewerContext.js +5 -0
- package/src/contexts/WorkspaceContext.js +5 -0
- package/src/contexts/index.js +4 -0
- package/src/extend/PluginContext.js +5 -0
- package/src/extend/PluginProvider.jsx +22 -0
- package/src/extend/index.js +9 -0
- package/src/extend/pluginMapping.js +44 -0
- package/src/extend/pluginPreprocessing.js +45 -0
- package/src/extend/pluginValidation.js +58 -0
- package/src/extend/usePlugins.js +13 -0
- package/src/extend/withPlugins.jsx +46 -0
- package/src/hooks/index.js +4 -0
- package/src/hooks/useCanvasWorldService.js +10 -0
- package/src/hooks/useThumbnailService.js +8 -0
- package/src/i18n.js +71 -0
- package/src/index.js +18 -0
- package/src/init.js +20 -0
- package/src/lib/AnnotationFactory.js +23 -0
- package/src/lib/AnnotationItem.js +123 -0
- package/src/lib/AnnotationList.js +31 -0
- package/src/lib/AnnotationPage.js +41 -0
- package/src/lib/AnnotationResource.js +122 -0
- package/src/lib/CanvasAnnotationDisplay.js +148 -0
- package/src/lib/CanvasGroupings.js +55 -0
- package/src/lib/CanvasWorld.js +214 -0
- package/src/lib/CompanionWindowRegistry.js +23 -0
- package/src/lib/FullScreenHandle.jsx +76 -0
- package/src/lib/MiradorCanvas.js +211 -0
- package/src/lib/MiradorManifest.js +44 -0
- package/src/lib/MiradorViewer.jsx +53 -0
- package/src/lib/MosaicLayout.js +77 -0
- package/src/lib/OpenSeadragonCanvasOverlay.js +114 -0
- package/src/lib/ThumbnailFactory.js +310 -0
- package/src/lib/TruncatedHit.js +34 -0
- package/src/lib/asArray.js +11 -0
- package/src/lib/htmlRules.js +28 -0
- package/src/lib/iiif.js +12 -0
- package/src/lib/index.js +23 -0
- package/src/lib/readImageMetadata.js +21 -0
- package/src/lib/svgShapesToPath.js +49 -0
- package/src/locales/README.md +60 -0
- package/src/locales/ar/translation.json +141 -0
- package/src/locales/bg/translation.json +164 -0
- package/src/locales/de/translation.json +169 -0
- package/src/locales/en/translation.json +170 -0
- package/src/locales/et/translation.json +164 -0
- package/src/locales/fa/translation.json +164 -0
- package/src/locales/fr/translation.json +158 -0
- package/src/locales/hr/translation.json +164 -0
- package/src/locales/hu/translation.json +166 -0
- package/src/locales/it/translation.json +162 -0
- package/src/locales/ja/translation.json +156 -0
- package/src/locales/kr/translation.json +162 -0
- package/src/locales/lt/translation.json +153 -0
- package/src/locales/nbNo/translation.json +162 -0
- package/src/locales/nl/translation.json +139 -0
- package/src/locales/pl/translation.json +162 -0
- package/src/locales/ptBr/translation.json +133 -0
- package/src/locales/sr/translation.json +155 -0
- package/src/locales/sv/translation.json +157 -0
- package/src/locales/ta/translation.json +167 -0
- package/src/locales/vi/translation.json +156 -0
- package/src/locales/zhCn/translation.json +163 -0
- package/src/locales/zhTw/translation.json +163 -0
- package/src/plugins/OSDReferences.js +15 -0
- package/src/plugins/index.js +1 -0
- package/src/state/actions/action-types.js +76 -0
- package/src/state/actions/annotation.js +123 -0
- package/src/state/actions/auth.js +109 -0
- package/src/state/actions/canvas.js +65 -0
- package/src/state/actions/catalog.js +22 -0
- package/src/state/actions/companionWindow.js +107 -0
- package/src/state/actions/config.js +49 -0
- package/src/state/actions/elasticLayout.js +10 -0
- package/src/state/actions/errors.js +22 -0
- package/src/state/actions/index.js +19 -0
- package/src/state/actions/infoResponse.js +90 -0
- package/src/state/actions/layers.js +14 -0
- package/src/state/actions/manifest.js +65 -0
- package/src/state/actions/search.js +97 -0
- package/src/state/actions/window.js +209 -0
- package/src/state/actions/workspace.js +84 -0
- package/src/state/createPluggableStore.js +24 -0
- package/src/state/createStore.js +33 -0
- package/src/state/index.js +21 -0
- package/src/state/reducers/accessTokens.js +59 -0
- package/src/state/reducers/annotations.js +48 -0
- package/src/state/reducers/auth.js +43 -0
- package/src/state/reducers/catalog.js +30 -0
- package/src/state/reducers/companionWindows.js +49 -0
- package/src/state/reducers/config.js +39 -0
- package/src/state/reducers/elasticLayout.js +29 -0
- package/src/state/reducers/errors.js +51 -0
- package/src/state/reducers/index.js +15 -0
- package/src/state/reducers/infoResponses.js +61 -0
- package/src/state/reducers/layers.js +23 -0
- package/src/state/reducers/manifests.js +52 -0
- package/src/state/reducers/rootReducer.js +44 -0
- package/src/state/reducers/search.js +145 -0
- package/src/state/reducers/utils.js +45 -0
- package/src/state/reducers/viewers.js +42 -0
- package/src/state/reducers/windows.js +185 -0
- package/src/state/reducers/workspace.js +111 -0
- package/src/state/sagas/annotations.js +48 -0
- package/src/state/sagas/app.js +56 -0
- package/src/state/sagas/auth.js +151 -0
- package/src/state/sagas/iiif.js +233 -0
- package/src/state/sagas/index.js +30 -0
- package/src/state/sagas/windows.js +293 -0
- package/src/state/selectors/annotations.js +138 -0
- package/src/state/selectors/auth.js +100 -0
- package/src/state/selectors/canvases.js +260 -0
- package/src/state/selectors/companionWindows.js +182 -0
- package/src/state/selectors/config.js +100 -0
- package/src/state/selectors/getters.js +90 -0
- package/src/state/selectors/index.js +17 -0
- package/src/state/selectors/layers.js +79 -0
- package/src/state/selectors/manifests.js +433 -0
- package/src/state/selectors/ranges.js +147 -0
- package/src/state/selectors/searches.js +249 -0
- package/src/state/selectors/sequences.js +134 -0
- package/src/state/selectors/thumbnails.js +28 -0
- package/src/state/selectors/utils.js +18 -0
- package/src/state/selectors/viewer.js +19 -0
- package/src/state/selectors/windows.js +98 -0
- package/src/state/selectors/workspace.js +52 -0
- package/src/state/selectors/wrappers.js +15 -0
- package/src/styles/react-mosaic-component.js +288 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import compact from 'lodash/compact';
|
|
2
|
+
import { v4 as uuid } from 'uuid';
|
|
3
|
+
|
|
4
|
+
/** */
|
|
5
|
+
export default class AnnotationResource {
|
|
6
|
+
/** */
|
|
7
|
+
constructor(resource = {}) {
|
|
8
|
+
this.resource = resource;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** */
|
|
12
|
+
isOnlyTag() {
|
|
13
|
+
return this.motivations.length === 1 && this.motivations[0] === 'oa:tagging';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** */
|
|
17
|
+
get id() {
|
|
18
|
+
this._id = this._id || this.resource['@id'] || (this.resources[0] && this.resources[0]['@id']) || uuid();
|
|
19
|
+
return this._id;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** */
|
|
23
|
+
get targetId() {
|
|
24
|
+
const on = this.on[0];
|
|
25
|
+
switch (typeof on) {
|
|
26
|
+
case 'string':
|
|
27
|
+
return on.replace(/#?xywh=(.*)$/, '');
|
|
28
|
+
case 'object':
|
|
29
|
+
return on.full.replace(/#?xywh=(.*)$/, '');
|
|
30
|
+
default:
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @return {[Array]}
|
|
37
|
+
*/
|
|
38
|
+
get motivations() {
|
|
39
|
+
return compact(new Array(this.resource.motivation)).flat();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** */
|
|
43
|
+
get resources() {
|
|
44
|
+
return compact(new Array(this.resource.resource)).flat();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** */
|
|
48
|
+
get on() {
|
|
49
|
+
return compact(new Array(this.resource.on)).flat();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** */
|
|
53
|
+
get tags() {
|
|
54
|
+
if (this.isOnlyTag()) {
|
|
55
|
+
return this.resources.map((r) => r.chars);
|
|
56
|
+
}
|
|
57
|
+
return this.resources.filter((r) => r['@type'] === 'oa:Tag').map((r) => r.chars);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** */
|
|
61
|
+
get chars() {
|
|
62
|
+
return this.resources
|
|
63
|
+
.filter((r) => r['@type'] !== 'oa:Tag')
|
|
64
|
+
.map((r) => r.chars)
|
|
65
|
+
.join(' ');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** */
|
|
69
|
+
get selector() {
|
|
70
|
+
const on = this.on[0];
|
|
71
|
+
switch (typeof on) {
|
|
72
|
+
case 'string':
|
|
73
|
+
return on;
|
|
74
|
+
case 'object':
|
|
75
|
+
// For choices, just return the default for now. FIXME: enhance for SVG
|
|
76
|
+
// selectors
|
|
77
|
+
if (on.selector['@type'] === 'oa:Choice') {
|
|
78
|
+
return on.selector.default;
|
|
79
|
+
}
|
|
80
|
+
return on.selector;
|
|
81
|
+
default:
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** */
|
|
87
|
+
get svgSelector() {
|
|
88
|
+
const on = this.on[0];
|
|
89
|
+
|
|
90
|
+
switch (typeof on) {
|
|
91
|
+
case 'string':
|
|
92
|
+
return null;
|
|
93
|
+
case 'object':
|
|
94
|
+
if (on.selector && on.selector.item && on.selector.item['@type'] === 'oa:SvgSelector') {
|
|
95
|
+
return on.selector.item;
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
default:
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** */
|
|
104
|
+
get fragmentSelector() {
|
|
105
|
+
const { selector } = this;
|
|
106
|
+
|
|
107
|
+
let match;
|
|
108
|
+
|
|
109
|
+
switch (typeof selector) {
|
|
110
|
+
case 'string':
|
|
111
|
+
match = selector.match(/xywh=(.*)$/);
|
|
112
|
+
break;
|
|
113
|
+
case 'object':
|
|
114
|
+
match = selector.value.match(/xywh=(.*)$/);
|
|
115
|
+
break;
|
|
116
|
+
default:
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return match && match[1].split(',').map((str) => parseInt(str, 10));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CanvasAnnotationDisplay - class used to display a SVG and fragment based
|
|
3
|
+
* annotations.
|
|
4
|
+
*/
|
|
5
|
+
import { buildPath2D } from '../lib/svgShapesToPath';
|
|
6
|
+
|
|
7
|
+
export default class CanvasAnnotationDisplay {
|
|
8
|
+
/** */
|
|
9
|
+
constructor({ resource, palette, zoomRatio, offset, selected, hovered }) {
|
|
10
|
+
this.resource = resource;
|
|
11
|
+
this.palette = palette;
|
|
12
|
+
this.zoomRatio = zoomRatio;
|
|
13
|
+
this.offset = offset;
|
|
14
|
+
this.selected = selected;
|
|
15
|
+
this.hovered = hovered;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** */
|
|
19
|
+
toContext(context) {
|
|
20
|
+
this.context = context;
|
|
21
|
+
if (this.resource.svgSelector) {
|
|
22
|
+
this.svgContext();
|
|
23
|
+
} else if (this.resource.fragmentSelector) {
|
|
24
|
+
this.fragmentContext();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** */
|
|
29
|
+
get svgString() {
|
|
30
|
+
return this.resource.svgSelector.value;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
parseOpacity(value) {
|
|
34
|
+
if (typeof value === 'string' && value.trim().endsWith('%')) {
|
|
35
|
+
return parseFloat(value) / 100;
|
|
36
|
+
}
|
|
37
|
+
return parseFloat(value);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** */
|
|
41
|
+
svgContext() {
|
|
42
|
+
let currentPalette;
|
|
43
|
+
if (this.hovered) {
|
|
44
|
+
currentPalette = this.palette.hovered;
|
|
45
|
+
} else if (this.selected) {
|
|
46
|
+
currentPalette = this.palette.selected;
|
|
47
|
+
} else {
|
|
48
|
+
currentPalette = this.palette.default;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (currentPalette.globalAlpha === 0) return;
|
|
52
|
+
|
|
53
|
+
[...this.svgPaths].forEach((element) => {
|
|
54
|
+
/**
|
|
55
|
+
* Note: Path2D is not supported in IE11.
|
|
56
|
+
* TODO: Support multi canvas offset
|
|
57
|
+
* One example: https://developer.mozilla.org/en-US/docs/Web/API/Path2D/addPath
|
|
58
|
+
*/
|
|
59
|
+
this.context.save();
|
|
60
|
+
this.context.translate(this.offset.x, this.offset.y);
|
|
61
|
+
const p = buildPath2D(element);
|
|
62
|
+
|
|
63
|
+
// Setup styling from SVG -> Canvas
|
|
64
|
+
this.context.strokeStyle = this.color;
|
|
65
|
+
if (element.getAttribute('stroke-dasharray')) {
|
|
66
|
+
this.context.setLineDash(element.getAttribute('stroke-dasharray').split(','));
|
|
67
|
+
}
|
|
68
|
+
const svgToCanvasMap = {
|
|
69
|
+
fill: 'fillStyle',
|
|
70
|
+
stroke: 'strokeStyle',
|
|
71
|
+
'stroke-dashoffset': 'lineDashOffset',
|
|
72
|
+
'stroke-linecap': 'lineCap',
|
|
73
|
+
'stroke-linejoin': 'lineJoin',
|
|
74
|
+
'stroke-miterlimit': 'miterlimit',
|
|
75
|
+
'stroke-width': 'lineWidth',
|
|
76
|
+
};
|
|
77
|
+
Object.keys(svgToCanvasMap).forEach((key) => {
|
|
78
|
+
if (element.getAttribute(key)) {
|
|
79
|
+
this.context[svgToCanvasMap[key]] = element.getAttribute(key);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Resize the stroke based off of the zoomRatio (currentZoom / maxZoom)
|
|
84
|
+
this.context.lineWidth /= this.zoomRatio;
|
|
85
|
+
|
|
86
|
+
// Reset the color if it is selected or hovered on
|
|
87
|
+
if (this.selected || this.hovered) {
|
|
88
|
+
this.context.strokeStyle = currentPalette.strokeStyle || currentPalette.fillStyle;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.context.globalAlpha = currentPalette.globalAlpha;
|
|
92
|
+
// Set the globalAlpha for fill, draw the fill and then update the globalAlpha for stroke
|
|
93
|
+
if (element.getAttribute('fill') && element.getAttribute('fill') !== 'none') {
|
|
94
|
+
if (element.getAttribute('fill-opacity')) {
|
|
95
|
+
this.context.globalAlpha = currentPalette.globalAlpha * this.parseOpacity(element.getAttribute('fill-opacity'));
|
|
96
|
+
}
|
|
97
|
+
this.context.fill(p);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (element.getAttribute('stroke-opacity')) {
|
|
101
|
+
this.context.globalAlpha = currentPalette.globalAlpha * this.parseOpacity(element.getAttribute('stroke-opacity'));
|
|
102
|
+
} else {
|
|
103
|
+
this.context.globalAlpha = currentPalette.globalAlpha;
|
|
104
|
+
}
|
|
105
|
+
this.context.stroke(p);
|
|
106
|
+
this.context.restore();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** */
|
|
111
|
+
fragmentContext() {
|
|
112
|
+
const fragment = this.resource.fragmentSelector;
|
|
113
|
+
fragment[0] += this.offset.x;
|
|
114
|
+
fragment[1] += this.offset.y;
|
|
115
|
+
|
|
116
|
+
let currentPalette;
|
|
117
|
+
if (this.selected) {
|
|
118
|
+
currentPalette = this.palette.selected;
|
|
119
|
+
} else if (this.hovered) {
|
|
120
|
+
currentPalette = this.palette.hovered;
|
|
121
|
+
} else {
|
|
122
|
+
currentPalette = this.palette.default;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
this.context.save();
|
|
126
|
+
Object.keys(currentPalette).forEach((key) => {
|
|
127
|
+
this.context[key] = currentPalette[key];
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
if (currentPalette.globalAlpha === 0) return;
|
|
131
|
+
|
|
132
|
+
if (currentPalette.fillStyle) {
|
|
133
|
+
this.context.fillRect(...fragment);
|
|
134
|
+
} else {
|
|
135
|
+
this.context.lineWidth = 1 / this.zoomRatio;
|
|
136
|
+
this.context.strokeRect(...fragment);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this.context.restore();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** */
|
|
143
|
+
get svgPaths() {
|
|
144
|
+
const parser = new DOMParser();
|
|
145
|
+
const xmlDoc = parser.parseFromString(this.svgString, 'text/xml');
|
|
146
|
+
return Array.from(xmlDoc.querySelectorAll('circle, ellipse, rect, line, polygon, polyline, path'));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
*/
|
|
4
|
+
export default class CanvasGroupings {
|
|
5
|
+
/**
|
|
6
|
+
*/
|
|
7
|
+
constructor(canvases, viewType = 'single') {
|
|
8
|
+
this.canvases = canvases;
|
|
9
|
+
this.viewType = viewType;
|
|
10
|
+
this._groupings = null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*/
|
|
15
|
+
getCanvases(index) {
|
|
16
|
+
switch (this.viewType) {
|
|
17
|
+
case 'book':
|
|
18
|
+
return this.groupings()[Math.ceil(index / 2)];
|
|
19
|
+
default:
|
|
20
|
+
return this.groupings()[index];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Groups a set of canvases based on the view type. Single, is just an array
|
|
26
|
+
* of canvases, while book view creates pairs.
|
|
27
|
+
*/
|
|
28
|
+
groupings() {
|
|
29
|
+
if (this._groupings) {
|
|
30
|
+
return this._groupings;
|
|
31
|
+
}
|
|
32
|
+
if (this.viewType === 'scroll') {
|
|
33
|
+
return [this.canvases];
|
|
34
|
+
}
|
|
35
|
+
if (this.viewType !== 'book') {
|
|
36
|
+
return this.canvases.map((canvas) => [canvas]);
|
|
37
|
+
}
|
|
38
|
+
const groupings = [];
|
|
39
|
+
this.canvases.forEach((canvas, i) => {
|
|
40
|
+
if (i === 0) {
|
|
41
|
+
groupings.push([canvas]);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Odd page
|
|
45
|
+
if (i % 2 !== 0) {
|
|
46
|
+
groupings.push([canvas]);
|
|
47
|
+
} else {
|
|
48
|
+
// Even page
|
|
49
|
+
groupings[Math.ceil(i / 2)].push(canvas);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
this._groupings = groupings;
|
|
53
|
+
return groupings;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import normalizeUrl from 'normalize-url';
|
|
2
|
+
import { getIiifResourceImageService } from './iiif';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* CanvasWorld
|
|
6
|
+
*/
|
|
7
|
+
export default class CanvasWorld {
|
|
8
|
+
/**
|
|
9
|
+
* @param {Array} canvases - Array of Manifesto:Canvas objects to create a
|
|
10
|
+
* world from.
|
|
11
|
+
*/
|
|
12
|
+
constructor(miradorCanvases, layers, viewingDirection = 'left-to-right') {
|
|
13
|
+
this.canvases = miradorCanvases;
|
|
14
|
+
this.layers = layers;
|
|
15
|
+
this.viewingDirection = viewingDirection;
|
|
16
|
+
this._canvasDimensions = null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** */
|
|
20
|
+
get canvasIds() {
|
|
21
|
+
return this.canvases.map((canvas) => canvas.id);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** */
|
|
25
|
+
get canvasDimensions() {
|
|
26
|
+
if (this._canvasDimensions) {
|
|
27
|
+
return this._canvasDimensions;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const [dirX, dirY] = this.canvasDirection;
|
|
31
|
+
const scale =
|
|
32
|
+
dirY === 0 ? Math.min(...this.canvases.map((c) => c.getHeight())) : Math.min(...this.canvases.map((c) => c.getWidth()));
|
|
33
|
+
let incX = 0;
|
|
34
|
+
let incY = 0;
|
|
35
|
+
|
|
36
|
+
const canvasDims = this.canvases.reduce((acc, canvas) => {
|
|
37
|
+
let canvasHeight = 0;
|
|
38
|
+
let canvasWidth = 0;
|
|
39
|
+
|
|
40
|
+
if (!Number.isNaN(canvas.aspectRatio)) {
|
|
41
|
+
if (dirY === 0) {
|
|
42
|
+
// constant height
|
|
43
|
+
canvasHeight = scale;
|
|
44
|
+
canvasWidth = Math.floor(scale * canvas.aspectRatio);
|
|
45
|
+
} else {
|
|
46
|
+
// constant width
|
|
47
|
+
canvasWidth = scale;
|
|
48
|
+
canvasHeight = Math.floor(scale * (1 / canvas.aspectRatio));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
acc.push({
|
|
53
|
+
canvas,
|
|
54
|
+
height: canvasHeight,
|
|
55
|
+
width: canvasWidth,
|
|
56
|
+
x: incX,
|
|
57
|
+
y: incY,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
incX += dirX * canvasWidth;
|
|
61
|
+
incY += dirY * canvasHeight;
|
|
62
|
+
return acc;
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
const worldHeight = dirY === 0 ? scale : Math.abs(incY);
|
|
66
|
+
const worldWidth = dirX === 0 ? scale : Math.abs(incX);
|
|
67
|
+
|
|
68
|
+
this._canvasDimensions = canvasDims.reduce((acc, dims) => {
|
|
69
|
+
acc.push({
|
|
70
|
+
...dims,
|
|
71
|
+
x: dirX === -1 ? dims.x + worldWidth - dims.width : dims.x,
|
|
72
|
+
y: dirY === -1 ? dims.y + worldHeight - dims.height : dims.y,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return acc;
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
78
|
+
return this._canvasDimensions;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* contentResourceToWorldCoordinates - calculates the contentResource coordinates
|
|
83
|
+
* respective to the world.
|
|
84
|
+
*/
|
|
85
|
+
contentResourceToWorldCoordinates(contentResource) {
|
|
86
|
+
const miradorCanvasIndex = this.canvases.findIndex((c) => c.imageResources.find((r) => r.id === contentResource.id));
|
|
87
|
+
const canvas = this.canvases[miradorCanvasIndex];
|
|
88
|
+
if (!canvas) return [];
|
|
89
|
+
|
|
90
|
+
const [x, y, w, h] = this.canvasToWorldCoordinates(canvas.id);
|
|
91
|
+
|
|
92
|
+
const fragmentOffset = canvas.onFragment(contentResource.id);
|
|
93
|
+
if (fragmentOffset) {
|
|
94
|
+
return [x + fragmentOffset[0], y + fragmentOffset[1], fragmentOffset[2], fragmentOffset[3]];
|
|
95
|
+
}
|
|
96
|
+
return [x, y, w, h];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** */
|
|
100
|
+
canvasToWorldCoordinates(canvasId) {
|
|
101
|
+
const canvasDimensions = this.canvasDimensions.find((c) => c.canvas.id === canvasId);
|
|
102
|
+
|
|
103
|
+
return [canvasDimensions.x, canvasDimensions.y, canvasDimensions.width, canvasDimensions.height];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** */
|
|
107
|
+
get canvasDirection() {
|
|
108
|
+
switch (this.viewingDirection) {
|
|
109
|
+
case 'left-to-right':
|
|
110
|
+
return [1, 0];
|
|
111
|
+
case 'right-to-left':
|
|
112
|
+
return [-1, 0];
|
|
113
|
+
case 'top-to-bottom':
|
|
114
|
+
return [0, 1];
|
|
115
|
+
case 'bottom-to-top':
|
|
116
|
+
return [0, -1];
|
|
117
|
+
default:
|
|
118
|
+
return [1, 0];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Get the IIIF content resource for an image */
|
|
123
|
+
contentResource(infoResponseId) {
|
|
124
|
+
const miradorCanvas = this.canvases.find((c) =>
|
|
125
|
+
c.imageServiceIds.some(
|
|
126
|
+
(id) =>
|
|
127
|
+
id &&
|
|
128
|
+
infoResponseId &&
|
|
129
|
+
normalizeUrl(id, { stripAuthentication: false }) === normalizeUrl(infoResponseId, { stripAuthentication: false }),
|
|
130
|
+
),
|
|
131
|
+
);
|
|
132
|
+
if (!miradorCanvas) return undefined;
|
|
133
|
+
return miradorCanvas.imageResources.find(
|
|
134
|
+
(r) =>
|
|
135
|
+
normalizeUrl(getIiifResourceImageService(r).id, { stripAuthentication: false }) ===
|
|
136
|
+
normalizeUrl(infoResponseId, { stripAuthentication: false }),
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** @private */
|
|
141
|
+
getLayerMetadata(contentResource) {
|
|
142
|
+
const miradorCanvas = this.canvases.find((c) => c.imageResources.find((r) => r.id === contentResource.id));
|
|
143
|
+
|
|
144
|
+
if (!miradorCanvas) return undefined;
|
|
145
|
+
|
|
146
|
+
const resourceIndex = miradorCanvas.imageResources.findIndex((r) => r.id === contentResource.id);
|
|
147
|
+
const resource = miradorCanvas.imageResources.find((r) => r.id === contentResource.id);
|
|
148
|
+
|
|
149
|
+
const layer = this.layers && this.layers[miradorCanvas.canvas.id];
|
|
150
|
+
const imageResourceLayer = (layer && layer[contentResource.id]) || {};
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
index: resourceIndex,
|
|
154
|
+
opacity: 1,
|
|
155
|
+
total: miradorCanvas.imageResources.length,
|
|
156
|
+
visibility: !!resource.preferred,
|
|
157
|
+
...imageResourceLayer,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** */
|
|
162
|
+
layerOpacityOfImageResource(contentResource) {
|
|
163
|
+
const layer = this.getLayerMetadata(contentResource);
|
|
164
|
+
if (!layer) return 1;
|
|
165
|
+
if (!layer.visibility) return 0;
|
|
166
|
+
|
|
167
|
+
return layer.opacity;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** */
|
|
171
|
+
layerIndexOfImageResource(contentResource) {
|
|
172
|
+
const layer = this.getLayerMetadata(contentResource);
|
|
173
|
+
if (!layer) return undefined;
|
|
174
|
+
|
|
175
|
+
return layer.index;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* offsetByCanvas - calculates the offset for a given canvas target. Currently
|
|
180
|
+
* assumes a horrizontal only layout.
|
|
181
|
+
*/
|
|
182
|
+
offsetByCanvas(canvasTarget) {
|
|
183
|
+
const coordinates = this.canvasToWorldCoordinates(canvasTarget);
|
|
184
|
+
return {
|
|
185
|
+
x: coordinates[0],
|
|
186
|
+
y: coordinates[1],
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** */
|
|
191
|
+
hasDimensions() {
|
|
192
|
+
return this.canvasDimensions.length > 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* worldBounds - calculates the "World" bounds. World in this case is canvases
|
|
197
|
+
* lined up horizontally starting from left to right.
|
|
198
|
+
*/
|
|
199
|
+
worldBounds() {
|
|
200
|
+
const worldWidth = Math.max(0, ...this.canvasDimensions.map((c) => c.x + c.width));
|
|
201
|
+
const worldHeight = Math.max(0, ...this.canvasDimensions.map((c) => c.y + c.height));
|
|
202
|
+
|
|
203
|
+
return [0, 0, worldWidth, worldHeight];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** */
|
|
207
|
+
canvasAtPoint(point) {
|
|
208
|
+
const canvasDimensions = this.canvasDimensions.find(
|
|
209
|
+
(c) => c.x <= point.x && point.x <= c.x + c.width && c.y <= point.y && point.y <= c.y + c.height,
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
return canvasDimensions && canvasDimensions.canvas;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import ThumbnailNavigation from '../containers/ThumbnailNavigation';
|
|
2
|
+
import WindowSideBarAnnotationsPanel from '../containers/WindowSideBarAnnotationsPanel';
|
|
3
|
+
import WindowSideBarInfoPanel from '../containers/WindowSideBarInfoPanel';
|
|
4
|
+
import WindowSideBarCanvasPanel from '../containers/WindowSideBarCanvasPanel';
|
|
5
|
+
import AttributionPanel from '../containers/AttributionPanel';
|
|
6
|
+
import SearchPanel from '../containers/SearchPanel';
|
|
7
|
+
import LayersPanel from '../containers/LayersPanel';
|
|
8
|
+
import CustomPanel from '../containers/CustomPanel';
|
|
9
|
+
import WindowSideBarCollectionPanel from '../containers/WindowSideBarCollectionPanel';
|
|
10
|
+
|
|
11
|
+
const map = {
|
|
12
|
+
annotations: WindowSideBarAnnotationsPanel,
|
|
13
|
+
attribution: AttributionPanel,
|
|
14
|
+
canvas: WindowSideBarCanvasPanel,
|
|
15
|
+
collection: WindowSideBarCollectionPanel,
|
|
16
|
+
custom: CustomPanel,
|
|
17
|
+
info: WindowSideBarInfoPanel,
|
|
18
|
+
layers: LayersPanel,
|
|
19
|
+
search: SearchPanel,
|
|
20
|
+
thumbnailNavigation: ThumbnailNavigation,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default map;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useCallback, useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Used to request or exit fullscreen using the native Fullscreen API.
|
|
6
|
+
*/
|
|
7
|
+
export function useFullScreenHandle() {
|
|
8
|
+
const [active, setActive] = useState(false);
|
|
9
|
+
|
|
10
|
+
/** */
|
|
11
|
+
const handleFullScreenChange = () => {
|
|
12
|
+
setActive(document.fullscreenElement === document.body);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
document.addEventListener('fullscreenchange', handleFullScreenChange);
|
|
17
|
+
return () => document.removeEventListener('fullscreenchange', handleFullScreenChange);
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
/** */
|
|
21
|
+
const requestFullscreen = () => document.body.requestFullscreen();
|
|
22
|
+
|
|
23
|
+
const enter = useCallback(() => {
|
|
24
|
+
if (document.fullscreenElement) {
|
|
25
|
+
return document.exitFullscreen().then(() => requestFullscreen());
|
|
26
|
+
}
|
|
27
|
+
return requestFullscreen();
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
const exit = useCallback(() => {
|
|
31
|
+
if (document.fullscreenElement !== document.body) return Promise.resolve();
|
|
32
|
+
return document.exitFullscreen();
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
return useMemo(
|
|
36
|
+
() => ({
|
|
37
|
+
active,
|
|
38
|
+
enter,
|
|
39
|
+
exit,
|
|
40
|
+
}),
|
|
41
|
+
[active, enter, exit],
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Used to set its children to fullscreen.
|
|
47
|
+
*/
|
|
48
|
+
export const FullScreen = ({ handle, onChange = undefined, children = null, className = '' }) => {
|
|
49
|
+
const fullScreenClasses = ['fullscreen', className, handle.active ? 'fullscreen-enabled' : ''].filter(Boolean);
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (onChange) {
|
|
53
|
+
onChange(handle.active, handle);
|
|
54
|
+
}
|
|
55
|
+
}, [handle, handle.active, onChange]);
|
|
56
|
+
|
|
57
|
+
const styles = handle.active
|
|
58
|
+
? {
|
|
59
|
+
height: '100%',
|
|
60
|
+
width: '100%',
|
|
61
|
+
}
|
|
62
|
+
: {};
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div className={fullScreenClasses.join(' ')} style={styles}>
|
|
66
|
+
{children}
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
FullScreen.propTypes = {
|
|
72
|
+
children: PropTypes.node,
|
|
73
|
+
className: PropTypes.string,
|
|
74
|
+
handle: PropTypes.object.isRequired,
|
|
75
|
+
onChange: PropTypes.func,
|
|
76
|
+
};
|