UNPKG

3.16 kBMarkdownView Raw
1# we-edit-office
2
3It provide an example to create an office suites with all we-edit parts.
4It would create a default office for quick playaround if
5* document.title==="test", or
6* an element with id=OfficeContainer in html page
7
8## components
9* WeEditUI : setup UI
10* Office: a default office to manage workspaces
11* Workspace: a workspace for a type/group of document, such as *.doc
12 * Workspace.Desk: to define a uniform workspace desk style[layout,toolbar,...]
13 * Workspace.Layout: to define layout of workspace[left,canvas,right]
14
15* Ribbon: a domain to help create ribbons
16 * Ribbon,
17 * Toolbar,
18 * ToolbarSeparator,
19 * Text : text content toolbar,
20 * Paragraph: paragraph content toolbar,
21 * File: file functional toolbar,
22 * History: undo/redo toolbar,
23 * Table: table content toolbar,
24 * Picture: picture content toolbar,
25 * Layout: layout toolbar,
26 * Tabs, Tab,
27 * CheckIconButton,
28 * DropDownButton
29* Dashboard:
30
31## short-cut function
32* create(container, office=<Office/>)
33
34
35## install
36```bash
37 npm install we-edit
38```
39
40## example
41```jsx
42import {WeEdit,Viewer, Editor} from "we-edit"
43import {WeEditUI, Office, Workspace } from "we-edit/office"
44import iDocx from "we-edit/input-docx"
45
46 iDocx.install()
47
48 const IconRead=props=><span/>
49 const IconPrint=props=><span/>
50 const IconWeb=props=><span/>
51
52 const docxWorkspace=(
53 <Workspace accept="*.docx" layout="print" debug={false}>
54 <Viewer
55 toolBar={null}
56 ruler={false}
57 layout="read"
58 icon={<IconRead/>}
59 representation="pagination">
60
61 </Viewer>
62
63 <Editor
64 layout="print"
65 icon={<IconPrint/>}
66 representation="pagination"
67 >
68
69 </Editor>
70
71 <Editor
72 ruler={false}
73 layout="web"
74 icon={<IconWeb/>}
75 representation="html">
76
77 </Editor>
78 </Workspace>
79 )
80 const inddWorkspace=(
81 <Workspace accept="*.indd">
82 <Viewer
83 layout="print"
84 icon={<IconPrint/>}
85 representation="pagination"
86 />
87 </Workspace>
88 )
89
90 const notSupported=(
91 <Workspace accept="*">
92 not supported content
93 </Workspace>
94 )
95
96 //you can manage office by yourself as following
97 const myOffice=(
98 <WeEdit>{/*manage multiple document state*/}
99 <WeEditUI fonts={["Arial", "Calibri", "Cambria"]}>{/* setup UI and manage workspaces*/}
100 {docxWorkspace}
101 {inddWorkspace}
102 {notSupported}
103 </WeEditUI>
104 </WeEdit>
105 )
106 ReactDOM.render(myOffice, document.querySelector("#officeContainer"))
107 /* //or you can use default office to install/uninstall workspace
108 //install order is critical, first in, last chance
109 Office.install(notSupported)
110 Office.insall(inddWorkspace)
111 ReactDOM.render(<Office/>, document.querySelector("#officeContainer"))
112 Office.install(docxWorkspace)
113 */
114```
\No newline at end of file