forked from summernote/summernote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsummernote.js
4280 lines (3780 loc) · 131 KB
/
summernote.js
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
/**
* Super simple wysiwyg editor on Bootstrap v0.5.3
* http://hackerwins.github.io/summernote/
*
* summernote.js
* Copyright 2013 Alan Hong. and outher contributors
* summernote may be freely distributed under the MIT license./
*
* Date: 2014-07-25T03:05Z
*/
(function (factory) {
/* global define */
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {
// Browser globals: jQuery
factory(window.jQuery);
}
}(function ($) {
if ('function' !== typeof Array.prototype.reduce) {
/**
* Array.prototype.reduce fallback
*
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
*/
Array.prototype.reduce = function (callback, optInitialValue) {
var idx, value, length = this.length >>> 0, isValueSet = false;
if (1 < arguments.length) {
value = optInitialValue;
isValueSet = true;
}
for (idx = 0; length > idx; ++idx) {
if (this.hasOwnProperty(idx)) {
if (isValueSet) {
value = callback(value, this[idx], idx, this);
} else {
value = this[idx];
isValueSet = true;
}
}
}
if (!isValueSet) {
throw new TypeError('Reduce of empty array with no initial value');
}
return value;
};
}
var isSupportAmd = typeof define === 'function' && define.amd;
/**
* returns whether font is installed or not.
* @param {String} fontName
* @return {Boolean}
*/
var isFontInstalled = function (fontName) {
var testFontName = fontName === 'Comic Sans MS' ? 'Courier New' : 'Comic Sans MS';
var $tester = $('<div>').css({
position: 'absolute',
left: '-9999px',
top: '-9999px',
fontSize: '200px'
}).text('mmmmmmmmmwwwwwww').appendTo(document.body);
var originalWidth = $tester.css('fontFamily', testFontName).width();
var width = $tester.css('fontFamily', fontName + ',' + testFontName).width();
$tester.remove();
return originalWidth !== width;
};
/**
* Object which check platform and agent
*/
var agent = {
isMac: navigator.appVersion.indexOf('Mac') > -1,
isMSIE: navigator.userAgent.indexOf('MSIE') > -1 || navigator.userAgent.indexOf('Trident') > -1,
isFF: navigator.userAgent.indexOf('Firefox') > -1,
jqueryVersion: parseFloat($.fn.jquery),
isSupportAmd: isSupportAmd,
hasCodeMirror: isSupportAmd ? require.specified('CodeMirror') : !!window.CodeMirror,
isFontInstalled: isFontInstalled
};
/**
* func utils (for high-order func's arg)
*/
var func = (function () {
var eq = function (elA) {
return function (elB) {
return elA === elB;
};
};
var eq2 = function (elA, elB) {
return elA === elB;
};
var ok = function () {
return true;
};
var fail = function () {
return false;
};
var not = function (f) {
return function () {
return !f.apply(f, arguments);
};
};
var self = function (a) {
return a;
};
var idCounter = 0;
/**
* generate a globally-unique id
*
* @param {String} [prefix]
*/
var uniqueId = function (prefix) {
var id = ++idCounter + '';
return prefix ? prefix + id : id;
};
/**
* returns bnd (bounds) from rect
*
* - IE Compatability Issue: http://goo.gl/sRLOAo
* - Scroll Issue: http://goo.gl/sNjUc
*
* @param {Rect} rect
* @return {Object} bounds
* @return {Number} bounds.top
* @return {Number} bounds.left
* @return {Number} bounds.width
* @return {Number} bounds.height
*/
var rect2bnd = function (rect) {
var $document = $(document);
return {
top: rect.top + $document.scrollTop(),
left: rect.left + $document.scrollLeft(),
width: rect.right - rect.left,
height: rect.bottom - rect.top
};
};
/**
* returns a copy of the object where the keys have become the values and the values the keys.
* @param {Object} obj
* @return {Object}
*/
var invertObject = function (obj) {
var inverted = {};
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
inverted[obj[key]] = key;
}
}
return inverted;
};
return {
eq: eq,
eq2: eq2,
ok: ok,
fail: fail,
not: not,
self: self,
uniqueId: uniqueId,
rect2bnd: rect2bnd,
invertObject: invertObject
};
})();
/**
* list utils
*/
var list = (function () {
/**
* returns the first element of an array.
* @param {Array} array
*/
var head = function (array) {
return array[0];
};
/**
* returns the last element of an array.
* @param {Array} array
*/
var last = function (array) {
return array[array.length - 1];
};
/**
* returns everything but the last entry of the array.
* @param {Array} array
*/
var initial = function (array) {
return array.slice(0, array.length - 1);
};
/**
* returns the rest of the elements in an array.
* @param {Array} array
*/
var tail = function (array) {
return array.slice(1);
};
/**
* returns next item.
* @param {Array} array
*/
var next = function (array, item) {
var idx = array.indexOf(item);
if (idx === -1) { return null; }
return array[idx + 1];
};
/**
* returns prev item.
* @param {Array} array
*/
var prev = function (array, item) {
var idx = array.indexOf(item);
if (idx === -1) { return null; }
return array[idx - 1];
};
/**
* get sum from a list
* @param {Array} array - array
* @param {Function} fn - iterator
*/
var sum = function (array, fn) {
fn = fn || func.self;
return array.reduce(function (memo, v) {
return memo + fn(v);
}, 0);
};
/**
* returns a copy of the collection with array type.
* @param {Collection} collection - collection eg) node.childNodes, ...
*/
var from = function (collection) {
var result = [], idx = -1, length = collection.length;
while (++idx < length) {
result[idx] = collection[idx];
}
return result;
};
/**
* cluster elements by predicate function.
* @param {Array} array - array
* @param {Function} fn - predicate function for cluster rule
* @param {Array[]}
*/
var clusterBy = function (array, fn) {
if (!array.length) { return []; }
var aTail = tail(array);
return aTail.reduce(function (memo, v) {
var aLast = last(memo);
if (fn(last(aLast), v)) {
aLast[aLast.length] = v;
} else {
memo[memo.length] = [v];
}
return memo;
}, [[head(array)]]);
};
/**
* returns a copy of the array with all falsy values removed
* @param {Array} array - array
* @param {Function} fn - predicate function for cluster rule
*/
var compact = function (array) {
var aResult = [];
for (var idx = 0, sz = array.length; idx < sz; idx ++) {
if (array[idx]) { aResult.push(array[idx]); }
}
return aResult;
};
return { head: head, last: last, initial: initial, tail: tail,
prev: prev, next: next, sum: sum, from: from,
compact: compact, clusterBy: clusterBy };
})();
/**
* Dom functions
*/
var dom = (function () {
/**
* returns whether node is `note-editable` or not.
*
* @param {Element} node
* @return {Boolean}
*/
var isEditable = function (node) {
return node && $(node).hasClass('note-editable');
};
var isControlSizing = function (node) {
return node && $(node).hasClass('note-control-sizing');
};
/**
* build layoutInfo from $editor(.note-editor)
*
* @param {jQuery} $editor
* @return {Object}
*/
var buildLayoutInfo = function ($editor) {
var makeFinder;
// air mode
if ($editor.hasClass('note-air-editor')) {
var id = list.last($editor.attr('id').split('-'));
makeFinder = function (sIdPrefix) {
return function () { return $(sIdPrefix + id); };
};
return {
editor: function () { return $editor; },
editable: function () { return $editor; },
popover: makeFinder('#note-popover-'),
handle: makeFinder('#note-handle-'),
dialog: makeFinder('#note-dialog-')
};
// frame mode
} else {
makeFinder = function (sClassName) {
return function () { return $editor.find(sClassName); };
};
return {
editor: function () { return $editor; },
dropzone: makeFinder('.note-dropzone'),
toolbar: makeFinder('.note-toolbar'),
editable: makeFinder('.note-editable'),
codable: makeFinder('.note-codable'),
statusbar: makeFinder('.note-statusbar'),
popover: makeFinder('.note-popover'),
handle: makeFinder('.note-handle'),
dialog: makeFinder('.note-dialog')
};
}
};
/**
* returns predicate which judge whether nodeName is same
* @param {String} sNodeName
*/
var makePredByNodeName = function (sNodeName) {
// nodeName is always uppercase.
return function (node) {
return node && node.nodeName === sNodeName;
};
};
var isPara = function (node) {
// Chrome(v31.0), FF(v25.0.1) use DIV for paragraph
return node && /^DIV|^P|^LI|^H[1-7]/.test(node.nodeName);
};
var isList = function (node) {
return node && /^UL|^OL/.test(node.nodeName);
};
var isCell = function (node) {
return node && /^TD|^TH/.test(node.nodeName);
};
/**
* find nearest ancestor predicate hit
*
* @param {Element} node
* @param {Function} pred - predicate function
*/
var ancestor = function (node, pred) {
while (node) {
if (pred(node)) { return node; }
if (isEditable(node)) { break; }
node = node.parentNode;
}
return null;
};
/**
* returns new array of ancestor nodes (until predicate hit).
*
* @param {Element} node
* @param {Function} [optional] pred - predicate function
*/
var listAncestor = function (node, pred) {
pred = pred || func.fail;
var aAncestor = [];
ancestor(node, function (el) {
aAncestor.push(el);
return pred(el);
});
return aAncestor;
};
/**
* returns common ancestor node between two nodes.
*
* @param {Element} nodeA
* @param {Element} nodeB
*/
var commonAncestor = function (nodeA, nodeB) {
var aAncestor = listAncestor(nodeA);
for (var n = nodeB; n; n = n.parentNode) {
if ($.inArray(n, aAncestor) > -1) { return n; }
}
return null; // difference document area
};
/**
* listing all Nodes between two nodes.
* FIXME: nodeA and nodeB must be sorted, use comparePoints later.
*
* @param {Element} nodeA
* @param {Element} nodeB
*/
var listBetween = function (nodeA, nodeB) {
var aNode = [];
var isStart = false, isEnd = false;
// DFS(depth first search) with commonAcestor.
(function fnWalk(node) {
if (!node) { return; } // traverse fisnish
if (node === nodeA) { isStart = true; } // start point
if (isStart && !isEnd) { aNode.push(node); } // between
if (node === nodeB) { isEnd = true; return; } // end point
for (var idx = 0, sz = node.childNodes.length; idx < sz; idx++) {
fnWalk(node.childNodes[idx]);
}
})(commonAncestor(nodeA, nodeB));
return aNode;
};
/**
* listing all previous siblings (until predicate hit).
* @param {Element} node
* @param {Function} [optional] pred - predicate function
*/
var listPrev = function (node, pred) {
pred = pred || func.fail;
var aNext = [];
while (node) {
aNext.push(node);
if (pred(node)) { break; }
node = node.previousSibling;
}
return aNext;
};
/**
* listing next siblings (until predicate hit).
*
* @param {Element} node
* @param {Function} [pred] - predicate function
*/
var listNext = function (node, pred) {
pred = pred || func.fail;
var aNext = [];
while (node) {
aNext.push(node);
if (pred(node)) { break; }
node = node.nextSibling;
}
return aNext;
};
/**
* listing descendant nodes
*
* @param {Element} node
* @param {Function} [pred] - predicate function
*/
var listDescendant = function (node, pred) {
var aDescendant = [];
pred = pred || func.ok;
// start DFS(depth first search) with node
(function fnWalk(current) {
if (node !== current && pred(current)) {
aDescendant.push(current);
}
for (var idx = 0, sz = current.childNodes.length; idx < sz; idx++) {
fnWalk(current.childNodes[idx]);
}
})(node);
return aDescendant;
};
/**
* insert node after preceding
*
* @param {Element} node
* @param {Element} preceding - predicate function
*/
var insertAfter = function (node, preceding) {
var next = preceding.nextSibling, parent = preceding.parentNode;
if (next) {
parent.insertBefore(node, next);
} else {
parent.appendChild(node);
}
return node;
};
/**
* append elements.
*
* @param {Element} node
* @param {Collection} aChild
*/
var appends = function (node, aChild) {
$.each(aChild, function (idx, child) {
node.appendChild(child);
});
return node;
};
var isText = makePredByNodeName('#text');
/**
* returns #text's text size or element's childNodes size
*
* @param {Element} node
*/
var length = function (node) {
if (isText(node)) { return node.nodeValue.length; }
return node.childNodes.length;
};
/**
* returns whether boundaryPoint is edge or not.
*
* @param {BoundaryPoint} boundaryPoitn
* @return {Boolean}
*/
var isEdgeBP = function (boundaryPoint) {
return boundaryPoint.offset === 0 ||
boundaryPoint.offset === length(boundaryPoint.node);
};
/**
* returns offset from parent.
*
* @param {Element} node
*/
var position = function (node) {
var offset = 0;
while ((node = node.previousSibling)) { offset += 1; }
return offset;
};
var hasChildren = function (node) {
return node && node.childNodes && node.childNodes.length;
};
/**
* returns previous boundaryPoint
*
* @param {BoundaryPoint} boundaryPoitn
* @return {BoundaryPoint}
*/
var prevBP = function (boundaryPoint) {
var node = boundaryPoint.node,
offset = boundaryPoint.offset;
if (offset === 0) {
if (isEditable(node)) { return null; }
return {node: node.parentNode, offset: position(node)};
} else {
if (hasChildren(node)) {
var child = node.childNodes[offset - 1];
return {node: child, offset: length(child)};
} else {
return {node: node, offset: offset - 1};
}
}
};
/**
* return offsetPath(array of offset) from ancestor
*
* @param {Element} ancestor - ancestor node
* @param {Element} node
*/
var makeOffsetPath = function (ancestor, node) {
var aAncestor = list.initial(listAncestor(node, func.eq(ancestor)));
return $.map(aAncestor, position).reverse();
};
/**
* return element from offsetPath(array of offset)
*
* @param {Element} ancestor - ancestor node
* @param {array} aOffset - offsetPath
*/
var fromOffsetPath = function (ancestor, aOffset) {
var current = ancestor;
for (var i = 0, sz = aOffset.length; i < sz; i++) {
current = current.childNodes[aOffset[i]];
}
return current;
};
/**
* split element or #text
*
* @param {Element} node
* @param {Number} offset
*/
var split = function (node, offset) {
if (offset === 0) { return node; }
if (offset >= length(node)) { return node.nextSibling; }
// splitText
if (isText(node)) { return node.splitText(offset); }
// splitElement
var child = node.childNodes[offset];
node = insertAfter(node.cloneNode(false), node);
return appends(node, listNext(child));
};
/**
* split dom tree by boundaryPoint(pivot and offset)
*
* @param {Element} root
* @param {Element} pivot - this will be boundaryPoint's node
* @param {Number} offset - this will be boundaryPoint's offset
*/
var splitTree = function (root, pivot, offset) {
var aAncestor = listAncestor(pivot, func.eq(root));
if (aAncestor.length === 1) { return split(pivot, offset); }
return aAncestor.reduce(function (node, parent) {
var clone = parent.cloneNode(false);
insertAfter(clone, parent);
if (node === pivot) {
node = split(node, offset);
}
appends(clone, listNext(node));
return clone;
});
};
/**
* remove node, (bRemoveChild: remove child or not)
* @param {Element} node
* @param {Boolean} bRemoveChild
*/
var remove = function (node, bRemoveChild) {
if (!node || !node.parentNode) { return; }
if (node.removeNode) { return node.removeNode(bRemoveChild); }
var elParent = node.parentNode;
if (!bRemoveChild) {
var aNode = [];
var i, sz;
for (i = 0, sz = node.childNodes.length; i < sz; i++) {
aNode.push(node.childNodes[i]);
}
for (i = 0, sz = aNode.length; i < sz; i++) {
elParent.insertBefore(aNode[i], node);
}
}
elParent.removeChild(node);
};
var html = function ($node) {
return dom.isTextarea($node[0]) ? $node.val() : $node.html();
};
return {
blank: agent.isMSIE ? ' ' : '<br/>',
emptyPara: '<p><br/></p>',
isEditable: isEditable,
isControlSizing: isControlSizing,
buildLayoutInfo: buildLayoutInfo,
isText: isText,
isPara: isPara,
isList: isList,
isTable: makePredByNodeName('TABLE'),
isCell: isCell,
isAnchor: makePredByNodeName('A'),
isDiv: makePredByNodeName('DIV'),
isLi: makePredByNodeName('LI'),
isSpan: makePredByNodeName('SPAN'),
isB: makePredByNodeName('B'),
isU: makePredByNodeName('U'),
isS: makePredByNodeName('S'),
isI: makePredByNodeName('I'),
isImg: makePredByNodeName('IMG'),
isTextarea: makePredByNodeName('TEXTAREA'),
length: length,
isEdgeBP: isEdgeBP,
prevBP: prevBP,
ancestor: ancestor,
listAncestor: listAncestor,
listNext: listNext,
listPrev: listPrev,
listDescendant: listDescendant,
commonAncestor: commonAncestor,
listBetween: listBetween,
insertAfter: insertAfter,
position: position,
makeOffsetPath: makeOffsetPath,
fromOffsetPath: fromOffsetPath,
splitTree: splitTree,
remove: remove,
html: html
};
})();
var settings = {
// version
version: '0.5.3',
/**
* options
*/
options: {
width: null, // set editor width
height: null, // set editor height, ex) 300
minHeight: null, // set minimum height of editor
maxHeight: null, // set maximum height of editor
focus: false, // set focus to editable area after initializing summernote
tabsize: 4, // size of tab ex) 2 or 4
styleWithSpan: true, // style with span (Chrome and FF only)
disableLinkTarget: false, // hide link Target Checkbox
disableDragAndDrop: false, // disable drag and drop event
disableResizeEditor: false, // disable resizing editor
codemirror: { // codemirror options
mode: 'text/html',
htmlMode: true,
lineNumbers: true,
autoFormatOnStart: false
},
// language
lang: 'en-US', // language 'en-US', 'ko-KR', ...
direction: null, // text direction, ex) 'rtl'
// toolbar
toolbar: [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'superscript', 'subscript', 'strikethrough', 'clear']],
['fontname', ['fontname']],
// ['fontsize', ['fontsize']], // Still buggy
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['table', ['table']],
['insert', ['link', 'picture', 'video', 'hr']],
['view', ['fullscreen', 'codeview']],
['help', ['help']]
],
// air mode: inline editor
airMode: false,
// airPopover: [
// ['style', ['style']],
// ['font', ['bold', 'italic', 'underline', 'clear']],
// ['fontname', ['fontname']],
// ['fontsize', ['fontsize']], // Still buggy
// ['color', ['color']],
// ['para', ['ul', 'ol', 'paragraph']],
// ['height', ['height']],
// ['table', ['table']],
// ['insert', ['link', 'picture', 'video']],
// ['help', ['help']]
// ],
airPopover: [
['color', ['color']],
['font', ['bold', 'underline', 'clear']],
['para', ['ul', 'paragraph']],
['table', ['table']],
['insert', ['link', 'picture']]
],
// style tag
styleTags: ['p', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
// default fontName
defaultFontName: 'Helvetica Neue',
// fontName
fontNames: [
'Arial', 'Arial Black', 'Comic Sans MS', 'Courier New',
'Helvetica Neue', 'Impact', 'Lucida Grande',
'Tahoma', 'Times New Roman', 'Verdana'
],
// pallete colors(n x n)
colors: [
['#000000', '#424242', '#636363', '#9C9C94', '#CEC6CE', '#EFEFEF', '#F7F7F7', '#FFFFFF'],
['#FF0000', '#FF9C00', '#FFFF00', '#00FF00', '#00FFFF', '#0000FF', '#9C00FF', '#FF00FF'],
['#F7C6CE', '#FFE7CE', '#FFEFC6', '#D6EFD6', '#CEDEE7', '#CEE7F7', '#D6D6E7', '#E7D6DE'],
['#E79C9C', '#FFC69C', '#FFE79C', '#B5D6A5', '#A5C6CE', '#9CC6EF', '#B5A5D6', '#D6A5BD'],
['#E76363', '#F7AD6B', '#FFD663', '#94BD7B', '#73A5AD', '#6BADDE', '#8C7BC6', '#C67BA5'],
['#CE0000', '#E79439', '#EFC631', '#6BA54A', '#4A7B8C', '#3984C6', '#634AA5', '#A54A7B'],
['#9C0000', '#B56308', '#BD9400', '#397B21', '#104A5A', '#085294', '#311873', '#731842'],
['#630000', '#7B3900', '#846300', '#295218', '#083139', '#003163', '#21104A', '#4A1031']
],
// fontSize
fontSizes: ['8', '9', '10', '11', '12', '14', '18', '24', '36'],
// lineHeight
lineHeights: ['1.0', '1.2', '1.4', '1.5', '1.6', '1.8', '2.0', '3.0'],
// insertTable max size
insertTableMaxSize: {
col: 10,
row: 10
},
// callbacks
oninit: null, // initialize
onfocus: null, // editable has focus
onblur: null, // editable out of focus
onenter: null, // enter key pressed
onkeyup: null, // keyup
onkeydown: null, // keydown
onImageUpload: null, // imageUpload
onImageUploadError: null, // imageUploadError
onToolbarClick: null,
/**
* manipulate link address when user create link
* @param {String} sLinkUrl
* @return {String}
*/
onCreateLink: function (sLinkUrl) {
if (sLinkUrl.indexOf('@') !== -1 && sLinkUrl.indexOf(':') === -1) {
sLinkUrl = 'mailto:' + sLinkUrl;
} else if (sLinkUrl.indexOf('://') === -1) {
sLinkUrl = 'http://' + sLinkUrl;
}
return sLinkUrl;
},
keyMap: {
pc: {
'CTRL+Z': 'undo',
'CTRL+Y': 'redo',
'TAB': 'tab',
'SHIFT+TAB': 'untab',
'CTRL+B': 'bold',
'CTRL+I': 'italic',
'CTRL+U': 'underline',
'CTRL+SHIFT+S': 'strikethrough',
'CTRL+BACKSLASH': 'removeFormat',
'CTRL+SHIFT+L': 'justifyLeft',
'CTRL+SHIFT+E': 'justifyCenter',
'CTRL+SHIFT+R': 'justifyRight',
'CTRL+SHIFT+J': 'justifyFull',
'CTRL+SHIFT+NUM7': 'insertUnorderedList',
'CTRL+SHIFT+NUM8': 'insertOrderedList',
'CTRL+LEFTBRACKET': 'outdent',
'CTRL+RIGHTBRACKET': 'indent',
'CTRL+NUM0': 'formatPara',
'CTRL+NUM1': 'formatH1',
'CTRL+NUM2': 'formatH2',
'CTRL+NUM3': 'formatH3',
'CTRL+NUM4': 'formatH4',
'CTRL+NUM5': 'formatH5',
'CTRL+NUM6': 'formatH6',
'CTRL+ENTER': 'insertHorizontalRule',
'CTRL+K': 'showLinkDialog'
},
mac: {
'CMD+Z': 'undo',
'CMD+SHIFT+Z': 'redo',
'TAB': 'tab',
'SHIFT+TAB': 'untab',
'CMD+B': 'bold',
'CMD+I': 'italic',
'CMD+U': 'underline',
'CMD+SHIFT+S': 'strikethrough',
'CMD+BACKSLASH': 'removeFormat',
'CMD+SHIFT+L': 'justifyLeft',
'CMD+SHIFT+E': 'justifyCenter',
'CMD+SHIFT+R': 'justifyRight',
'CMD+SHIFT+J': 'justifyFull',
'CMD+SHIFT+NUM7': 'insertUnorderedList',
'CMD+SHIFT+NUM8': 'insertOrderedList',
'CMD+LEFTBRACKET': 'outdent',
'CMD+RIGHTBRACKET': 'indent',
'CMD+NUM0': 'formatPara',
'CMD+NUM1': 'formatH1',
'CMD+NUM2': 'formatH2',
'CMD+NUM3': 'formatH3',
'CMD+NUM4': 'formatH4',
'CMD+NUM5': 'formatH5',
'CMD+NUM6': 'formatH6',
'CMD+ENTER': 'insertHorizontalRule',
'CMD+K': 'showLinkDialog'
}
}
},
// default language: en-US
lang: {
'en-US': {
font: {
bold: 'Bold',
italic: 'Italic',
underline: 'Underline',
strikethrough: 'Strikethrough',
subscript: 'Subscript',
superscript: 'Superscript',
clear: 'Remove Font Style',
height: 'Line Height',
name: 'Font Family',
size: 'Font Size'
},
image: {
image: 'Picture',
insert: 'Insert Image',
resizeFull: 'Resize Full',
resizeHalf: 'Resize Half',
resizeQuarter: 'Resize Quarter',
floatLeft: 'Float Left',
floatRight: 'Float Right',
floatNone: 'Float None',
dragImageHere: 'Drag an image here',
selectFromFiles: 'Select from files',
url: 'Image URL',
remove: 'Remove Image'
},
link: {
link: 'Link',
insert: 'Insert Link',
unlink: 'Unlink',
edit: 'Edit',
textToDisplay: 'Text to display',
url: 'To what URL should this link go?',
openInNewWindow: 'Open in new window'
},
video: {
video: 'Video',
videoLink: 'Video Link',
insert: 'Insert Video',
url: 'Video URL?',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion or Youku)'
},
table: {
table: 'Table'
},
hr: {
insert: 'Insert Horizontal Rule'
},
style: {
style: 'Style',
normal: 'Normal',
blockquote: 'Quote',
pre: 'Code',
h1: 'Header 1',
h2: 'Header 2',
h3: 'Header 3',