@zenuml/core 3.32.7 → 3.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenuml/core",
3
- "version": "3.32.7",
3
+ "version": "3.33.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,121 +0,0 @@
1
- = Integration Guide
2
- :icons: font
3
-
4
- == Audience
5
- This document is written for those want to integrate ZenUML to their applications. If you are an end
6
- user, please read tutorials; if your would like to contribute, please read contributor's guide.
7
-
8
-
9
- == Integration
10
- An important goal of this project is to be easily integrated into other projects.
11
- There are mainly two ways to do this.
12
-
13
- === As a library
14
-
15
- ZenUML Core exposes a simple API for integration:
16
-
17
- [source, typescript]
18
- ----
19
- interface IZenUml {
20
- get code(): string | undefined;
21
- get theme(): string | undefined;
22
- // Resolve after rendering is finished.
23
- render: (code: string | undefined, theme: string | undefined) => Promise<IZenUml>
24
- }
25
-
26
- // client code
27
- import ZenUml from '@ZenUML/core'
28
- const zenUml = new ZenUml(el)
29
- await zenUml.render('A.method', {theme: 'theme-blue'})
30
- ----
31
-
32
- ==== When rendering is finished
33
- When rendering is finished, the `render` method will return a promise that resolves to the
34
- instance of `IZenUml`. The `html` properties of the instance will be updated to the rendered
35
- HTML.
36
-
37
- [NOTE]
38
- ====
39
- Vue's reactive system works against the `data`, `props` and `computed` properties of a component.
40
- This means a parent component is not necessarily be notified when a child component is `mounted` or `updated`.
41
- So this means we can not use the `mounted` or `updated` hook on `LifelineLayer` to emit `rendered` event.
42
- ====
43
-
44
- It is tricky to know when the rendering is finished. The `Lifeline` components used `$nextTick`
45
- in their `mounted` and `updated` hooks to set the top when a `creation` message is sent to it.
46
- We have to wait until all those `$nextTick` calls are finished.
47
-
48
- [NOTE]
49
- ====
50
- It seems that (to be confirmed) the `$nextTick` calls are queued and executed in ONE tick. This
51
- makes it easier to control the timing when to resolve the `render` promise. We only need to wait
52
- ONE `$nextTick` call to be finished.
53
- ====
54
-
55
- The diagram is rendered in the following steps:
56
-
57
- 1. The lifeline layer;
58
- 2. The message layer;
59
- 3. Update lifeline layer with `setTimeout` for `creation` messages.
60
-
61
- === As an iframe
62
-
63
- You can embed the ZenUML core renderer as an application within another app, where you store the diagram
64
- data in the host app. It takes around 5 minutes to get a basic example running.
65
-
66
- ==== Quick test
67
- To test this out open `https://embed.zenuml.com/embed.html`. In the developer console, type in the
68
- following command.
69
-
70
- [source,js]
71
- ----
72
- window.postMessage( {action: 'eval', args: { code: 'ZenUML.Hello' }})
73
- ----
74
- ==== The protocol
75
-
76
- The protocol is a simple JSON object with the following fields.
77
-
78
- [source,json]
79
- ----
80
- {
81
- "action": "eval",
82
- "args": {
83
- "code": "ZenUML.Hello",
84
- "style": "#diagram { background-color: red; }",
85
- "theme": "blue",
86
- "css": "https://github.com/abruzzi/zenuml-css-overrides/blob/master/zenuml-override.css"
87
- }
88
- }
89
- ----
90
-
91
- ==== Example
92
-
93
- [source,html]
94
- ----
95
- <iframe src="https://embed.zenuml.com/embed.html" id="zenuml-iframe"
96
- style="width: 100%; height: 100%; border: none;">
97
-
98
- </iframe>
99
- <script>
100
- const iframe = document.getElementById('zenuml-iframe');
101
- const message = {
102
- action: 'eval',
103
- args: {
104
- code: 'ZenUML.Hello',
105
- style: '#diagram { background-color: red; }',
106
- theme: 'blue',
107
- css: ''
108
- }
109
- };
110
- setTimeout(() => {
111
- iframe.contentWindow.postMessage(message, '*');
112
- }, 1000);
113
- </script>
114
- ----
115
-
116
- [source,js]
117
- ----
118
- document.getElementsByTagName('iframe')[0] // get iframe
119
- .contentWindow // get target window
120
- .postMessage({action: "eval", args: { code: 'A.m' }})
121
- ----