@cu-mkp/editioncrafter 1.2.1 → 1.3.0-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.
@@ -0,0 +1,11 @@
1
+ const NotesActions = {}
2
+
3
+ NotesActions.loadNotes = function loadNotes(state, noteData) {
4
+ return {
5
+ ...state,
6
+ loaded: true,
7
+ notes: noteData,
8
+ }
9
+ }
10
+
11
+ export default NotesActions
@@ -3,12 +3,26 @@ function getHeaderUrlFromManifestUrl(manifestUrl) {
3
3
  return `${truncated}/html/index.html`
4
4
  }
5
5
 
6
+ function getHeaderUrlsFromManifestUrls(data) {
7
+ if (typeof data === 'string') {
8
+ return getHeaderUrlFromManifestUrl(data)
9
+ }
10
+
11
+ const result = {}
12
+
13
+ Object.entries(data).forEach((ent) => {
14
+ result[ent[0]] = getHeaderUrlFromManifestUrl(ent[1])
15
+ })
16
+
17
+ return result
18
+ }
19
+
6
20
  export default function documentInitalState(iiifManifest, documentName, transcriptionTypes, variorum = false, derivativeNames = null, threePanel = false) {
7
21
  return {
8
22
  documentName,
9
23
  derivativeNames,
10
24
  manifestURL: iiifManifest,
11
- headerUrl: getHeaderUrlFromManifestUrl(iiifManifest),
25
+ headerUrl: getHeaderUrlsFromManifestUrls(iiifManifest),
12
26
  transcriptionTypes,
13
27
  variorum,
14
28
  threePanel,
@@ -0,0 +1,8 @@
1
+ export default function notesInitialState(notesURL) {
2
+ return {
3
+ notes: '',
4
+ loaded: false,
5
+ URL: notesURL,
6
+ }
7
+ }
8
+
@@ -4,16 +4,19 @@ import { createReducer } from '../model/ReduxStore'
4
4
  import DiplomaticActions from './DiplomaticActions'
5
5
  import DocumentActions from './DocumentActions'
6
6
  import GlossaryActions from './GlossaryActions'
7
+ import NotesActions from './NotesActions'
7
8
 
8
9
  import diplomaticInitialState from './initialState/diplomaticInitialState'
9
10
  import documentInitialState from './initialState/documentInitialState'
10
11
  import glossaryInitialState from './initialState/glossaryInitialState'
12
+ import notesInitialState from './initialState/notesInitialState'
11
13
 
12
14
  export default function rootReducer(config) {
13
15
  const {
14
16
  documentName,
15
17
  documentInfo,
16
18
  glossaryURL,
19
+ notesURL,
17
20
  threePanel = false,
18
21
  } = config
19
22
  const variorum = documentInfo && Object.keys(documentInfo).length > 1
@@ -34,5 +37,6 @@ export default function rootReducer(config) {
34
37
  diplomatic: createReducer('DiplomaticActions', DiplomaticActions, diplomaticInitialState),
35
38
  document: createReducer('DocumentActions', DocumentActions, documentInitialState(iiifManifest, documentName, transcriptionTypes, variorum, derivativeNames, threePanel)),
36
39
  glossary: createReducer('GlossaryActions', GlossaryActions, glossaryInitialState(glossaryURL)),
40
+ notes: createReducer('NotesActions', NotesActions, notesInitialState(notesURL)),
37
41
  })
38
42
  }
@@ -8,6 +8,7 @@ import {
8
8
  } from 'react-router-dom'
9
9
  import { dispatchAction } from '../model/ReduxStore'
10
10
  import GlossaryView from './GlossaryView'
11
+ import NotesView from './NotesView'
11
12
  import ImageGridView from './ImageGridView'
12
13
  import ImageView from './ImageView'
13
14
  import SinglePaneView from './SinglePaneView'
@@ -345,6 +346,9 @@ function DocumentView(props) {
345
346
  if (transcriptionType === 'glossary') {
346
347
  return 'GlossaryView'
347
348
  }
349
+ if (transcriptionType === 'notes') {
350
+ return 'NotesView'
351
+ }
348
352
  return xmlMode ? 'XMLView' : 'TranscriptionView'
349
353
  }
350
354
 
@@ -479,6 +483,16 @@ function DocumentView(props) {
479
483
  />
480
484
  )
481
485
  }
486
+ if (viewType === 'NotesView') {
487
+ return (
488
+ <NotesView
489
+ key={key}
490
+ documentView={docView}
491
+ documentViewActions={documentViewActions}
492
+ side={side}
493
+ />
494
+ )
495
+ }
482
496
  return (
483
497
  <div>ERROR: Unrecognized viewType.</div>
484
498
  )
@@ -312,6 +312,11 @@ function Navigation(props) {
312
312
  {DocumentHelper.transcriptionTypeLabels.glossary}
313
313
  </MenuItem>
314
314
  ) }
315
+ { props.notes && (
316
+ <MenuItem value="notes" key="notes">
317
+ {DocumentHelper.transcriptionTypeLabels.notes}
318
+ </MenuItem>
319
+ )}
315
320
  </Select>
