@cu-mkp/editioncrafter 1.0.2 → 1.0.4-beta.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/README.md +7 -7
- package/dist/editioncrafter.js +65802 -0
- package/dist/editioncrafter.umd.cjs +553 -0
- package/dist/es/src/action/DiplomaticActions.js +9 -11
- package/dist/es/src/action/DocumentActions.js +164 -154
- package/dist/es/src/action/GlossaryActions.js +9 -11
- package/dist/es/src/action/initialState/diplomaticInitialState.js +2 -2
- package/dist/es/src/action/initialState/documentInitialState.js +9 -12
- package/dist/es/src/action/initialState/glossaryInitialState.js +3 -3
- package/dist/es/src/action/rootReducer.js +31 -29
- package/dist/es/src/component/AlphabetLinks.js +44 -66
- package/dist/es/src/component/CustomizedTooltops.js +101 -110
- package/dist/es/src/component/DiploMatic.js +64 -91
- package/dist/es/src/component/DocumentView.js +442 -366
- package/dist/es/src/component/EditorComment.js +51 -75
- package/dist/es/src/component/ErrorBoundary.js +37 -61
- package/dist/es/src/component/FigureImage.js +56 -67
- package/dist/es/src/component/GlossaryView.js +157 -149
- package/dist/es/src/component/HelpPopper.js +96 -78
- package/dist/es/src/component/ImageGridView.js +184 -249
- package/dist/es/src/component/ImageView.js +155 -165
- package/dist/es/src/component/ImageZoomControl.js +19 -38
- package/dist/es/src/component/JumpToFolio.js +56 -60
- package/dist/es/src/component/Navigation.js +374 -328
- package/dist/es/src/component/Pagination.js +73 -70
- package/dist/es/src/component/Parser.js +11 -32
- package/dist/es/src/component/RingSpinner.js +31 -32
- package/dist/es/src/component/RouteListener.js +30 -21
- package/dist/es/src/component/SeaDragonComponent.js +33 -56
- package/dist/es/src/component/SinglePaneView.js +15 -33
- package/dist/es/src/component/SplitPaneView.js +151 -170
- package/dist/es/src/component/TranscriptionView.js +190 -179
- package/dist/es/src/component/Watermark.js +21 -30
- package/dist/es/src/component/XMLView.js +60 -82
- package/dist/es/src/hooks/useIsWidthUp.js +9 -7
- package/dist/es/src/icons/ByIcon.js +16 -16
- package/dist/es/src/icons/CcIcon.js +16 -16
- package/dist/es/src/icons/NcIcon.js +16 -16
- package/dist/es/src/icons/SaIcon.js +16 -16
- package/dist/es/src/icons/SideMenuIconLeft.js +30 -38
- package/dist/es/src/icons/SideMenuIconRight.js +32 -38
- package/dist/es/src/index.js +21 -20
- package/dist/es/src/lib/copyObject.js +3 -2
- package/dist/es/src/lib/registerServiceWorker.js +77 -54
- package/dist/es/src/model/DocumentHelper.js +7 -6
- package/dist/es/src/model/Folio.js +64 -86
- package/dist/es/src/model/ReduxStore.js +32 -78
- package/dist/es/src/model/folioLayout.js +275 -280
- package/dist/es/src/saga/RouteListenerSaga.js +89 -193
- package/dist/es/src/saga/rootSaga.js +9 -16
- package/dist/es/src/scss/_imageView.scss +1 -1
- package/dist/es/src/scss/_navigation.scss +1 -1
- package/dist/es/src/scss/editioncrafter.scss +1 -1
- package/dist/style.css +1 -0
- package/package.json +36 -51
- package/dist/editioncrafter.min.js +0 -2
- package/dist/editioncrafter.min.js.LICENSE.txt +0 -144
|
@@ -1,466 +1,542 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import ImageGridView from './ImageGridView';
|
|
20
|
-
import TranscriptionView from './TranscriptionView';
|
|
21
|
-
import XMLView from './XMLView';
|
|
22
|
-
import GlossaryView from './GlossaryView';
|
|
23
|
-
import SinglePaneView from './SinglePaneView';
|
|
24
|
-
var paneDefaults = {
|
|
1
|
+
import withWidth, { isWidthUp } from '@material-ui/core/withWidth'
|
|
2
|
+
import React, { useEffect, useState } from 'react'
|
|
3
|
+
import { connect } from 'react-redux'
|
|
4
|
+
import {
|
|
5
|
+
useLocation,
|
|
6
|
+
useNavigate,
|
|
7
|
+
useParams,
|
|
8
|
+
} from 'react-router-dom'
|
|
9
|
+
import { dispatchAction } from '../model/ReduxStore'
|
|
10
|
+
import GlossaryView from './GlossaryView'
|
|
11
|
+
import ImageGridView from './ImageGridView'
|
|
12
|
+
import ImageView from './ImageView'
|
|
13
|
+
import SinglePaneView from './SinglePaneView'
|
|
14
|
+
import SplitPaneView from './SplitPaneView'
|
|
15
|
+
import TranscriptionView from './TranscriptionView'
|
|
16
|
+
import XMLView from './XMLView'
|
|
17
|
+
|
|
18
|
+
const paneDefaults = {
|
|
25
19
|
isXMLMode: false,
|
|
26
|
-
width: 0
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var _useState11 = useState(props.containerWidth < 960),
|
|
50
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
51
|
-
singlePaneMode = _useState12[0],
|
|
52
|
-
setSinglePaneMode = _useState12[1];
|
|
53
|
-
var params = useParams();
|
|
54
|
-
var navigate = useNavigate();
|
|
55
|
-
var location = useLocation();
|
|
56
|
-
|
|
57
|
-
//"reload" the page if the config props change
|
|
58
|
-
useEffect(function () {
|
|
59
|
-
dispatchAction(props, 'RouteListenerSaga.userNavigatation', location);
|
|
60
|
-
}, [props.config]);
|
|
61
|
-
useEffect(function () {
|
|
62
|
-
setSinglePaneMode(props.containerWidth < 960);
|
|
63
|
-
}, [props.containerWidth]);
|
|
20
|
+
width: 0,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function DocumentView(props) {
|
|
24
|
+
const [linkedMode, setLinkedMode] = useState(!props.document.variorum)
|
|
25
|
+
const [bookMode, setBookMode] = useState(false)
|
|
26
|
+
const [left, setLeft] = useState(paneDefaults)
|
|
27
|
+
const [right, setRight] = useState(paneDefaults)
|
|
28
|
+
const [third, setThird] = useState(paneDefaults)
|
|
29
|
+
const [singlePaneMode, setSinglePaneMode] = useState(props.containerWidth < 960)
|
|
30
|
+
|
|
31
|
+
const params = useParams()
|
|
32
|
+
const navigate = useNavigate()
|
|
33
|
+
const location = useLocation()
|
|
34
|
+
|
|
35
|
+
// "reload" the page if the config props change
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
dispatchAction(props, 'RouteListenerSaga.userNavigatation', location)
|
|
38
|
+
}, [props.config])
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
setSinglePaneMode(props.containerWidth < 960)
|
|
42
|
+
}, [props.containerWidth])
|
|
64
43
|
|
|
65
44
|
// Navigate while keeping existing search params
|
|
66
|
-
|
|
67
|
-
navigate(pathname + location.search)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
45
|
+
const navigateWithParams = (pathname) => {
|
|
46
|
+
navigate(pathname + location.search)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const getViewports = () => {
|
|
50
|
+
const {
|
|
51
|
+
folioID,
|
|
52
|
+
transcriptionType,
|
|
53
|
+
folioID2,
|
|
54
|
+
transcriptionType2,
|
|
55
|
+
folioID3,
|
|
56
|
+
transcriptionType3,
|
|
57
|
+
} = params
|
|
58
|
+
const { document } = props
|
|
59
|
+
const firstTranscriptionType = document.variorum ? Object.keys(document.transcriptionTypes[Object.keys(document.transcriptionTypes)[0]])[0] : Object.keys(document.transcriptionTypes)[0]
|
|
78
60
|
if (!folioID) {
|
|
79
61
|
// route /folios
|
|
80
62
|
return {
|
|
81
63
|
left: {
|
|
82
64
|
folioID: '-1',
|
|
83
|
-
transcriptionType: 'g'
|
|
65
|
+
transcriptionType: 'g',
|
|
84
66
|
},
|
|
85
67
|
right: {
|
|
86
68
|
folioID: '-1',
|
|
87
|
-
transcriptionType: document.variorum ? 'g' : firstTranscriptionType
|
|
69
|
+
transcriptionType: document.variorum ? 'g' : firstTranscriptionType,
|
|
88
70
|
},
|
|
89
71
|
third: {
|
|
90
72
|
folioID: '-1',
|
|
91
|
-
transcriptionType: 'g'
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
var rightTranscriptionType;
|
|
100
|
-
var thirdFolioID;
|
|
101
|
-
var thirdTranscriptionType;
|
|
73
|
+
transcriptionType: 'g',
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const leftFolioValid = Object.keys(document.folioIndex).includes(folioID)
|
|
78
|
+
const leftFolioID = leftFolioValid ? folioID : '-1'
|
|
79
|
+
let leftTranscriptionType; let rightFolioID; let
|
|
80
|
+
rightTranscriptionType; let thirdFolioID; let thirdTranscriptionType
|
|
102
81
|
if (folioID2) {
|
|
103
82
|
// route /ec/:folioID/:transcriptionType/:folioID2/:transcriptionType2
|
|
104
|
-
|
|
105
|
-
leftTranscriptionType = leftFolioValid ? transcriptionType : 'g'
|
|
106
|
-
rightFolioID = rightFolioValid ? folioID2 : '-1'
|
|
107
|
-
rightTranscriptionType = rightFolioValid ? transcriptionType2
|
|
83
|
+
const rightFolioValid = Object.keys(document.folioIndex).includes(folioID2)
|
|
84
|
+
leftTranscriptionType = leftFolioValid ? transcriptionType : 'g'
|
|
85
|
+
rightFolioID = rightFolioValid ? folioID2 : '-1'
|
|
86
|
+
rightTranscriptionType = rightFolioValid ? transcriptionType2 || firstTranscriptionType : 'g'
|
|
108
87
|
if (folioID3) {
|
|
109
88
|
// route /ec/:folioID/:transcriptionType/:folioID2/:transcriptionType2/:folioID3/:transcriptionType3
|
|
110
|
-
|
|
111
|
-
thirdFolioID = thirdFolioValid ? folioID3 : '-1'
|
|
112
|
-
thirdTranscriptionType = thirdFolioValid ? transcriptionType3
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
89
|
+
const thirdFolioValid = Object.keys(document.folioIndex).includes(folioID3)
|
|
90
|
+
thirdFolioID = thirdFolioValid ? folioID3 : '-1'
|
|
91
|
+
thirdTranscriptionType = thirdFolioValid ? transcriptionType3 || firstTranscriptionType : 'g'
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
thirdFolioID = '-1'
|
|
95
|
+
thirdTranscriptionType = 'g'
|
|
116
96
|
}
|
|
117
|
-
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
118
99
|
// route /ec/:folioID
|
|
119
100
|
// route /ec/:folioID/:transcriptionType
|
|
120
|
-
leftTranscriptionType = 'f'
|
|
121
|
-
rightFolioID = leftFolioValid ? folioID : '-1'
|
|
122
|
-
rightTranscriptionType = leftFolioValid ? transcriptionType
|
|
123
|
-
thirdFolioID = '-1'
|
|
124
|
-
thirdTranscriptionType = 'g'
|
|
101
|
+
leftTranscriptionType = 'f'
|
|
102
|
+
rightFolioID = leftFolioValid ? folioID : '-1'
|
|
103
|
+
rightTranscriptionType = leftFolioValid ? transcriptionType || firstTranscriptionType : 'g'
|
|
104
|
+
thirdFolioID = '-1'
|
|
105
|
+
thirdTranscriptionType = 'g'
|
|
125
106
|
}
|
|
107
|
+
|
|
126
108
|
return {
|
|
127
109
|
left: {
|
|
128
110
|
folioID: leftFolioID,
|
|
129
|
-
transcriptionType: leftTranscriptionType
|
|
111
|
+
transcriptionType: leftTranscriptionType,
|
|
130
112
|
},
|
|
131
113
|
right: {
|
|
132
114
|
folioID: rightFolioID,
|
|
133
|
-
transcriptionType: rightTranscriptionType
|
|
115
|
+
transcriptionType: rightTranscriptionType,
|
|
134
116
|
},
|
|
135
117
|
third: {
|
|
136
118
|
folioID: thirdFolioID,
|
|
137
|
-
transcriptionType: thirdTranscriptionType
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
119
|
+
transcriptionType: thirdTranscriptionType,
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
dispatchAction(props, 'DiplomaticActions.setFixedFrameMode', true)
|
|
126
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
127
|
+
}, [])
|
|
128
|
+
|
|
129
|
+
const setXMLMode = (side, xmlMode) => {
|
|
146
130
|
if (side === 'left') {
|
|
147
|
-
setLeft(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
})
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
var handleSetBookMode = function handleSetBookMode(shortid, bool) {
|
|
161
|
-
setBookMode(bool);
|
|
131
|
+
setLeft({ ...left, isXMLMode: xmlMode })
|
|
132
|
+
}
|
|
133
|
+
else if (side === 'right') {
|
|
134
|
+
setRight({ ...right, isXMLMode: xmlMode })
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
setThird({ ...third, isXMLMode: xmlMode })
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const handleSetBookMode = (shortid, bool) => {
|
|
142
|
+
setBookMode(bool)
|
|
143
|
+
|
|
162
144
|
if (bool) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
var jumpToFolio = function jumpToFolio(folioName, side) {
|
|
171
|
-
var document = props.document;
|
|
145
|
+
const [versoID, rectoID] = findBookFolios(shortid)
|
|
146
|
+
navigateFolios(versoID, 'f', rectoID, 'f')
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const jumpToFolio = (folioName, side) => {
|
|
151
|
+
const { document } = props
|
|
172
152
|
// Convert folioName to ID (and confirm it exists)
|
|
173
153
|
if (document.folioByName[folioName]) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}) : document.folios;
|
|
154
|
+
const folioID = document.folioByName[folioName]?.id
|
|
155
|
+
changeCurrentFolio(folioID, side, getViewports()[side].transcriptionType)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const findBookFolios = (folioID) => {
|
|
160
|
+
const { document } = props
|
|
161
|
+
const versoFolio = document.folioIndex[folioID]
|
|
162
|
+
const { name, pageNumber } = versoFolio
|
|
163
|
+
|
|
164
|
+
const documentFolios = document.variorum ? document.folios.filter(f => f.doc_id === versoFolio.doc_id) : document.folios
|
|
165
|
+
|
|
187
166
|
if (!name.endsWith('v') && name.endsWith('r')) {
|
|
188
|
-
return [documentFolios[pageNumber - 1].id, documentFolios[pageNumber].id]
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
})
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
167
|
+
return [documentFolios[pageNumber - 1].id, documentFolios[pageNumber].id]
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (documentFolios[pageNumber + 1]) {
|
|
171
|
+
return [documentFolios[pageNumber].id, documentFolios[pageNumber + 1].id]
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return [documentFolios[pageNumber].id, null]
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const onWidth = (leftWidth, rightWidth, thirdWidth) => {
|
|
178
|
+
setLeft({ ...left, width: leftWidth })
|
|
179
|
+
setRight({ ...right, width: rightWidth })
|
|
180
|
+
setThird({ ...third, width: thirdWidth })
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const changeTranscriptionType = (side, transcriptionType) => {
|
|
184
|
+
const currentViewports = getViewports()
|
|
205
185
|
if (side === 'left') {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
navigateFolios(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
186
|
+
const { folioID } = currentViewports.left
|
|
187
|
+
const otherSide = currentViewports.right
|
|
188
|
+
navigateFolios(
|
|
189
|
+
folioID,
|
|
190
|
+
transcriptionType,
|
|
191
|
+
otherSide.folioID,
|
|
192
|
+
otherSide.transcriptionType,
|
|
193
|
+
currentViewports.third.folioID,
|
|
194
|
+
currentViewports.third.transcriptionType,
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
else if (side === 'right') {
|
|
198
|
+
const { folioID } = currentViewports.right
|
|
199
|
+
const otherSide = currentViewports.left
|
|
200
|
+
navigateFolios(
|
|
201
|
+
otherSide.folioID,
|
|
202
|
+
otherSide.transcriptionType,
|
|
203
|
+
folioID,
|
|
204
|
+
transcriptionType,
|
|
205
|
+
currentViewports.third.folioID,
|
|
206
|
+
currentViewports.third.transcriptionType,
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
const { folioID } = currentViewports.third
|
|
211
|
+
navigateFolios(
|
|
212
|
+
currentViewports.left.folioID,
|
|
213
|
+
currentViewports.left.transcriptionType,
|
|
214
|
+
currentViewports.right.folioID,
|
|
215
|
+
currentViewports.right.transcriptionType,
|
|
216
|
+
folioID,
|
|
217
|
+
transcriptionType,
|
|
218
|
+
)
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const navigateFolios = (folioID, transcriptionType, folioID2, transcriptionType2, folioID3, transcriptionType3) => {
|
|
219
223
|
if (!folioID) {
|
|
220
224
|
// goto grid view
|
|
221
|
-
navigateWithParams('/ec')
|
|
222
|
-
return
|
|
225
|
+
navigateWithParams('/ec')
|
|
226
|
+
return
|
|
223
227
|
}
|
|
224
228
|
if (!transcriptionType) {
|
|
225
229
|
// goto folioID, tc
|
|
226
|
-
navigateWithParams(
|
|
227
|
-
return
|
|
230
|
+
navigateWithParams(`/ec/${folioID}`)
|
|
231
|
+
return
|
|
228
232
|
}
|
|
229
233
|
if (!folioID2) {
|
|
230
234
|
// goto folioID, transcriptionType
|
|
231
|
-
navigateWithParams(
|
|
232
|
-
return
|
|
235
|
+
navigateWithParams(`/ec/${folioID}/${transcriptionType}`)
|
|
236
|
+
return
|
|
233
237
|
}
|
|
234
238
|
if (!transcriptionType2) {
|
|
235
239
|
// goto folioID, transcriptionType, folioID2, tc
|
|
236
|
-
navigateWithParams(
|
|
237
|
-
return
|
|
240
|
+
navigateWithParams(`/ec/${folioID}/${transcriptionType}/${folioID2}/tc`)
|
|
241
|
+
return
|
|
238
242
|
}
|
|
239
243
|
if (!folioID3) {
|
|
240
244
|
// goto folioID, transcriptionType, folioID2, transcriptionType2
|
|
241
|
-
navigateWithParams(
|
|
242
|
-
return
|
|
245
|
+
navigateWithParams(`/ec/${folioID}/${transcriptionType}/${folioID2}/${transcriptionType2}`)
|
|
246
|
+
return
|
|
243
247
|
}
|
|
244
248
|
if (!transcriptionType3) {
|
|
245
249
|
// goto folioID, transcriptionType, folioID2, transcriptionType2, folioID3, tc
|
|
246
|
-
navigateWithParams(
|
|
247
|
-
return
|
|
250
|
+
navigateWithParams(`/ec/${folioID}/${transcriptionType}/${folioID2}/${transcriptionType2}/${folioID3}/f`)
|
|
251
|
+
return
|
|
248
252
|
}
|
|
249
253
|
// goto folioID, transcrptionType, folioID2, transcriptionType2, folioID3, transcriptionType3
|
|
250
|
-
navigateWithParams(
|
|
251
|
-
}
|
|
252
|
-
|
|
254
|
+
navigateWithParams(`/ec/${folioID}/${transcriptionType}/${folioID2}/${transcriptionType2}/${folioID3}/${transcriptionType3}`)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const changeCurrentFolio = (folioID, side, transcriptionType) => {
|
|
253
258
|
// Lookup prev/next
|
|
254
|
-
|
|
259
|
+
const currentViewports = getViewports()
|
|
260
|
+
|
|
255
261
|
if (bookMode) {
|
|
256
|
-
|
|
257
|
-
_findBookFolios4 = _slicedToArray(_findBookFolios3, 2),
|
|
258
|
-
versoID = _findBookFolios4[0],
|
|
259
|
-
rectoID = _findBookFolios4[1];
|
|
262
|
+
const [versoID, rectoID] = findBookFolios(folioID)
|
|
260
263
|
if (versoID) {
|
|
261
|
-
navigateFolios(versoID, 'f', rectoID, 'f')
|
|
264
|
+
navigateFolios(versoID, 'f', rectoID, 'f')
|
|
262
265
|
}
|
|
263
|
-
}
|
|
266
|
+
}
|
|
267
|
+
else if (linkedMode) {
|
|
264
268
|
if (side === 'left') {
|
|
265
|
-
|
|
266
|
-
navigateFolios(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
const otherSide = currentViewports.right
|
|
270
|
+
navigateFolios(
|
|
271
|
+
folioID,
|
|
272
|
+
transcriptionType,
|
|
273
|
+
folioID,
|
|
274
|
+
otherSide.transcriptionType,
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
else if (side === 'right') {
|
|
278
|
+
const otherSide = currentViewports.left
|
|
279
|
+
navigateFolios(
|
|
280
|
+
folioID,
|
|
281
|
+
otherSide.transcriptionType,
|
|
282
|
+
folioID,
|
|
283
|
+
transcriptionType,
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
navigateFolios(
|
|
288
|
+
currentViewports.left.folioID,
|
|
289
|
+
currentViewports.left.transcriptionType,
|
|
290
|
+
currentViewports.right.folioID,
|
|
291
|
+
currentViewports.right.transcriptionType,
|
|
292
|
+
folioID,
|
|
293
|
+
transcriptionType,
|
|
294
|
+
)
|
|
272
295
|
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
296
|
+
}
|
|
297
|
+
else if (side === 'left') {
|
|
298
|
+
const otherSide = currentViewports.right
|
|
299
|
+
const thirdPane = currentViewports.third
|
|
300
|
+
navigateFolios(
|
|
301
|
+
folioID,
|
|
302
|
+
transcriptionType,
|
|
303
|
+
otherSide.folioID,
|
|
304
|
+
otherSide.transcriptionType,
|
|
305
|
+
thirdPane.folioID,
|
|
306
|
+
thirdPane.transcriptionType,
|
|
307
|
+
)
|
|
308
|
+
}
|
|
309
|
+
else if (side === 'right') {
|
|
310
|
+
const otherSide = currentViewports.left
|
|
311
|
+
const thirdPane = currentViewports.third
|
|
312
|
+
navigateFolios(
|
|
313
|
+
otherSide.folioID,
|
|
314
|
+
otherSide.transcriptionType,
|
|
315
|
+
folioID,
|
|
316
|
+
transcriptionType,
|
|
317
|
+
thirdPane.folioID,
|
|
318
|
+
thirdPane.transcriptionType,
|
|
319
|
+
)
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
navigateFolios(
|
|
323
|
+
currentViewports.left.folioID,
|
|
324
|
+
currentViewports.left.transcriptionType,
|
|
325
|
+
currentViewports.right.folioID,
|
|
326
|
+
currentViewports.right.transcriptionType,
|
|
327
|
+
folioID,
|
|
328
|
+
transcriptionType,
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const determineViewType = (side) => {
|
|
334
|
+
const { transcriptionType } = getViewports()[side]
|
|
335
|
+
const xmlMode = side === 'left'
|
|
336
|
+
? left.isXMLMode
|
|
337
|
+
: side === 'right' ? right.isXMLMode : third.isXMLMode
|
|
338
|
+
|
|
288
339
|
if (transcriptionType === 'g') {
|
|
289
|
-
return 'ImageGridView'
|
|
340
|
+
return 'ImageGridView'
|
|
290
341
|
}
|
|
291
342
|
if (transcriptionType === 'f') {
|
|
292
|
-
return 'ImageView'
|
|
343
|
+
return 'ImageView'
|
|
293
344
|
}
|
|
294
345
|
if (transcriptionType === 'glossary') {
|
|
295
|
-
return 'GlossaryView'
|
|
346
|
+
return 'GlossaryView'
|
|
296
347
|
}
|
|
297
|
-
return xmlMode ? 'XMLView' : 'TranscriptionView'
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
348
|
+
return xmlMode ? 'XMLView' : 'TranscriptionView'
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const viewportState = (side) => {
|
|
352
|
+
const { document: doc } = props
|
|
353
|
+
const viewport = getViewports()[side]
|
|
302
354
|
|
|
303
355
|
// blank folio ID
|
|
304
356
|
if (viewport.folioID === '-1') {
|
|
305
|
-
return
|
|
357
|
+
return {
|
|
358
|
+
...side === 'left' ? left : side === 'right' ? right : third,
|
|
306
359
|
iiifShortID: viewport.folioID,
|
|
307
|
-
transcriptionType: viewport.transcriptionType
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
360
|
+
transcriptionType: viewport.transcriptionType,
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const shortID = viewport.folioID
|
|
365
|
+
const documentFolios = doc.variorum ? doc.folios.filter(f => f.doc_id === doc.folioIndex[shortID].doc_id) : doc.folios
|
|
366
|
+
const folioCount = documentFolios.length
|
|
367
|
+
let nextID = ''
|
|
368
|
+
let prevID = ''
|
|
369
|
+
let current_hasPrev = false
|
|
370
|
+
let current_hasNext = false
|
|
371
|
+
|
|
319
372
|
if (bookMode) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
var current_idx = doc.folioIndex[versoID].pageNumber;
|
|
373
|
+
const [versoID] = findBookFolios(shortID)
|
|
374
|
+
const current_idx = doc.folioIndex[versoID].pageNumber
|
|
375
|
+
|
|
324
376
|
if (current_idx > -1) {
|
|
325
|
-
current_hasNext = current_idx < folioCount - 2
|
|
326
|
-
nextID = current_hasNext ? documentFolios[current_idx + 2].id : ''
|
|
327
|
-
current_hasPrev = current_idx > 1 && folioCount > 1
|
|
328
|
-
prevID = current_hasPrev ? documentFolios[current_idx - 2].id : ''
|
|
377
|
+
current_hasNext = (current_idx < (folioCount - 2))
|
|
378
|
+
nextID = current_hasNext ? documentFolios[current_idx + 2].id : ''
|
|
379
|
+
current_hasPrev = (current_idx > 1 && folioCount > 1)
|
|
380
|
+
prevID = current_hasPrev ? documentFolios[current_idx - 2].id : ''
|
|
329
381
|
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
const current_idx = doc.folioIndex[shortID].pageNumber
|
|
385
|
+
if (current_idx > -1) {
|
|
386
|
+
current_hasNext = (current_idx < (folioCount - 1))
|
|
387
|
+
nextID = current_hasNext ? documentFolios[current_idx + 1].id : ''
|
|
388
|
+
|
|
389
|
+
current_hasPrev = (current_idx > 0 && folioCount > 1)
|
|
390
|
+
prevID = current_hasPrev ? documentFolios[current_idx - 1].id : ''
|
|
337
391
|
}
|
|
338
392
|
}
|
|
339
|
-
|
|
393
|
+
|
|
394
|
+
return {
|
|
395
|
+
...side === 'left' ? left : side === 'right' ? right : third,
|
|
340
396
|
iiifShortID: shortID,
|
|
341
397
|
transcriptionType: viewport.transcriptionType,
|
|
342
398
|
hasPrevious: current_hasPrev,
|
|
343
399
|
hasNext: current_hasNext,
|
|
344
400
|
previousFolioShortID: prevID,
|
|
345
401
|
nextFolioShortID: nextID,
|
|
346
|
-
documentID: doc.variorum ? doc.folioIndex[shortID].doc_id : doc.documentName
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
402
|
+
documentID: doc.variorum ? doc.folioIndex[shortID].doc_id : doc.documentName,
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const documentViewActions = {
|
|
407
|
+
setXMLMode,
|
|
408
|
+
setLinkedMode,
|
|
352
409
|
setBookMode: handleSetBookMode,
|
|
353
|
-
changeTranscriptionType
|
|
354
|
-
changeCurrentFolio
|
|
355
|
-
jumpToFolio
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
410
|
+
changeTranscriptionType,
|
|
411
|
+
changeCurrentFolio,
|
|
412
|
+
jumpToFolio,
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const renderPane = (side, docView) => {
|
|
416
|
+
const viewType = determineViewType(side)
|
|
417
|
+
const key = viewPaneKey(side)
|
|
418
|
+
const folioID = docView[side].iiifShortID
|
|
419
|
+
const document = docView[side].documentID
|
|
420
|
+
const { transcriptionType } = docView[side]
|
|
421
|
+
|
|
363
422
|
if (viewType === 'ImageView') {
|
|
364
|
-
return
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
423
|
+
return (
|
|
424
|
+
<ImageView
|
|
425
|
+
key={key}
|
|
426
|
+
folioID={folioID}
|
|
427
|
+
documentView={docView}
|
|
428
|
+
documentViewActions={documentViewActions}
|
|
429
|
+
side={side}
|
|
430
|
+
/>
|
|
431
|
+
)
|
|
432
|
+
} if (viewType === 'TranscriptionView') {
|
|
433
|
+
return (
|
|
434
|
+
<TranscriptionView
|
|
435
|
+
key={key}
|
|
436
|
+
documentView={docView}
|
|
437
|
+
documentViewActions={documentViewActions}
|
|
438
|
+
side={side}
|
|
439
|
+
folioID={folioID}
|
|
440
|
+
transcriptionType={transcriptionType}
|
|
441
|
+
/>
|
|
442
|
+
)
|
|
443
|
+
} if (viewType === 'XMLView') {
|
|
444
|
+
return (
|
|
445
|
+
<XMLView
|
|
446
|
+
key={key}
|
|
447
|
+
folioID={folioID}
|
|
448
|
+
transcriptionType={transcriptionType}
|
|
449
|
+
documentView={docView}
|
|
450
|
+
documentViewActions={documentViewActions}
|
|
451
|
+
side={side}
|
|
452
|
+
/>
|
|
453
|
+
)
|
|
454
|
+
} if (viewType === 'ImageGridView') {
|
|
455
|
+
return (
|
|
456
|
+
<ImageGridView
|
|
457
|
+
key={key}
|
|
458
|
+
documentView={docView}
|
|
459
|
+
documentViewActions={documentViewActions}
|
|
460
|
+
side={side}
|
|
461
|
+
selectedDoc={document || props.document.variorum && Object.keys(props.document.derivativeNames)[side === 'left' ? 0 : side === 'right' ? 1 : Object.keys(props.document.derivativeNames).length > 2 ? 2 : 1]}
|
|
462
|
+
/>
|
|
463
|
+
)
|
|
464
|
+
} if (viewType === 'GlossaryView') {
|
|
465
|
+
return (
|
|
466
|
+
<GlossaryView
|
|
467
|
+
key={key}
|
|
468
|
+
documentView={docView}
|
|
469
|
+
documentViewActions={documentViewActions}
|
|
470
|
+
side={side}
|
|
471
|
+
/>
|
|
472
|
+
)
|
|
473
|
+
}
|
|
474
|
+
return (
|
|
475
|
+
<div>ERROR: Unrecognized viewType.</div>
|
|
476
|
+
)
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
const viewPaneKey = (side) => {
|
|
480
|
+
const pane = side === 'left'
|
|
481
|
+
? left
|
|
482
|
+
: side === 'right'
|
|
483
|
+
? right
|
|
484
|
+
: third
|
|
485
|
+
|
|
413
486
|
if (pane.viewType === 'ImageGridView') {
|
|
414
|
-
return
|
|
487
|
+
return `${side}-${pane.viewType}`
|
|
415
488
|
}
|
|
416
489
|
if (typeof pane.folio !== 'undefined') {
|
|
417
|
-
return
|
|
490
|
+
return `${side}-${pane.viewType}-${pane.folio.id}`
|
|
418
491
|
}
|
|
419
|
-
return
|
|
420
|
-
};
|
|
421
|
-
if (!props.document.loaded) {
|
|
422
|
-
return null;
|
|
492
|
+
return `${side}-${pane.viewType}`
|
|
423
493
|
}
|
|
424
494
|
|
|
495
|
+
if (!props.document.loaded) { return null }
|
|
496
|
+
|
|
425
497
|
// combine component state with state from props
|
|
426
|
-
|
|
427
|
-
linkedMode
|
|
428
|
-
bookMode
|
|
498
|
+
const docView = {
|
|
499
|
+
linkedMode,
|
|
500
|
+
bookMode,
|
|
429
501
|
left: viewportState('left'),
|
|
430
502
|
right: viewportState('right'),
|
|
431
|
-
third: viewportState('third')
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
503
|
+
third: viewportState('third'),
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
const mobileDocView = {
|
|
507
|
+
linkedMode,
|
|
508
|
+
bookMode,
|
|
509
|
+
left,
|
|
510
|
+
right: { ...viewportState('right') },
|
|
511
|
+
}
|
|
512
|
+
|
|
439
513
|
if (isWidthUp('md', props.width) && !singlePaneMode) {
|
|
440
|
-
return
|
|
441
|
-
style:
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
514
|
+
return (
|
|
515
|
+
<div style={{ height: '100%' }}>
|
|
516
|
+
<SplitPaneView
|
|
517
|
+
leftPane={renderPane('left', docView)}
|
|
518
|
+
rightPane={renderPane('right', docView)}
|
|
519
|
+
thirdPane={renderPane('third', docView)}
|
|
520
|
+
onWidth={onWidth}
|
|
521
|
+
threePanel={props.document.threePanel}
|
|
522
|
+
/>
|
|
523
|
+
</div>
|
|
524
|
+
)
|
|
451
525
|
}
|
|
452
|
-
return
|
|
453
|
-
style:
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
}
|
|
526
|
+
return (
|
|
527
|
+
<div style={{ height: '100%' }}>
|
|
528
|
+
<SinglePaneView
|
|
529
|
+
singlePane={renderPane(viewportState('left').iiifShortID === '-1' ? 'left' : 'right', docView)}
|
|
530
|
+
/>
|
|
531
|
+
</div>
|
|
532
|
+
)
|
|
533
|
+
}
|
|
534
|
+
|
|
460
535
|
function mapStateToProps(state) {
|
|
461
536
|
return {
|
|
462
537
|
document: state.document,
|
|
463
|
-
glossary: state.glossary
|
|
464
|
-
}
|
|
538
|
+
glossary: state.glossary,
|
|
539
|
+
}
|
|
465
540
|
}
|
|
466
|
-
|
|
541
|
+
|
|
542
|
+
export default withWidth()(connect(mapStateToProps)(DocumentView))
|