forked from aunger/editor-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
57 lines (49 loc) · 1.39 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React, { useState, useEffect, useMemo } from 'react';
import { createBasicUsfmEditor, withChapterPaging, withChapterSelection, withToolbar } from "usfm-editor"
import style from "./style-override.lazy.css"
import { DemoToolbarSpecs } from './DemoToolbarSpecs'
const loading = String.raw`
\id XXA LOADING
\ide UTF-8
\c 1
\p
\v 1 Loading, please wait...
`.trimLeft()
function App() {
const [sourceString, setSourceString] = useState(loading);
const [output, setOutput] = useState()
const [id, setId] = useState()
const CustomEditor = useMemo(
() => withToolbar(withChapterSelection(withChapterPaging(createBasicUsfmEditor()))),
[sourceString]
)
useEffect(() => {
window.fetch("https://git.door43.org/unfoldingWord/en_ult/raw/tag/25/27-DAN.usfm")
.then(r=> r.text())
.then(text => { setSourceString(text) })
})
const HandleOutputData = (data) => {
console.log(data)
setOutput(data)
}
const onIdentificationChangeHandle = (id) => {
console.log(id)
setId(id)
}
return (
<div className="App">
<header className="App-header">
<p>
USFM Editor
</p>
</header>
<CustomEditor
usfmString={sourceString}
toolbarSpecs={DemoToolbarSpecs}
onChange={HandleOutputData}
onIdentificationChange={onIdentificationChangeHandle}
/>
</div>
);
}
export default App;