forked from Alex-D/Trumbowyg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
445 lines (399 loc) · 17.4 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
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Trumbowyg by Alex-D</title>
<base href="/test/base/url/">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<style>
html,
body {
margin: 0;
padding: 0;
background-color: #f4f7fa;
font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
}
header {
text-align: center;
}
.container {
max-width: 960px;
margin: 0 auto;
}
.dark-section {
background: #111;
color: #ddd;
margin-top: 50px;
padding: 50px 0 100px;
}
.dark-section .title {
font-weight: normal;
text-align: center;
font-size: 32px;
margin: 20px 0 50px;
}
.form-submit {
background: transparent;
border: 1px solid #555;
color: #ccc;
padding: 7px 13px;
margin-right: 17px;
float: right;
}
h2 {
font-size: 26px;
}
h1 + pre,
h2 + pre,
h3 + pre,
h4 + pre {
margin-top: -20px;
}
</style>
<link rel="stylesheet" href="/dist/ui/trumbowyg.css">
<link rel="stylesheet" href="/dist/plugins/colors/ui/trumbowyg.colors.css">
</head>
<body>
<div class="container">
<header>
<h1>Examples of use Trumbowyg</h1>
<p>
Close an editor on clic on "Close" in top right corner. <br>
To reopen an editor, double-click on his text.
</p>
</header>
<div id="default-editor">
<h2>This editor is the default build of Trumbowyg.</h2>
<p>
Lorem ipsum dolor sit amet, <a href="https://alex-d.github.io/Trumbowyg/">consectetur adipisicing</a> elit. Possimus, aliquam, minima fugiat placeat provident optio nam reiciendis eius beatae quibusdam!
</p>
<p>
The text is derived from Cicero's De Finibus Bonorum et Malorum (On the Ends of Goods and Evils, or alternatively [About] The Purposes of Good and Evil ). The original passage began: Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit (Translation: "Neither is there anyone who loves grief itself since it is grief and thus wants to obtain it").
</p>
<code><pre>
$('#default-editor').trumbowyg();
</pre></code>
</div>
<div id="simple-editor">
<h2>This is a minimalist demo of Trumbowyg.</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus, aliquam, minima fugiat placeat provident optio nam reiciendis eius beatae quibusdam!
</p>
<code><pre>
$('#simple-editor').trumbowyg({
btns: ['strong', 'em', 'del']
});
</pre></code>
</div>
<div id="upload-editor">
<h2>This is a minimalist demo of Trumbowyg with upload image plugin.</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus, aliquam, minima fugiat placeat provident optio nam reiciendis eius beatae quibusdam!
</p>
<code><pre>
$('#simple-editor').trumbowyg({
btns: ['strong', 'em', 'del', 'upload'],
btnsDef: {
upload: {
ico: 'insertImage'
}
}
});
</pre></code>
</div>
<div id="flat-buttonpane">
<h2>All buttons of Trumbowyg are here.</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus, aliquam, minima fugiat placeat provident optio nam reiciendis eius beatae quibusdam!
</p>
</div>
<div id="customized-buttonpane">
<h2>This is a demo of Trumbowyg with a customized button pane</h2>
<p>
The text is derived from Cicero's De Finibus Bonorum et Malorum (On the Ends of Goods and Evils, or alternatively [About] The Purposes of Good and Evil ). The original passage began: Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit (Translation: "Neither is there anyone who loves grief itself since it is grief and thus wants to obtain it").
</p>
<p style="text-align: center;">
<img src="https://raw.githubusercontent.com/Alex-D/Trumbowyg/develop/banner.jpg" alt="Trumbowyg logo">
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dignissimos, minima, asperiores libero architecto sequi fugit dolore sunt in officiis facere ut quaerat ullam laudantium delectus aliquam tenetur alias! Ea, nisi, est earum temporibus dolores quas qui repellendus aliquid voluptatibus tempore facilis eligendi omnis reiciendis nihil ullam quo dolorem nam deleniti. Fugit dignissimos dolorum dolore voluptate repudiandae recusandae debitis. Neque, adipisci, maiores magni aliquam molestiae ex natus minus quod tempora nemo debitis eum laboriosam voluptatum ut architecto animi nobis vero quis dolore eaque! Corporis, dolore, illum, autem in eum ea doloribus ut consequuntur modi et ullam adipisci blanditiis corrupti ab voluptate.
</p>
<p>
It is not known exactly when the text acquired its current standard form; it may have been as late as the 1960s. The passage was discovered by Richard McClintock, a Latin scholar who is the publications director at Hampden-Sydney College in Virginia, by searching for citings of the rarely used word 'consectetur' in classical literature.
</p>
<code><pre>
/* Add new words for customs btnsDef just below */
$.extend(true, $.trumbowyg.langs, {
fr: {
align: 'Alignement',
image: 'Image'
}
});
$('#customized-buttonpane').trumbowyg({
lang: 'fr',
fixedBtnPane: true,
semantic: false,
btnsDef: {
// Customizables dropdowns
align: {
dropdown: ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
ico: 'justifyLeft'
},
image: {
dropdown: ['insertImage', 'upload', 'base64'],
ico: 'insertImage'
}
},
btns: ['viewHTML',
['formatting'],
['align'],
['image'],
['preformatted'],
'fullscreen', 'close']
});
</pre></code>
</div>
<textarea id="form-content" cols="30" rows="10" required>
<h1>This editor is create from a textarea</h1>
<p>
Even though using "lorem ipsum" often arouses curiosity due to its resemblance to classical Latin, it is not intended to have meaning. Where text is visible in a document, people tend to focus on the textual content rather than upon overall presentation, so publishers use lorem ipsum when displaying a typeface or design in order to direct the focus to presentation. "Lorem ipsum" also approximates a typical distribution of spaces in English. <br>
The most common lorem ipsum text reads as follows: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<code><pre>
$('#form-content').trumbowyg({
lang: 'fr',
mobile: true,
fixedBtnPane: true,
fixedFullWidth: true,
semantic: true,
resetCss: true,
autoAjustHeight: true,
autogrow: true
});
</pre></code>
</textarea>
<textarea id="empty-textarea" cols="30" rows="10" required></textarea>
<textarea id="disabled-textarea" cols="30" rows="10" disabled>
Disabled textarea
</textarea>
<button id="enable-disabled-textarea">Enable</button>
<button id="disable-disabled-textarea">Disable</button>
<div id="dynamic-iframe-example"></div>
</div>
<div class="dark-section">
<div class="container">
<form action="#">
<h2 class="title">The dark side of Trumbowyg</h2>
<div class="trumbowyg-dark">
<textarea id="placeholder-editor" cols="30" rows="10" placeholder="This is a placeholder..." required></textarea>
</div>
<button type="submit" class="form-submit">Submit</button>
</form>
</div>
</div>
<script src="/node_modules/jquery/dist/jquery.min.js"></script>
<script src="/dist/trumbowyg.js"></script>
<script src="/dist/langs/fr.min.js"></script>
<script src="/dist/plugins/base64/trumbowyg.base64.js"></script>
<script src="/dist/plugins/colors/trumbowyg.colors.js"></script>
<script src="/dist/plugins/noembed/trumbowyg.noembed.js"></script>
<script src="/dist/plugins/pasteimage/trumbowyg.pasteimage.js"></script>
<script src="/dist/plugins/template/trumbowyg.template.js"></script>
<script src="/dist/plugins/preformatted/trumbowyg.preformatted.js"></script>
<script src="/dist/plugins/ruby/trumbowyg.ruby.js"></script>
<script src="/dist/plugins/upload/trumbowyg.upload.js"></script>
<script>
/** Default editor configuration **/
$('#default-editor, #empty-textarea, #disabled-textarea')
.trumbowyg()
.on('tbwinit tbwfocus tbwblur tbwchange tbwresize tbwpaste tbwopenfullscreen tbwclosefullscreen tbwclose', function(e){
console.log(e.type);
});
$('#enable-disabled-textarea').click(function () {
$('#disabled-textarea').trumbowyg('enable');
});
$('#disable-disabled-textarea').click(function () {
$('#disabled-textarea').trumbowyg('disable');
});
/** Minimal configuration **/
$('#simple-editor')
.trumbowyg({
btns: ['strong', 'em', 'del']
});
/** Minimal with upload **/
$('#upload-editor')
.trumbowyg({
btns: ['strong', 'em', 'del', 'upload'],
btnsDef: {
upload: {
ico: 'insertImage',
title: 'insertImage'
}
}
});
/* Add imagur parameters to upload plugin */
var uploadOptions = {
serverPath: 'https://api.imgur.com/3/image',
fileFieldName: 'image',
headers: {'Authorization': 'Client-ID 9e57cb1c4791cea'},
urlPropertyName: 'data.link',
imageWidthModalEdit: true
};
/** Full flat button pane **/
$('#flat-buttonpane')
.trumbowyg({
btns: [
['viewHTML'],
['p', 'blockquote', 'h1', 'h2', 'h3', 'h4'],
['strong', 'em', 'underline', 'del'],
['superscript', 'subscript'],
['createLink', 'unlink'],
['insertImage'],
['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
['unorderedList', 'orderedList'],
['horizontalRule'],
['removeformat'],
['upload', 'base64', 'noembed'],
['ruby'],
['foreColor', 'backColor'],
['preformatted'],
['template'],
['fullscreen', 'close']
],
plugins: {
upload: uploadOptions,
templates: [
{
name: 'Template 1',
html: '<p>I am a template!</p>'
},
{
name: 'Template 2',
html: '<p>I am a different template!</p>'
}
]
}
});
/********************************************************
* Customized button pane + buttons groups + dropdowns
* Use upload and base64 plugins
*******************************************************/
/* Add new words for customs btnsDef just below */
$.extend(true, $.trumbowyg.langs, {
fr: {
align: 'Alignement',
image: 'Image'
}
});
var customizedButtonPaneTbwOptions = {
lang: 'fr',
fixedBtnPane: true,
semantic: false,
btnsDef: {
// Customizable dropdowns
align: {
dropdown: ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
ico: 'justifyLeft'
},
image: {
dropdown: ['insertImage', 'upload', 'base64', 'noembed'],
ico: 'insertImage'
}
},
btns: [
['viewHTML'],
['formatting'],
['bold', 'italic', 'strikethrough'],
['link'],
['align'],
['image'],
['foreColor', 'backColor'],
['preformatted'],
['fullscreen', 'close']
],
changeActiveDropdownIcon: true,
minimalLinks: true,
defaultLinkTarget: '_blank',
plugins: {
upload: uploadOptions
}
};
$('#customized-buttonpane')
.trumbowyg(customizedButtonPaneTbwOptions)
.on('dblclick', function(){
$(this).trumbowyg(customizedButtonPaneTbwOptions);
});
/** Simple customization with current options **/
var formTbwOptions = {
lang: 'fr',
mobile: true,
fixedBtnPane: true,
fixedFullWidth: true,
semantic: true,
resetCss: true,
removeformatPasted: true,
tagsToRemove: ['script', 'style'],
imageWidthModalEdit: true,
autogrow: true,
autogrowOnEnter: true,
btnsDef: {
strong: {
fn: 'bold',
key: 'G'
}
}
};
$('#form-content')
.trumbowyg(formTbwOptions)
.on('dblclick', function(){
$(this).trumbowyg(formTbwOptions);
});
/** Dynamic Iframe **/
// Create the iframe element.
var $iframe = $('<iframe/>').css({
width: '100%',
height: 400,
border: 0
});
$('#dynamic-iframe-example').append($iframe);
// Get the document of the iframe.
var $editor = $('<div>', {
id: 'editor'
}).html(
'<h2>This is within an iframe</h2> <p>Soc'
+ 'tempor pulvinar ac ultricies, placerat in, elementum,'
+ 'adipiscing pid, mid augue pulvinar eros nisi! In magn'
+ 'magnis. Porttitor platea turpis nisi. Pulvinar massa,'
+ ' habitasse <strong>a nunc rhoncus adipiscing</strong></p>');
setTimeout(function(){
var contextIframe = $iframe.contents()[0];
// Set the style on the head of the iframe.
$('head', contextIframe).append($('<link>', {
href: '/dist/ui/trumbowyg.css',
rel: 'stylesheet'
}));
// Set the content to be editable.
$('body', contextIframe).append($editor);
$editor
.trumbowyg()
.on('dblclick', function(){
$(this).trumbowyg();
});
}, 500);
/** Editor with placeholder **/
$('#placeholder-editor')
.trumbowyg({
autogrowOnEnter: true,
})
.on('dblclick', function(){
$(this).trumbowyg();
})
.on('tbwfocus', function(){
console.log('focus event fired');
})
.on('tbwblur', function(){
console.log('blur event fired');
});
</script>
</body>
</html>