UNPKG

3.1 kBMarkdownView Raw
1# we-edit
2
3## install
4```sh
5npm install we-edit
6```
7
8## design
9* Loader (input) -> we-edit models
10* Viewer/Editor/Emitter -> we-edit document
11* Represenation(pagination/html/text) -> view document
12* Emitter.Format -> output document
13* Streamer -> file/url/...
14
15###example
16```js
17 //to convert docx to pdf, svg, and html on console
18 //you have to install
19 // and we-edit-input-docx
20 // and we-edit-output-(pdf|svg|html),
21 // and we-edit-representation-(pagination|html),
22 // and we-edit-loader-stream-file
23 import {Loader, Emitter, Stream, render} from "we-edit"
24 render(
25 <Loader type="file" path="./test.docx">
26 <Emitter>
27 <Stream type="file" path="./test" name={({format})=>`test.${format}`}>
28 <Emitter.Format type="pdf"/>
29 <Emitter.Format type="svg"/>
30 <Emitter.Format type="html"/>
31 </Stream>
32 </Emitter>
33 </Loader>
34 )
35 .then(a=>console.log(a))
36 .catch(e=>console.error(e))
37
38 //to view test.docx in browser in pages
39 //you have to install
40 // and we-edit-input-docx
41 // and we-edit-representation-pagination,
42 // and we-edit-loader-stream-file
43 import {Loader, Viewer, Representation} from "we-edit"
44 import ReactDOM from "react-dom"
45 ReactDOM.render(
46 <Loader type="file" path="./test.docx">
47 <Viewer representation={<Representation type="pagination"/>}>
48 </Loader>,
49 document.body
50 )
51
52 //to edit test.docx in browser in pages
53 //you have to install
54 // and we-edit-input-docx
55 // and we-edit-representation-pagination,
56 // and we-edit-loader-stream-file
57 import {Loader, Editor, Representation} from "we-edit"
58 import ReactDOM from "react-dom"
59 ReactDOM.render(
60 <Loader type="file" path="./test.docx">
61 <Editor representation={<Representation type="pagination"/>}/>
62 </Loader>,
63 document.body
64 )
65
66 //to edit test.docx in browser in pages, and view in html
67 //you have to install
68 // and we-edit-input-docx
69 // and we-edit-representation-pagination&html,
70 // and we-edit-loader-stream-file
71 import {Loader, Editor, Representation} from "we-edit"
72 import ReactDOM from "react-dom"
73 ReactDOM.render(
74 <Loader type="file" path="./test.docx">
75 <div style={{position:"absolute",left:0,width:500}}>
76 <Editor representation={<Representation type="pagination"/>}/>
77 </div>
78
79 <div style={{position:"absolute",right:0,width:500}}>
80 <Viewer representation={<Representation type="html"/>}/>
81 </div>
82 </Loader>,
83 document.body
84 )
85
86 //for more featur office, check we-edit-office
87```
88
89
90## API
91
92### top level
93
94#### input
95* support
96* load
97* create
98* Viewable
99* Editable
100* EditableDocument
101
102#### components
103* WeEdit
104
105* Loader[type]
106
107* Editor
108* Viewer
109* Emitter
110* Emitter.Format[type]
111
112* models
113
114* Represenation[type]
115
116* Stream[type]
117* Stream.Collection
118
119* WithStore
120* WithSelection
121
122* onlyWhen
123* when
124
125* Cursor
126* Selection
127
128#### state
129* ACTION
130* DOMAIN="we-edit"
131* reducer
132* getActive
133* getContent
134* getSelection
135* getFile
136* getUndos
137* getRedos
138
139#### tools
140* getClientRect
141* shallowEqual
142* uuid
143
144### models
145* Document
146* Section
147* Paragraph
148* Text
149* Header
150* Footer
151* Image
152* Table
153* Row
154* Cell
155* List
156* Frame
157* Shape
\No newline at end of file