forked from ZenUml/core
-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
127 lines (115 loc) · 3.72 KB
/
index.html
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!doctype html>
<html>
<head>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
rel="preload stylesheet"
as="style"
href="https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@300;400;500;700&display=swap"
/>
<style id="zenumlstyle">
/* Prefix your CSS rules with `#diagram` */
/*@import url('https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&display=swap');*/
/*!*@import url("https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@300;400;500;700&display=swap");*!*/
/*#diagram1 .sequence-diagram {*/
/* font-family: "Kalam", serif;*/
/*}*/
</style>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link
rel="stylesheet"
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/default.min.css"
crossorigin="anonymous"
/>
<script src="https://cdn.jsdelivr.net/npm/codemirror@5.65.1/lib/codemirror.min.js"></script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.1/codemirror.min.css"
integrity="sha512-uf06llspW44/LZpHzHT6qBOIVODjWtv4MxCricRxkzvopAlSWnTf6hpZTFxuuZcuNE9CBQhqE0Seu1CoRk84nQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<title>ZenUML Core Demo</title>
<style>
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: monospace;
font-size: 13px;
height: 1000px;
}
.zenuml .CodeMirror .CodeMirror-cursor {
border-color: #000;
border-left-width: 1px;
}
.grid {
display: grid;
}
.grid-cols-6 {
grid-template-columns: repeat(6, minmax(0, 1fr));
}
.col-span-2 {
grid-column: span 2 / span 2;
}
.col-span-4 {
grid-column: span 4 / span 4;
}
</style>
</head>
<body>
<noscript>
<strong
>We're sorry but vue-sequence doesn't work properly without JavaScript
enabled. Please enable it to continue.</strong
>
</noscript>
<div class="m-1 grid grid-cols-6" id="diagram1">
<div class="col-span-2">
<textarea
id="text"
class="col-span-1 m-1 border-2"
cols="30"
rows="200"
></textarea>
</div>
<div class="col-span-4">
<pre class="zenuml" style="margin: 0"></pre>
</div>
</div>
<script type="module">
import { waitUntil, debounce } from "./src/utils.ts";
import { createConfig } from "./src/config.ts";
const editor = CodeMirror.fromTextArea(document.getElementById("text"), {
lineNumbers: true,
singleCursorHeightPerLine: false,
});
const updateDiagram = debounce((content) => {
const config = createConfig({
onContentChange: (code) => editor.setValue(code),
});
window.zenUml.render(content, config).then((r) => {
window.parentLogger
.child({ name: "index.html" })
.debug("render resolved", r);
});
}, 500);
editor.on("change", function (cm) {
waitUntil(
() => window.zenUml,
() => {
updateDiagram(cm.getValue());
// Save to localStorage
localStorage.setItem("zenuml-cm-code", cm.getValue());
},
);
});
// Load saved code from localStorage
const savedCode = localStorage.getItem("zenuml-cm-code");
if (savedCode) {
editor.setValue(savedCode);
}
</script>
<script type="module" src="./src/main.ts"></script>
</body>
</html>