-
Notifications
You must be signed in to change notification settings - Fork 4
/
getting-started.html
51 lines (44 loc) · 2.06 KB
/
getting-started.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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>editron - getting started</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- editron required fonts and styles -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/editron/dist/editron.css" rel="stylesheet" type="text/css" />
<!-- editron required dependency -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mithril/2.0.4/mithril.min.js"></script>
<!-- editron library and main controller, exposed to window.editron -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/editron/dist/editron-modules.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/editron/dist/editron.js"></script>
<!-- optionally add font -->
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,700" rel="stylesheet">
<style type="text/css">
.editron-container {
font-family: "Roboto";
}
</style>
</head>
<body>
<div class="editor" style="max-width: 480px;"></div>
<script type="text/javascript">
window.jsonSchema = {
type: "object",
required: ["title"],
properties: {
title: {
title: "simple-string",
type: "string",
minLength: 1
}
}
};
const Controller = window.editron.Controller;
const controller = new Controller(window.jsonSchema);
controller.createEditor("#", document.querySelector(".editor"));
console.log("data", controller.service("data").get());
// listen to changes in title
controller.service("data").observe("#/title", (event) => console.log(event));
</script>
</body>
</html>