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
58
59
60
61
62
| import { types } from "mobx-state-tree";
|
| const Region = types.model({
| name: types.string,
| });
|
| export const ImageRegion = types.compose(
| "Image",
| Region,
| types
| .model({
| id: types.identifier,
| type: types.literal("image"),
| })
| .actions(() => ({
| draw() {
| // console.log("DRAW", self.id);
| },
| })),
| );
|
| export const TextRegion = types.compose(
| "Text",
| Region,
| types
| .model({
| id: types.identifier,
| type: types.literal("text"),
| })
| .actions(() => ({
| select() {
| // console.log("SELECT", self.id);
| },
| })),
| );
|
| // const HyperTextRegion = types.model({
| // id: types.identifier,
| // type: types.literal(""),
| // });
|
| // const AudioRegion = types.model({
| // id: types.identifier,
| // type: types.literal(""),
| // });
|
| const TestRaw = types.model("TestRaw", {
| regions: types.array(types.union(ImageRegion, TextRegion)),
| // inheritance: types.array(Region), // wrong :(
| meta: types.number,
| });
|
| const TestMeta = types.model({
| meta: types.model({
| width: 120,
| height: 100,
| }),
| });
|
| const Test = types.compose("Test", TestRaw, TestMeta);
|
| export default Test;
|
|