1 | # we-edit-variant
|
2 |
|
3 | It's to support dynamic content in WE document
|
4 |
|
5 | # components
|
6 | * Provider[value]: to provide a variant context
|
7 | * VariantRepresentation[variants]: a representation supporting variants
|
8 | * withVariant(dom): a hoc transformer to support variants
|
9 | * install/unstall: to make default representation dom support variants
|
10 |
|
11 | # variant types
|
12 | * $exp
|
13 | * $if
|
14 | * $for
|
15 | * $image
|
16 | * $script
|
17 | * $sub
|
18 | * $type
|
19 |
|
20 |
|
21 | # examples
|
22 | ```jsx
|
23 | import react from "react"
|
24 | import ReactDOM from "react-dom"
|
25 | import {dom,Editor} from "we-edit"
|
26 | import {withVariant, VariantRepresentation} from "we-edit/variant"
|
27 |
|
28 | const {Document,Paragraph, Text, $if, $for, $exp}=withVariant(dom)
|
29 |
|
30 | const doc=(
|
31 | <Document>
|
32 | <$if condition="id===1">
|
33 | <Paragraph>
|
34 | <$for init="var i=0" test="i<3" update="i++">
|
35 | <Text>hello</Text>
|
36 | </$for>
|
37 | <Text>
|
38 | <$exp expression="firstName"/>
|
39 | </Text>
|
40 | </Paragraph>
|
41 | </$if>
|
42 | </Document>
|
43 | )
|
44 |
|
45 | ReactDOM.render(
|
46 | <Editor>
|
47 | <VariantRepresenation variants={{id:"1",firstName:"tester"}} type="pagination">
|
48 | {doc}
|
49 | </VariantRepresentation>
|
50 | </Editor>,
|
51 | document.querySelector("#editor")
|
52 | )
|
53 | ``` |
\ | No newline at end of file |