summernote-rails 0.7.1.0 → 0.8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -6
- data/lib/summernote-rails/version.rb +1 -1
- data/vendor/assets/javascripts/summernote/locales/hu-HU.js +31 -1
- data/vendor/assets/javascripts/summernote/locales/sk-SK.js +7 -7
- data/vendor/assets/javascripts/summernote/plugin/specialchars/summernote-ext-specialchars.js +2 -2
- data/vendor/assets/javascripts/summernote/summernote.js +426 -326
- data/vendor/assets/stylesheets/font/summernote.eot +0 -0
- data/vendor/assets/stylesheets/font/summernote.ttf +0 -0
- data/vendor/assets/stylesheets/font/summernote.woff +0 -0
- data/vendor/assets/stylesheets/summernote.css +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 772439bde305c4acec0a11d4158a627a6d118e27
|
|
4
|
+
data.tar.gz: e1d7d988777fa4e50cf0fc4f79b1cda386439b20
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3045ceaec55b26ae5d259fe0d2b27aabfc169c41b095a27a2bd5de9f24abd1aac697f652df728df0baed43bddd2cdbdebe1d284c031eb5fa0a4d0a2416565469
|
|
7
|
+
data.tar.gz: fab4f494071689568e06ecc711d5c2c934c039d184e22c32642d3a77d77ff78015f15386732d164e5bd3a0fa6312a652330a27c36cc6c0725980f1e3364952d3
|
data/README.md
CHANGED
|
@@ -14,7 +14,6 @@ Add the following gems to your application's Gemfile:
|
|
|
14
14
|
|
|
15
15
|
```ruby
|
|
16
16
|
gem 'summernote-rails', 'current version number'
|
|
17
|
-
gem 'font-awesome-rails' # required
|
|
18
17
|
gem 'bootstrap-sass' # required
|
|
19
18
|
```
|
|
20
19
|
|
|
@@ -30,7 +29,6 @@ In app/assets/stylesheets/application.scss,
|
|
|
30
29
|
|
|
31
30
|
```css
|
|
32
31
|
@import "bootstrap";
|
|
33
|
-
@import "font-awesome";
|
|
34
32
|
@import "summernote";
|
|
35
33
|
```
|
|
36
34
|
|
|
@@ -71,7 +69,7 @@ $('[data-provider="summernote"]').each(function(){
|
|
|
71
69
|
})
|
|
72
70
|
```
|
|
73
71
|
|
|
74
|
-
Or, if you want to code in coffeescript,
|
|
72
|
+
Or, if you want to code in coffeescript,
|
|
75
73
|
|
|
76
74
|
```coffeescript
|
|
77
75
|
$ ->
|
|
@@ -89,7 +87,7 @@ Then, if you are using simple_form, you can use the `:summernote` input type. Th
|
|
|
89
87
|
<% end %>
|
|
90
88
|
```
|
|
91
89
|
|
|
92
|
-
Or, if you prefer haml-style,
|
|
90
|
+
Or, if you prefer haml-style,
|
|
93
91
|
|
|
94
92
|
```haml
|
|
95
93
|
= simple_form_for(:example) do | f |
|
|
@@ -172,8 +170,8 @@ Also, you can move the above javascript code lines to app/assets/javascripts/sum
|
|
|
172
170
|
...
|
|
173
171
|
[
|
|
174
172
|
'insert'
|
|
175
|
-
[
|
|
176
|
-
'hello'
|
|
173
|
+
[
|
|
174
|
+
'hello'
|
|
177
175
|
]
|
|
178
176
|
]
|
|
179
177
|
...
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
floatLeft: 'Igazítás balra',
|
|
21
21
|
floatRight: 'Igazítás jobbra',
|
|
22
22
|
floatNone: 'Igazítás törlése',
|
|
23
|
-
dragImageHere: 'Ide
|
|
23
|
+
dragImageHere: 'Ide húzhat képet vagy szöveget',
|
|
24
|
+
dropImage: 'Engedje el a képet vagy szöveget',
|
|
24
25
|
selectFromFiles: 'Fájlok kiválasztása',
|
|
25
26
|
url: 'Kép URL címe',
|
|
26
27
|
remove: 'Kép törlése'
|
|
@@ -95,6 +96,35 @@
|
|
|
95
96
|
paragraphFormatting: 'Bekezdés formázása',
|
|
96
97
|
documentStyle: 'Dokumentumstílus'
|
|
97
98
|
},
|
|
99
|
+
help: {
|
|
100
|
+
'insertParagraph': 'Új bekezdés',
|
|
101
|
+
'undo': 'Visszavonás',
|
|
102
|
+
'redo': 'Újra',
|
|
103
|
+
'tab': 'Behúzás növelése',
|
|
104
|
+
'untab': 'Behúzás csökkentése',
|
|
105
|
+
'bold': 'Félkövérre állítás',
|
|
106
|
+
'italic': 'Dőltre állítás',
|
|
107
|
+
'underline': 'Aláhúzás',
|
|
108
|
+
'strikethrough': 'Áthúzás',
|
|
109
|
+
'removeFormat': 'Formázás törlése',
|
|
110
|
+
'justifyLeft': 'Balra igazítás',
|
|
111
|
+
'justifyCenter': 'Középre igazítás',
|
|
112
|
+
'justifyRight': 'Jobbra igazítás',
|
|
113
|
+
'justifyFull': 'Sorkizárt',
|
|
114
|
+
'insertUnorderedList': 'Számozatlan lista be/ki',
|
|
115
|
+
'insertOrderedList': 'Számozott lista be/ki',
|
|
116
|
+
'outdent': 'Jelenlegi bekezdés behúzásának megszüntetése',
|
|
117
|
+
'indent': 'Jelenlegi bekezdés behúzása',
|
|
118
|
+
'formatPara': 'Blokk formázása bekezdésként (P tag)',
|
|
119
|
+
'formatH1': 'Blokk formázása, mint Fejléc 1',
|
|
120
|
+
'formatH2': 'Blokk formázása, mint Fejléc 2',
|
|
121
|
+
'formatH3': 'Blokk formázása, mint Fejléc 3',
|
|
122
|
+
'formatH4': 'Blokk formázása, mint Fejléc 4',
|
|
123
|
+
'formatH5': 'Blokk formázása, mint Fejléc 5',
|
|
124
|
+
'formatH6': 'Blokk formázása, mint Fejléc 6',
|
|
125
|
+
'insertHorizontalRule': 'Vízszintes vonal beszúrása',
|
|
126
|
+
'linkDialog.show': 'Link párbeszédablak megjelenítése'
|
|
127
|
+
},
|
|
98
128
|
history: {
|
|
99
129
|
undo: 'Visszavonás',
|
|
100
130
|
redo: 'Újra'
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
font: {
|
|
5
5
|
bold: 'Tučné',
|
|
6
6
|
italic: 'Kurzíva',
|
|
7
|
-
underline: '
|
|
7
|
+
underline: 'Podčiarknutie',
|
|
8
8
|
clear: 'Odstrániť štýl písma',
|
|
9
9
|
height: 'Výška riadku',
|
|
10
|
-
strikethrough: '
|
|
10
|
+
strikethrough: 'Prečiarknuté',
|
|
11
11
|
size: 'Veľkosť písma'
|
|
12
12
|
},
|
|
13
13
|
image: {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
videoLink: 'Odkaz videa',
|
|
29
29
|
insert: 'Vložiť video',
|
|
30
30
|
url: 'URL videa?',
|
|
31
|
-
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion
|
|
31
|
+
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion alebo Youku)'
|
|
32
32
|
},
|
|
33
33
|
link: {
|
|
34
34
|
link: 'Odkaz',
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
codeview: 'HTML kód'
|
|
68
68
|
},
|
|
69
69
|
paragraph: {
|
|
70
|
-
paragraph: '
|
|
71
|
-
outdent: '
|
|
70
|
+
paragraph: 'Odsek',
|
|
71
|
+
outdent: 'Zväčšiť odsadenie',
|
|
72
72
|
indent: 'Zmenšiť odsadenie',
|
|
73
73
|
left: 'Zarovnať doľava',
|
|
74
74
|
center: 'Zarovnať na stred',
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
more: 'Dalšie farby',
|
|
81
81
|
background: 'Farba pozadia',
|
|
82
82
|
foreground: 'Farba písma',
|
|
83
|
-
transparent: '
|
|
83
|
+
transparent: 'Priehľadnosť',
|
|
84
84
|
setTransparent: 'Nastaviť priehľadnosť',
|
|
85
85
|
reset: 'Obnoviť',
|
|
86
86
|
resetToDefault: 'Obnoviť prednastavené'
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
close: 'Zavrieť',
|
|
91
91
|
textFormatting: 'Formátovanie textu',
|
|
92
92
|
action: 'Akcia',
|
|
93
|
-
paragraphFormatting: '
|
|
93
|
+
paragraphFormatting: 'Formátovanie odseku',
|
|
94
94
|
documentStyle: 'Štýl dokumentu'
|
|
95
95
|
},
|
|
96
96
|
history: {
|
data/vendor/assets/javascripts/summernote/plugin/specialchars/summernote-ext-specialchars.js
CHANGED
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
return;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
deferred.resolve(decodeURIComponent($selectedNode.find('button').
|
|
244
|
+
deferred.resolve(decodeURIComponent($selectedNode.find('button').attr('data-value')));
|
|
245
245
|
$specialCharDialog.modal('hide');
|
|
246
246
|
}
|
|
247
247
|
|
|
@@ -289,7 +289,7 @@
|
|
|
289
289
|
|
|
290
290
|
$specialCharNode.on('click', function (event) {
|
|
291
291
|
event.preventDefault();
|
|
292
|
-
deferred.resolve(decodeURIComponent($(event.currentTarget).find('button').
|
|
292
|
+
deferred.resolve(decodeURIComponent($(event.currentTarget).find('button').attr('data-value')));
|
|
293
293
|
ui.hideDialog(self.$dialog);
|
|
294
294
|
});
|
|
295
295
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Super simple wysiwyg editor v0.
|
|
2
|
+
* Super simple wysiwyg editor v0.8.1
|
|
3
3
|
* http://summernote.org/
|
|
4
4
|
*
|
|
5
5
|
* summernote.js
|
|
6
6
|
* Copyright 2013-2015 Alan Hong. and other contributors
|
|
7
7
|
* summernote may be freely distributed under the MIT license./
|
|
8
8
|
*
|
|
9
|
-
* Date:
|
|
9
|
+
* Date: 2016-02-15T18:35Z
|
|
10
10
|
*/
|
|
11
11
|
(function (factory) {
|
|
12
12
|
/* global define */
|
|
@@ -72,6 +72,12 @@
|
|
|
72
72
|
return a;
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
+
var invoke = function (obj, method) {
|
|
76
|
+
return function () {
|
|
77
|
+
return obj[method].apply(obj, arguments);
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
75
81
|
var idCounter = 0;
|
|
76
82
|
|
|
77
83
|
/**
|
|
@@ -87,7 +93,7 @@
|
|
|
87
93
|
/**
|
|
88
94
|
* returns bnd (bounds) from rect
|
|
89
95
|
*
|
|
90
|
-
* - IE
|
|
96
|
+
* - IE Compatibility Issue: http://goo.gl/sRLOAo
|
|
91
97
|
* - Scroll Issue: http://goo.gl/sNjUc
|
|
92
98
|
*
|
|
93
99
|
* @param {Rect} rect
|
|
@@ -143,6 +149,7 @@
|
|
|
143
149
|
self: self,
|
|
144
150
|
not: not,
|
|
145
151
|
and: and,
|
|
152
|
+
invoke: invoke,
|
|
146
153
|
uniqueId: uniqueId,
|
|
147
154
|
rect2bnd: rect2bnd,
|
|
148
155
|
invertObject: invertObject,
|
|
@@ -384,6 +391,24 @@
|
|
|
384
391
|
}
|
|
385
392
|
}
|
|
386
393
|
|
|
394
|
+
var isEdge = /Edge\/\d+/.test(userAgent);
|
|
395
|
+
|
|
396
|
+
var hasCodeMirror = !!window.CodeMirror;
|
|
397
|
+
if (!hasCodeMirror && isSupportAmd && require) {
|
|
398
|
+
if (require.hasOwnProperty('resolve')) {
|
|
399
|
+
try {
|
|
400
|
+
// If CodeMirror can't be resolved, `require.resolve` will throw an
|
|
401
|
+
// exception and `hasCodeMirror` won't be set to `true`.
|
|
402
|
+
require.resolve('codemirror');
|
|
403
|
+
hasCodeMirror = true;
|
|
404
|
+
} catch (e) {
|
|
405
|
+
hasCodeMirror = false;
|
|
406
|
+
}
|
|
407
|
+
} else if (require.hasOwnProperty('specified')) {
|
|
408
|
+
hasCodeMirror = require.specified('codemirror');
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
387
412
|
/**
|
|
388
413
|
* @class core.agent
|
|
389
414
|
*
|
|
@@ -395,13 +420,16 @@
|
|
|
395
420
|
var agent = {
|
|
396
421
|
isMac: navigator.appVersion.indexOf('Mac') > -1,
|
|
397
422
|
isMSIE: isMSIE,
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
423
|
+
isEdge: isEdge,
|
|
424
|
+
isFF: !isEdge && /firefox/i.test(userAgent),
|
|
425
|
+
isPhantom: /PhantomJS/i.test(userAgent),
|
|
426
|
+
isWebkit: !isEdge && /webkit/i.test(userAgent),
|
|
427
|
+
isChrome: !isEdge && /chrome/i.test(userAgent),
|
|
428
|
+
isSafari: !isEdge && /safari/i.test(userAgent),
|
|
401
429
|
browserVersion: browserVersion,
|
|
402
430
|
jqueryVersion: parseFloat($.fn.jquery),
|
|
403
431
|
isSupportAmd: isSupportAmd,
|
|
404
|
-
hasCodeMirror:
|
|
432
|
+
hasCodeMirror: hasCodeMirror,
|
|
405
433
|
isFontInstalled: isFontInstalled,
|
|
406
434
|
isW3CRangeSupport: !!document.createRange
|
|
407
435
|
};
|
|
@@ -756,20 +784,20 @@
|
|
|
756
784
|
* @param {Function} [pred] - predicate function
|
|
757
785
|
*/
|
|
758
786
|
var listDescendant = function (node, pred) {
|
|
759
|
-
var
|
|
787
|
+
var descendants = [];
|
|
760
788
|
pred = pred || func.ok;
|
|
761
789
|
|
|
762
790
|
// start DFS(depth first search) with node
|
|
763
791
|
(function fnWalk(current) {
|
|
764
792
|
if (node !== current && pred(current)) {
|
|
765
|
-
|
|
793
|
+
descendants.push(current);
|
|
766
794
|
}
|
|
767
795
|
for (var idx = 0, len = current.childNodes.length; idx < len; idx++) {
|
|
768
796
|
fnWalk(current.childNodes[idx]);
|
|
769
797
|
}
|
|
770
798
|
})(node);
|
|
771
799
|
|
|
772
|
-
return
|
|
800
|
+
return descendants;
|
|
773
801
|
};
|
|
774
802
|
|
|
775
803
|
/**
|
|
@@ -849,7 +877,7 @@
|
|
|
849
877
|
};
|
|
850
878
|
|
|
851
879
|
/**
|
|
852
|
-
* returns
|
|
880
|
+
* returns whether node is left edge of ancestor or not.
|
|
853
881
|
*
|
|
854
882
|
* @param {Node} node
|
|
855
883
|
* @param {Node} ancestor
|
|
@@ -1476,7 +1504,6 @@
|
|
|
1476
1504
|
};
|
|
1477
1505
|
})();
|
|
1478
1506
|
|
|
1479
|
-
|
|
1480
1507
|
/**
|
|
1481
1508
|
* @param {jQuery} $note
|
|
1482
1509
|
* @param {Object} options
|
|
@@ -1514,9 +1541,14 @@
|
|
|
1514
1541
|
* destory modules and other resources and initialize it again
|
|
1515
1542
|
*/
|
|
1516
1543
|
this.reset = function () {
|
|
1544
|
+
var disabled = self.isDisabled();
|
|
1517
1545
|
this.code(dom.emptyPara);
|
|
1518
1546
|
this._destroy();
|
|
1519
1547
|
this._initialize();
|
|
1548
|
+
|
|
1549
|
+
if (disabled) {
|
|
1550
|
+
self.disable();
|
|
1551
|
+
}
|
|
1520
1552
|
};
|
|
1521
1553
|
|
|
1522
1554
|
this._initialize = function () {
|
|
@@ -1658,7 +1690,7 @@
|
|
|
1658
1690
|
this.createInvokeHandler = function (namespace, value) {
|
|
1659
1691
|
return function (event) {
|
|
1660
1692
|
event.preventDefault();
|
|
1661
|
-
self.invoke(namespace, value || $(event.target).
|
|
1693
|
+
self.invoke(namespace, value || $(event.target).closest('[data-value]').data('value'));
|
|
1662
1694
|
};
|
|
1663
1695
|
};
|
|
1664
1696
|
|
|
@@ -1682,10 +1714,6 @@
|
|
|
1682
1714
|
return this.initialize();
|
|
1683
1715
|
};
|
|
1684
1716
|
|
|
1685
|
-
$.summernote = $.summernote || {
|
|
1686
|
-
lang: {}
|
|
1687
|
-
};
|
|
1688
|
-
|
|
1689
1717
|
$.fn.extend({
|
|
1690
1718
|
/**
|
|
1691
1719
|
* Summernote API
|
|
@@ -1818,7 +1846,9 @@
|
|
|
1818
1846
|
|
|
1819
1847
|
var dropdown = renderer.create('<div class="dropdown-menu">', function ($node, options) {
|
|
1820
1848
|
var markup = $.isArray(options.items) ? options.items.map(function (item) {
|
|
1821
|
-
|
|
1849
|
+
var value = (typeof item === 'string') ? item : (item.value || '');
|
|
1850
|
+
var content = options.template ? options.template(item) : item;
|
|
1851
|
+
return '<li><a href="#" data-value="' + value + '">' + content + '</a></li>';
|
|
1822
1852
|
}).join('') : options.items;
|
|
1823
1853
|
|
|
1824
1854
|
$node.html(markup);
|
|
@@ -1826,7 +1856,9 @@
|
|
|
1826
1856
|
|
|
1827
1857
|
var dropdownCheck = renderer.create('<div class="dropdown-menu note-check">', function ($node, options) {
|
|
1828
1858
|
var markup = $.isArray(options.items) ? options.items.map(function (item) {
|
|
1829
|
-
|
|
1859
|
+
var value = (typeof item === 'string') ? item : (item.value || '');
|
|
1860
|
+
var content = options.template ? options.template(item) : item;
|
|
1861
|
+
return '<li><a href="#" data-value="' + value + '">' + icon(options.checkClassName) + ' ' + content + '</a></li>';
|
|
1830
1862
|
}).join('') : options.items;
|
|
1831
1863
|
$node.html(markup);
|
|
1832
1864
|
});
|
|
@@ -1859,7 +1891,10 @@
|
|
|
1859
1891
|
});
|
|
1860
1892
|
});
|
|
1861
1893
|
|
|
1862
|
-
var dialog = renderer.create('<div class="modal" aria-hidden="false"/>', function ($node, options) {
|
|
1894
|
+
var dialog = renderer.create('<div class="modal" aria-hidden="false" tabindex="-1"/>', function ($node, options) {
|
|
1895
|
+
if (options.fade) {
|
|
1896
|
+
$node.addClass('fade');
|
|
1897
|
+
}
|
|
1863
1898
|
$node.html([
|
|
1864
1899
|
'<div class="modal-dialog">',
|
|
1865
1900
|
' <div class="modal-content">',
|
|
@@ -1879,11 +1914,19 @@
|
|
|
1879
1914
|
});
|
|
1880
1915
|
|
|
1881
1916
|
var popover = renderer.create([
|
|
1882
|
-
'<div class="note-popover popover
|
|
1917
|
+
'<div class="note-popover popover in">',
|
|
1883
1918
|
' <div class="arrow"/>',
|
|
1884
1919
|
' <div class="popover-content note-children-container"/>',
|
|
1885
1920
|
'</div>'
|
|
1886
|
-
].join(''))
|
|
1921
|
+
].join(''), function ($node, options) {
|
|
1922
|
+
var direction = typeof options.direction !== 'undefined' ? options.direction : 'bottom';
|
|
1923
|
+
|
|
1924
|
+
$node.addClass(direction);
|
|
1925
|
+
|
|
1926
|
+
if (options.hideArrow) {
|
|
1927
|
+
$node.find('.arrow').hide();
|
|
1928
|
+
}
|
|
1929
|
+
});
|
|
1887
1930
|
|
|
1888
1931
|
var icon = function (iconClassName, tagName) {
|
|
1889
1932
|
tagName = tagName || 'i';
|
|
@@ -1967,6 +2010,10 @@
|
|
|
1967
2010
|
}
|
|
1968
2011
|
};
|
|
1969
2012
|
|
|
2013
|
+
$.summernote = $.summernote || {
|
|
2014
|
+
lang: {}
|
|
2015
|
+
};
|
|
2016
|
+
|
|
1970
2017
|
$.extend($.summernote.lang, {
|
|
1971
2018
|
'en-US': {
|
|
1972
2019
|
font: {
|
|
@@ -2073,7 +2120,7 @@
|
|
|
2073
2120
|
documentStyle: 'Document Style',
|
|
2074
2121
|
extraKeys: 'Extra keys'
|
|
2075
2122
|
},
|
|
2076
|
-
help
|
|
2123
|
+
help: {
|
|
2077
2124
|
'insertParagraph': 'Insert Paragraph',
|
|
2078
2125
|
'undo': 'Undoes the last command',
|
|
2079
2126
|
'redo': 'Redoes the last command',
|
|
@@ -2178,7 +2225,7 @@
|
|
|
2178
2225
|
keyMap.BACKSPACE,
|
|
2179
2226
|
keyMap.TAB,
|
|
2180
2227
|
keyMap.ENTER,
|
|
2181
|
-
keyMap.
|
|
2228
|
+
keyMap.SPACE
|
|
2182
2229
|
], keyCode);
|
|
2183
2230
|
},
|
|
2184
2231
|
/**
|
|
@@ -2204,7 +2251,6 @@
|
|
|
2204
2251
|
};
|
|
2205
2252
|
})();
|
|
2206
2253
|
|
|
2207
|
-
|
|
2208
2254
|
var range = (function () {
|
|
2209
2255
|
|
|
2210
2256
|
/**
|
|
@@ -2387,15 +2433,15 @@
|
|
|
2387
2433
|
return this;
|
|
2388
2434
|
};
|
|
2389
2435
|
|
|
2390
|
-
|
|
2391
2436
|
/**
|
|
2392
2437
|
* Moves the scrollbar to start container(sc) of current range
|
|
2393
2438
|
*
|
|
2394
2439
|
* @return {WrappedRange}
|
|
2395
2440
|
*/
|
|
2396
|
-
this.scrollIntoView = function (
|
|
2397
|
-
|
|
2398
|
-
|
|
2441
|
+
this.scrollIntoView = function (container) {
|
|
2442
|
+
var height = $(container).height();
|
|
2443
|
+
if (container.scrollTop + height < this.sc.offsetTop) {
|
|
2444
|
+
container.scrollTop += Math.abs(container.scrollTop + height - this.sc.offsetTop);
|
|
2399
2445
|
}
|
|
2400
2446
|
|
|
2401
2447
|
return this;
|
|
@@ -2841,8 +2887,6 @@
|
|
|
2841
2887
|
*/
|
|
2842
2888
|
return {
|
|
2843
2889
|
/**
|
|
2844
|
-
* @method
|
|
2845
|
-
*
|
|
2846
2890
|
* create Range Object From arguments or Browser Selection
|
|
2847
2891
|
*
|
|
2848
2892
|
* @param {Node} sc - start container
|
|
@@ -2851,48 +2895,63 @@
|
|
|
2851
2895
|
* @param {Number} eo - end offset
|
|
2852
2896
|
* @return {WrappedRange}
|
|
2853
2897
|
*/
|
|
2854
|
-
create
|
|
2855
|
-
if (
|
|
2856
|
-
|
|
2857
|
-
var selection = document.getSelection();
|
|
2858
|
-
if (!selection || selection.rangeCount === 0) {
|
|
2859
|
-
return null;
|
|
2860
|
-
} else if (dom.isBody(selection.anchorNode)) {
|
|
2861
|
-
// Firefox: returns entire body as range on initialization. We won't never need it.
|
|
2862
|
-
return null;
|
|
2863
|
-
}
|
|
2864
|
-
|
|
2865
|
-
var nativeRng = selection.getRangeAt(0);
|
|
2866
|
-
sc = nativeRng.startContainer;
|
|
2867
|
-
so = nativeRng.startOffset;
|
|
2868
|
-
ec = nativeRng.endContainer;
|
|
2869
|
-
eo = nativeRng.endOffset;
|
|
2870
|
-
} else { // IE8: TextRange
|
|
2871
|
-
var textRange = document.selection.createRange();
|
|
2872
|
-
var textRangeEnd = textRange.duplicate();
|
|
2873
|
-
textRangeEnd.collapse(false);
|
|
2874
|
-
var textRangeStart = textRange;
|
|
2875
|
-
textRangeStart.collapse(true);
|
|
2876
|
-
|
|
2877
|
-
var startPoint = textRangeToPoint(textRangeStart, true),
|
|
2878
|
-
endPoint = textRangeToPoint(textRangeEnd, false);
|
|
2879
|
-
|
|
2880
|
-
// same visible point case: range was collapsed.
|
|
2881
|
-
if (dom.isText(startPoint.node) && dom.isLeftEdgePoint(startPoint) &&
|
|
2882
|
-
dom.isTextNode(endPoint.node) && dom.isRightEdgePoint(endPoint) &&
|
|
2883
|
-
endPoint.node.nextSibling === startPoint.node) {
|
|
2884
|
-
startPoint = endPoint;
|
|
2885
|
-
}
|
|
2886
|
-
|
|
2887
|
-
sc = startPoint.cont;
|
|
2888
|
-
so = startPoint.offset;
|
|
2889
|
-
ec = endPoint.cont;
|
|
2890
|
-
eo = endPoint.offset;
|
|
2891
|
-
}
|
|
2898
|
+
create: function (sc, so, ec, eo) {
|
|
2899
|
+
if (arguments.length === 4) {
|
|
2900
|
+
return new WrappedRange(sc, so, ec, eo);
|
|
2892
2901
|
} else if (arguments.length === 2) { //collapsed
|
|
2893
2902
|
ec = sc;
|
|
2894
2903
|
eo = so;
|
|
2904
|
+
return new WrappedRange(sc, so, ec, eo);
|
|
2905
|
+
} else {
|
|
2906
|
+
var wrappedRange = this.createFromSelection();
|
|
2907
|
+
if (!wrappedRange && arguments.length === 1) {
|
|
2908
|
+
wrappedRange = this.createFromNode(arguments[0]);
|
|
2909
|
+
return wrappedRange.collapse(dom.emptyPara === arguments[0].innerHTML);
|
|
2910
|
+
}
|
|
2911
|
+
return wrappedRange;
|
|
2912
|
+
}
|
|
2913
|
+
},
|
|
2914
|
+
|
|
2915
|
+
createFromSelection: function () {
|
|
2916
|
+
var sc, so, ec, eo;
|
|
2917
|
+
if (agent.isW3CRangeSupport) {
|
|
2918
|
+
var selection = document.getSelection();
|
|
2919
|
+
if (!selection || selection.rangeCount === 0) {
|
|
2920
|
+
return null;
|
|
2921
|
+
} else if (dom.isBody(selection.anchorNode)) {
|
|
2922
|
+
// Firefox: returns entire body as range on initialization.
|
|
2923
|
+
// We won't never need it.
|
|
2924
|
+
return null;
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2927
|
+
var nativeRng = selection.getRangeAt(0);
|
|
2928
|
+
sc = nativeRng.startContainer;
|
|
2929
|
+
so = nativeRng.startOffset;
|
|
2930
|
+
ec = nativeRng.endContainer;
|
|
2931
|
+
eo = nativeRng.endOffset;
|
|
2932
|
+
} else { // IE8: TextRange
|
|
2933
|
+
var textRange = document.selection.createRange();
|
|
2934
|
+
var textRangeEnd = textRange.duplicate();
|
|
2935
|
+
textRangeEnd.collapse(false);
|
|
2936
|
+
var textRangeStart = textRange;
|
|
2937
|
+
textRangeStart.collapse(true);
|
|
2938
|
+
|
|
2939
|
+
var startPoint = textRangeToPoint(textRangeStart, true),
|
|
2940
|
+
endPoint = textRangeToPoint(textRangeEnd, false);
|
|
2941
|
+
|
|
2942
|
+
// same visible point case: range was collapsed.
|
|
2943
|
+
if (dom.isText(startPoint.node) && dom.isLeftEdgePoint(startPoint) &&
|
|
2944
|
+
dom.isTextNode(endPoint.node) && dom.isRightEdgePoint(endPoint) &&
|
|
2945
|
+
endPoint.node.nextSibling === startPoint.node) {
|
|
2946
|
+
startPoint = endPoint;
|
|
2947
|
+
}
|
|
2948
|
+
|
|
2949
|
+
sc = startPoint.cont;
|
|
2950
|
+
so = startPoint.offset;
|
|
2951
|
+
ec = endPoint.cont;
|
|
2952
|
+
eo = endPoint.offset;
|
|
2895
2953
|
}
|
|
2954
|
+
|
|
2896
2955
|
return new WrappedRange(sc, so, ec, eo);
|
|
2897
2956
|
},
|
|
2898
2957
|
|
|
@@ -2955,7 +3014,7 @@
|
|
|
2955
3014
|
* @param {Object} bookmark
|
|
2956
3015
|
* @return {WrappedRange}
|
|
2957
3016
|
*/
|
|
2958
|
-
createFromBookmark
|
|
3017
|
+
createFromBookmark: function (editable, bookmark) {
|
|
2959
3018
|
var sc = dom.fromOffsetPath(editable, bookmark.s.path);
|
|
2960
3019
|
var so = bookmark.s.offset;
|
|
2961
3020
|
var ec = dom.fromOffsetPath(editable, bookmark.e.path);
|
|
@@ -3055,7 +3114,7 @@
|
|
|
3055
3114
|
var editable = $editable[0];
|
|
3056
3115
|
|
|
3057
3116
|
var makeSnapshot = function () {
|
|
3058
|
-
var rng = range.create();
|
|
3117
|
+
var rng = range.create(editable);
|
|
3059
3118
|
var emptyBookmark = {s: {path: [], offset: 0}, e: {path: [], offset: 0}};
|
|
3060
3119
|
|
|
3061
3120
|
return {
|
|
@@ -3079,7 +3138,6 @@
|
|
|
3079
3138
|
* Leaves the stack intact, so that "Redo" can still be used.
|
|
3080
3139
|
*/
|
|
3081
3140
|
this.rewind = function () {
|
|
3082
|
-
|
|
3083
3141
|
// Create snap shot if not yet recorded
|
|
3084
3142
|
if ($editable.html() !== stack[stackOffset].contents) {
|
|
3085
3143
|
this.recordUndo();
|
|
@@ -3090,16 +3148,13 @@
|
|
|
3090
3148
|
|
|
3091
3149
|
// Apply that snapshot.
|
|
3092
3150
|
applySnapshot(stack[stackOffset]);
|
|
3093
|
-
|
|
3094
3151
|
};
|
|
3095
3152
|
|
|
3096
|
-
|
|
3097
3153
|
/**
|
|
3098
3154
|
* @method reset
|
|
3099
3155
|
* Resets the history stack completely; reverting to an empty editor.
|
|
3100
3156
|
*/
|
|
3101
3157
|
this.reset = function () {
|
|
3102
|
-
|
|
3103
3158
|
// Clear the stack.
|
|
3104
3159
|
stack = [];
|
|
3105
3160
|
|
|
@@ -3111,7 +3166,6 @@
|
|
|
3111
3166
|
|
|
3112
3167
|
// Record our first snapshot (of nothing).
|
|
3113
3168
|
this.recordUndo();
|
|
3114
|
-
|
|
3115
3169
|
};
|
|
3116
3170
|
|
|
3117
3171
|
/**
|
|
@@ -3284,7 +3338,7 @@
|
|
|
3284
3338
|
'font-underline': document.queryCommandState('underline') ? 'underline' : 'normal',
|
|
3285
3339
|
'font-subscript': document.queryCommandState('subscript') ? 'subscript' : 'normal',
|
|
3286
3340
|
'font-superscript': document.queryCommandState('superscript') ? 'superscript' : 'normal',
|
|
3287
|
-
'font-strikethrough': document.queryCommandState('
|
|
3341
|
+
'font-strikethrough': document.queryCommandState('strikethrough') ? 'strikethrough' : 'normal'
|
|
3288
3342
|
});
|
|
3289
3343
|
} catch (e) {}
|
|
3290
3344
|
|
|
@@ -3320,38 +3374,28 @@
|
|
|
3320
3374
|
* @alternateClassName Bullet
|
|
3321
3375
|
*/
|
|
3322
3376
|
var Bullet = function () {
|
|
3377
|
+
var self = this;
|
|
3378
|
+
|
|
3323
3379
|
/**
|
|
3324
|
-
* @method insertOrderedList
|
|
3325
|
-
*
|
|
3326
3380
|
* toggle ordered list
|
|
3327
|
-
*
|
|
3328
|
-
* @type command
|
|
3329
3381
|
*/
|
|
3330
|
-
this.insertOrderedList = function () {
|
|
3331
|
-
this.toggleList('OL');
|
|
3382
|
+
this.insertOrderedList = function (editable) {
|
|
3383
|
+
this.toggleList('OL', editable);
|
|
3332
3384
|
};
|
|
3333
3385
|
|
|
3334
3386
|
/**
|
|
3335
|
-
* @method insertUnorderedList
|
|
3336
|
-
*
|
|
3337
3387
|
* toggle unordered list
|
|
3338
|
-
*
|
|
3339
|
-
* @type command
|
|
3340
3388
|
*/
|
|
3341
|
-
this.insertUnorderedList = function () {
|
|
3342
|
-
this.toggleList('UL');
|
|
3389
|
+
this.insertUnorderedList = function (editable) {
|
|
3390
|
+
this.toggleList('UL', editable);
|
|
3343
3391
|
};
|
|
3344
3392
|
|
|
3345
3393
|
/**
|
|
3346
|
-
* @method indent
|
|
3347
|
-
*
|
|
3348
3394
|
* indent
|
|
3349
|
-
*
|
|
3350
|
-
* @type command
|
|
3351
3395
|
*/
|
|
3352
|
-
this.indent = function () {
|
|
3396
|
+
this.indent = function (editable) {
|
|
3353
3397
|
var self = this;
|
|
3354
|
-
var rng = range.create().wrapBodyInlineWithPara();
|
|
3398
|
+
var rng = range.create(editable).wrapBodyInlineWithPara();
|
|
3355
3399
|
|
|
3356
3400
|
var paras = rng.nodes(dom.isPara, { includeAncestor: true });
|
|
3357
3401
|
var clustereds = list.clusterBy(paras, func.peq2('parentNode'));
|
|
@@ -3373,15 +3417,11 @@
|
|
|
3373
3417
|
};
|
|
3374
3418
|
|
|
3375
3419
|
/**
|
|
3376
|
-
* @method outdent
|
|
3377
|
-
*
|
|
3378
3420
|
* outdent
|
|
3379
|
-
*
|
|
3380
|
-
* @type command
|
|
3381
3421
|
*/
|
|
3382
|
-
this.outdent = function () {
|
|
3422
|
+
this.outdent = function (editable) {
|
|
3383
3423
|
var self = this;
|
|
3384
|
-
var rng = range.create().wrapBodyInlineWithPara();
|
|
3424
|
+
var rng = range.create(editable).wrapBodyInlineWithPara();
|
|
3385
3425
|
|
|
3386
3426
|
var paras = rng.nodes(dom.isPara, { includeAncestor: true });
|
|
3387
3427
|
var clustereds = list.clusterBy(paras, func.peq2('parentNode'));
|
|
@@ -3404,15 +3444,12 @@
|
|
|
3404
3444
|
};
|
|
3405
3445
|
|
|
3406
3446
|
/**
|
|
3407
|
-
* @method toggleList
|
|
3408
|
-
*
|
|
3409
3447
|
* toggle list
|
|
3410
3448
|
*
|
|
3411
3449
|
* @param {String} listName - OL or UL
|
|
3412
3450
|
*/
|
|
3413
|
-
this.toggleList = function (listName) {
|
|
3414
|
-
var
|
|
3415
|
-
var rng = range.create().wrapBodyInlineWithPara();
|
|
3451
|
+
this.toggleList = function (listName, editable) {
|
|
3452
|
+
var rng = range.create(editable).wrapBodyInlineWithPara();
|
|
3416
3453
|
|
|
3417
3454
|
var paras = rng.nodes(dom.isPara, { includeAncestor: true });
|
|
3418
3455
|
var bookmark = rng.paraBookmark(paras);
|
|
@@ -3446,8 +3483,6 @@
|
|
|
3446
3483
|
};
|
|
3447
3484
|
|
|
3448
3485
|
/**
|
|
3449
|
-
* @method wrapList
|
|
3450
|
-
*
|
|
3451
3486
|
* @param {Node[]} paras
|
|
3452
3487
|
* @param {String} listName
|
|
3453
3488
|
* @return {Node[]}
|
|
@@ -3554,11 +3589,10 @@
|
|
|
3554
3589
|
/**
|
|
3555
3590
|
* insert tab
|
|
3556
3591
|
*
|
|
3557
|
-
* @param {jQuery} $editable
|
|
3558
3592
|
* @param {WrappedRange} rng
|
|
3559
3593
|
* @param {Number} tabsize
|
|
3560
3594
|
*/
|
|
3561
|
-
this.insertTab = function (
|
|
3595
|
+
this.insertTab = function (rng, tabsize) {
|
|
3562
3596
|
var tab = dom.createText(new Array(tabsize + 1).join(dom.NBSP_CHAR));
|
|
3563
3597
|
rng = rng.deleteContents();
|
|
3564
3598
|
rng.insertNode(tab, true);
|
|
@@ -3570,8 +3604,8 @@
|
|
|
3570
3604
|
/**
|
|
3571
3605
|
* insert paragraph
|
|
3572
3606
|
*/
|
|
3573
|
-
this.insertParagraph = function (
|
|
3574
|
-
var rng = range.create();
|
|
3607
|
+
this.insertParagraph = function (editable) {
|
|
3608
|
+
var rng = range.create(editable);
|
|
3575
3609
|
|
|
3576
3610
|
// deleteContents on range.
|
|
3577
3611
|
rng = rng.deleteContents();
|
|
@@ -3622,7 +3656,7 @@
|
|
|
3622
3656
|
}
|
|
3623
3657
|
}
|
|
3624
3658
|
|
|
3625
|
-
range.create(nextPara, 0).normalize().select().scrollIntoView(
|
|
3659
|
+
range.create(nextPara, 0).normalize().select().scrollIntoView(editable);
|
|
3626
3660
|
};
|
|
3627
3661
|
};
|
|
3628
3662
|
|
|
@@ -3693,6 +3727,9 @@
|
|
|
3693
3727
|
var options = context.options;
|
|
3694
3728
|
var lang = options.langInfo;
|
|
3695
3729
|
|
|
3730
|
+
var editable = $editable[0];
|
|
3731
|
+
var lastRange = null;
|
|
3732
|
+
|
|
3696
3733
|
var style = new Style();
|
|
3697
3734
|
var table = new Table();
|
|
3698
3735
|
var typing = new Typing();
|
|
@@ -3726,6 +3763,9 @@
|
|
|
3726
3763
|
context.triggerEvent('paste', event);
|
|
3727
3764
|
});
|
|
3728
3765
|
|
|
3766
|
+
// init content before set event
|
|
3767
|
+
$editable.html(dom.html($note) || dom.emptyPara);
|
|
3768
|
+
|
|
3729
3769
|
// [workaround] IE doesn't have input events for contentEditable
|
|
3730
3770
|
// - see: https://goo.gl/4bfIvA
|
|
3731
3771
|
var changeEventName = agent.isMSIE ? 'DOMCharacterDataModified DOMSubtreeModified DOMNodeInserted' : 'input';
|
|
@@ -3740,7 +3780,7 @@
|
|
|
3740
3780
|
});
|
|
3741
3781
|
|
|
3742
3782
|
if (!options.airMode && options.height) {
|
|
3743
|
-
|
|
3783
|
+
this.setHeight(options.height);
|
|
3744
3784
|
}
|
|
3745
3785
|
if (!options.airMode && options.maxHeight) {
|
|
3746
3786
|
$editable.css('max-height', options.maxHeight);
|
|
@@ -3749,7 +3789,6 @@
|
|
|
3749
3789
|
$editable.css('min-height', options.minHeight);
|
|
3750
3790
|
}
|
|
3751
3791
|
|
|
3752
|
-
$editable.html(dom.html($note) || dom.emptyPara);
|
|
3753
3792
|
history.recordUndo();
|
|
3754
3793
|
};
|
|
3755
3794
|
|
|
@@ -3780,14 +3819,12 @@
|
|
|
3780
3819
|
};
|
|
3781
3820
|
|
|
3782
3821
|
/**
|
|
3783
|
-
* createRange
|
|
3784
|
-
*
|
|
3785
3822
|
* create range
|
|
3786
3823
|
* @return {WrappedRange}
|
|
3787
3824
|
*/
|
|
3788
3825
|
this.createRange = function () {
|
|
3789
3826
|
this.focus();
|
|
3790
|
-
return range.create();
|
|
3827
|
+
return range.create(editable);
|
|
3791
3828
|
};
|
|
3792
3829
|
|
|
3793
3830
|
/**
|
|
@@ -3798,10 +3835,9 @@
|
|
|
3798
3835
|
* @param {Boolean} [thenCollapse=false]
|
|
3799
3836
|
*/
|
|
3800
3837
|
this.saveRange = function (thenCollapse) {
|
|
3801
|
-
this.
|
|
3802
|
-
$editable.data('range', range.create());
|
|
3838
|
+
lastRange = this.createRange();
|
|
3803
3839
|
if (thenCollapse) {
|
|
3804
|
-
|
|
3840
|
+
lastRange.collapse().select();
|
|
3805
3841
|
}
|
|
3806
3842
|
};
|
|
3807
3843
|
|
|
@@ -3811,9 +3847,8 @@
|
|
|
3811
3847
|
* restore lately range
|
|
3812
3848
|
*/
|
|
3813
3849
|
this.restoreRange = function () {
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
rng.select();
|
|
3850
|
+
if (lastRange) {
|
|
3851
|
+
lastRange.select();
|
|
3817
3852
|
this.focus();
|
|
3818
3853
|
}
|
|
3819
3854
|
};
|
|
@@ -3875,7 +3910,6 @@
|
|
|
3875
3910
|
context.memo('help.redo', lang.help.redo);
|
|
3876
3911
|
|
|
3877
3912
|
/**
|
|
3878
|
-
* beforeCommand
|
|
3879
3913
|
* before command
|
|
3880
3914
|
*/
|
|
3881
3915
|
var beforeCommand = this.beforeCommand = function () {
|
|
@@ -3885,7 +3919,6 @@
|
|
|
3885
3919
|
};
|
|
3886
3920
|
|
|
3887
3921
|
/**
|
|
3888
|
-
* afterCommand
|
|
3889
3922
|
* after command
|
|
3890
3923
|
* @param {Boolean} isPreventTrigger
|
|
3891
3924
|
*/
|
|
@@ -3916,8 +3949,6 @@
|
|
|
3916
3949
|
/* jshint ignore:end */
|
|
3917
3950
|
|
|
3918
3951
|
/**
|
|
3919
|
-
* tab
|
|
3920
|
-
*
|
|
3921
3952
|
* handle tab key
|
|
3922
3953
|
*/
|
|
3923
3954
|
this.tab = function () {
|
|
@@ -3926,17 +3957,14 @@
|
|
|
3926
3957
|
table.tab(rng);
|
|
3927
3958
|
} else {
|
|
3928
3959
|
beforeCommand();
|
|
3929
|
-
typing.insertTab(
|
|
3960
|
+
typing.insertTab(rng, options.tabSize);
|
|
3930
3961
|
afterCommand();
|
|
3931
3962
|
}
|
|
3932
3963
|
};
|
|
3933
3964
|
context.memo('help.tab', lang.help.tab);
|
|
3934
3965
|
|
|
3935
3966
|
/**
|
|
3936
|
-
* untab
|
|
3937
|
-
*
|
|
3938
3967
|
* handle shift+tab key
|
|
3939
|
-
*
|
|
3940
3968
|
*/
|
|
3941
3969
|
this.untab = function () {
|
|
3942
3970
|
var rng = this.createRange();
|
|
@@ -3947,8 +3975,6 @@
|
|
|
3947
3975
|
context.memo('help.untab', lang.help.untab);
|
|
3948
3976
|
|
|
3949
3977
|
/**
|
|
3950
|
-
* wrapCommand
|
|
3951
|
-
*
|
|
3952
3978
|
* run given function between beforeCommand and afterCommand
|
|
3953
3979
|
*/
|
|
3954
3980
|
this.wrapCommand = function (fn) {
|
|
@@ -3960,35 +3986,30 @@
|
|
|
3960
3986
|
};
|
|
3961
3987
|
|
|
3962
3988
|
/**
|
|
3963
|
-
* insertParagraph
|
|
3964
|
-
*
|
|
3965
3989
|
* insert paragraph
|
|
3966
3990
|
*/
|
|
3967
3991
|
this.insertParagraph = this.wrapCommand(function () {
|
|
3968
|
-
typing.insertParagraph(
|
|
3992
|
+
typing.insertParagraph(editable);
|
|
3969
3993
|
});
|
|
3970
3994
|
context.memo('help.insertParagraph', lang.help.insertParagraph);
|
|
3971
3995
|
|
|
3972
|
-
/**
|
|
3973
|
-
* insertOrderedList
|
|
3974
|
-
*/
|
|
3975
3996
|
this.insertOrderedList = this.wrapCommand(function () {
|
|
3976
|
-
bullet.insertOrderedList(
|
|
3997
|
+
bullet.insertOrderedList(editable);
|
|
3977
3998
|
});
|
|
3978
3999
|
context.memo('help.insertOrderedList', lang.help.insertOrderedList);
|
|
3979
4000
|
|
|
3980
4001
|
this.insertUnorderedList = this.wrapCommand(function () {
|
|
3981
|
-
bullet.insertUnorderedList(
|
|
4002
|
+
bullet.insertUnorderedList(editable);
|
|
3982
4003
|
});
|
|
3983
4004
|
context.memo('help.insertUnorderedList', lang.help.insertUnorderedList);
|
|
3984
4005
|
|
|
3985
4006
|
this.indent = this.wrapCommand(function () {
|
|
3986
|
-
bullet.indent(
|
|
4007
|
+
bullet.indent(editable);
|
|
3987
4008
|
});
|
|
3988
4009
|
context.memo('help.indent', lang.help.indent);
|
|
3989
4010
|
|
|
3990
4011
|
this.outdent = this.wrapCommand(function () {
|
|
3991
|
-
bullet.outdent(
|
|
4012
|
+
bullet.outdent(editable);
|
|
3992
4013
|
});
|
|
3993
4014
|
context.memo('help.outdent', lang.help.outdent);
|
|
3994
4015
|
|
|
@@ -4013,11 +4034,11 @@
|
|
|
4013
4034
|
}
|
|
4014
4035
|
|
|
4015
4036
|
$image.show();
|
|
4016
|
-
range.create().insertNode($image[0]);
|
|
4037
|
+
range.create(editable).insertNode($image[0]);
|
|
4017
4038
|
range.createFromNodeAfter($image[0]).select();
|
|
4018
4039
|
afterCommand();
|
|
4019
|
-
}).fail(function () {
|
|
4020
|
-
context.triggerEvent('image.upload.error');
|
|
4040
|
+
}).fail(function (e) {
|
|
4041
|
+
context.triggerEvent('image.upload.error', e);
|
|
4021
4042
|
});
|
|
4022
4043
|
};
|
|
4023
4044
|
|
|
@@ -4062,7 +4083,8 @@
|
|
|
4062
4083
|
* @param {Node} node
|
|
4063
4084
|
*/
|
|
4064
4085
|
this.insertNode = this.wrapCommand(function (node) {
|
|
4065
|
-
|
|
4086
|
+
var rng = this.createRange();
|
|
4087
|
+
rng.insertNode(node);
|
|
4066
4088
|
range.createFromNodeAfter(node).select();
|
|
4067
4089
|
});
|
|
4068
4090
|
|
|
@@ -4071,7 +4093,8 @@
|
|
|
4071
4093
|
* @param {String} text
|
|
4072
4094
|
*/
|
|
4073
4095
|
this.insertText = this.wrapCommand(function (text) {
|
|
4074
|
-
var
|
|
4096
|
+
var rng = this.createRange();
|
|
4097
|
+
var textNode = rng.insertNode(dom.createText(text));
|
|
4075
4098
|
range.create(textNode, dom.nodeLength(textNode)).select();
|
|
4076
4099
|
});
|
|
4077
4100
|
|
|
@@ -4095,7 +4118,7 @@
|
|
|
4095
4118
|
* @param {String} markup
|
|
4096
4119
|
*/
|
|
4097
4120
|
this.pasteHTML = this.wrapCommand(function (markup) {
|
|
4098
|
-
var contents =
|
|
4121
|
+
var contents = this.createRange().pasteHTML(markup);
|
|
4099
4122
|
range.createFromNodeAfter(list.last(contents)).select();
|
|
4100
4123
|
});
|
|
4101
4124
|
|
|
@@ -4126,15 +4149,13 @@
|
|
|
4126
4149
|
};
|
|
4127
4150
|
/* jshint ignore:end */
|
|
4128
4151
|
|
|
4129
|
-
|
|
4130
4152
|
/**
|
|
4131
4153
|
* fontSize
|
|
4132
4154
|
*
|
|
4133
4155
|
* @param {String} value - px
|
|
4134
4156
|
*/
|
|
4135
4157
|
this.fontSize = function (value) {
|
|
4136
|
-
this.
|
|
4137
|
-
var rng = range.create();
|
|
4158
|
+
var rng = this.createRange();
|
|
4138
4159
|
|
|
4139
4160
|
if (rng && rng.isCollapsed()) {
|
|
4140
4161
|
var spans = style.styleNodes(rng);
|
|
@@ -4164,15 +4185,13 @@
|
|
|
4164
4185
|
* insert horizontal rule
|
|
4165
4186
|
*/
|
|
4166
4187
|
this.insertHorizontalRule = this.wrapCommand(function () {
|
|
4167
|
-
var
|
|
4168
|
-
var hrNode = rng.insertNode($('<HR/>')[0]);
|
|
4188
|
+
var hrNode = this.createRange().insertNode(dom.create('HR'));
|
|
4169
4189
|
if (hrNode.nextSibling) {
|
|
4170
4190
|
range.create(hrNode.nextSibling, 0).normalize().select();
|
|
4171
4191
|
}
|
|
4172
4192
|
});
|
|
4173
4193
|
context.memo('help.insertHorizontalRule', lang.help.insertHorizontalRule);
|
|
4174
4194
|
|
|
4175
|
-
|
|
4176
4195
|
/**
|
|
4177
4196
|
* remove bogus node and character
|
|
4178
4197
|
*/
|
|
@@ -4201,7 +4220,7 @@
|
|
|
4201
4220
|
* @param {String} value
|
|
4202
4221
|
*/
|
|
4203
4222
|
this.lineHeight = this.wrapCommand(function (value) {
|
|
4204
|
-
style.stylePara(
|
|
4223
|
+
style.stylePara(this.createRange(), {
|
|
4205
4224
|
lineHeight: value
|
|
4206
4225
|
});
|
|
4207
4226
|
});
|
|
@@ -4242,7 +4261,7 @@
|
|
|
4242
4261
|
|
|
4243
4262
|
var anchors = [];
|
|
4244
4263
|
if (isTextChanged) {
|
|
4245
|
-
|
|
4264
|
+
rng = rng.deleteContents();
|
|
4246
4265
|
var anchor = rng.insertNode($('<A>' + linkText + '</A>')[0]);
|
|
4247
4266
|
anchors.push(anchor);
|
|
4248
4267
|
} else {
|
|
@@ -4285,9 +4304,7 @@
|
|
|
4285
4304
|
* @return {String} [return.url=""]
|
|
4286
4305
|
*/
|
|
4287
4306
|
this.getLinkInfo = function () {
|
|
4288
|
-
this.
|
|
4289
|
-
|
|
4290
|
-
var rng = range.create().expand(dom.isAnchor);
|
|
4307
|
+
var rng = this.createRange().expand(dom.isAnchor);
|
|
4291
4308
|
|
|
4292
4309
|
// Get the first anchor on range(for edit).
|
|
4293
4310
|
var $anchor = $(list.head(rng.nodes(dom.isAnchor)));
|
|
@@ -4318,12 +4335,12 @@
|
|
|
4318
4335
|
/**
|
|
4319
4336
|
* insert Table
|
|
4320
4337
|
*
|
|
4321
|
-
* @param {String}
|
|
4338
|
+
* @param {String} dimension of table (ex : "5x5")
|
|
4322
4339
|
*/
|
|
4323
|
-
this.insertTable = this.wrapCommand(function (
|
|
4324
|
-
var dimension =
|
|
4340
|
+
this.insertTable = this.wrapCommand(function (dim) {
|
|
4341
|
+
var dimension = dim.split('x');
|
|
4325
4342
|
|
|
4326
|
-
var rng =
|
|
4343
|
+
var rng = this.createRange().deleteContents();
|
|
4327
4344
|
rng.insertNode(table.createTable(dimension[0], dimension[1], options));
|
|
4328
4345
|
});
|
|
4329
4346
|
|
|
@@ -4381,22 +4398,21 @@
|
|
|
4381
4398
|
context.triggerEvent('media.delete', $target, $editable);
|
|
4382
4399
|
});
|
|
4383
4400
|
|
|
4401
|
+
/**
|
|
4402
|
+
* returns whether editable area has focus or not.
|
|
4403
|
+
*/
|
|
4404
|
+
this.hasFocus = function () {
|
|
4405
|
+
return $editable.is(':focus');
|
|
4406
|
+
};
|
|
4407
|
+
|
|
4384
4408
|
/**
|
|
4385
4409
|
* set focus
|
|
4386
4410
|
*/
|
|
4387
4411
|
this.focus = function () {
|
|
4388
4412
|
// [workaround] Screen will move when page is scolled in IE.
|
|
4389
4413
|
// - do focus when not focused
|
|
4390
|
-
if (
|
|
4414
|
+
if (!this.hasFocus()) {
|
|
4391
4415
|
$editable.focus();
|
|
4392
|
-
|
|
4393
|
-
// [workaround] for firefox bug http://goo.gl/lVfAaI
|
|
4394
|
-
if (!$editable.is(':focus') && agent.isFF) {
|
|
4395
|
-
range.createFromNode($editable[0])
|
|
4396
|
-
.normalize()
|
|
4397
|
-
.collapse()
|
|
4398
|
-
.select();
|
|
4399
|
-
}
|
|
4400
4416
|
}
|
|
4401
4417
|
};
|
|
4402
4418
|
|
|
@@ -4407,6 +4423,20 @@
|
|
|
4407
4423
|
this.isEmpty = function () {
|
|
4408
4424
|
return dom.isEmpty($editable[0]) || dom.emptyPara === $editable.html();
|
|
4409
4425
|
};
|
|
4426
|
+
|
|
4427
|
+
/**
|
|
4428
|
+
* Removes all contents and restores the editable instance to an _emptyPara_.
|
|
4429
|
+
*/
|
|
4430
|
+
this.empty = function () {
|
|
4431
|
+
context.invoke('code', dom.emptyPara);
|
|
4432
|
+
};
|
|
4433
|
+
|
|
4434
|
+
/**
|
|
4435
|
+
* set height for editable
|
|
4436
|
+
*/
|
|
4437
|
+
this.setHeight = function (height) {
|
|
4438
|
+
$editable.outerHeight(height);
|
|
4439
|
+
};
|
|
4410
4440
|
};
|
|
4411
4441
|
|
|
4412
4442
|
var Clipboard = function (context) {
|
|
@@ -4439,9 +4469,9 @@
|
|
|
4439
4469
|
// - Webkit: event.clipboardData
|
|
4440
4470
|
if (this.needKeydownHook()) {
|
|
4441
4471
|
this.$paste = $('<div />').attr('contenteditable', true).css({
|
|
4442
|
-
position
|
|
4443
|
-
left
|
|
4444
|
-
opacity
|
|
4472
|
+
position: 'absolute',
|
|
4473
|
+
left: -100000,
|
|
4474
|
+
opacity: 0
|
|
4445
4475
|
});
|
|
4446
4476
|
$editable.before(this.$paste);
|
|
4447
4477
|
|
|
@@ -4471,7 +4501,7 @@
|
|
|
4471
4501
|
array[i] = decodedData.charCodeAt(i);
|
|
4472
4502
|
}
|
|
4473
4503
|
|
|
4474
|
-
var blob = new Blob([array], { type
|
|
4504
|
+
var blob = new Blob([array], { type: 'image/png' });
|
|
4475
4505
|
blob.name = 'clipboard.png';
|
|
4476
4506
|
|
|
4477
4507
|
context.invoke('editor.restoreRange');
|
|
@@ -4767,8 +4797,7 @@
|
|
|
4767
4797
|
};
|
|
4768
4798
|
|
|
4769
4799
|
$editor.toggleClass('fullscreen');
|
|
4770
|
-
|
|
4771
|
-
if (isFullscreen) {
|
|
4800
|
+
if (this.isFullscreen()) {
|
|
4772
4801
|
$editable.data('orgHeight', $editable.css('height'));
|
|
4773
4802
|
|
|
4774
4803
|
$window.on('resize', function () {
|
|
@@ -4786,7 +4815,11 @@
|
|
|
4786
4815
|
$scrollbar.css('overflow', 'visible');
|
|
4787
4816
|
}
|
|
4788
4817
|
|
|
4789
|
-
context.invoke('toolbar.updateFullscreen', isFullscreen);
|
|
4818
|
+
context.invoke('toolbar.updateFullscreen', this.isFullscreen());
|
|
4819
|
+
};
|
|
4820
|
+
|
|
4821
|
+
this.isFullscreen = function () {
|
|
4822
|
+
return $editor.hasClass('fullscreen');
|
|
4790
4823
|
};
|
|
4791
4824
|
};
|
|
4792
4825
|
|
|
@@ -4904,8 +4937,8 @@
|
|
|
4904
4937
|
|
|
4905
4938
|
var AutoLink = function (context) {
|
|
4906
4939
|
var self = this;
|
|
4907
|
-
|
|
4908
|
-
var linkPattern = /^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|
|
|
4940
|
+
var defaultScheme = 'http://';
|
|
4941
|
+
var linkPattern = /^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|mailto:[A-Z0-9._%+-]+@)?(www\.)?(.+)$/i;
|
|
4909
4942
|
|
|
4910
4943
|
this.events = {
|
|
4911
4944
|
'summernote.keyup': function (we, e) {
|
|
@@ -4932,9 +4965,11 @@
|
|
|
4932
4965
|
}
|
|
4933
4966
|
|
|
4934
4967
|
var keyword = this.lastWordRange.toString();
|
|
4968
|
+
var match = keyword.match(linkPattern);
|
|
4935
4969
|
|
|
4936
|
-
if (
|
|
4937
|
-
var
|
|
4970
|
+
if (match && (match[1] || match[2])) {
|
|
4971
|
+
var link = match[1] ? keyword : defaultScheme + keyword;
|
|
4972
|
+
var node = $('<a />').html(keyword).attr('href', link)[0];
|
|
4938
4973
|
|
|
4939
4974
|
this.lastWordRange.insertNode(node);
|
|
4940
4975
|
this.lastWordRange = null;
|
|
@@ -4943,10 +4978,6 @@
|
|
|
4943
4978
|
|
|
4944
4979
|
};
|
|
4945
4980
|
|
|
4946
|
-
this.nodeFromKeyword = function (keyword) {
|
|
4947
|
-
return $('<a />').html(keyword).attr('href', keyword)[0];
|
|
4948
|
-
};
|
|
4949
|
-
|
|
4950
4981
|
this.handleKeydown = function (e) {
|
|
4951
4982
|
if (list.contains([key.code.ENTER, key.code.SPACE], e.keyCode)) {
|
|
4952
4983
|
var wordRange = context.invoke('editor.createRange').getWordRange();
|
|
@@ -5041,6 +5072,20 @@
|
|
|
5041
5072
|
this.addToolbarButtons();
|
|
5042
5073
|
this.addImagePopoverButtons();
|
|
5043
5074
|
this.addLinkPopoverButtons();
|
|
5075
|
+
this.fontInstalledMap = {};
|
|
5076
|
+
};
|
|
5077
|
+
|
|
5078
|
+
this.destroy = function () {
|
|
5079
|
+
delete this.fontInstalledMap;
|
|
5080
|
+
};
|
|
5081
|
+
|
|
5082
|
+
this.isFontInstalled = function (name) {
|
|
5083
|
+
if (!self.fontInstalledMap.hasOwnProperty(name)) {
|
|
5084
|
+
self.fontInstalledMap[name] = agent.isFontInstalled(name) ||
|
|
5085
|
+
list.contains(options.fontNamesIgnoreCheck, name);
|
|
5086
|
+
}
|
|
5087
|
+
|
|
5088
|
+
return self.fontInstalledMap[name];
|
|
5044
5089
|
};
|
|
5045
5090
|
|
|
5046
5091
|
this.addToolbarButtons = function () {
|
|
@@ -5057,6 +5102,19 @@
|
|
|
5057
5102
|
ui.dropdown({
|
|
5058
5103
|
className: 'dropdown-style',
|
|
5059
5104
|
items: context.options.styleTags,
|
|
5105
|
+
template: function (item) {
|
|
5106
|
+
|
|
5107
|
+
if (typeof item === 'string') {
|
|
5108
|
+
item = { tag: item, title: item };
|
|
5109
|
+
}
|
|
5110
|
+
|
|
5111
|
+
var tag = item.tag;
|
|
5112
|
+
var title = item.title;
|
|
5113
|
+
var style = item.style ? ' style="' + item.style + '" ' : '';
|
|
5114
|
+
var className = item.className ? ' className="' + item.className + '"' : '';
|
|
5115
|
+
|
|
5116
|
+
return '<' + tag + style + className + '>' + title + '</' + tag + '>';
|
|
5117
|
+
},
|
|
5060
5118
|
click: context.createInvokeHandler('editor.formatBlock')
|
|
5061
5119
|
})
|
|
5062
5120
|
]).render();
|
|
@@ -5099,6 +5157,7 @@
|
|
|
5099
5157
|
|
|
5100
5158
|
context.memo('button.strikethrough', function () {
|
|
5101
5159
|
return ui.button({
|
|
5160
|
+
className: 'note-btn-strikethrough',
|
|
5102
5161
|
contents: ui.icon(options.icons.strikethrough),
|
|
5103
5162
|
tooltip: lang.font.strikethrough + representShortcut('strikethrough'),
|
|
5104
5163
|
click: context.createInvokeHandler('editor.strikethrough')
|
|
@@ -5107,6 +5166,7 @@
|
|
|
5107
5166
|
|
|
5108
5167
|
context.memo('button.superscript', function () {
|
|
5109
5168
|
return ui.button({
|
|
5169
|
+
className: 'note-btn-superscript',
|
|
5110
5170
|
contents: ui.icon(options.icons.superscript),
|
|
5111
5171
|
tooltip: lang.font.superscript,
|
|
5112
5172
|
click: context.createInvokeHandler('editor.superscript')
|
|
@@ -5115,6 +5175,7 @@
|
|
|
5115
5175
|
|
|
5116
5176
|
context.memo('button.subscript', function () {
|
|
5117
5177
|
return ui.button({
|
|
5178
|
+
className: 'note-btn-subscript',
|
|
5118
5179
|
contents: ui.icon(options.icons.subscript),
|
|
5119
5180
|
tooltip: lang.font.subscript,
|
|
5120
5181
|
click: context.createInvokeHandler('editor.subscript')
|
|
@@ -5133,11 +5194,11 @@
|
|
|
5133
5194
|
}),
|
|
5134
5195
|
ui.dropdownCheck({
|
|
5135
5196
|
className: 'dropdown-fontname',
|
|
5136
|
-
checkClassName
|
|
5137
|
-
items: options.fontNames.filter(
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
}
|
|
5197
|
+
checkClassName: options.icons.menuCheck,
|
|
5198
|
+
items: options.fontNames.filter(self.isFontInstalled),
|
|
5199
|
+
template: function (item) {
|
|
5200
|
+
return '<span style="font-family:' + item + '">' + item + '</span>';
|
|
5201
|
+
},
|
|
5141
5202
|
click: context.createInvokeHandler('editor.fontName')
|
|
5142
5203
|
})
|
|
5143
5204
|
]).render();
|
|
@@ -5155,7 +5216,7 @@
|
|
|
5155
5216
|
}),
|
|
5156
5217
|
ui.dropdownCheck({
|
|
5157
5218
|
className: 'dropdown-fontsize',
|
|
5158
|
-
checkClassName
|
|
5219
|
+
checkClassName: options.icons.menuCheck,
|
|
5159
5220
|
items: options.fontSizes,
|
|
5160
5221
|
click: context.createInvokeHandler('editor.fontSize')
|
|
5161
5222
|
})
|
|
@@ -5167,19 +5228,20 @@
|
|
|
5167
5228
|
className: 'note-color',
|
|
5168
5229
|
children: [
|
|
5169
5230
|
ui.button({
|
|
5170
|
-
className
|
|
5231
|
+
className: 'note-current-color-button',
|
|
5171
5232
|
contents: ui.icon(options.icons.font + ' note-recent-color'),
|
|
5172
5233
|
tooltip: lang.color.recent,
|
|
5173
|
-
click:
|
|
5234
|
+
click: function (e) {
|
|
5235
|
+
var $button = $(e.currentTarget);
|
|
5236
|
+
context.invoke('editor.color', {
|
|
5237
|
+
backColor: $button.attr('data-backColor'),
|
|
5238
|
+
foreColor: $button.attr('data-foreColor')
|
|
5239
|
+
});
|
|
5240
|
+
},
|
|
5174
5241
|
callback: function ($button) {
|
|
5175
5242
|
var $recentColor = $button.find('.note-recent-color');
|
|
5176
|
-
$recentColor.css(
|
|
5177
|
-
|
|
5178
|
-
});
|
|
5179
|
-
|
|
5180
|
-
$button.data('value', {
|
|
5181
|
-
backColor: 'yellow'
|
|
5182
|
-
});
|
|
5243
|
+
$recentColor.css('background-color', '#FFFF00');
|
|
5244
|
+
$button.attr('data-backColor', '#FFFF00');
|
|
5183
5245
|
}
|
|
5184
5246
|
}),
|
|
5185
5247
|
ui.button({
|
|
@@ -5196,7 +5258,7 @@
|
|
|
5196
5258
|
'<div class="btn-group">',
|
|
5197
5259
|
' <div class="note-palette-title">' + lang.color.background + '</div>',
|
|
5198
5260
|
' <div>',
|
|
5199
|
-
' <button class="note-color-reset btn btn-default" data-event="backColor" data-value="inherit">',
|
|
5261
|
+
' <button type="button" class="note-color-reset btn btn-default" data-event="backColor" data-value="inherit">',
|
|
5200
5262
|
lang.color.transparent,
|
|
5201
5263
|
' </button>',
|
|
5202
5264
|
' </div>',
|
|
@@ -5205,7 +5267,7 @@
|
|
|
5205
5267
|
'<div class="btn-group">',
|
|
5206
5268
|
' <div class="note-palette-title">' + lang.color.foreground + '</div>',
|
|
5207
5269
|
' <div>',
|
|
5208
|
-
' <button class="note-color-reset btn btn-default" data-event="removeFormat" data-value="foreColor">',
|
|
5270
|
+
' <button type="button" class="note-color-reset btn btn-default" data-event="removeFormat" data-value="foreColor">',
|
|
5209
5271
|
lang.color.resetToDefault,
|
|
5210
5272
|
' </button>',
|
|
5211
5273
|
' </div>',
|
|
@@ -5232,11 +5294,8 @@
|
|
|
5232
5294
|
var $color = $button.closest('.note-color').find('.note-recent-color');
|
|
5233
5295
|
var $currentButton = $button.closest('.note-color').find('.note-current-color-button');
|
|
5234
5296
|
|
|
5235
|
-
var colorInfo = $currentButton.data('value');
|
|
5236
|
-
colorInfo[eventName] = value;
|
|
5237
5297
|
$color.css(key, value);
|
|
5238
|
-
$currentButton.
|
|
5239
|
-
|
|
5298
|
+
$currentButton.attr('data-' + eventName, value);
|
|
5240
5299
|
context.invoke('editor.' + eventName, value);
|
|
5241
5300
|
}
|
|
5242
5301
|
}
|
|
@@ -5245,7 +5304,7 @@
|
|
|
5245
5304
|
}).render();
|
|
5246
5305
|
});
|
|
5247
5306
|
|
|
5248
|
-
context.memo('button.
|
|
5307
|
+
context.memo('button.ul', function () {
|
|
5249
5308
|
return ui.button({
|
|
5250
5309
|
contents: ui.icon(options.icons.unorderedlist),
|
|
5251
5310
|
tooltip: lang.lists.unordered + representShortcut('insertUnorderedList'),
|
|
@@ -5253,7 +5312,7 @@
|
|
|
5253
5312
|
}).render();
|
|
5254
5313
|
});
|
|
5255
5314
|
|
|
5256
|
-
context.memo('button.
|
|
5315
|
+
context.memo('button.ol', function () {
|
|
5257
5316
|
return ui.button({
|
|
5258
5317
|
contents: ui.icon(options.icons.orderedlist),
|
|
5259
5318
|
tooltip: lang.lists.ordered + representShortcut('insertOrderedList'),
|
|
@@ -5261,11 +5320,54 @@
|
|
|
5261
5320
|
}).render();
|
|
5262
5321
|
});
|
|
5263
5322
|
|
|
5323
|
+
var justifyLeft = ui.button({
|
|
5324
|
+
contents: ui.icon(options.icons.alignLeft),
|
|
5325
|
+
tooltip: lang.paragraph.left + representShortcut('justifyLeft'),
|
|
5326
|
+
click: context.createInvokeHandler('editor.justifyLeft')
|
|
5327
|
+
});
|
|
5328
|
+
|
|
5329
|
+
var justifyCenter = ui.button({
|
|
5330
|
+
contents: ui.icon(options.icons.alignCenter),
|
|
5331
|
+
tooltip: lang.paragraph.center + representShortcut('justifyCenter'),
|
|
5332
|
+
click: context.createInvokeHandler('editor.justifyCenter')
|
|
5333
|
+
});
|
|
5334
|
+
|
|
5335
|
+
var justifyRight = ui.button({
|
|
5336
|
+
contents: ui.icon(options.icons.alignRight),
|
|
5337
|
+
tooltip: lang.paragraph.right + representShortcut('justifyRight'),
|
|
5338
|
+
click: context.createInvokeHandler('editor.justifyRight')
|
|
5339
|
+
});
|
|
5340
|
+
|
|
5341
|
+
var justifyFull = ui.button({
|
|
5342
|
+
contents: ui.icon(options.icons.alignJustify),
|
|
5343
|
+
tooltip: lang.paragraph.justify + representShortcut('justifyFull'),
|
|
5344
|
+
click: context.createInvokeHandler('editor.justifyFull')
|
|
5345
|
+
});
|
|
5346
|
+
|
|
5347
|
+
var outdent = ui.button({
|
|
5348
|
+
contents: ui.icon(options.icons.outdent),
|
|
5349
|
+
tooltip: lang.paragraph.outdent + representShortcut('outdent'),
|
|
5350
|
+
click: context.createInvokeHandler('editor.outdent')
|
|
5351
|
+
});
|
|
5352
|
+
|
|
5353
|
+
var indent = ui.button({
|
|
5354
|
+
contents: ui.icon(options.icons.indent),
|
|
5355
|
+
tooltip: lang.paragraph.indent + representShortcut('indent'),
|
|
5356
|
+
click: context.createInvokeHandler('editor.indent')
|
|
5357
|
+
});
|
|
5358
|
+
|
|
5359
|
+
context.memo('button.justifyLeft', func.invoke(justifyLeft, 'render'));
|
|
5360
|
+
context.memo('button.justifyCenter', func.invoke(justifyCenter, 'render'));
|
|
5361
|
+
context.memo('button.justifyRight', func.invoke(justifyRight, 'render'));
|
|
5362
|
+
context.memo('button.justifyFull', func.invoke(justifyFull, 'render'));
|
|
5363
|
+
context.memo('button.outdent', func.invoke(outdent, 'render'));
|
|
5364
|
+
context.memo('button.indent', func.invoke(indent, 'render'));
|
|
5365
|
+
|
|
5264
5366
|
context.memo('button.paragraph', function () {
|
|
5265
5367
|
return ui.buttonGroup([
|
|
5266
5368
|
ui.button({
|
|
5267
5369
|
className: 'dropdown-toggle',
|
|
5268
|
-
contents: ui.icon(options.icons.
|
|
5370
|
+
contents: ui.icon(options.icons.alignLeft) + ' ' + ui.icon(options.icons.caret, 'span'),
|
|
5269
5371
|
tooltip: lang.paragraph.paragraph,
|
|
5270
5372
|
data: {
|
|
5271
5373
|
toggle: 'dropdown'
|
|
@@ -5274,43 +5376,11 @@
|
|
|
5274
5376
|
ui.dropdown([
|
|
5275
5377
|
ui.buttonGroup({
|
|
5276
5378
|
className: 'note-align',
|
|
5277
|
-
children: [
|
|
5278
|
-
ui.button({
|
|
5279
|
-
contents: ui.icon(options.icons.alignLeft),
|
|
5280
|
-
tooltip: lang.paragraph.left + representShortcut('justifyLeft'),
|
|
5281
|
-
click: context.createInvokeHandler('editor.justifyLeft')
|
|
5282
|
-
}),
|
|
5283
|
-
ui.button({
|
|
5284
|
-
contents: ui.icon(options.icons.alignCenter),
|
|
5285
|
-
tooltip: lang.paragraph.center + representShortcut('justifyCenter'),
|
|
5286
|
-
click: context.createInvokeHandler('editor.justifyCenter')
|
|
5287
|
-
}),
|
|
5288
|
-
ui.button({
|
|
5289
|
-
contents: ui.icon(options.icons.alignRight),
|
|
5290
|
-
tooltip: lang.paragraph.right + representShortcut('justifyRight'),
|
|
5291
|
-
click: context.createInvokeHandler('editor.justifyRight')
|
|
5292
|
-
}),
|
|
5293
|
-
ui.button({
|
|
5294
|
-
contents: ui.icon(options.icons.alignJustify),
|
|
5295
|
-
tooltip: lang.paragraph.justify + representShortcut('justifyFull'),
|
|
5296
|
-
click: context.createInvokeHandler('editor.justifyFull')
|
|
5297
|
-
})
|
|
5298
|
-
]
|
|
5379
|
+
children: [justifyLeft, justifyCenter, justifyRight, justifyFull]
|
|
5299
5380
|
}),
|
|
5300
5381
|
ui.buttonGroup({
|
|
5301
5382
|
className: 'note-list',
|
|
5302
|
-
children: [
|
|
5303
|
-
ui.button({
|
|
5304
|
-
contents: ui.icon(options.icons.outdent),
|
|
5305
|
-
tooltip: lang.paragraph.outdent + representShortcut('outdent'),
|
|
5306
|
-
click: context.createInvokeHandler('editor.outdent')
|
|
5307
|
-
}),
|
|
5308
|
-
ui.button({
|
|
5309
|
-
contents: ui.icon(options.icons.indent),
|
|
5310
|
-
tooltip: lang.paragraph.indent + representShortcut('indent'),
|
|
5311
|
-
click: context.createInvokeHandler('editor.indent')
|
|
5312
|
-
})
|
|
5313
|
-
]
|
|
5383
|
+
children: [outdent, indent]
|
|
5314
5384
|
})
|
|
5315
5385
|
])
|
|
5316
5386
|
]).render();
|
|
@@ -5328,7 +5398,7 @@
|
|
|
5328
5398
|
}),
|
|
5329
5399
|
ui.dropdownCheck({
|
|
5330
5400
|
items: options.lineHeights,
|
|
5331
|
-
checkClassName
|
|
5401
|
+
checkClassName: options.icons.menuCheck,
|
|
5332
5402
|
className: 'dropdown-line-height',
|
|
5333
5403
|
click: context.createInvokeHandler('editor.lineHeight')
|
|
5334
5404
|
})
|
|
@@ -5558,6 +5628,15 @@
|
|
|
5558
5628
|
},
|
|
5559
5629
|
'.note-btn-underline': function () {
|
|
5560
5630
|
return styleInfo['font-underline'] === 'underline';
|
|
5631
|
+
},
|
|
5632
|
+
'.note-btn-subscript': function () {
|
|
5633
|
+
return styleInfo['font-subscript'] === 'subscript';
|
|
5634
|
+
},
|
|
5635
|
+
'.note-btn-superscript': function () {
|
|
5636
|
+
return styleInfo['font-superscript'] === 'superscript';
|
|
5637
|
+
},
|
|
5638
|
+
'.note-btn-strikethrough': function () {
|
|
5639
|
+
return styleInfo['font-strikethrough'] === 'strikethrough';
|
|
5561
5640
|
}
|
|
5562
5641
|
});
|
|
5563
5642
|
|
|
@@ -5567,10 +5646,7 @@
|
|
|
5567
5646
|
.replace(/\s+$/, '')
|
|
5568
5647
|
.replace(/^\s+/, '');
|
|
5569
5648
|
});
|
|
5570
|
-
var fontName = list.find(fontNames,
|
|
5571
|
-
return agent.isFontInstalled(name) ||
|
|
5572
|
-
list.contains(options.fontNamesIgnoreCheck, name);
|
|
5573
|
-
});
|
|
5649
|
+
var fontName = list.find(fontNames, self.isFontInstalled);
|
|
5574
5650
|
|
|
5575
5651
|
$toolbar.find('.dropdown-fontname li a').each(function () {
|
|
5576
5652
|
// always compare string to avoid creating another func.
|
|
@@ -5669,6 +5745,10 @@
|
|
|
5669
5745
|
context.invoke('buttons.build', $toolbar, options.toolbar);
|
|
5670
5746
|
}
|
|
5671
5747
|
|
|
5748
|
+
if (options.toolbarContainer) {
|
|
5749
|
+
$toolbar.appendTo(options.toolbarContainer);
|
|
5750
|
+
}
|
|
5751
|
+
|
|
5672
5752
|
$note.on('summernote.keyup summernote.mouseup summernote.change', function () {
|
|
5673
5753
|
context.invoke('buttons.updateCurrentStyle');
|
|
5674
5754
|
});
|
|
@@ -5739,6 +5819,7 @@
|
|
|
5739
5819
|
this.$dialog = ui.dialog({
|
|
5740
5820
|
className: 'link-dialog',
|
|
5741
5821
|
title: lang.link.insert,
|
|
5822
|
+
fade: options.dialogsFade,
|
|
5742
5823
|
body: body,
|
|
5743
5824
|
footer: footer
|
|
5744
5825
|
}).render().appendTo($container);
|
|
@@ -5884,6 +5965,12 @@
|
|
|
5884
5965
|
};
|
|
5885
5966
|
|
|
5886
5967
|
this.update = function () {
|
|
5968
|
+
// Prevent focusing on editable when invoke('code') is executed
|
|
5969
|
+
if (!context.invoke('editor.hasFocus')) {
|
|
5970
|
+
this.hide();
|
|
5971
|
+
return;
|
|
5972
|
+
}
|
|
5973
|
+
|
|
5887
5974
|
var rng = context.invoke('editor.createRange');
|
|
5888
5975
|
if (rng.isCollapsed() && rng.isOnAnchor()) {
|
|
5889
5976
|
var anchor = dom.ancestor(rng.sc, dom.isAnchor);
|
|
@@ -5938,6 +6025,7 @@
|
|
|
5938
6025
|
|
|
5939
6026
|
this.$dialog = ui.dialog({
|
|
5940
6027
|
title: lang.image.insert,
|
|
6028
|
+
fade: options.dialogsFade,
|
|
5941
6029
|
body: body,
|
|
5942
6030
|
footer: footer
|
|
5943
6031
|
}).render().appendTo($container);
|
|
@@ -6083,6 +6171,7 @@
|
|
|
6083
6171
|
|
|
6084
6172
|
this.$dialog = ui.dialog({
|
|
6085
6173
|
title: lang.video.insert,
|
|
6174
|
+
fade: options.dialogsFade,
|
|
6086
6175
|
body: body,
|
|
6087
6176
|
footer: footer
|
|
6088
6177
|
}).render().appendTo($container);
|
|
@@ -6180,7 +6269,6 @@
|
|
|
6180
6269
|
return $video[0];
|
|
6181
6270
|
};
|
|
6182
6271
|
|
|
6183
|
-
|
|
6184
6272
|
this.show = function () {
|
|
6185
6273
|
var text = context.invoke('editor.getSelectedText');
|
|
6186
6274
|
context.invoke('editor.saveRange');
|
|
@@ -6252,27 +6340,15 @@
|
|
|
6252
6340
|
|
|
6253
6341
|
this.createShortCutList = function () {
|
|
6254
6342
|
var keyMap = options.keyMap[agent.isMac ? 'mac' : 'pc'];
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
var $row = $('<div class="help-list-item"/>');
|
|
6260
|
-
|
|
6261
|
-
var command = keyMap[keyString];
|
|
6262
|
-
var str = context.memo('help.' + command) ? context.memo('help.' + command) : command;
|
|
6263
|
-
var $keyString = $('<label />').css({
|
|
6343
|
+
return Object.keys(keyMap).map(function (key) {
|
|
6344
|
+
var command = keyMap[key];
|
|
6345
|
+
var $row = $('<div><div class="help-list-item"/></div>');
|
|
6346
|
+
$row.append($('<label><kbd>' + key + '</kdb></label>').css({
|
|
6264
6347
|
'width': 180,
|
|
6265
|
-
'max-width': 200,
|
|
6266
6348
|
'margin-right': 10
|
|
6267
|
-
}).html(
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
$row.html($keyString).append($description);
|
|
6271
|
-
|
|
6272
|
-
$list.append($row);
|
|
6273
|
-
});
|
|
6274
|
-
|
|
6275
|
-
return $list.html();
|
|
6349
|
+
})).append($('<span/>').html(context.memo('help.' + command) || command));
|
|
6350
|
+
return $row.html();
|
|
6351
|
+
}).join('');
|
|
6276
6352
|
};
|
|
6277
6353
|
|
|
6278
6354
|
this.initialize = function () {
|
|
@@ -6280,7 +6356,7 @@
|
|
|
6280
6356
|
|
|
6281
6357
|
var body = [
|
|
6282
6358
|
'<p class="text-center">',
|
|
6283
|
-
'<a href="//summernote.org/" target="_blank">Summernote 0.
|
|
6359
|
+
'<a href="//summernote.org/" target="_blank">Summernote 0.8.1</a> · ',
|
|
6284
6360
|
'<a href="//github.com/summernote/summernote" target="_blank">Project</a> · ',
|
|
6285
6361
|
'<a href="//github.com/summernote/summernote/issues" target="_blank">Issues</a>',
|
|
6286
6362
|
'</p>'
|
|
@@ -6288,6 +6364,7 @@
|
|
|
6288
6364
|
|
|
6289
6365
|
this.$dialog = ui.dialog({
|
|
6290
6366
|
title: lang.options.help,
|
|
6367
|
+
fade: options.dialogsFade,
|
|
6291
6368
|
body: this.createShortCutList(),
|
|
6292
6369
|
footer: body,
|
|
6293
6370
|
callback: function ($node) {
|
|
@@ -6311,7 +6388,7 @@
|
|
|
6311
6388
|
*/
|
|
6312
6389
|
this.showHelpDialog = function () {
|
|
6313
6390
|
return $.Deferred(function (deferred) {
|
|
6314
|
-
ui.
|
|
6391
|
+
ui.onDialogShown(self.$dialog, function () {
|
|
6315
6392
|
context.triggerEvent('dialog.shown');
|
|
6316
6393
|
deferred.resolve();
|
|
6317
6394
|
});
|
|
@@ -6398,7 +6475,9 @@
|
|
|
6398
6475
|
var self = this;
|
|
6399
6476
|
var ui = $.summernote.ui;
|
|
6400
6477
|
|
|
6478
|
+
var POPOVER_DIST = 5;
|
|
6401
6479
|
var hint = context.options.hint || [];
|
|
6480
|
+
var direction = context.options.hintDirection || 'bottom';
|
|
6402
6481
|
var hints = $.isArray(hint) ? hint : [hint];
|
|
6403
6482
|
|
|
6404
6483
|
this.events = {
|
|
@@ -6407,7 +6486,7 @@
|
|
|
6407
6486
|
self.handleKeyup(e);
|
|
6408
6487
|
}
|
|
6409
6488
|
},
|
|
6410
|
-
'summernote.keydown'
|
|
6489
|
+
'summernote.keydown': function (we, e) {
|
|
6411
6490
|
self.handleKeydown(e);
|
|
6412
6491
|
},
|
|
6413
6492
|
'summernote.dialog.shown': function () {
|
|
@@ -6422,9 +6501,13 @@
|
|
|
6422
6501
|
this.initialize = function () {
|
|
6423
6502
|
this.lastWordRange = null;
|
|
6424
6503
|
this.$popover = ui.popover({
|
|
6425
|
-
className: 'note-hint-popover'
|
|
6504
|
+
className: 'note-hint-popover',
|
|
6505
|
+
hideArrow: true,
|
|
6506
|
+
direction: ''
|
|
6426
6507
|
}).render().appendTo('body');
|
|
6427
6508
|
|
|
6509
|
+
this.$popover.hide();
|
|
6510
|
+
|
|
6428
6511
|
this.$content = this.$popover.find('.popover-content');
|
|
6429
6512
|
|
|
6430
6513
|
this.$content.on('click', '.note-hint-item', function () {
|
|
@@ -6481,13 +6564,17 @@
|
|
|
6481
6564
|
|
|
6482
6565
|
this.replace = function () {
|
|
6483
6566
|
var $item = this.$content.find('.note-hint-item.active');
|
|
6484
|
-
var node = this.nodeFromItem($item);
|
|
6485
|
-
this.lastWordRange.insertNode(node);
|
|
6486
|
-
range.createFromNode(node).collapse().select();
|
|
6487
6567
|
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6568
|
+
if ($item.length) {
|
|
6569
|
+
var node = this.nodeFromItem($item);
|
|
6570
|
+
this.lastWordRange.insertNode(node);
|
|
6571
|
+
range.createFromNode(node).collapse().select();
|
|
6572
|
+
|
|
6573
|
+
this.lastWordRange = null;
|
|
6574
|
+
this.hide();
|
|
6575
|
+
context.invoke('editor.focus');
|
|
6576
|
+
}
|
|
6577
|
+
|
|
6491
6578
|
};
|
|
6492
6579
|
|
|
6493
6580
|
this.nodeFromItem = function ($item) {
|
|
@@ -6572,10 +6659,8 @@
|
|
|
6572
6659
|
|
|
6573
6660
|
var bnd = func.rect2bnd(list.last(wordRange.getClientRects()));
|
|
6574
6661
|
if (bnd) {
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
top: bnd.top + bnd.height
|
|
6578
|
-
}).hide();
|
|
6662
|
+
|
|
6663
|
+
this.$popover.hide();
|
|
6579
6664
|
|
|
6580
6665
|
this.lastWordRange = wordRange;
|
|
6581
6666
|
|
|
@@ -6584,6 +6669,20 @@
|
|
|
6584
6669
|
self.createGroup(idx, keyword).appendTo(self.$content);
|
|
6585
6670
|
}
|
|
6586
6671
|
});
|
|
6672
|
+
|
|
6673
|
+
// set position for popover after group is created
|
|
6674
|
+
if (direction === 'top') {
|
|
6675
|
+
this.$popover.css({
|
|
6676
|
+
left: bnd.left,
|
|
6677
|
+
top: bnd.top - this.$popover.outerHeight() - POPOVER_DIST
|
|
6678
|
+
});
|
|
6679
|
+
} else {
|
|
6680
|
+
this.$popover.css({
|
|
6681
|
+
left: bnd.left,
|
|
6682
|
+
top: bnd.top + bnd.height + POPOVER_DIST
|
|
6683
|
+
});
|
|
6684
|
+
}
|
|
6685
|
+
|
|
6587
6686
|
}
|
|
6588
6687
|
} else {
|
|
6589
6688
|
this.hide();
|
|
@@ -6602,7 +6701,7 @@
|
|
|
6602
6701
|
|
|
6603
6702
|
|
|
6604
6703
|
$.summernote = $.extend($.summernote, {
|
|
6605
|
-
version: '0.
|
|
6704
|
+
version: '0.8.1',
|
|
6606
6705
|
ui: ui,
|
|
6607
6706
|
|
|
6608
6707
|
plugins: {},
|
|
@@ -6622,7 +6721,7 @@
|
|
|
6622
6721
|
'autoLink': AutoLink,
|
|
6623
6722
|
'autoSync': AutoSync,
|
|
6624
6723
|
'placeholder': Placeholder,
|
|
6625
|
-
'buttons'
|
|
6724
|
+
'buttons': Buttons,
|
|
6626
6725
|
'toolbar': Toolbar,
|
|
6627
6726
|
'linkDialog': LinkDialog,
|
|
6628
6727
|
'linkPopover': LinkPopover,
|
|
@@ -6713,6 +6812,7 @@
|
|
|
6713
6812
|
},
|
|
6714
6813
|
|
|
6715
6814
|
dialogsInBody: false,
|
|
6815
|
+
dialogsFade: false,
|
|
6716
6816
|
|
|
6717
6817
|
maximumImageFileSize: null,
|
|
6718
6818
|
|
|
@@ -6796,44 +6896,44 @@
|
|
|
6796
6896
|
}
|
|
6797
6897
|
},
|
|
6798
6898
|
icons: {
|
|
6799
|
-
'align': '
|
|
6800
|
-
'alignCenter': '
|
|
6801
|
-
'alignJustify': '
|
|
6802
|
-
'alignLeft': '
|
|
6803
|
-
'alignRight': '
|
|
6804
|
-
'indent': '
|
|
6805
|
-
'outdent': '
|
|
6806
|
-
'arrowsAlt': '
|
|
6807
|
-
'bold': '
|
|
6808
|
-
'caret': 'caret',
|
|
6809
|
-
'circle': '
|
|
6810
|
-
'close': '
|
|
6811
|
-
'code': '
|
|
6812
|
-
'eraser': '
|
|
6813
|
-
'font': '
|
|
6814
|
-
'frame': '
|
|
6815
|
-
'italic': '
|
|
6816
|
-
'link': '
|
|
6817
|
-
'unlink': '
|
|
6818
|
-
'magic': '
|
|
6819
|
-
'menuCheck': '
|
|
6820
|
-
'minus': '
|
|
6821
|
-
'orderedlist': '
|
|
6822
|
-
'pencil': '
|
|
6823
|
-
'picture': '
|
|
6824
|
-
'question': '
|
|
6825
|
-
'redo': '
|
|
6826
|
-
'square': '
|
|
6827
|
-
'strikethrough': '
|
|
6828
|
-
'subscript': '
|
|
6829
|
-
'superscript': '
|
|
6830
|
-
'table': '
|
|
6831
|
-
'textHeight': '
|
|
6832
|
-
'trash': '
|
|
6833
|
-
'underline': '
|
|
6834
|
-
'undo': '
|
|
6835
|
-
'unorderedlist': '
|
|
6836
|
-
'video': '
|
|
6899
|
+
'align': 'note-icon-align',
|
|
6900
|
+
'alignCenter': 'note-icon-align-center',
|
|
6901
|
+
'alignJustify': 'note-icon-align-justify',
|
|
6902
|
+
'alignLeft': 'note-icon-align-left',
|
|
6903
|
+
'alignRight': 'note-icon-align-right',
|
|
6904
|
+
'indent': 'note-icon-align-indent',
|
|
6905
|
+
'outdent': 'note-icon-align-outdent',
|
|
6906
|
+
'arrowsAlt': 'note-icon-arrows-alt',
|
|
6907
|
+
'bold': 'note-icon-bold',
|
|
6908
|
+
'caret': 'note-icon-caret',
|
|
6909
|
+
'circle': 'note-icon-circle',
|
|
6910
|
+
'close': 'note-icon-close',
|
|
6911
|
+
'code': 'note-icon-code',
|
|
6912
|
+
'eraser': 'note-icon-eraser',
|
|
6913
|
+
'font': 'note-icon-font',
|
|
6914
|
+
'frame': 'note-icon-frame',
|
|
6915
|
+
'italic': 'note-icon-italic',
|
|
6916
|
+
'link': 'note-icon-link',
|
|
6917
|
+
'unlink': 'note-icon-chain-broken',
|
|
6918
|
+
'magic': 'note-icon-magic',
|
|
6919
|
+
'menuCheck': 'note-icon-check',
|
|
6920
|
+
'minus': 'note-icon-minus',
|
|
6921
|
+
'orderedlist': 'note-icon-orderedlist',
|
|
6922
|
+
'pencil': 'note-icon-pencil',
|
|
6923
|
+
'picture': 'note-icon-picture',
|
|
6924
|
+
'question': 'note-icon-question',
|
|
6925
|
+
'redo': 'note-icon-redo',
|
|
6926
|
+
'square': 'note-icon-square',
|
|
6927
|
+
'strikethrough': 'note-icon-strikethrough',
|
|
6928
|
+
'subscript': 'note-icon-subscript',
|
|
6929
|
+
'superscript': 'note-icon-superscript',
|
|
6930
|
+
'table': 'note-icon-table',
|
|
6931
|
+
'textHeight': 'note-icon-text-height',
|
|
6932
|
+
'trash': 'note-icon-trash',
|
|
6933
|
+
'underline': 'note-icon-underline',
|
|
6934
|
+
'undo': 'note-icon-undo',
|
|
6935
|
+
'unorderedlist': 'note-icon-unorderedlist',
|
|
6936
|
+
'video': 'note-icon-video'
|
|
6837
6937
|
}
|
|
6838
6938
|
}
|
|
6839
6939
|
});
|