activeadmin_trumbowyg 0.1.3 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/app/assets/fonts/active_admin-trumbowyg.svg +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/da.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/de.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/fa.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/fr.min.js +3 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/lt.min.js +8 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/sq.min.js +8 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/th.min.js +9 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/zh_tw.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/allowtagsfrompaste/trumbowyg.allowtagsfrompaste.js +143 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/allowtagsfrompaste/trumbowyg.allowtagsfrompaste.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.js +21 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.js +23 -90
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.js +24 -2
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/sass/trumbowyg.colors.scss +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.css +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.min.css +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.js +1190 -876
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/sass/trumbowyg.emoji.scss +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.css +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.min.css +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontfamily/trumbowyg.fontfamily.js +82 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontfamily/trumbowyg.fontfamily.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontsize/trumbowyg.fontsize.js +160 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontsize/trumbowyg.fontsize.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/trumbowyg.highlight.js +82 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/trumbowyg.highlight.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/ui/sass/trumbowyg.highlight.scss +25 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.css +20 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.min.css +2 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/history/trumbowyg.history.js +202 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/history/trumbowyg.history.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.js +10 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/lineheight/trumbowyg.lineheight.js +122 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/lineheight/trumbowyg.lineheight.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/trumbowyg.mathml.js +98 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/trumbowyg.mathml.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/sass/trumbowyg.mathml.scss +36 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.css +29 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.min.css +2 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/trumbowyg.mention.js +111 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/trumbowyg.mention.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/sass/trumbowyg.mention.scss +39 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/trumbowyg.mention.css +32 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/trumbowyg.mention.min.css +2 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.js +12 -2
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.js +96 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js +16 -3
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/trumbowyg.resizimg.js +69 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/trumbowyg.resizimg.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/ruby/trumbowyg.ruby.js +82 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/ruby/trumbowyg.ruby.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/trumbowyg.table.js +236 -86
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/trumbowyg.table.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/ui/sass/trumbowyg.table.scss +42 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/ui/trumbowyg.table.css +33 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/ui/trumbowyg.table.min.css +2 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/template/trumbowyg.template.js +19 -7
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/template/trumbowyg.template.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.js +44 -20
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/trumbowyg.js +215 -78
- data/app/assets/javascripts/activeadmin/trumbowyg/trumbowyg.min.js +2 -2
- data/app/assets/javascripts/activeadmin/trumbowyg/ui/icons.svg +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/ui/sass/trumbowyg.scss +25 -12
- data/app/assets/javascripts/activeadmin/trumbowyg/ui/trumbowyg.css +23 -20
- data/app/assets/javascripts/activeadmin/trumbowyg/ui/trumbowyg.min.css +2 -2
- data/app/assets/stylesheets/activeadmin/_trumbowyg_input.sass +5 -3
- data/app/assets/stylesheets/activeadmin/trumbowyg/ui/icons.svg +1 -1
- data/app/assets/stylesheets/activeadmin/trumbowyg/ui/sass/trumbowyg.scss +25 -12
- data/app/assets/stylesheets/activeadmin/trumbowyg/ui/trumbowyg.css +23 -20
- data/app/assets/stylesheets/activeadmin/trumbowyg/ui/trumbowyg.min.css +2 -2
- data/lib/activeadmin/trumbowyg/version.rb +1 -1
- metadata +40 -72
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ar.min.js +0 -11
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/bg.min.js +0 -8
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/by.min.js +0 -8
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ca.min.js +0 -11
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/cs.min.js +0 -8
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/da.min.js +0 -9
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/de.min.js +0 -9
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/el.min.js +0 -12
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/es.min.js +0 -9
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/es_ar.min.js +0 -10
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/fa.min.js +0 -10
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/fi.min.js +0 -9
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/fr.min.js +0 -10
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/he.min.js +0 -9
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/hr.min.js +0 -9
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/hu.min.js +0 -10
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/id.min.js +0 -11
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/it.min.js +0 -8
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ja.min.js +0 -10
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ko.min.js +0 -10
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/mn.min.js +0 -8
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/my.min.js +0 -8
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/nl.min.js +0 -9
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/no_nb.min.js +0 -10
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ph.min.js +0 -8
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/pl.min.js +0 -9
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/pt.min.js +0 -11
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/pt_br.min.js +0 -11
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ro.min.js +0 -12
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/rs.min.js +0 -8
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/rs_latin.min.js +0 -9
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ru.min.js +0 -8
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/sk.min.js +0 -8
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/sv.min.js +0 -12
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/tr.min.js +0 -9
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ua.min.js +0 -8
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/vi.min.js +0 -9
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/zh_cn.min.js +0 -11
- data/app/assets/stylesheets/activeadmin/trumbowyg/langs/zh_tw.min.js +0 -11
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.js +0 -121
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.min.js +0 -1
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.js +0 -179
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.min.js +0 -1
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.js +0 -176
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.min.js +0 -1
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/ui/sass/trumbowyg.colors.scss +0 -49
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.css +0 -43
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.min.css +0 -2
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.js +0 -965
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.min.js +0 -1
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/ui/sass/trumbowyg.emoji.scss +0 -56
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.css +0 -47
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.min.css +0 -2
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.js +0 -83
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.min.js +0 -1
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.js +0 -101
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.min.js +0 -1
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js +0 -41
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js +0 -1
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js +0 -123
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js +0 -1
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/table/trumbowyg.table.js +0 -154
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/table/trumbowyg.table.min.js +0 -1
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/template/trumbowyg.template.js +0 -58
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/template/trumbowyg.template.min.js +0 -1
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.js +0 -242
- data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.min.js +0 -1
- data/app/assets/stylesheets/activeadmin/trumbowyg/trumbowyg.js +0 -1688
- data/app/assets/stylesheets/activeadmin/trumbowyg/trumbowyg.min.js +0 -2
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Trumbowyg v2.
|
2
|
+
* Trumbowyg v2.11.1 - A lightweight WYSIWYG editor
|
3
3
|
* Trumbowyg core file
|
4
4
|
* ------------------------
|
5
5
|
* @link http://alex-d.github.io/Trumbowyg
|
@@ -62,7 +62,8 @@ jQuery.trumbowyg = {
|
|
62
62
|
description: 'Description',
|
63
63
|
title: 'Title',
|
64
64
|
text: 'Text',
|
65
|
-
target: 'Target'
|
65
|
+
target: 'Target',
|
66
|
+
width: 'Width'
|
66
67
|
}
|
67
68
|
},
|
68
69
|
|
@@ -84,6 +85,7 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
84
85
|
fixedFullWidth: false,
|
85
86
|
autogrow: false,
|
86
87
|
autogrowOnEnter: false,
|
88
|
+
imageWidthModalEdit: false,
|
87
89
|
|
88
90
|
prefix: 'trumbowyg-',
|
89
91
|
|
@@ -114,7 +116,9 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
114
116
|
|
115
117
|
// imgDblClickHandler: default is defined in constructor
|
116
118
|
|
117
|
-
plugins: {}
|
119
|
+
plugins: {},
|
120
|
+
urlProtocol: false,
|
121
|
+
minimalLinks: false
|
118
122
|
},
|
119
123
|
writable: false,
|
120
124
|
enumerable: true,
|
@@ -169,6 +173,10 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
169
173
|
case 'disable':
|
170
174
|
return t.setDisabled(true);
|
171
175
|
|
176
|
+
// Toggle
|
177
|
+
case 'toggle':
|
178
|
+
return t.toggle();
|
179
|
+
|
172
180
|
// Destroy
|
173
181
|
case 'destroy':
|
174
182
|
return t.destroy();
|
@@ -220,25 +228,17 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
220
228
|
if ($('#' + trumbowygIconsId, t.doc).length === 0 && svgPathOption !== false) {
|
221
229
|
if (svgPathOption == null) {
|
222
230
|
// Hack to get svgPathOption based on trumbowyg.js path
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
var stackLines = e.stack.split('\n');
|
230
|
-
|
231
|
-
for (var i in stackLines) {
|
232
|
-
if (!stackLines[i].match(/https?:\/\//)) {
|
233
|
-
continue;
|
234
|
-
}
|
235
|
-
svgPathOption = stackLines[Number(i)].match(/((https?:\/\/.+\/)([^\/]+\.js))(\?.*)?:/)[1].split('/');
|
236
|
-
svgPathOption.pop();
|
237
|
-
svgPathOption = svgPathOption.join('/') + '/ui/icons.svg';
|
238
|
-
break;
|
239
|
-
}
|
231
|
+
var scriptElements = document.getElementsByTagName('script');
|
232
|
+
for (var i = 0; i < scriptElements.length; i += 1) {
|
233
|
+
var source = scriptElements[i].src;
|
234
|
+
var matches = source.match('trumbowyg(\.min)?\.js');
|
235
|
+
if (matches != null) {
|
236
|
+
svgPathOption = source.substring(0, source.indexOf(matches[0])) + 'ui/icons.svg';
|
240
237
|
}
|
241
238
|
}
|
239
|
+
if (svgPathOption == null) {
|
240
|
+
console.warn('You must define svgPath: https://goo.gl/CfTY9U'); // jshint ignore:line
|
241
|
+
}
|
242
242
|
}
|
243
243
|
|
244
244
|
var div = t.doc.createElement('div');
|
@@ -279,7 +279,8 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
279
279
|
};
|
280
280
|
t.btnsDef = {
|
281
281
|
viewHTML: {
|
282
|
-
fn: 'toggle'
|
282
|
+
fn: 'toggle',
|
283
|
+
class: 'trumbowyg-not-disable',
|
283
284
|
},
|
284
285
|
|
285
286
|
undo: {
|
@@ -411,6 +412,8 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
411
412
|
t.o.imgDblClickHandler = t.getDefaultImgDblClickHandler();
|
412
413
|
}
|
413
414
|
|
415
|
+
t.urlPrefix = t.setupUrlPrefix();
|
416
|
+
|
414
417
|
t.disabled = t.o.disabled || (editorElem.nodeName === 'TEXTAREA' && editorElem.disabled);
|
415
418
|
|
416
419
|
if (options.btns) {
|
@@ -443,6 +446,14 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
443
446
|
};
|
444
447
|
|
445
448
|
Trumbowyg.prototype = {
|
449
|
+
DEFAULT_SEMANTIC_MAP: {
|
450
|
+
'b': 'strong',
|
451
|
+
'i': 'em',
|
452
|
+
's': 'del',
|
453
|
+
'strike': 'del',
|
454
|
+
'div': 'p'
|
455
|
+
},
|
456
|
+
|
446
457
|
init: function () {
|
447
458
|
var t = this;
|
448
459
|
t.height = t.$ta.height();
|
@@ -475,6 +486,18 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
475
486
|
this.btnsDef[btnName] = btnDef;
|
476
487
|
},
|
477
488
|
|
489
|
+
setupUrlPrefix: function () {
|
490
|
+
var protocol = this.o.urlProtocol;
|
491
|
+
if (!protocol) {
|
492
|
+
return;
|
493
|
+
}
|
494
|
+
|
495
|
+
if (typeof(protocol) !== 'string') {
|
496
|
+
return 'https://';
|
497
|
+
}
|
498
|
+
return /:\/\/$/.test(protocol) ? protocol : protocol + '://';
|
499
|
+
},
|
500
|
+
|
478
501
|
buildEditor: function () {
|
479
502
|
var t = this,
|
480
503
|
prefix = t.o.prefix,
|
@@ -553,7 +576,7 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
553
576
|
var ctrl = false,
|
554
577
|
composition = false,
|
555
578
|
debounceButtonPaneStatus,
|
556
|
-
updateEventName =
|
579
|
+
updateEventName = 'keyup';
|
557
580
|
|
558
581
|
t.$ed
|
559
582
|
.on('dblclick', 'img', t.o.imgDblClickHandler)
|
@@ -588,7 +611,8 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
588
611
|
if ((e.ctrlKey || e.metaKey) && (keyCode === 89 || keyCode === 90)) {
|
589
612
|
t.$c.trigger('tbwchange');
|
590
613
|
} else if (!ctrl && keyCode !== 17) {
|
591
|
-
t.
|
614
|
+
var compositionEndIE = t.isIE ? e.type === 'compositionend' : true;
|
615
|
+
t.semanticCode(false, compositionEndIE && keyCode === 13);
|
592
616
|
t.$c.trigger('tbwchange');
|
593
617
|
} else if (typeof e.which === 'undefined') {
|
594
618
|
t.semanticCode(false, false, true);
|
@@ -596,9 +620,14 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
596
620
|
|
597
621
|
setTimeout(function () {
|
598
622
|
ctrl = false;
|
599
|
-
},
|
623
|
+
}, 50);
|
600
624
|
})
|
601
|
-
.on('mouseup keydown keyup', function () {
|
625
|
+
.on('mouseup keydown keyup', function (e) {
|
626
|
+
if ((!e.ctrlKey && !e.metaKey) || e.altKey) {
|
627
|
+
setTimeout(function () { // "hold on" to the ctrl key for 50ms
|
628
|
+
ctrl = false;
|
629
|
+
}, 50);
|
630
|
+
}
|
602
631
|
clearTimeout(debounceButtonPaneStatus);
|
603
632
|
debounceButtonPaneStatus = setTimeout(function () {
|
604
633
|
t.updateButtonPaneStatus();
|
@@ -727,7 +756,10 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
727
756
|
} catch (c) {
|
728
757
|
}
|
729
758
|
});
|
730
|
-
|
759
|
+
|
760
|
+
if ($btnGroup.html().trim().length > 0) {
|
761
|
+
$btnPane.append($btnGroup);
|
762
|
+
}
|
731
763
|
});
|
732
764
|
|
733
765
|
t.$box.prepend($btnPane);
|
@@ -756,7 +788,9 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
756
788
|
$('body', t.doc).trigger('mousedown');
|
757
789
|
}
|
758
790
|
|
759
|
-
if (t.$btnPane.hasClass(prefix + 'disable')
|
791
|
+
if ((t.$btnPane.hasClass(prefix + 'disable') || t.$box.hasClass(prefix + 'disabled')) &&
|
792
|
+
!$(this).hasClass(prefix + 'active') &&
|
793
|
+
!$(this).hasClass(prefix + 'not-disable')) {
|
760
794
|
return false;
|
761
795
|
}
|
762
796
|
|
@@ -769,10 +803,11 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
769
803
|
if (isDropdown) {
|
770
804
|
$btn.addClass(prefix + 'open-dropdown');
|
771
805
|
var dropdownPrefix = prefix + 'dropdown',
|
772
|
-
|
773
|
-
class: dropdownPrefix + '-' + btnName + ' ' + dropdownPrefix + ' ' + prefix + 'fixed-top'
|
774
|
-
|
775
|
-
|
806
|
+
dropdownOptions = { // the dropdown
|
807
|
+
class: dropdownPrefix + '-' + btnName + ' ' + dropdownPrefix + ' ' + prefix + 'fixed-top'
|
808
|
+
};
|
809
|
+
dropdownOptions['data-' + dropdownPrefix] = btnName;
|
810
|
+
var $dropdown = $('<div/>', dropdownOptions);
|
776
811
|
$.each(isDropdown, function (i, def) {
|
777
812
|
if (t.btnsDef[def] && t.isSupportedBtn(def)) {
|
778
813
|
$dropdown.append(t.buildSubBtn(def));
|
@@ -1003,7 +1038,7 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1003
1038
|
var t = this,
|
1004
1039
|
d = t.doc,
|
1005
1040
|
prefix = t.o.prefix,
|
1006
|
-
$dropdown = $('[data-dropdown=' + name + ']', t.$box),
|
1041
|
+
$dropdown = $('[data-' + prefix + 'dropdown=' + name + ']', t.$box),
|
1007
1042
|
$btn = $('.' + prefix + name + '-button', t.$btnPane),
|
1008
1043
|
show = $dropdown.is(':hidden');
|
1009
1044
|
|
@@ -1023,8 +1058,8 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1023
1058
|
|
1024
1059
|
$('body', d).on('mousedown.' + t.eventNamespace, function (e) {
|
1025
1060
|
if (!$dropdown.is(e.target)) {
|
1026
|
-
$('.' + prefix + 'dropdown',
|
1027
|
-
$('.' + prefix + 'active',
|
1061
|
+
$('.' + prefix + 'dropdown', t.$box).hide();
|
1062
|
+
$('.' + prefix + 'active', t.$btnPane).removeClass(prefix + 'active');
|
1028
1063
|
$('body', d).off('mousedown.' + t.eventNamespace);
|
1029
1064
|
}
|
1030
1065
|
});
|
@@ -1035,11 +1070,14 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1035
1070
|
// HTML Code management
|
1036
1071
|
html: function (html) {
|
1037
1072
|
var t = this;
|
1073
|
+
|
1038
1074
|
if (html != null) {
|
1039
1075
|
t.$ta.val(html);
|
1040
1076
|
t.syncCode(true);
|
1077
|
+
t.$c.trigger('tbwchange');
|
1041
1078
|
return t;
|
1042
1079
|
}
|
1080
|
+
|
1043
1081
|
return t.$ta.val();
|
1044
1082
|
},
|
1045
1083
|
syncTextarea: function () {
|
@@ -1087,9 +1125,10 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1087
1125
|
t.syncCode(force);
|
1088
1126
|
|
1089
1127
|
if (t.o.semantic) {
|
1090
|
-
t.semanticTag('b'
|
1091
|
-
t.semanticTag('i'
|
1092
|
-
t.semanticTag('
|
1128
|
+
t.semanticTag('b');
|
1129
|
+
t.semanticTag('i');
|
1130
|
+
t.semanticTag('s');
|
1131
|
+
t.semanticTag('strike');
|
1093
1132
|
|
1094
1133
|
if (full) {
|
1095
1134
|
var inlineElementsSelector = t.o.inlineElementsSelector,
|
@@ -1111,7 +1150,7 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1111
1150
|
};
|
1112
1151
|
wrapInlinesInParagraphsFrom(t.$ed.children(inlineElementsSelector).first());
|
1113
1152
|
|
1114
|
-
t.semanticTag('div',
|
1153
|
+
t.semanticTag('div', true);
|
1115
1154
|
|
1116
1155
|
// Unwrap paragraphs content, containing nothing usefull
|
1117
1156
|
t.$ed.find('p').filter(function () {
|
@@ -1137,7 +1176,17 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1137
1176
|
}
|
1138
1177
|
},
|
1139
1178
|
|
1140
|
-
semanticTag: function (oldTag,
|
1179
|
+
semanticTag: function (oldTag, copyAttributes) {
|
1180
|
+
var newTag;
|
1181
|
+
|
1182
|
+
if (this.o.semantic != null && typeof this.o.semantic === 'object' && this.o.semantic.hasOwnProperty(oldTag)) {
|
1183
|
+
newTag = this.o.semantic[oldTag];
|
1184
|
+
} else if (this.o.semantic === true && this.DEFAULT_SEMANTIC_MAP.hasOwnProperty(oldTag)) {
|
1185
|
+
newTag = this.DEFAULT_SEMANTIC_MAP[oldTag];
|
1186
|
+
} else {
|
1187
|
+
return;
|
1188
|
+
}
|
1189
|
+
|
1141
1190
|
$(oldTag, this.$ed).each(function () {
|
1142
1191
|
var $oldTag = $(this);
|
1143
1192
|
$oldTag.wrap('<' + newTag + '/>');
|
@@ -1155,6 +1204,7 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1155
1204
|
var t = this,
|
1156
1205
|
documentSelection = t.doc.getSelection(),
|
1157
1206
|
node = documentSelection.focusNode,
|
1207
|
+
text = new XMLSerializer().serializeToString(documentSelection.getRangeAt(0).cloneContents()),
|
1158
1208
|
url,
|
1159
1209
|
title,
|
1160
1210
|
target;
|
@@ -1165,9 +1215,12 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1165
1215
|
|
1166
1216
|
if (node && node.nodeName === 'A') {
|
1167
1217
|
var $a = $(node);
|
1218
|
+
text = $a.text();
|
1168
1219
|
url = $a.attr('href');
|
1169
|
-
|
1170
|
-
|
1220
|
+
if (!t.o.minimalLinks) {
|
1221
|
+
title = $a.attr('title');
|
1222
|
+
target = $a.attr('target');
|
1223
|
+
}
|
1171
1224
|
var range = t.doc.createRange();
|
1172
1225
|
range.selectNode(node);
|
1173
1226
|
documentSelection.removeAllRanges();
|
@@ -1176,37 +1229,71 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1176
1229
|
|
1177
1230
|
t.saveRange();
|
1178
1231
|
|
1179
|
-
|
1232
|
+
var options = {
|
1180
1233
|
url: {
|
1181
1234
|
label: 'URL',
|
1182
1235
|
required: true,
|
1183
1236
|
value: url
|
1184
1237
|
},
|
1185
|
-
title: {
|
1186
|
-
label: t.lang.title,
|
1187
|
-
value: title
|
1188
|
-
},
|
1189
1238
|
text: {
|
1190
1239
|
label: t.lang.text,
|
1191
|
-
value:
|
1192
|
-
},
|
1193
|
-
target: {
|
1194
|
-
label: t.lang.target,
|
1195
|
-
value: target
|
1240
|
+
value: text
|
1196
1241
|
}
|
1197
|
-
}
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1242
|
+
};
|
1243
|
+
if (!t.o.minimalLinks) {
|
1244
|
+
Object.assign(options, {
|
1245
|
+
title: {
|
1246
|
+
label: t.lang.title,
|
1247
|
+
value: title
|
1248
|
+
},
|
1249
|
+
target: {
|
1250
|
+
label: t.lang.target,
|
1251
|
+
value: target
|
1252
|
+
}
|
1253
|
+
});
|
1254
|
+
}
|
1255
|
+
|
1256
|
+
t.openModalInsert(t.lang.createLink, options, function (v) { // v is value
|
1257
|
+
var url = t.prependUrlPrefix(v.url);
|
1258
|
+
if (!url.length) {
|
1259
|
+
return false;
|
1201
1260
|
}
|
1202
|
-
|
1203
|
-
|
1261
|
+
|
1262
|
+
var link = $(['<a href="', url, '">', v.text || v.url, '</a>'].join(''));
|
1263
|
+
|
1264
|
+
if (!t.o.minimalLinks) {
|
1265
|
+
if (v.title.length > 0) {
|
1266
|
+
link.attr('title', v.title);
|
1267
|
+
}
|
1268
|
+
if (v.target.length > 0) {
|
1269
|
+
link.attr('target', v.target);
|
1270
|
+
}
|
1204
1271
|
}
|
1205
1272
|
t.range.deleteContents();
|
1206
1273
|
t.range.insertNode(link[0]);
|
1274
|
+
t.syncCode();
|
1275
|
+
t.$c.trigger('tbwchange');
|
1207
1276
|
return true;
|
1208
1277
|
});
|
1209
1278
|
},
|
1279
|
+
prependUrlPrefix: function (url) {
|
1280
|
+
var t = this;
|
1281
|
+
if (!t.urlPrefix) {
|
1282
|
+
return url;
|
1283
|
+
}
|
1284
|
+
|
1285
|
+
var VALID_LINK_PREFIX = /^([a-z][-+.a-z0-9]*:|\/|#)/i;
|
1286
|
+
if (VALID_LINK_PREFIX.test(url)) {
|
1287
|
+
return url;
|
1288
|
+
}
|
1289
|
+
|
1290
|
+
var SIMPLE_EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
1291
|
+
if (SIMPLE_EMAIL_REGEX.test(url)) {
|
1292
|
+
return 'mailto:' + url;
|
1293
|
+
}
|
1294
|
+
|
1295
|
+
return t.urlPrefix + url;
|
1296
|
+
},
|
1210
1297
|
unlink: function () {
|
1211
1298
|
var t = this,
|
1212
1299
|
documentSelection = t.doc.getSelection(),
|
@@ -1229,7 +1316,8 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1229
1316
|
insertImage: function () {
|
1230
1317
|
var t = this;
|
1231
1318
|
t.saveRange();
|
1232
|
-
|
1319
|
+
|
1320
|
+
var options = {
|
1233
1321
|
url: {
|
1234
1322
|
label: 'URL',
|
1235
1323
|
required: true
|
@@ -1238,9 +1326,26 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1238
1326
|
label: t.lang.description,
|
1239
1327
|
value: t.getRangeText()
|
1240
1328
|
}
|
1241
|
-
}
|
1329
|
+
};
|
1330
|
+
|
1331
|
+
if (t.o.imageWidthModalEdit) {
|
1332
|
+
options.width = {};
|
1333
|
+
}
|
1334
|
+
|
1335
|
+
t.openModalInsert(t.lang.insertImage, options, function (v) { // v are values
|
1242
1336
|
t.execCmd('insertImage', v.url);
|
1243
|
-
$('img[src="' + v.url + '"]:not([alt])', t.$box)
|
1337
|
+
var $img = $('img[src="' + v.url + '"]:not([alt])', t.$box);
|
1338
|
+
$img.attr('alt', v.alt);
|
1339
|
+
|
1340
|
+
if (t.o.imageWidthModalEdit) {
|
1341
|
+
$img.attr({
|
1342
|
+
width: v.width
|
1343
|
+
});
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
t.syncCode();
|
1347
|
+
t.$c.trigger('tbwchange');
|
1348
|
+
|
1244
1349
|
return true;
|
1245
1350
|
});
|
1246
1351
|
},
|
@@ -1325,8 +1430,9 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1325
1430
|
var $modal = $('<div/>', {
|
1326
1431
|
class: prefix + 'modal ' + prefix + 'fixed-top'
|
1327
1432
|
}).css({
|
1328
|
-
top: t.$btnPane.height()
|
1329
|
-
|
1433
|
+
top: t.$box.offset().top + t.$btnPane.height(),
|
1434
|
+
zIndex: 99999
|
1435
|
+
}).appendTo($(document.body));
|
1330
1436
|
|
1331
1437
|
// Click on overlay close modal by cancelling them
|
1332
1438
|
t.$overlay.one('click', function () {
|
@@ -1412,7 +1518,7 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1412
1518
|
t.$overlay.off();
|
1413
1519
|
|
1414
1520
|
// Find the modal box
|
1415
|
-
var $modalBox = $('.' + prefix + 'modal-box',
|
1521
|
+
var $modalBox = $('.' + prefix + 'modal-box', $(document.body));
|
1416
1522
|
|
1417
1523
|
$modalBox.animate({
|
1418
1524
|
top: '-' + $modalBox.height()
|
@@ -1431,7 +1537,7 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1431
1537
|
html = '';
|
1432
1538
|
|
1433
1539
|
$.each(fields, function (fieldName, field) {
|
1434
|
-
var l = field.label,
|
1540
|
+
var l = field.label || fieldName,
|
1435
1541
|
n = field.name || fieldName,
|
1436
1542
|
a = field.attributes || {};
|
1437
1543
|
|
@@ -1439,8 +1545,10 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1439
1545
|
return prop + '="' + a[prop] + '"';
|
1440
1546
|
}).join(' ');
|
1441
1547
|
|
1442
|
-
html += '<label><input type="' + (field.type || 'text') + '" name="' + n + '"
|
1443
|
-
(
|
1548
|
+
html += '<label><input type="' + (field.type || 'text') + '" name="' + n + '"' +
|
1549
|
+
(field.type === 'checkbox' && field.value ? ' checked="checked"' : ' value="' + (field.value || '').replace(/"/g, '"')) +
|
1550
|
+
'"' + attr + '><span class="' + prefix + 'input-infos"><span>' +
|
1551
|
+
(lg[l] ? lg[l] : l) +
|
1444
1552
|
'</span></span></label>';
|
1445
1553
|
});
|
1446
1554
|
|
@@ -1451,19 +1559,27 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1451
1559
|
values = {};
|
1452
1560
|
|
1453
1561
|
$.each(fields, function (fieldName, field) {
|
1454
|
-
var
|
1562
|
+
var n = field.name || fieldName;
|
1563
|
+
|
1564
|
+
var $field = $('input[name="' + n + '"]', $form),
|
1455
1565
|
inputType = $field.attr('type');
|
1456
1566
|
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1567
|
+
switch (inputType.toLowerCase()) {
|
1568
|
+
case 'checkbox':
|
1569
|
+
values[n] = $field.is(':checked');
|
1570
|
+
break;
|
1571
|
+
case 'radio':
|
1572
|
+
values[n] = $field.filter(':checked').val();
|
1573
|
+
break;
|
1574
|
+
default:
|
1575
|
+
values[n] = $.trim($field.val());
|
1576
|
+
break;
|
1461
1577
|
}
|
1462
1578
|
// Validate value
|
1463
|
-
if (field.required && values[
|
1579
|
+
if (field.required && values[n] === '') {
|
1464
1580
|
valid = false;
|
1465
1581
|
t.addErrorOnModalField($field, t.lang.required);
|
1466
|
-
} else if (field.pattern && !field.pattern.test(values[
|
1582
|
+
} else if (field.pattern && !field.pattern.test(values[n])) {
|
1467
1583
|
valid = false;
|
1468
1584
|
t.addErrorOnModalField($field, field.patternError);
|
1469
1585
|
}
|
@@ -1517,7 +1633,7 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1517
1633
|
src = base64;
|
1518
1634
|
}
|
1519
1635
|
|
1520
|
-
|
1636
|
+
var options = {
|
1521
1637
|
url: {
|
1522
1638
|
label: 'URL',
|
1523
1639
|
value: src,
|
@@ -1527,15 +1643,34 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1527
1643
|
label: t.lang.description,
|
1528
1644
|
value: $img.attr('alt')
|
1529
1645
|
}
|
1530
|
-
}
|
1531
|
-
|
1646
|
+
};
|
1647
|
+
|
1648
|
+
if (t.o.imageWidthModalEdit) {
|
1649
|
+
options.width = {
|
1650
|
+
value: $img.attr('width') ? $img.attr('width') : ''
|
1651
|
+
};
|
1652
|
+
}
|
1653
|
+
|
1654
|
+
t.openModalInsert(t.lang.insertImage, options, function (v) {
|
1655
|
+
if (v.url !== base64) {
|
1532
1656
|
$img.attr({
|
1533
|
-
src: v.
|
1657
|
+
src: v.url
|
1534
1658
|
});
|
1535
1659
|
}
|
1536
1660
|
$img.attr({
|
1537
1661
|
alt: v.alt
|
1538
1662
|
});
|
1663
|
+
|
1664
|
+
if (t.o.imageWidthModalEdit) {
|
1665
|
+
if (parseInt(v.width) > 0) {
|
1666
|
+
$img.attr({
|
1667
|
+
width: v.width
|
1668
|
+
});
|
1669
|
+
} else {
|
1670
|
+
$img.removeAttr('width');
|
1671
|
+
}
|
1672
|
+
}
|
1673
|
+
|
1539
1674
|
return true;
|
1540
1675
|
});
|
1541
1676
|
return false;
|
@@ -1660,7 +1795,9 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
|
|
1660
1795
|
|
1661
1796
|
tags.push(tag);
|
1662
1797
|
|
1663
|
-
return t.getTagsRecursive(element, tags).filter(function(tag) {
|
1798
|
+
return t.getTagsRecursive(element, tags).filter(function (tag) {
|
1799
|
+
return tag != null;
|
1800
|
+
});
|
1664
1801
|
},
|
1665
1802
|
|
1666
1803
|
// Plugins
|