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.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -0
  3. data/app/assets/fonts/active_admin-trumbowyg.svg +1 -1
  4. data/app/assets/javascripts/activeadmin/trumbowyg/langs/da.min.js +1 -1
  5. data/app/assets/javascripts/activeadmin/trumbowyg/langs/de.min.js +1 -1
  6. data/app/assets/javascripts/activeadmin/trumbowyg/langs/fa.min.js +1 -1
  7. data/app/assets/javascripts/activeadmin/trumbowyg/langs/fr.min.js +3 -1
  8. data/app/assets/javascripts/activeadmin/trumbowyg/langs/lt.min.js +8 -0
  9. data/app/assets/javascripts/activeadmin/trumbowyg/langs/sq.min.js +8 -0
  10. data/app/assets/javascripts/activeadmin/trumbowyg/langs/th.min.js +9 -0
  11. data/app/assets/javascripts/activeadmin/trumbowyg/langs/zh_tw.min.js +1 -1
  12. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/allowtagsfrompaste/trumbowyg.allowtagsfrompaste.js +143 -0
  13. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/allowtagsfrompaste/trumbowyg.allowtagsfrompaste.min.js +1 -0
  14. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.js +21 -1
  15. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.min.js +1 -1
  16. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.js +23 -90
  17. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.min.js +1 -1
  18. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.js +24 -2
  19. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.min.js +1 -1
  20. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/sass/trumbowyg.colors.scss +1 -1
  21. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.css +1 -1
  22. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.min.css +1 -1
  23. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.js +1190 -876
  24. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.min.js +1 -1
  25. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/sass/trumbowyg.emoji.scss +1 -1
  26. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.css +1 -1
  27. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.min.css +1 -1
  28. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontfamily/trumbowyg.fontfamily.js +82 -0
  29. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontfamily/trumbowyg.fontfamily.min.js +1 -0
  30. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontsize/trumbowyg.fontsize.js +160 -0
  31. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontsize/trumbowyg.fontsize.min.js +1 -0
  32. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/trumbowyg.highlight.js +82 -0
  33. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/trumbowyg.highlight.min.js +1 -0
  34. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/ui/sass/trumbowyg.highlight.scss +25 -0
  35. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.css +20 -0
  36. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.min.css +2 -0
  37. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/history/trumbowyg.history.js +202 -0
  38. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/history/trumbowyg.history.min.js +1 -0
  39. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.js +10 -1
  40. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.min.js +1 -1
  41. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/lineheight/trumbowyg.lineheight.js +122 -0
  42. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/lineheight/trumbowyg.lineheight.min.js +1 -0
  43. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/trumbowyg.mathml.js +98 -0
  44. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/trumbowyg.mathml.min.js +1 -0
  45. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/sass/trumbowyg.mathml.scss +36 -0
  46. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.css +29 -0
  47. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.min.css +2 -0
  48. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/trumbowyg.mention.js +111 -0
  49. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/trumbowyg.mention.min.js +1 -0
  50. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/sass/trumbowyg.mention.scss +39 -0
  51. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/trumbowyg.mention.css +32 -0
  52. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/trumbowyg.mention.min.css +2 -0
  53. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.js +12 -2
  54. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.min.js +1 -1
  55. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.js +96 -0
  56. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.min.js +1 -0
  57. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js +1 -1
  58. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js +1 -1
  59. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js +16 -3
  60. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js +1 -1
  61. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/trumbowyg.resizimg.js +69 -0
  62. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/trumbowyg.resizimg.min.js +1 -0
  63. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/ruby/trumbowyg.ruby.js +82 -0
  64. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/ruby/trumbowyg.ruby.min.js +1 -0
  65. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/trumbowyg.table.js +236 -86
  66. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/trumbowyg.table.min.js +1 -1
  67. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/ui/sass/trumbowyg.table.scss +42 -0
  68. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/ui/trumbowyg.table.css +33 -0
  69. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/ui/trumbowyg.table.min.css +2 -0
  70. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/template/trumbowyg.template.js +19 -7
  71. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/template/trumbowyg.template.min.js +1 -1
  72. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.js +44 -20
  73. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.min.js +1 -1
  74. data/app/assets/javascripts/activeadmin/trumbowyg/trumbowyg.js +215 -78
  75. data/app/assets/javascripts/activeadmin/trumbowyg/trumbowyg.min.js +2 -2
  76. data/app/assets/javascripts/activeadmin/trumbowyg/ui/icons.svg +1 -1
  77. data/app/assets/javascripts/activeadmin/trumbowyg/ui/sass/trumbowyg.scss +25 -12
  78. data/app/assets/javascripts/activeadmin/trumbowyg/ui/trumbowyg.css +23 -20
  79. data/app/assets/javascripts/activeadmin/trumbowyg/ui/trumbowyg.min.css +2 -2
  80. data/app/assets/stylesheets/activeadmin/_trumbowyg_input.sass +5 -3
  81. data/app/assets/stylesheets/activeadmin/trumbowyg/ui/icons.svg +1 -1
  82. data/app/assets/stylesheets/activeadmin/trumbowyg/ui/sass/trumbowyg.scss +25 -12
  83. data/app/assets/stylesheets/activeadmin/trumbowyg/ui/trumbowyg.css +23 -20
  84. data/app/assets/stylesheets/activeadmin/trumbowyg/ui/trumbowyg.min.css +2 -2
  85. data/lib/activeadmin/trumbowyg/version.rb +1 -1
  86. metadata +40 -72
  87. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ar.min.js +0 -11
  88. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/bg.min.js +0 -8
  89. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/by.min.js +0 -8
  90. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ca.min.js +0 -11
  91. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/cs.min.js +0 -8
  92. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/da.min.js +0 -9
  93. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/de.min.js +0 -9
  94. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/el.min.js +0 -12
  95. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/es.min.js +0 -9
  96. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/es_ar.min.js +0 -10
  97. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/fa.min.js +0 -10
  98. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/fi.min.js +0 -9
  99. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/fr.min.js +0 -10
  100. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/he.min.js +0 -9
  101. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/hr.min.js +0 -9
  102. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/hu.min.js +0 -10
  103. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/id.min.js +0 -11
  104. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/it.min.js +0 -8
  105. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ja.min.js +0 -10
  106. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ko.min.js +0 -10
  107. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/mn.min.js +0 -8
  108. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/my.min.js +0 -8
  109. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/nl.min.js +0 -9
  110. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/no_nb.min.js +0 -10
  111. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ph.min.js +0 -8
  112. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/pl.min.js +0 -9
  113. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/pt.min.js +0 -11
  114. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/pt_br.min.js +0 -11
  115. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ro.min.js +0 -12
  116. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/rs.min.js +0 -8
  117. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/rs_latin.min.js +0 -9
  118. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ru.min.js +0 -8
  119. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/sk.min.js +0 -8
  120. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/sv.min.js +0 -12
  121. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/tr.min.js +0 -9
  122. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ua.min.js +0 -8
  123. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/vi.min.js +0 -9
  124. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/zh_cn.min.js +0 -11
  125. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/zh_tw.min.js +0 -11
  126. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.js +0 -121
  127. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.min.js +0 -1
  128. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.js +0 -179
  129. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.min.js +0 -1
  130. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.js +0 -176
  131. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.min.js +0 -1
  132. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/ui/sass/trumbowyg.colors.scss +0 -49
  133. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.css +0 -43
  134. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.min.css +0 -2
  135. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.js +0 -965
  136. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.min.js +0 -1
  137. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/ui/sass/trumbowyg.emoji.scss +0 -56
  138. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.css +0 -47
  139. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.min.css +0 -2
  140. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.js +0 -83
  141. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.min.js +0 -1
  142. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.js +0 -101
  143. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.min.js +0 -1
  144. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js +0 -41
  145. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js +0 -1
  146. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js +0 -123
  147. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js +0 -1
  148. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/table/trumbowyg.table.js +0 -154
  149. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/table/trumbowyg.table.min.js +0 -1
  150. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/template/trumbowyg.template.js +0 -58
  151. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/template/trumbowyg.template.min.js +0 -1
  152. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.js +0 -242
  153. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.min.js +0 -1
  154. data/app/assets/stylesheets/activeadmin/trumbowyg/trumbowyg.js +0 -1688
  155. data/app/assets/stylesheets/activeadmin/trumbowyg/trumbowyg.min.js +0 -2
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Trumbowyg v2.8.1 - A lightweight WYSIWYG editor
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
- try {
224
- throw new Error();
225
- } catch (e) {
226
- if (!e.hasOwnProperty('stack')) {
227
- console.warn('You must define svgPath: https://goo.gl/CfTY9U'); // jshint ignore:line
228
- } else {
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 = t.isIE ? 'keyup' : 'input';
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.semanticCode(false, e.type === 'compositionend' && keyCode === 13);
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
- }, 200);
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
- $btnPane.append($btnGroup);
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') && !$(this).hasClass(prefix + 'active') && !$(this).hasClass(prefix + 'not-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
- $dropdown = $('<div/>', { // the dropdown
773
- class: dropdownPrefix + '-' + btnName + ' ' + dropdownPrefix + ' ' + prefix + 'fixed-top',
774
- 'data-dropdown': btnName
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', d).hide();
1027
- $('.' + prefix + 'active', d).removeClass(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', 'strong');
1091
- t.semanticTag('i', 'em');
1092
- t.semanticTag('strike', 'del');
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', 'p', true);
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, newTag, copyAttributes) {
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
- title = $a.attr('title');
1170
- target = $a.attr('target');
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
- t.openModalInsert(t.lang.createLink, {
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: t.getRangeText()
1192
- },
1193
- target: {
1194
- label: t.lang.target,
1195
- value: target
1240
+ value: text
1196
1241
  }
1197
- }, function (v) { // v is value
1198
- var link = $(['<a href="', v.url, '">', v.text, '</a>'].join(''));
1199
- if (v.title.length > 0) {
1200
- link.attr('title', v.title);
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
- if (v.target.length > 0) {
1203
- link.attr('target', v.target);
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
- t.openModalInsert(t.lang.insertImage, {
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
- }, function (v) { // v are values
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).attr('alt', v.alt);
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
- }).appendTo(t.$box);
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', t.$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 + '" value="' + (field.value || '').replace(/"/g, '&quot;') + '"' + attr + '><span class="' + prefix + 'input-infos"><span>' +
1443
- ((!l) ? (lg[fieldName] ? lg[fieldName] : fieldName) : (lg[l] ? lg[l] : l)) +
1548
+ html += '<label><input type="' + (field.type || 'text') + '" name="' + n + '"' +
1549
+ (field.type === 'checkbox' && field.value ? ' checked="checked"' : ' value="' + (field.value || '').replace(/"/g, '&quot;')) +
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 $field = $('input[name="' + fieldName + '"]', $form),
1562
+ var n = field.name || fieldName;
1563
+
1564
+ var $field = $('input[name="' + n + '"]', $form),
1455
1565
  inputType = $field.attr('type');
1456
1566
 
1457
- if (inputType.toLowerCase() === 'checkbox') {
1458
- values[fieldName] = $field.is(':checked');
1459
- } else {
1460
- values[fieldName] = $.trim($field.val());
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[fieldName] === '') {
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[fieldName])) {
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
- t.openModalInsert(t.lang.insertImage, {
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
- }, function (v) {
1531
- if (v.src !== base64) {
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.src
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) { return tag != null; });
1798
+ return t.getTagsRecursive(element, tags).filter(function (tag) {
1799
+ return tag != null;
1800
+ });
1664
1801
  },
1665
1802
 
1666
1803
  // Plugins