@cu-mkp/editioncrafter 1.3.0 → 1.3.1-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/dist/editioncrafter.js +15222 -15172
- package/dist/es/src/EditionCrafter/component/DiploMatic.js +31 -17
- package/dist/es/src/EditionCrafter/component/DocumentView.js +48 -6
- package/dist/es/src/EditionCrafter/component/RouteListener.js +1 -1
- package/dist/es/src/EditionCrafter/component/TranscriptionView.js +3 -2
- package/dist/es/src/EditionCrafter/saga/RouteListenerSaga.js +3 -2
- package/dist/es/src/TagExplore/index.jsx +6 -4
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import withWidth from '@material-ui/core/withWidth'
|
|
2
2
|
import { createBrowserHistory } from 'history'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
|
-
import React, { useEffect, useRef, useState } from 'react'
|
|
4
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
|
5
5
|
import { connect, Provider } from 'react-redux'
|
|
6
6
|
import {
|
|
7
|
+
BrowserRouter,
|
|
7
8
|
HashRouter,
|
|
8
9
|
Navigate,
|
|
9
10
|
Route,
|
|
@@ -24,6 +25,8 @@ function DiploMatic(props) {
|
|
|
24
25
|
})
|
|
25
26
|
}, [])
|
|
26
27
|
|
|
28
|
+
const Router = useMemo(() => props.config.serverNav ? BrowserRouter : HashRouter, [props.config.serverNav])
|
|
29
|
+
|
|
27
30
|
useEffect(() => {
|
|
28
31
|
if (containerRef.current) {
|
|
29
32
|
setContainerWidth(containerRef.current.offsetWidth)
|
|
@@ -36,23 +39,34 @@ function DiploMatic(props) {
|
|
|
36
39
|
const { fixedFrameMode } = props.diplomatic
|
|
37
40
|
const fixedFrameModeClass = fixedFrameMode ? 'editioncrafter' : 'editioncrafter sticky'
|
|
38
41
|
|
|
39
|
-
const mainBody
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
const mainBody
|
|
43
|
+
= (
|
|
44
|
+
<div id="diplomatic" className={fixedFrameModeClass} ref={containerRef} style={{ height: containerHeight }}>
|
|
45
|
+
<RouteListener divider={props.config.divider} />
|
|
46
|
+
<div id="content" style={{ height: '100%' }}>
|
|
47
|
+
{
|
|
48
|
+
props.config.serverNav
|
|
49
|
+
? (
|
|
50
|
+
<DocumentView {...props} containerWidth={containerWidth} />
|
|
51
|
+
)
|
|
52
|
+
: (
|
|
53
|
+
<Routes>
|
|
54
|
+
<Route path="/ec/:folioID/:transcriptionType/:folioID2/:transcriptionType2/:folioID3/:transcriptionType3" element={<DocumentView {...props} containerWidth={containerWidth} />} exact />
|
|
55
|
+
<Route path="/ec/:folioID/:transcriptionType/:folioID2/:transcriptionType2" element={<DocumentView {...props} containerWidth={containerWidth} />} exact />
|
|
56
|
+
<Route path="/ec/:folioID/:transcriptionType" element={<DocumentView {...props} containerWidth={containerWidth} />} exact />
|
|
57
|
+
<Route path="/ec/:folioID" element={<DocumentView {...props} containerWidth={containerWidth} />} exact />
|
|
58
|
+
<Route path="/ec" element={<DocumentView {...props} containerWidth={containerWidth} />} exact />
|
|
59
|
+
<Route path="/" element={<Navigate to="/ec" />} exact />
|
|
60
|
+
</Routes>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
)
|
|
54
66
|
|
|
55
|
-
const topLevel = !(props.tagExplorerMode === true)
|
|
67
|
+
const topLevel = !(props.tagExplorerMode === true)
|
|
68
|
+
? <Router><TagFilterProvider>{mainBody}</TagFilterProvider></Router>
|
|
69
|
+
: mainBody
|
|
56
70
|
|
|
57
71
|
return (
|
|
58
72
|
<Provider store={props.store}>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import withWidth, { isWidthUp } from '@material-ui/core/withWidth'
|
|
2
|
-
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import React, { useEffect, useMemo, useState } from 'react'
|
|
3
3
|
import { connect } from 'react-redux'
|
|
4
4
|
import {
|
|
5
5
|
useLocation,
|
|
@@ -30,13 +30,55 @@ function DocumentView(props) {
|
|
|
30
30
|
const [third, setThird] = useState(paneDefaults)
|
|
31
31
|
const [singlePaneMode, setSinglePaneMode] = useState(props.containerWidth < 960)
|
|
32
32
|
|
|
33
|
-
const
|
|
34
|
-
const
|
|
33
|
+
const navigateRouter = useNavigate()
|
|
34
|
+
const navigateWindow = (path) => {
|
|
35
|
+
window.location.href = path
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Memoize the navigation method
|
|
39
|
+
*/
|
|
40
|
+
const navigate = useMemo(() => (props.config.serverNav
|
|
41
|
+
? (props.config.navigate || navigateWindow)
|
|
42
|
+
: navigateRouter), [props.config.serverNav, props.config.navigate, navigateRouter])
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Memoize the URL divider ('ec' by default)
|
|
46
|
+
*/
|
|
47
|
+
const divider = useMemo(() => (props.config.divider || '/ec'), [props.config.divider])
|
|
35
48
|
const location = useLocation()
|
|
36
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Memoize the base URL of the current page (before the divider)
|
|
52
|
+
*/
|
|
53
|
+
const baseUrl = useMemo(() => (
|
|
54
|
+
props.config.serverNav
|
|
55
|
+
? location.pathname.split(divider)[0]
|
|
56
|
+
: null
|
|
57
|
+
), [props.config.serverNav, location, divider])
|
|
58
|
+
|
|
59
|
+
const routerParams = useParams()
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Memoize the folio parameters
|
|
63
|
+
*/
|
|
64
|
+
const params = useMemo(() => {
|
|
65
|
+
if (!props.config.serverNav) {
|
|
66
|
+
return routerParams
|
|
67
|
+
}
|
|
68
|
+
const suffix = location.pathname.split(divider)[1]?.split('/')
|
|
69
|
+
return ({
|
|
70
|
+
folioID: suffix[1],
|
|
71
|
+
transcriptionType: suffix[2],
|
|
72
|
+
folioID2: suffix[3],
|
|
73
|
+
transcriptionType2: suffix[4],
|
|
74
|
+
folioID3: suffix[5],
|
|
75
|
+
transcriptionType3: suffix[6],
|
|
76
|
+
})
|
|
77
|
+
}, [location, routerParams, props.config.serverNav, divider])
|
|
78
|
+
|
|
37
79
|
// "reload" the page if the config props change
|
|
38
80
|
useEffect(() => {
|
|
39
|
-
dispatchAction(props, 'RouteListenerSaga.userNavigation', location.pathname)
|
|
81
|
+
dispatchAction(props, 'RouteListenerSaga.userNavigation', location.pathname, divider.replaceAll('/', ''))
|
|
40
82
|
}, [props.config])
|
|
41
83
|
|
|
42
84
|
useEffect(() => {
|
|
@@ -45,7 +87,7 @@ function DocumentView(props) {
|
|
|
45
87
|
|
|
46
88
|
// Navigate while keeping existing search params
|
|
47
89
|
const navigateWithParams = (pathname) => {
|
|
48
|
-
navigate(pathname + location.search)
|
|
90
|
+
navigate(baseUrl + pathname + location.search)
|
|
49
91
|
}
|
|
50
92
|
|
|
51
93
|
const getViewports = () => {
|
|
@@ -125,7 +167,7 @@ function DocumentView(props) {
|
|
|
125
167
|
|
|
126
168
|
useEffect(() => {
|
|
127
169
|
dispatchAction(props, 'DiplomaticActions.setFixedFrameMode', true)
|
|
128
|
-
|
|
170
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
171
|
}, [])
|
|
130
172
|
|
|
131
173
|
const setXMLMode = (side, xmlMode) => {
|
|
@@ -10,7 +10,7 @@ function RouteListener(props) {
|
|
|
10
10
|
const { pathname } = useLocation()
|
|
11
11
|
|
|
12
12
|
const userNavigated = () => {
|
|
13
|
-
dispatchAction(props, 'RouteListenerSaga.userNavigation', pathname)
|
|
13
|
+
dispatchAction(props, 'RouteListenerSaga.userNavigation', pathname, props.divider && props.divider.replaceAll('/', ''))
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
useEffect(() => {
|
|
@@ -107,8 +107,6 @@ function htmlToReactParserOptions(selectedZone, selectedTags) {
|
|
|
107
107
|
function TranscriptionView(props) {
|
|
108
108
|
const [searchParams] = useSearchParams()
|
|
109
109
|
|
|
110
|
-
const { tags } = useContext(TagFilterContext)
|
|
111
|
-
|
|
112
110
|
const {
|
|
113
111
|
side,
|
|
114
112
|
folioID,
|
|
@@ -118,6 +116,9 @@ function TranscriptionView(props) {
|
|
|
118
116
|
documentViewActions,
|
|
119
117
|
} = props
|
|
120
118
|
|
|
119
|
+
const { tagsLeft, tagsRight } = useContext(TagFilterContext)
|
|
120
|
+
const tags = side === 'left' ? tagsLeft : tagsRight
|
|
121
|
+
|
|
121
122
|
if (folioID === '-1') {
|
|
122
123
|
return (
|
|
123
124
|
<Watermark
|
|
@@ -55,11 +55,12 @@ function* parseTags(headerUrl) {
|
|
|
55
55
|
|
|
56
56
|
function* userNavigation(action) {
|
|
57
57
|
const pathname = action.payload.params[0]
|
|
58
|
+
const divider = action.payload.params[1] || 'ec'
|
|
58
59
|
const pathSegments = pathname.split('/')
|
|
59
60
|
|
|
60
61
|
if (pathSegments.length > 1) {
|
|
61
|
-
switch (pathSegments
|
|
62
|
-
case
|
|
62
|
+
switch (pathSegments.includes(divider)) {
|
|
63
|
+
case true:
|
|
63
64
|
{
|
|
64
65
|
yield resolveDocumentManifest()
|
|
65
66
|
yield resolveDocumentTags()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
import { HashRouter } from 'react-router-dom'
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
2
|
+
import { BrowserRouter, HashRouter } from 'react-router-dom'
|
|
3
3
|
import initSqlJs from 'sql.js'
|
|
4
4
|
import sqlJsInfo from 'sql.js/package.json'
|
|
5
5
|
import Loading from '../common/components/Loading'
|
|
@@ -71,6 +71,8 @@ function TagExplore(props) {
|
|
|
71
71
|
const [ecProps, setECProps] = useState(null)
|
|
72
72
|
const [filters, setFilters] = useState(initialFilters)
|
|
73
73
|
|
|
74
|
+
const Router = useMemo(() => props.serverNav ? BrowserRouter : HashRouter, [props.serverNav])
|
|
75
|
+
|
|
74
76
|
useEffect(() => {
|
|
75
77
|
const loadDb = async () => {
|
|
76
78
|
const db = await initDb(props.dbUrl)
|
|
@@ -96,12 +98,12 @@ function TagExplore(props) {
|
|
|
96
98
|
|
|
97
99
|
return (
|
|
98
100
|
<div className="tag-explore">
|
|
99
|
-
<
|
|
101
|
+
<Router>
|
|
100
102
|
<TagFilterProvider>
|
|
101
103
|
<TagExploreSidebar db={db} />
|
|
102
104
|
<EditionCrafter {...ecProps} />
|
|
103
105
|
</TagFilterProvider>
|
|
104
|
-
</
|
|
106
|
+
</Router>
|
|
105
107
|
</div>
|
|
106
108
|
)
|
|
107
109
|
}
|