-
-
Notifications
You must be signed in to change notification settings - Fork 614
/
index.html
1812 lines (1656 loc) · 70.1 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
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Plugins | Trumbowyg: A lightweight WYSIWYG editor | Alex-D / Alexandre Demode</title>
<meta name="description" content="Trumbowyg is a jQuery plugin for create WYSIWYG editor">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="../../favicon.png">
<link rel="stylesheet" href="../../css/main.css">
</head>
<body class="documentation-body">
<svg xmlns="http://www.w3.org/2000/svg" style="overflow: hidden;visibility: hidden;height: 0;width: 0;">
<symbol id="trumbowyg-link" viewBox="0 0 72 72">
<path d="M30.9 49.1l-6.7 6.7c-.8.8-1.6.9-2.1.9s-1.4-.1-2.1-.9l-5.2-5.2c-1.1-1.1-1.1-3.1 0-4.2l6.1-6.1.2-.2 6.5-6.5c-1.2-.6-2.5-.9-3.8-.9-2.3 0-4.6.9-6.3 2.6L10.8 42c-3.5 3.5-3.5 9.2 0 12.7l5.2 5.2c1.7 1.7 4 2.6 6.3 2.6s4.6-.9 6.3-2.6l6.7-6.7C38 50.5 38.6 46.3 37 43l-6.1 6.1zM38.5 22.7l6.7-6.7c.8-.8 1.6-.9 2.1-.9s1.4.1 2.1.9l5.2 5.2c1.1 1.1 1.1 3.1 0 4.2l-6.1 6.1-.2.2-6.5 6.5c1.2.6 2.5.9 3.8.9 2.3 0 4.6-.9 6.3-2.6l6.7-6.7c3.5-3.5 3.5-9.2 0-12.7l-5.2-5.2c-1.7-1.7-4-2.6-6.3-2.6s-4.6.9-6.3 2.6l-6.7 6.7c-2.7 2.7-3.3 6.9-1.7 10.2l6.1-6.1z"></path>
<path d="M44.1 30.7c.2-.2.4-.6.4-.9 0-.3-.1-.6-.4-.9l-2.3-2.3c-.2-.2-.6-.4-.9-.4-.3 0-.6.1-.9.4L25.8 40.8c-.2.2-.4.6-.4.9 0 .3.1.6.4.9l2.3 2.3c.2.2.6.4.9.4.3 0 .6-.1.9-.4l14.2-14.2z"></path>
</symbol>
</svg>
<div class="sidebar">
<div class="sidebar-inner">
<header class="header-documentation">
<a href="../../" class="documentation-logo-link">
<img src="../../img/logo-doc.svg" alt="" class="documentation-logo">
</a>
<h1 class="documentation-title">
Plugins
</h1>
<nav class="documentation-menu">
<a href="../">Docs</a><span class="documentation-menu-dot"> •</span>
<a href="./">Plugins</a><span class="documentation-menu-dot"> •</span>
<a href="../core/">Core</a><span class="documentation-menu-dot"> •</span>
<a href="../../demos/">Demos</a>
</nav>
</header>
<aside class="documentation-summary">
<ul>
<li>
<a href="#existing-plugins">Existing plugins</a>
<ul>
<li><a href="#plugin-allowtagsfrompaste">Allow tags from paste</a></li>
<li><a href="#plugin-base64">Base 64</a></li>
<li><a href="#plugin-cleanpaste">Clean paste</a></li>
<li><a href="#plugin-colors">Colors</a></li>
<li><a href="#plugin-emoji">Emoji</a></li>
<li><a href="#plugin-fontfamily">Font family</a></li>
<li><a href="#plugin-fontsize">Font size</a></li>
<li><a href="#plugin-giphy">Giphy</a></li>
<li><a href="#plugin-highlight">Highlight</a></li>
<li><a href="#plugin-history">History</a></li>
<li><a href="#plugin-indent">Indent</a></li>
<li><a href="#plugin-insertaudio">Insert audio</a></li>
<li><a href="#plugin-lineheight">Line height</a></li>
<li><a href="#plugin-mathml">MathML</a></li>
<li><a href="#plugin-mention">Mention</a></li>
<li><a href="#plugin-noembed">Noembed</a></li>
<li><a href="#plugin-pasteembed">Paste embed</a></li>
<li><a href="#plugin-pasteimage">Paste image</a></li>
<li><a href="#plugin-preformatted">Preformatted</a></li>
<li><a href="#plugin-resizimg">Resizimg</a></li>
<li><a href="#plugin-ruby">Ruby</a></li>
<li><a href="#plugin-specialchars">Special Chars</a></li>
<li><a href="#plugin-table">Table</a></li>
<li><a href="#plugin-template">Template</a></li>
<li><a href="#plugin-upload">Upload</a></li>
</ul>
</li>
<li>
<a href="#create-your-own">Create your own</a>
<ul>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#skeleton">Skeleton</a></li>
<li><a href="#interact-with-content">Interact with content</a></li>
</ul>
</li>
</ul>
</aside>
<div class="documentation-sidebar-beer">
<a href="../../#donate">
<img src="../../img/beer.svg" alt="" class="beer-icon">
<span class="beer-label">
Do you enjoy Trumbowyg? <br>
Buy me some beers :)
</span>
</a>
</div>
</div>
</div>
<main class="main">
<section id="existing-plugins" class="wrapper section">
<h2 class="section-title">Existing plugins</h2>
<p>
If you want to add a plugin, be sure to read the
<a href="../#use-plugins">use plugins section of documentation</a> before continue.
</p>
<div class="feature">
<h3 id="plugin-allowtagsfrompaste">Allow tags from paste</h3>
<p>
Allow tags from paste plugin allows you to filter tags allowed when an user paste some code into the editor.
</p>
<p>
<a href="../../demos/#plugins-allowtagsfrompaste" class="button button-demo">Try allow tags from paste live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/allowtagsfrompaste/trumbowyg.allowtagsfrompaste.js" class="button button-demo">
View allow tags from paste plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg plugins... -->
<script src="trumbowyg/dist/plugins/allowtagsfrompaste/trumbowyg.allowtagsfrompaste.min.js"></script>
</code></pre>
<p>
Then you can configure your custom tag whitelist. Any tag pasted which is not in
<code>allowedTags</code> list will be unwrap, only the text will be kept.
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
plugins: {
allowTagsFromPaste: {
allowedTags: ['h4', 'p', 'br']
}
}
});
</code></pre>
<p class="note">
Enabling this plugin will force disable the <code>removeformatPasted</code> core option (set it to <code>false</code>).
</p>
</div>
<div class="feature">
<h3 id="plugin-base64">Base 64</h3>
<p>
Base 64 plugin allows you to insert images inline as base64.
</p>
<p>
<a href="../../demos/#plugins-base64" class="button button-demo">Try base64 live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/base64/trumbowyg.base64.js" class="button button-demo">
View base64 plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg plugins... -->
<script src="trumbowyg/dist/plugins/base64/trumbowyg.base64.min.js"></script>
</code></pre>
<p>
Then you can use the new button definition <code>base64</code>
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['base64']
]
});
</code></pre>
</div>
<div class="feature">
<h3 id="plugin-cleanpaste">Clean paste</h3>
<p>
Clean paste plugin handle paste events, clean the HTML code before insert content into the editor.
</p>
<p>
<a href="../../demos/#plugins-cleanpaste" class="button button-demo">Try cleanpaste live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/cleanpaste/trumbowyg.cleanpaste.js" class="button button-demo">
View cleanpaste plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg plugins... -->
<script src="trumbowyg/dist/plugins/cleanpaste/trumbowyg.cleanpaste.min.js"></script>
</code></pre>
<p>
Clean paste works now on every new Trumbowyg instance.
</p>
</div>
<div class="feature">
<h3 id="plugin-colors">Colors</h3>
<p>
Colors plugin allows you to change foreground and background color of your text.
</p>
<p>
<a href="../../demos/#plugins-colors" class="button button-demo">Try colors live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/colors/trumbowyg.colors.js" class="button button-demo">
View colors plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg colors style in <head>... -->
<link rel="stylesheet" href="trumbowyg/dist/plugins/colors/ui/trumbowyg.colors.min.css">
</code></pre>
<pre><code class="html">
<!-- Import Trumbowyg colors JS at the end of <body>... -->
<script src="trumbowyg/dist/plugins/colors/trumbowyg.colors.min.js"></script>
</code></pre>
<p>
Then you can use the new button definitions <code>foreColor</code> and <code>backColor</code>
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['foreColor', 'backColor']
]
});
</code></pre>
<h4>Options</h4>
<dl>
<dt><strong><code>colorList</code></strong> <code class="type">array<string></code></dt>
<dd>
List of colors available for both <code>foreColor</code> and <code>backColor</code> dropdowns.
<br>
<strong>Default</strong>:
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/colors/trumbowyg.colors.js">check the code</a>
or
<a href="../../demos/#plugins-colors">the demo</a>
</dd>
<dt><strong><code>foreColorList</code></strong> <code class="type">array<string></code></dt>
<dd>
List of colors available used in the <code>foreColor</code> dropdown instead of <code>colorList</code>'s one.
<br>
<strong>Default</strong>: fallbacks on <code>colorList</code>
</dd>
<dt><strong><code>allowCustomForeColor</code></strong> <code class="type">boolean</code></dt>
<dd>
Allow user to pick a color outside the list.
<br>
<strong>Default</strong>: <code>true</code>
</dd>
<dt><strong><code>backColorList</code></strong> <code class="type">array<string></code></dt>
<dd>
List of colors available used in the <code>backColor</code> dropdown instead of <code>colorList</code>'s one.
<br>
<strong>Default</strong>: fallbacks on <code>colorList</code>
</dd>
<dt><strong><code>allowCustomBackColor</code></strong> <code class="type">boolean</code></dt>
<dd>
Allow user to pick a color outside the list.
<br>
<strong>Default</strong>: <code>true</code>
</dd>
<dt><strong><code>displayAsList</code></strong> <code class="type">boolean</code></dt>
<dd>
Switch from square to labelled list view. Default view is the square's one.
<br>
<strong>Default</strong>: <code>false</code>
</dd>
</dl>
<p>
Example with <code>colorList</code> parameter:
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['foreColor', 'backColor']
],
plugins: {
colors: {
colorList: [
'000', '111', '222', 'ffea00'
]
}
}
});
</code></pre>
<p>
Example with both <code>foreColorList</code> and <code>backColorList</code>, displayed as list:
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['foreColor', 'backColor']
],
plugins: {
colors: {
foreColorList: [
'ff0000', '00ff00', '0000ff'
],
backColorList: [
'000', '333', '555'
],
displayAsList: true
}
}
});
</code></pre>
<p class="note">
If both <code>foreColorList</code> and <code>backColorList</code> are set, <code>colorList</code> will be not used at all.
</p>
</div>
<div class="feature">
<h3 id="plugin-emoji">Emoji</h3>
<p>
Emoji plugin allows you to insert some emojis in your editor.
</p>
<p>
<a href="../../demos/#plugins-emoji" class="button button-demo">Try emoji live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/emoji/trumbowyg.emoji.js" class="button button-demo">
View emoji plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg emoji style in <head>... -->
<link rel="stylesheet" href="trumbowyg/dist/plugins/emoji/ui/trumbowyg.emoji.min.css">
</code></pre>
<pre><code class="html">
<!-- Import Trumbowyg emoji at the end of <body>... -->
<script src="trumbowyg/dist/plugins/emoji/trumbowyg.emoji.min.js"></script>
</code></pre>
<p>
Then you can use the new button definition <code>emoji</code>
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['emoji']
]
});
</code></pre>
</div>
<div class="feature">
<h3 id="plugin-fontfamily">Font family</h3>
<p>
This plugin allows user to custom font family.
</p>
<p>
<a href="../../demos/#plugins-fontfamily" class="button button-demo">Try font family live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/fontfamily/trumbowyg.fontfamily.js" class="button button-demo">
View font family plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg fontfamily JS at the end of <body>... -->
<script src="trumbowyg/dist/plugins/fontfamily/trumbowyg.fontfamily.min.js"></script>
</code></pre>
<p>
Then you can use the new button definition <code>fontfamily</code>
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['fontfamily']
]
});
</code></pre>
<p>
You can also choose custom font list:
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['fontfamily']
],
plugins: {
fontfamily: {
fontList: [
{name: 'Arial', family: 'Arial, Helvetica, sans-serif'},
{name: 'Open Sans', family: '\'Open Sans\', sans-serif'}
]
}
}
});
</code></pre>
</div>
<div class="feature">
<h3 id="plugin-fontsize">Font size</h3>
<p>
This plugin allows user to custom font size.
</p>
<p>
<a href="../../demos/#plugins-fontsize" class="button button-demo">Try font size live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/fontsize/trumbowyg.fontsize.js" class="button button-demo">
View font size plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg font size JS at the end of <body>... -->
<script src="trumbowyg/dist/plugins/fontsize/trumbowyg.fontsize.min.js"></script>
</code></pre>
<p>
Then you can use the new button definition <code>fontsize</code>
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['fontsize']
]
});
</code></pre>
<p>
You can also choose custom size list:
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['fontsize']
],
plugins: {
fontsize: {
sizeList: [
'12px',
'14px',
'16px'
]
}
}
});
</code></pre>
<p>
If you want to disable the custom font size option, use the <code>allowCustomSize</code> option:
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['fontsize']
],
plugins: {
fontsize: {
allowCustomSize: false
}
}
});
</code></pre>
<p class="note">
Default <code>allowCustomSize</code> value is <code>true</code>.
</p>
</div>
<div class="feature">
<h3 id="plugin-giphy">Giphy</h3>
<p>
User can search and pick gif to insert from Giphy
</p>
<p>
<a href="../../demos/#plugins-giphy" class="button button-demo">Try Giphy plugin live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/giphy/trumbowyg.giphy.js" class="button button-demo">
View Giphy plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg Giphy style in <head>... -->
<link rel="stylesheet" href="trumbowyg/dist/plugins/giphy/ui/trumbowyg.giphy.min.css">
</code></pre>
<pre><code class="html">
<!-- Import Trumbowyg Giphy JS at the end of <body>... -->
<script src="trumbowyg/dist/plugins/giphy/trumbowyg.giphy.min.js"></script>
</code></pre>
<p>
Then, you need to <a href="https://developers.giphy.com/dashboard/?create=true">create a Giphy App to get an API Key</a>.
</p>
<p>
Use the new button definition <code>giphy</code> and your newly created Giphy API Key:
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['giphy']
],
plugins: {
giphy: {
apiKey: 'yourVeryOwnApiKey'
}
}
});
</code></pre>
<h4>Options</h4>
<dl>
<dt><strong><code>apiKey</code></strong> <code class="type">string</code> <strong>(required)</strong></dt>
<dd>
Giphy API Key of your application.
<a href="https://developers.giphy.com/dashboard/?create=true">Create a Giphy App to get an API Key</a>.
</dd>
<dt><strong><code>rating</code></strong> <code class="type">string</code></dt>
<dd>
Giphy image rating filter.
<a href="https://developers.giphy.com/docs/optional-settings/#rating">See Giphy documentation for allowed rating value details</a>.
<br>
<strong>Default</strong>: <code>g</code>
</dd>
<dt><strong><code>throttleDelay</code></strong> <code class="type">number</code> (in milliseconds)</dt>
<dd>
It's the delay between each Giphy API requests while user is typing his query.
<br>
<strong>Default</strong>: <code>300</code>
</dd>
<dt><strong><code>noResultGifUrl</code></strong> <code class="type">string</code></dt>
<dd>
The image URL shown when there is no result.
<br>
<strong>Default</strong>: <a href="https://media.giphy.com/media/2Faz9FbRzmwxY0pZS/giphy.gif" rel="noreferrer noopener"><code>https://media.giphy.com/media/2Faz9FbRzmwxY0pZS/giphy.gif</code></a>
</dd>
</dl>
<p>
Example with options:
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['giphy']
],
plugins: {
giphy: {
apiKey: 'yourVeryOwnApiKey',
rating: 'pg',
throttleDelay: 500,
noResultGifUrl: 'http://example.com/yourimage.gif'
}
}
});
</code></pre>
</div>
<div class="feature">
<h3 id="plugin-highlight">Code Highlight</h3>
<p>
This plugin allows user to add code highlight parts.
</p>
<p>
<a href="../../demos/#plugins-highlight" class="button button-demo">Try highlight plugin live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/highlight/trumbowyg.highlight.js" class="button button-demo">
View highlight plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<p>
This plugin require <strong>Prism</strong> which can be installed with:
<code>npm install prismjs</code>
</p>
<pre><code class="html">
<!-- Import prismjs style in <head>... -->
<link rel="stylesheet" href="node_modules/prismjs/themes/prism.css">
<!-- Import highlight plugin style in <head>... -->
<link rel="stylesheet" href="trumbowyg/dist/plugins/highlight/ui/trumbowyg.highlight.min.css">
<!-- Import prismjs and Trumbowyg highlight at the end of <body>... -->
<script src="node_modules/prismjs/prism.js"></script>
<script src="trumbowyg/dist/plugins/highlight/trumbowyg.highlight.min.js"></script>
</code></pre>
<p>
You also can add another prism language syntaxes for example:
</p>
<pre><code class="html">
<!-- Import prismjs and Trumbowyg highlight at the end of <body>... -->
<script src="node_modules/prismjs/prism.js"></script>
<script src="node_modules/prismjs/components/prism-csharp.js"></script>
<script src="node_modules/prismjs/components/prism-go.js"></script>
<script src="node_modules/prismjs/components/prism-markdown.js"></script>
<script src="trumbowyg/dist/plugins/highlight/trumbowyg.highlight.min.js"></script>
</code></pre>
<p>
Also on your website you must connect prismjs styles to lighting code worked. For example connect prism.css in head:
</p>
<pre><code class="html">
<!-- Import prismjs style in <head>... on your site -->
<link rel="stylesheet" href="node_modules/prismjs/themes/prism.css">
</code></pre>
<h4>Options</h4>
<dl>
<dt><strong><code>enableLineHighlight</code></strong> <code class="type">boolean</code></dt>
<dd>
Add a field to highlight some lines if enabled. <br>
You need to import the
<a href="https://prismjs.com/plugins/line-highlight/">Prism Line Highlight plugin</a> JS + CSS.
<br>
<strong>Default</strong>: <code>true</code>
</dd>
<dt><strong><code>languageNames</code></strong> <code class="type">Object<string, string></code></dt>
<dd>
Pairs with language code as key and language name as value.
<br>
<strong>Default</strong>:
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/highlight/trumbowyg.highlight.js">
List of all languages available in Prism
</a>
</dd>
</dl>
</div>
<div class="feature">
<h3 id="plugin-history">History</h3>
<p>
History plugin is an enhanced implementation of the undo and redo functionality.
It tracks changes of the editor and will add each change to a history stack.
If a word is typed in or text was pasted, it counts as a single stack entry.
</p>
<p>
<a href="../../demos/#plugins-history" class="button button-demo">Try history plugin live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/history/trumbowyg.history.js" class="button button-demo">
View history plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg history JS at the end of <body>... -->
<script src="trumbowyg/dist/plugins/history/trumbowyg.history.min.js"></script>
</code></pre>
<p>
Then you can use the new button definitions <code>historyUndo</code> and <code>historyRedo</code>
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['historyUndo', 'historyRedo']
]
});
</code></pre>
</div>
<div class="feature">
<h3 id="plugin-indent">Indent</h3>
<p>
This plugin allows you to indent or outdent your text.
</p>
<p>
<a href="../../demos/#plugins-indent" class="button button-demo">Try indent live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/indent/trumbowyg.indent.js" class="button button-demo">
View indent plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg indent at the end of <body>... -->
<script src="trumbowyg/dist/plugins/indent/trumbowyg.indent.min.js"></script>
</code></pre>
<p>
Then you can use the news buttons definition <code>indent</code> or <code>outdent</code>
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['indent', 'outdent']
]
});
</code></pre>
</div>
<div class="feature">
<h3 id="plugin-insertaudio">Insert audio</h3>
<p>
Do the same as insert image, but for audio.
</p>
<p>
<a href="../../demos/#plugins-insertaudio" class="button button-demo">Try insert audio live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/insertaudio/trumbowyg.insertaudio.js" class="button button-demo">
View insertAudio plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg insertAudio at the end of <body>... -->
<script src="trumbowyg/dist/plugins/insertaudio/trumbowyg.insertaudio.min.js"></script>
</code></pre>
<p>
Then you can use the new button definition <code>insertAudio</code>
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['insertAudio']
]
});
</code></pre>
</div>
<div class="feature">
<h3 id="plugin-lineheight">Line height</h3>
<p>
This plugin allows user to custom line height.
</p>
<p>
<a href="../../demos/#plugins-lineheight" class="button button-demo">Try line height live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/lineheight/trumbowyg.lineheight.js" class="button button-demo">
View line height plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg lineheight at the end of <body>... -->
<script src="trumbowyg/dist/plugins/lineheight/trumbowyg.lineheight.min.js"></script>
</code></pre>
<p>
Then you can use the new button definition <code>lineheight</code>
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['lineheight']
]
});
</code></pre>
<p>
You can also choose custom size list:
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['lineheight']
],
plugins: {
fontsize: {
sizeList: [
'12px',
'14px',
'16px'
]
}
}
});
</code></pre>
</div>
<div class="feature">
<h3 id="plugin-mathml">MathML</h3>
<p>
This plugin allows user to use MathML.
</p>
<p>
<a href="../../demos/#plugins-mathml" class="button button-demo">Try MathML live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/mathml/trumbowyg.mathml.js" class="button button-demo">
View MathML plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg MathML style in <head>... -->
<link rel="stylesheet" href="trumbowyg/dist/plugins/mathml/ui/trumbowyg.mathml.min.css">
</code></pre>
<pre><code class="html">
<!-- Import Trumbowyg MathJax at the end of <body>... -->
<script src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<!-- Import Trumbowyg MathML plugin at the end of <body>... -->
<script src="trumbowyg/dist/plugins/mathml/trumbowyg.mathml.min.js"></script>
</code></pre>
<p>
Then you can use the new button definition <code>mathml</code>
</p>
<pre><code class="javascript">
// MathJax inline configuration
MathJax.Hub.Config({
tex2jax: {
inlineMath: [
['$', '$'],
['\\(', '\\)']
]
}
});
// Trumbowyg initialization with MathML button
$('#editor')
.trumbowyg({
btns: [
'mathml'
]
});
</code></pre>
</div>
<div class="feature">
<h3 id="plugin-mention">Mention</h3>
<p>
This plugin allows to mention an user from a source list.
</p>
<p>
<a href="../../demos/#plugins-mention" class="button button-demo">Try mention live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/mention/trumbowyg.mention.js" class="button button-demo">
View mention plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg plugins... -->
<script src="trumbowyg/dist/plugins/mention/trumbowyg.mention.min.js"></script>
</code></pre>
<p>
Then you can use the new button definition <code>mention</code>
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['mention']
],
plugins: {
mention: {
source: [
{login: 'lucy'},
{login: 'jdoe'},
{login: 'mlisa'},
{login: 'jcesar'},
]
}
}
});
</code></pre>
<h4>Options</h4>
<dl>
<dt><strong><code>source</code></strong> <code class="type">array<object></code></dt>
<dd>
List of mentionable users.
Must contains <code>login</code> key if you do not override two other options.
<br>
<strong>Default</strong>: <code>[]</code>
</dd>
<dt><strong><code>formatDropdownItem</code></strong> <code class="type">function</code></dt>
<dd>
Custom format items in mention dropdown: <code>function (item) {}</code>. Must return a string.
<br>
<strong>Default output</strong>: <code>item.login</code>
</dd>
<dt><strong><code>formatResult</code></strong> <code class="type">function</code></dt>
<dd>
The string which will be inserted in editor: <code>function (item) {}</code>. Must return a string.
<br>
<strong>Default output</strong>: <code>'@' + item.login + ' '</code>
</dd>
</dl>
<p>
Example with options:
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['mention']
],
plugins: {
mention: {
source: [
{login: 'lucy', name: 'Lucy'},
{login: 'jdoe', name: 'John Doe'},
{login: 'mlisa', name: 'Mona Lisa'},
{login: 'jcesar', name: 'Julius Cesarius'},
],
formatDropdownItem: function (item) {
return item.name + ' (' + item.login + ')';
},
formatResult: function (item) {
return '@"' + item.name + '" ';
}
}
}
});
</code></pre>
</div>
<div class="feature">
<h3 id="plugin-noembed">Noembed</h3>
<p>
Allows you to embed any content from a link using <a href="https://noembed.com/">noembed.com</a> API.
</p>
<p>
<a href="../../demos/#plugins-noembed" class="button button-demo">Try noembed live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/noembed/trumbowyg.noembed.js" class="button button-demo">
View noembed plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg plugins... -->
<script src="trumbowyg/dist/plugins/noembed/trumbowyg.noembed.min.js"></script>
</code></pre>
<p>
Then you can use the new button definition <code>noembed</code>
</p>
<pre><code class="javascript">
$('#my-editor').trumbowyg({
btns: [
['noembed']
]
});
</code></pre>
</div>
<div class="feature">
<h3 id="plugin-pasteembed">Paste embed</h3>
<p>
Paste embed plugin handles paste events. It looks for paste event, checks if it's a URL and uses noembed.com API to retrieve an iframe from that URL. If it can't retrieve an iframe, it will put an anchor tag around the URL. It doesn't do anything on text or HTML paste.
</p>
<p>
<a href="../../demos/#plugins-pasteembed" class="button button-demo">Try paste embed live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/pasteembed/trumbowyg.pasteembed.js" class="button button-demo">
View pasteembed plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg plugins... -->
<script src="trumbowyg/dist/plugins/pasteembed/trumbowyg.pasteembed.min.js"></script>
</code></pre>
<p>
Paste embed now works on every new Trumbowyg instance.
</p>
</div>
<div class="feature">
<h3 id="plugin-pasteimage">Paste image</h3>
<p>
Paste image plugin handle paste events, check if you have image files in your clipboard, then paste them
into the editor as base64. It do nothing on text or HTML paste.
</p>
<p>
<a href="../../demos/#plugins-pasteimage" class="button button-demo">Try paste image live demo!</a>
<a href="https://github.com/Alex-D/Trumbowyg/tree/develop/plugins/pasteimage/trumbowyg.pasteimage.js" class="button button-demo">
View paste image plugin code on GitHub
</a>
</p>
<h4>How to use it?</h4>
<pre><code class="html">
<!-- Import Trumbowyg plugins... -->
<script src="trumbowyg/dist/plugins/pasteimage/trumbowyg.pasteimage.min.js"></script>
</code></pre>
<p>
Paste image works now on every new Trumbowyg instance.
</p>
</div>
<div class="feature">
<h3 id="plugin-preformatted">Preformatted</h3>
<p>
Wraps your code with <code><pre></code> tags.