-
Notifications
You must be signed in to change notification settings - Fork 4
/
multiple-editors.html
142 lines (118 loc) · 5.5 KB
/
multiple-editors.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de">
<head>
<title>Editron - Multiple Editors</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,700" rel="stylesheet">
<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" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mithril/2.0.4/mithril.min.js"></script>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
header > h1, #page > h1,
header > h2, #page > h2 {
text-align: center;
font-family: Roboto;
font-weight: 200;
margin: 24px 0;
}
header {
margin-bottom: 48px;
}
.editor {
padding: 48px; /* make space for floating control actions in list-items */
border-radius: 2;
background: #607D8B;
font-family: "Roboto";
}
#page {
width: 720px;
margin: 0 auto;
}
body {
display: flex;
flex-direction: column;
}
</style>
<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>
</head>
<body>
<div id="page">
<header>
<h1>Render editors of the same data on different spots</h1>
<span>
Sure, this is the basic data-binding example, but this is different in that it gives you an easy entry
point to render a form based on a simple string (json-pointer) and additionally modify the behaviour
on creation time. Besides: it does not make any guesses of data changes, it knows...
</span>
</header>
<h2>Application name only <em>#/application</em></h2>
<div id="editor-04" class="editor"></div>
<h2>Editor displaying everything</h2>
<div id="editor-01" class="editor"></div>
<h2>Editor displaying anything at <em>#/list</em></h2>
<div id="editor-02" class="editor"></div>
<h2>Editor displaying anything as a navigation list <em>(This would be an overview if the index-editor would be added)</em></h2>
<div id="editor-03" class="editor"></div>
<script type="text/javascript">
/* global editron */
/* eslint max-len: false */
var Controller = editron.Controller;
var editron = new Controller({
type: "object", properties: {
application: {
title: "application name",
type: "string"
},
list: {
type: "array",
title: "Items",
minItems: 1,
items: {
oneOf: [
{
type: "object",
title: "Title",
"editron:ui": {
attrs: {
"class": "mmf-card"
}
},
properties: {
title: {
type: "string",
format: "html"
}
}
},
{
type: "object",
title: "Any number",
"editron:ui": {
attrs: {
"class": "mmf-card"
}
},
properties: {
value: {
type: "number"
}
}
}
]
}
}
}
}, {});
editron.createEditor("#", document.querySelector("#editor-01"));
editron.createEditor("#/list", document.querySelector("#editor-02"));
editron.createEditor("#", document.querySelector("#editor-03"), { "editron:ui": { index: true } });
editron.createEditor("#/application", document.querySelector("#editor-04"));
</script>
</div>
</body>
</html>