-
Notifications
You must be signed in to change notification settings - Fork 95
/
demo-browser.html
305 lines (267 loc) · 9.04 KB
/
demo-browser.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Playground</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ"
crossorigin="anonymous">
<link href="https://cdn.quilljs.com/1.2.3/quill.snow.css" rel="stylesheet"></link>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" integrity="sha384-wITovz90syo1dJWVh32uuETPVEtGigN07tkttEqPv+uR2SE/mbQcG7ATL28aI9H0" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.js" integrity="sha384-/y1Nn9+QQAipbNQWU65krzJralCnuOasHncUFXGkdwntGeSvQicrYkiUBwsgUqc1" crossorigin="anonymous"></script>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.10.0/styles/default.min.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.10.0/highlight.min.js"></script>
<style>
.ql-viewer p,
.ql-viewer ol,
.ql-viewer ul,
.ql-viewer pre,
.ql-viewer blockquote,
.ql-viewer h1,
.ql-viewer h2,
.ql-viewer h3,
.ql-viewer h4,
.ql-viewer h5,
.ql-viewer h6 {
margin: 0;
padding: 0;
}
.ql-viewer {
padding: 12px 15px;border: 1px solid #c1c1c1;
}
.ql-viewer .ql-font-serif {
font-family: Georgia, Times New Roman, serif;
}
.ql-viewer .ql-font-monospace {
font-family: Monaco, Courier New, monospace;
}
.ql-viewer .ql-size-small {
font-size: 0.75em;
}
.ql-viewer .ql-size-large {
font-size: 1.5em;
}
.ql-viewer .ql-size-huge {
font-size: 2.5em;
}
.ql-viewer .ql-direction-rtl {
direction: rtl;
text-align: inherit;
}
.ql-viewer .ql-align-center {
text-align: center;
}
.ql-viewer .ql-align-justify {
text-align: justify;
}
.ql-viewer .ql-align-right {
text-align: right;
}
.ql-viewer blockquote {
border-left: 4px solid #ccc;
padding-left: 16px;
}
.ql-viewer code,
.ql-viewer pre {
background-color: #f0f0f0;
border-radius: 3px;
padding: 6px 10px;
}
.ql-viewer ul > li[data-checked=true]::before {
content: '\2611';
}
.ql-viewer ul > li[data-checked=false]::before {
content: '\2610';
}
.ql-viewer ol > li,
.ql-viewer ul > li {
list-style-type: none ;
}
.ql-viewer ol {
counter-reset: mylist
}
.ql-viewer ol > li:before {
counter-increment: mylist;
content: counter(mylist, decimal) '. ';
}
.ql-viewer ol ol > li:before {
content: counter(mylist, lower-alpha) '. ';
}
.ql-viewer ol ol ol > li:before {
content: counter(mylist, lower-roman) '. ';
}
.ql-viewer ol ol ol ol > li:before {
content: counter(mylist, decimal) '. ';
}
.ql-viewer ol ol ol ol ol > li:before {
content: counter(mylist, lower-alpha) '. ';
}
.ql-viewer ol ol ol ol ol ol > li:before {
content: counter(mylist, lower-roman) '. ';
}
.ql-viewer ol ol ol ol ol ol ol > li:before {
content: counter(mylist, decimal) '. ';
}
.ql-viewer ol ol ol ol ol ol ol ol > li:before {
content: counter(mylist, lower-alpha) '. ';
}
.ql-viewer ol ol ol ol ol ol ol ol ol > li:before {
content: counter(mylist, lower-roman) '. ';
}
/* ql indent */
.ql-viewer .ql-indent-1:not(.ql-direction-rtl) {
padding-left: 3em;
}
.ql-viewer .ql-indent-1.ql-direction-rtl.ql-align-right {
padding-right: 3em;
}
.ql-viewer .ql-indent-2:not(.ql-direction-rtl) {
padding-left: 6em;
}
.ql-viewer .ql-indent-2.ql-direction-rtl.ql-align-right {
padding-right: 6em;
}
.ql-viewer .ql-indent-3:not(.ql-direction-rtl) {
padding-left: 9em;
}
.ql-viewer .ql-indent-3.ql-direction-rtl.ql-align-right {
padding-right: 9em;
}
.ql-viewer .ql-indent-4:not(.ql-direction-rtl) {
padding-left: 12em;
}
.ql-viewer .ql-indent-4.ql-direction-rtl.ql-align-right {
padding-right: 12em;
}
.ql-viewer .ql-indent-5:not(.ql-direction-rtl) {
padding-left: 15em;
}
.ql-viewer .ql-indent-5.ql-direction-rtl.ql-align-right {
padding-right: 15em;
}
.ql-viewer .ql-indent-6:not(.ql-direction-rtl) {
padding-left: 18em;
}
.ql-viewer .ql-indent-6.ql-direction-rtl.ql-align-right {
padding-right: 18em;
}
.ql-viewer .ql-indent-7:not(.ql-direction-rtl) {
padding-left: 21em;
}
.ql-viewer .ql-indent-7.ql-direction-rtl.ql-align-right {
padding-right: 21em;
}
.ql-viewer .ql-indent-8:not(.ql-direction-rtl) {
padding-left: 24em;
}
.ql-viewer .ql-indent-8.ql-direction-rtl.ql-align-right {
padding-right: 24em;
}
.ql-viewer .ql-indent-9:not(.ql-direction-rtl) {
padding-left: 27em;
}
.ql-viewer .ql-indent-9.ql-direction-rtl.ql-align-right {
padding-right: 27em;
}
/* video */
.ql-viewer .ql-video {
display: block;
max-width: 100%;
}
.ql-viewer .ql-video.ql-align-center {
margin: 0 auto;
}
.ql-viewer .ql-video.ql-align-right {
margin: 0 0 0 auto;
}
</style>
</head>
<body>
<div class="container mt-5">
<div class="row">
<div class="col">
<div id="quill-toolbar"></div>
<div id="quill-editor"></div>
</div>
<div class="col ">
<div class="ql-container aql-snow">
<div id="converted-view" class="ql-viewer"
style="margin-top:69px;border-top:1px solid #cecece;"></div>
</div>
</div>
</div>
<div class="row pt-3">
<div class="col"></div>
<div class="col">
Open developer <code>console</code> to see deltas and generated html.
<br />
You can pass config options for <code>QuillDeltaToHtmlConverter</code>
used here by setting <code>window.opts_ = { /* config object */}</code> to a
configuration object
</div>
</div>
</div>
<script src="dist/browser/QuillDeltaToHtmlConverter.bundle.js"></script>
<script src="https://cdn.quilljs.com/1.2.3/quill.js"></script>
<script>
var toolbarOptions = [
['bold', 'italic', 'underline', 'strike',
{
'script': 'sub'
}, {
'script': 'super'
},
{
'color': []
}, {
'background': []
}, 'code'
],
[{
'font': []
}, {
'size': ['small', false, 'large', 'huge']
}],
['link', 'image', 'video', 'formula'],
['blockquote', 'code-block', {
'header': 1
},
{
'list': 'ordered'
}, {
'list': 'bullet'
}, {
'list': 'check'
}
],
[{
'indent': '-1'
}, {
'indent': '+1'
}, {
'direction': 'rtl'
}, {
'align': []
}],
['clean']
];
var quill = new Quill('#quill-editor', {
theme: 'snow',
placeholder: 'type here...',
formula: true,
syntax: true,
modules: {
toolbar: toolbarOptions
}
});
quill.on('text-change', function (v) {
var delta = quill.getContents();
console.log(delta.ops);
var qdc = new window.QuillDeltaToHtmlConverter(delta.ops, window.opts_ || {});
var html = qdc.convert();
console.log(html);
document.getElementById('converted-view').innerHTML = html;
});
</script>
</body>
</html>