316
321
  {!imageViewActive && (
317
322
  <ToggleButton
@@ -440,6 +445,7 @@ function mapStateToProps(state) {
440
445
  return {
441
446
  document: state.document,
442
447
  glossary: !!state.glossary.URL,
448
+ notes: !!state.notes.URL,
443
449
  }
444
450
  }
445
451
 
@@ -0,0 +1,50 @@
1
+ import { Typography } from '@material-ui/core'
2
+ import React, { Component } from 'react'
3
+ import ReactMarkdown from 'react-markdown'
4
+ import remarkGfm from 'remark-gfm'
5
+ import { connect } from 'react-redux'
6
+ import Navigation from './Navigation'
7
+
8
+ class NotesView extends Component {
9
+ constructor() {
10
+ super()
11
+ this.state = { filterTerm: '' }
12
+ }
13
+
14
+ onFilterChange = (event) => {
15
+ const filterTerm = event.target.value
16
+ this.setState({ ...this.state, filterTerm })
17
+ }
18
+
19
+ render() {
20
+ if (!this.props.notes.loaded)
21
+ return null
22
+
23
+ return (
24
+ <div id="notesView" style={{ position: 'relative', overflow: 'auto' }}>
25
+ <Navigation
26
+ side={this.props.side}
27
+ onFilterChange={this.onFilterChange}
28
+ value={this.state.filterTerm}
29
+ documentView={this.props.documentView}
30
+ documentViewActions={this.props.documentViewActions}
31
+ />
32
+
33
+ <div id="notesViewInner">
34
+ <div id="notesContent">
35
+ <ReactMarkdown children={this.props.notes.notes} remarkPlugins={[remarkGfm]}/>
36
+ </div>
37
+ </div>
38
+
39
+ </div>
40
+ )
41
+ }
42
+ }
43
+
44
+ function mapStateToProps(state) {
45
+ return {
46
+ notes: state.notes,
47
+ }
48
+ }
49
+
50
+ export default connect(mapStateToProps)(NotesView)
@@ -3,6 +3,7 @@ const DocumentHelper = {}
3
3
  DocumentHelper.transcriptionTypeLabels = {
4
4
  f: 'Facsimile', // keep
5
5
  glossary: 'Glossary', // keep
6
+ notes: 'Notes',
6
7
  }
7
8
 
8
9
  export default DocumentHelper
@@ -5,6 +5,7 @@ import { putResolveAction } from '../model/ReduxStore'
5
5
 
6
6
  const justDocument = state => state.document
7
7
  const justGlossary = state => state.glossary
8
+ const justNotes = state => state.notes
8
9
 
9
10
  function* parseTags(headerUrl) {
10
11
  const tags = {}
@@ -48,6 +49,7 @@ function* userNavigation(action) {
48
49
  yield resolveDocumentManifest()
49
50
  yield resolveDocumentTags()
50
51
  yield resolveGlossary()
52
+ yield resolveNotes()
51
53
  yield resolveFolio(pathSegments)
52
54
  break
53
55
  }
@@ -134,6 +136,15 @@ function* resolveGlossary() {
134
136
  }
135
137
  }
136
138
 
139
+ function* resolveNotes() {
140
+ const notes = yield select(justNotes)
141
+ if (!notes.loaded && notes.URL) {
142
+ const response = yield fetch(notes.URL)
143
+ const txt = yield response.text()
144
+ yield putResolveAction('NotesActions.loadNotes', txt)
145
+ }
146
+ }
147
+
137
148
  export default function* routeListenerSaga() {
138
149
  yield takeEvery('RouteListenerSaga.userNavigation', userNavigation)
139
150
  }
@@ -0,0 +1,49 @@
1
+ .editioncrafter {
2
+
3
+ #notesView {
4
+
5
+ #notesViewInner {
6
+ margin: 5px 0 0 0;
7
+ // @include md {
8
+ // margin: 52px 0 0 0;
9
+ // }
10
+ width: calc(100% - 1.2rem);
11
+ max-height: calc(100vh - 170px);
12
+ padding: 5px 16px;
13
+ }
14
+
15
+ #notesContent {
16
+ padding: max(80px, 5rem) 0 0;
17
+ max-height: 100vh;
18
+ -webkit-user-select: text;
19
+ -moz-user-select: text;
20
+ -ms-user-select: text;
21
+ user-select: text;
22
+ min-width: max(10rem, 160px);
23
+ @include md {
24
+ padding: max(3.5rem, 56px) 0 0;
25
+ }
26
+
27
+ table {
28
+ margin-top: 30px;
29
+ }
30
+
31
+ td, th {
32
+ border: 1px solid #ddd;
33
+ padding: 8px;
34
+ }
35
+
36
+ tr:nth-child(even){
37
+ background-color: #f2f2f2;
38
+ }
39
+
40
+ th {
41
+ padding-top: 12px;
42
+ padding-bottom: 12px;
43
+ text-align: left;
44
+ background-color: gray;
45
+ color: white;
46
+ }
47
+ }
48
+ }
49
+ }
@@ -105,6 +105,7 @@ animation: #{$str};
105
105
  @import "transcriptView";
106
106
  @import "xmlView";
107
107
  @import "glossary";
108
+ @import "notes";
108
109
  @import "jumpbox";
109
110
 
110
111
  @import "CETEIcean";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cu-mkp/editioncrafter",
3
3
  "type": "module",
4
- "version": "1.2.1",
4
+ "version": "1.3.0-beta.1",
5
5
  "private": false,
6
6
  "description": "A simple digital critical edition publication tool",
7
7
  "license": "MIT",
@@ -46,6 +46,7 @@
46
46
  "react-scroll": "^1.7.10",
47
47
  "redux": "^4.2.1",
48
48
  "redux-saga": "^1.2.2",
49
+ "remark-gfm": "^3.0.1",
49
50
  "sql.js": "^1.12.0"
50
51
  },
51
52
  "devDependencies": {