simditor 2.1.13.0 → 2.1.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a1eab9b36be1a087a73d9dfc94ff617e8c3f87e
4
- data.tar.gz: 91deabc3ffb2d1562ad388904c2e10bb1523a7f3
3
+ metadata.gz: f75a513dd663c540630620d3b1ee2dc6b211b236
4
+ data.tar.gz: 91250213440c024d653545761b4bf551c6870f2c
5
5
  SHA512:
6
- metadata.gz: f0d471b2eeb0efd1914186a03c23982ed7502d5901ffc2a79d75b33afa0300a75bcb7269efd4581772ecb83e9eca3f3e4e12f4434c0257b89df91f71c134c321
7
- data.tar.gz: 9c6671b4e293d12498cf39ce105a305148705b0ceb69159ad5f35151a984983d2c876256ef1c5254dfe8b5f84a8ee612cac62d138e9146840daaca207bbe38c6
6
+ metadata.gz: 5f9b58d8eb3395d197b1d611c6d9030cb28798f83c5c4386768bdbda53c4a814274f67e6e76856abdc1f998f3de439e1c98b7b4ed46115b0d44dda4d51906f03
7
+ data.tar.gz: 80f8ce824f6fc586584cc09010ba331418f35c08daede393ef77135887fcb428a53050370fab597ba1352b11566c2cde8b6d051baf942769c32184a61eb0c203
@@ -1,5 +1,5 @@
1
1
  module Simditor
2
2
  module Version
3
- EDITOR = "2.1.13.0"
3
+ EDITOR = "2.1.14"
4
4
  end
5
5
  end
@@ -8,7 +8,7 @@
8
8
  // Node. Does not work with strict CommonJS, but
9
9
  // only CommonJS-like environments that support module.exports,
10
10
  // like Node.
11
- module.exports = factory(require("jquery"),require("simplemodule"));
11
+ module.exports = factory(require("jquery"),require("simple-module"));
12
12
  } else {
13
13
  root.simple = root.simple || {};
14
14
  root.simple['hotkeys'] = factory(jQuery,SimpleModule);
@@ -1,12 +1,12 @@
1
1
  (function (root, factory) {
2
2
  if (typeof define === 'function' && define.amd) {
3
- // AMD. Register as an anonymous module.
4
- define('simple-module', ["jquery"], function ($) {
5
- return (root.returnExportsGlobal = factory($));
3
+ // AMD. Register as an anonymous module unless amdModuleId is set
4
+ define('simple-module', ["jquery"], function (a0) {
5
+ return (root['Module'] = factory(a0));
6
6
  });
7
7
  } else if (typeof exports === 'object') {
8
8
  // Node. Does not work with strict CommonJS, but
9
- // only CommonJS-like enviroments that support module.exports,
9
+ // only CommonJS-like environments that support module.exports,
10
10
  // like Node.
11
11
  module.exports = factory(require("jquery"));
12
12
  } else {
@@ -15,11 +15,11 @@
15
15
  }(this, function ($) {
16
16
 
17
17
  var Module,
18
- __slice = [].slice;
18
+ slice = [].slice;
19
19
 
20
20
  Module = (function() {
21
21
  Module.extend = function(obj) {
22
- var key, val, _ref;
22
+ var key, ref, val;
23
23
  if (!((obj != null) && typeof obj === 'object')) {
24
24
  return;
25
25
  }
@@ -29,11 +29,11 @@ Module = (function() {
29
29
  this[key] = val;
30
30
  }
31
31
  }
32
- return (_ref = obj.extended) != null ? _ref.call(this) : void 0;
32
+ return (ref = obj.extended) != null ? ref.call(this) : void 0;
33
33
  };
34
34
 
35
35
  Module.include = function(obj) {
36
- var key, val, _ref;
36
+ var key, ref, val;
37
37
  if (!((obj != null) && typeof obj === 'object')) {
38
38
  return;
39
39
  }
@@ -43,7 +43,7 @@ Module = (function() {
43
43
  this.prototype[key] = val;
44
44
  }
45
45
  }
46
- return (_ref = obj.included) != null ? _ref.call(this) : void 0;
46
+ return (ref = obj.included) != null ? ref.call(this) : void 0;
47
47
  };
48
48
 
49
49
  Module.connect = function(cls) {
@@ -67,29 +67,29 @@ Module = (function() {
67
67
  Module.prototype.opts = {};
68
68
 
69
69
  function Module(opts) {
70
- var cls, instance, instances, name, _base, _i, _len;
70
+ var base, cls, i, instance, instances, len, name;
71
71
  this.opts = $.extend({}, this.opts, opts);
72
- (_base = this.constructor)._connectedClasses || (_base._connectedClasses = []);
72
+ (base = this.constructor)._connectedClasses || (base._connectedClasses = []);
73
73
  instances = (function() {
74
- var _i, _len, _ref, _results;
75
- _ref = this.constructor._connectedClasses;
76
- _results = [];
77
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
78
- cls = _ref[_i];
74
+ var i, len, ref, results;
75
+ ref = this.constructor._connectedClasses;
76
+ results = [];
77
+ for (i = 0, len = ref.length; i < len; i++) {
78
+ cls = ref[i];
79
79
  name = cls.pluginName.charAt(0).toLowerCase() + cls.pluginName.slice(1);
80
80
  if (cls.prototype._connected) {
81
81
  cls.prototype._module = this;
82
82
  }
83
- _results.push(this[name] = new cls());
83
+ results.push(this[name] = new cls());
84
84
  }
85
- return _results;
85
+ return results;
86
86
  }).call(this);
87
87
  if (this._connected) {
88
88
  this.opts = $.extend({}, this.opts, this._module.opts);
89
89
  } else {
90
90
  this._init();
91
- for (_i = 0, _len = instances.length; _i < _len; _i++) {
92
- instance = instances[_i];
91
+ for (i = 0, len = instances.length; i < len; i++) {
92
+ instance = instances[i];
93
93
  if (typeof instance._init === "function") {
94
94
  instance._init();
95
95
  }
@@ -101,49 +101,49 @@ Module = (function() {
101
101
  Module.prototype._init = function() {};
102
102
 
103
103
  Module.prototype.on = function() {
104
- var args, _ref;
105
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
106
- (_ref = $(this)).on.apply(_ref, args);
104
+ var args, ref;
105
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
106
+ (ref = $(this)).on.apply(ref, args);
107
107
  return this;
108
108
  };
109
109
 
110
110
  Module.prototype.one = function() {
111
- var args, _ref;
112
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
113
- (_ref = $(this)).one.apply(_ref, args);
111
+ var args, ref;
112
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
113
+ (ref = $(this)).one.apply(ref, args);
114
114
  return this;
115
115
  };
116
116
 
117
117
  Module.prototype.off = function() {
118
- var args, _ref;
119
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
120
- (_ref = $(this)).off.apply(_ref, args);
118
+ var args, ref;
119
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
120
+ (ref = $(this)).off.apply(ref, args);
121
121
  return this;
122
122
  };
123
123
 
124
124
  Module.prototype.trigger = function() {
125
- var args, _ref;
126
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
127
- (_ref = $(this)).trigger.apply(_ref, args);
125
+ var args, ref;
126
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
127
+ (ref = $(this)).trigger.apply(ref, args);
128
128
  return this;
129
129
  };
130
130
 
131
131
  Module.prototype.triggerHandler = function() {
132
- var args, _ref;
133
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
134
- return (_ref = $(this)).triggerHandler.apply(_ref, args);
132
+ var args, ref;
133
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
134
+ return (ref = $(this)).triggerHandler.apply(ref, args);
135
135
  };
136
136
 
137
137
  Module.prototype._t = function() {
138
- var args, _ref;
139
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
140
- return (_ref = this.constructor)._t.apply(_ref, args);
138
+ var args, ref;
139
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
140
+ return (ref = this.constructor)._t.apply(ref, args);
141
141
  };
142
142
 
143
143
  Module._t = function() {
144
- var args, key, result, _ref;
145
- key = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
146
- result = ((_ref = this.i18n[this.locale]) != null ? _ref[key] : void 0) || '';
144
+ var args, key, ref, result;
145
+ key = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
146
+ result = ((ref = this.i18n[this.locale]) != null ? ref[key] : void 0) || '';
147
147
  if (!(args.length > 0)) {
148
148
  return result;
149
149
  }
@@ -167,8 +167,6 @@ Module = (function() {
167
167
 
168
168
  })();
169
169
 
170
-
171
170
  return Module;
172
171
 
173
-
174
172
  }));
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Simditor v2.1.13
3
3
  * http://simditor.tower.im/
4
- * 2015-09-06
4
+ * 2015-06-23
5
5
  */
6
6
  (function (root, factory) {
7
7
  if (typeof define === 'function' && define.amd) {
@@ -324,22 +324,21 @@ Formatter = (function(superClass) {
324
324
  this.editor = this._module;
325
325
  this._allowedTags = this.opts.allowedTags || ['br', 'a', 'img', 'b', 'strong', 'i', 'u', 'font', 'p', 'ul', 'ol', 'li', 'blockquote', 'pre', 'code', 'h1', 'h2', 'h3', 'h4', 'hr'];
326
326
  this._allowedAttributes = this.opts.allowedAttributes || {
327
- img: ['src', 'alt', 'width', 'height', 'data-image-src', 'data-image-size', 'data-image-name', 'data-non-image'],
327
+ img: ['src', 'alt', 'width', 'height', 'data-non-image'],
328
328
  a: ['href', 'target'],
329
329
  font: ['color'],
330
- pre: ['data-lang'],
331
- code: ['class'],
332
- p: ['data-indent', 'data-align'],
333
- h1: ['data-indent'],
334
- h2: ['data-indent'],
335
- h3: ['data-indent'],
336
- h4: ['data-indent']
330
+ code: ['class']
337
331
  };
338
- return this.editor.body.on('click', 'a', (function(_this) {
339
- return function(e) {
340
- return false;
341
- };
342
- })(this));
332
+ this._allowedStyles = this.opts.allowedStyles || {
333
+ p: ['margin-left', 'text-align'],
334
+ h1: ['margin-left'],
335
+ h2: ['margin-left'],
336
+ h3: ['margin-left'],
337
+ h4: ['margin-left']
338
+ };
339
+ return this.editor.body.on('click', 'a', function(e) {
340
+ return false;
341
+ });
343
342
  };
344
343
 
345
344
  Formatter.prototype.decorate = function($el) {
@@ -358,7 +357,7 @@ Formatter = (function(superClass) {
358
357
  };
359
358
 
360
359
  Formatter.prototype.autolink = function($el) {
361
- var $node, findLinkNode, j, lastIndex, len, linkNodes, match, re, replaceEls, text, uri;
360
+ var $link, $node, findLinkNode, j, lastIndex, len, linkNodes, match, re, replaceEls, subStr, text, uri;
362
361
  if ($el == null) {
363
362
  $el = this.editor.body;
364
363
  }
@@ -386,10 +385,12 @@ Formatter = (function(superClass) {
386
385
  match = null;
387
386
  lastIndex = 0;
388
387
  while ((match = re.exec(text)) !== null) {
389
- replaceEls.push(document.createTextNode(text.substring(lastIndex, match.index)));
388
+ subStr = text.substring(lastIndex, match.index);
389
+ replaceEls.push(document.createTextNode(subStr));
390
390
  lastIndex = re.lastIndex;
391
391
  uri = /^(http(s)?:\/\/|\/)/.test(match[0]) ? match[0] : 'http://' + match[0];
392
- replaceEls.push($('<a href="' + uri + '" rel="nofollow"></a>').text(match[0])[0]);
392
+ $link = $("<a href=\"" + uri + "\" rel=\"nofollow\"></a>").text(match[0]);
393
+ replaceEls.push($link[0]);
393
394
  }
394
395
  replaceEls.push(document.createTextNode(text.substring(lastIndex)));
395
396
  $node.replaceWith($(replaceEls));
@@ -473,9 +474,13 @@ Formatter = (function(superClass) {
473
474
  ref = $.makeArray($node[0].attributes);
474
475
  for (j = 0, len = ref.length; j < len; j++) {
475
476
  attr = ref[j];
477
+ if (attr.name === 'style') {
478
+ continue;
479
+ }
476
480
  if (!((allowedAttributes != null) && (ref1 = attr.name, indexOf.call(allowedAttributes, ref1) >= 0))) {
477
481
  $node.removeAttr(attr.name);
478
482
  }
483
+ this._cleanNodeStyles($node);
479
484
  }
480
485
  }
481
486
  } else if ($node[0].nodeType === 1 && !$node.is(':empty')) {
@@ -484,11 +489,9 @@ Formatter = (function(superClass) {
484
489
  contents.first().unwrap();
485
490
  } else if ($node.is('table')) {
486
491
  $p = $('<p/>');
487
- $node.find('tr').each((function(_this) {
488
- return function(i, tr) {
489
- return $p.append($(tr).text() + '<br/>');
490
- };
491
- })(this));
492
+ $node.find('tr').each(function(i, tr) {
493
+ return $p.append($(tr).text() + '<br/>');
494
+ });
492
495
  $node.replaceWith($p);
493
496
  contents = null;
494
497
  } else if ($node.is('thead, tfoot')) {
@@ -513,6 +516,36 @@ Formatter = (function(superClass) {
513
516
  return null;
514
517
  };
515
518
 
519
+ Formatter.prototype._cleanNodeStyles = function($node) {
520
+ var allowedStyles, j, len, pair, ref, ref1, style, styleStr, styles;
521
+ styleStr = $node.attr('style');
522
+ if (!styleStr) {
523
+ return;
524
+ }
525
+ $node.removeAttr('style');
526
+ allowedStyles = this._allowedStyles[$node[0].tagName.toLowerCase()];
527
+ if (!(allowedStyles && allowedStyles.length > 0)) {
528
+ return $node;
529
+ }
530
+ styles = {};
531
+ ref = styleStr.split(';');
532
+ for (j = 0, len = ref.length; j < len; j++) {
533
+ style = ref[j];
534
+ style = $.trim(style);
535
+ pair = style.split(':');
536
+ if (!(pair.length = 2)) {
537
+ continue;
538
+ }
539
+ if (ref1 = pair[0], indexOf.call(allowedStyles, ref1) >= 0) {
540
+ styles[$.trim(pair[0])] = $trim(pair[1]);
541
+ }
542
+ }
543
+ if (Object.keys(styles).length > 0) {
544
+ $node.css(styles);
545
+ }
546
+ return $node;
547
+ };
548
+
516
549
  Formatter.prototype.clearHtml = function(html, lineBreak) {
517
550
  var container, contents, result;
518
551
  if (lineBreak == null) {
@@ -532,7 +565,7 @@ Formatter = (function(superClass) {
532
565
  if (children.length > 0) {
533
566
  result += _this.clearHtml(children);
534
567
  }
535
- if (lineBreak && i < contents.length - 1 && $node.is('br, p, div, li, tr, pre, address, artticle, aside, dl, figcaption, footer, h1, h2, h3, h4, header')) {
568
+ if (lineBreak && i < contents.length - 1 && $node.is('br, p, div, li,tr, pre, address, artticle, aside, dl, figcaption, footer, h1, h2,h3, h4, header')) {
536
569
  return result += '\n';
537
570
  }
538
571
  }
@@ -546,19 +579,15 @@ Formatter = (function(superClass) {
546
579
  uselessP = function($el) {
547
580
  return !!($el.is('p') && !$el.text() && $el.children(':not(br)').length < 1);
548
581
  };
549
- return $contents.each((function(_this) {
550
- return function(i, el) {
551
- var $el;
552
- $el = $(el);
553
- if ($el.is(':not(img, br, col, td, hr, [class^="simditor-"]):empty')) {
554
- $el.remove();
555
- }
556
- if (uselessP($el)) {
557
- $el.remove();
558
- }
559
- return $el.find(':not(img, br, col, td, hr, [class^="simditor-"]):empty').remove();
560
- };
561
- })(this));
582
+ return $contents.each(function(i, el) {
583
+ var $el, invalid;
584
+ $el = $(el);
585
+ invalid = $el.is(':not(img, br, col, td, hr, [class^="simditor-"]):empty');
586
+ if (invalid || uselessP($el)) {
587
+ $el.remove();
588
+ }
589
+ return $el.find(':not(img, br, col, td, hr, [class^="simditor-"]):empty').remove();
590
+ });
562
591
  };
563
592
 
564
593
  return Formatter;
@@ -1660,17 +1689,15 @@ Util = (function(superClass) {
1660
1689
  return null;
1661
1690
  }
1662
1691
  blockEl = $node.parentsUntil(this.editor.body).addBack();
1663
- blockEl = blockEl.filter((function(_this) {
1664
- return function(i) {
1665
- var $n;
1666
- $n = blockEl.eq(i);
1667
- if ($.isFunction(filter)) {
1668
- return filter($n);
1669
- } else {
1670
- return $n.is(filter);
1671
- }
1672
- };
1673
- })(this));
1692
+ blockEl = blockEl.filter(function(i) {
1693
+ var $n;
1694
+ $n = blockEl.eq(i);
1695
+ if ($.isFunction(filter)) {
1696
+ return filter($n);
1697
+ } else {
1698
+ return $n.is(filter);
1699
+ }
1700
+ });
1674
1701
  if (blockEl.length) {
1675
1702
  return blockEl.first();
1676
1703
  } else {
@@ -1720,7 +1747,7 @@ Util = (function(superClass) {
1720
1747
  };
1721
1748
 
1722
1749
  Util.prototype.dataURLtoBlob = function(dataURL) {
1723
- var BlobBuilder, arrayBuffer, bb, byteString, hasArrayBufferViewSupport, hasBlobConstructor, i, intArray, j, mimeString, ref;
1750
+ var BlobBuilder, arrayBuffer, bb, blobArray, byteString, hasArrayBufferViewSupport, hasBlobConstructor, i, intArray, j, mimeString, ref, supportBlob;
1724
1751
  hasBlobConstructor = window.Blob && (function() {
1725
1752
  var e;
1726
1753
  try {
@@ -1740,7 +1767,8 @@ Util = (function(superClass) {
1740
1767
  }
1741
1768
  })();
1742
1769
  BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
1743
- if (!((hasBlobConstructor || BlobBuilder) && window.atob && window.ArrayBuffer && window.Uint8Array)) {
1770
+ supportBlob = hasBlobConstructor || BlobBuilder;
1771
+ if (!(supportBlob && window.atob && window.ArrayBuffer && window.Uint8Array)) {
1744
1772
  return false;
1745
1773
  }
1746
1774
  if (dataURL.split(',')[0].indexOf('base64') >= 0) {
@@ -1755,7 +1783,8 @@ Util = (function(superClass) {
1755
1783
  }
1756
1784
  mimeString = dataURL.split(',')[0].split(':')[1].split(';')[0];
1757
1785
  if (hasBlobConstructor) {
1758
- return new Blob([hasArrayBufferViewSupport ? intArray : arrayBuffer], {
1786
+ blobArray = hasArrayBufferViewSupport ? intArray : arrayBuffer;
1787
+ return new Blob(blobArray, {
1759
1788
  type: mimeString
1760
1789
  });
1761
1790
  }
@@ -2067,7 +2096,7 @@ Indentation = (function(superClass) {
2067
2096
  };
2068
2097
 
2069
2098
  Indentation.prototype.indentBlock = function(blockEl) {
2070
- var $blockEl, $childList, $nextTd, $nextTr, $parentLi, $pre, $td, $tr, indentLevel, range, tagName;
2099
+ var $blockEl, $childList, $nextTd, $nextTr, $parentLi, $pre, $td, $tr, marginLeft, range, tagName;
2071
2100
  $blockEl = $(blockEl);
2072
2101
  if (!$blockEl.length) {
2073
2102
  return;
@@ -2094,9 +2123,9 @@ Indentation = (function(superClass) {
2094
2123
  }
2095
2124
  this.editor.selection.restore();
2096
2125
  } else if ($blockEl.is('p, h1, h2, h3, h4')) {
2097
- indentLevel = $blockEl.attr('data-indent') || 0;
2098
- indentLevel = Math.min(indentLevel * 1 + 1, 10);
2099
- $blockEl.attr('data-indent', indentLevel);
2126
+ marginLeft = parseInt($blockEl.css('margin-left')) || 0;
2127
+ marginLeft = (Math.round(marginLeft / this.opts.indentWidth) + 1) * this.opts.indentWidth;
2128
+ $blockEl.css('margin-left', marginLeft);
2100
2129
  } else if ($blockEl.is('table') || $blockEl.is('.simditor-table')) {
2101
2130
  range = this.editor.selection.getRange();
2102
2131
  $td = $(range.commonAncestorContainer).closest('td, th');
@@ -2132,7 +2161,7 @@ Indentation = (function(superClass) {
2132
2161
  };
2133
2162
 
2134
2163
  Indentation.prototype.outdentBlock = function(blockEl) {
2135
- var $blockEl, $parent, $parentLi, $pre, $prevTd, $prevTr, $td, $tr, button, indentLevel, range, ref;
2164
+ var $blockEl, $parent, $parentLi, $pre, $prevTd, $prevTr, $td, $tr, button, marginLeft, range;
2136
2165
  $blockEl = $(blockEl);
2137
2166
  if (!($blockEl && $blockEl.length > 0)) {
2138
2167
  return;
@@ -2164,12 +2193,9 @@ Indentation = (function(superClass) {
2164
2193
  }
2165
2194
  this.editor.selection.restore();
2166
2195
  } else if ($blockEl.is('p, h1, h2, h3, h4')) {
2167
- indentLevel = (ref = $blockEl.attr('data-indent')) != null ? ref : 0;
2168
- indentLevel = indentLevel * 1 - 1;
2169
- if (indentLevel < 0) {
2170
- indentLevel = 0;
2171
- }
2172
- $blockEl.attr('data-indent', indentLevel);
2196
+ marginLeft = parseInt($blockEl.css('margin-left')) || 0;
2197
+ marginLeft = Math.max(Math.round(marginLeft / this.opts.indentWidth) - 1, 0) * this.opts.indentWidth;
2198
+ $blockEl.css('margin-left', marginLeft === 0 ? '' : marginLeft);
2173
2199
  } else if ($blockEl.is('table') || $blockEl.is('.simditor-table')) {
2174
2200
  range = this.editor.selection.getRange();
2175
2201
  $td = $(range.commonAncestorContainer).closest('td, th');
@@ -2226,7 +2252,8 @@ Simditor = (function(superClass) {
2226
2252
  placeholder: '',
2227
2253
  defaultImage: 'images/image.png',
2228
2254
  params: {},
2229
- upload: false
2255
+ upload: false,
2256
+ indentWidth: 40
2230
2257
  };
2231
2258
 
2232
2259
  Simditor.prototype._init = function() {
@@ -2317,9 +2344,9 @@ Simditor = (function(superClass) {
2317
2344
  };
2318
2345
 
2319
2346
  Simditor.prototype._placeholder = function() {
2320
- var children, ref;
2347
+ var children;
2321
2348
  children = this.body.children();
2322
- if (children.length === 0 || (children.length === 1 && this.util.isEmptyNode(children) && ((ref = children.data('indent')) != null ? ref : 0) < 1)) {
2349
+ if (children.length === 0 || (children.length === 1 && this.util.isEmptyNode(children) && parseInt(children.css('margin-left') || 0) < this.opts.indentWidth)) {
2323
2350
  return this.placeholderEl.show();
2324
2351
  } else {
2325
2352
  return this.placeholderEl.hide();
@@ -2394,14 +2421,12 @@ Simditor = (function(superClass) {
2394
2421
  };
2395
2422
 
2396
2423
  Simditor.prototype.hidePopover = function() {
2397
- return this.el.find('.simditor-popover').each((function(_this) {
2398
- return function(i, popover) {
2399
- popover = $(popover).data('popover');
2400
- if (popover.active) {
2401
- return popover.hide();
2402
- }
2403
- };
2404
- })(this));
2424
+ return this.el.find('.simditor-popover').each(function(i, popover) {
2425
+ popover = $(popover).data('popover');
2426
+ if (popover.active) {
2427
+ return popover.hide();
2428
+ }
2429
+ });
2405
2430
  };
2406
2431
 
2407
2432
  Simditor.prototype.destroy = function() {
@@ -2737,6 +2762,9 @@ Popover = (function(superClass) {
2737
2762
  }
2738
2763
  };
2739
2764
  })(this));
2765
+ if (this.active && this.target) {
2766
+ this.target.removeClass('selected');
2767
+ }
2740
2768
  this.target = $target.addClass('selected');
2741
2769
  if (this.active) {
2742
2770
  this.refresh(position);
@@ -3598,9 +3626,81 @@ CodePopover = (function(superClass) {
3598
3626
  }
3599
3627
 
3600
3628
  CodePopover.prototype.render = function() {
3601
- this._tpl = "<div class=\"code-settings\">\n <div class=\"settings-field\">\n <select class=\"select-lang\">\n <option value=\"-1\">" + (this._t('selectLanguage')) + "</option>\n <option value=\"bash\">Bash</option>\n <option value=\"c++\">C++</option>\n <option value=\"cs\">C#</option>\n <option value=\"css\">CSS</option>\n <option value=\"erlang\">Erlang</option>\n <option value=\"less\">Less</option>\n <option value=\"scss\">Sass</option>\n <option value=\"diff\">Diff</option>\n <option value=\"coffeeScript\">CoffeeScript</option>\n <option value=\"html\">Html,XML</option>\n <option value=\"json\">JSON</option>\n <option value=\"java\">Java</option>\n <option value=\"js\">JavaScript</option>\n <option value=\"markdown\">Markdown</option>\n <option value=\"oc\">Objective C</option>\n <option value=\"php\">PHP</option>\n <option value=\"perl\">Perl</option>\n <option value=\"python\">Python</option>\n <option value=\"ruby\">Ruby</option>\n <option value=\"sql\">SQL</option>\n </select>\n </div>\n</div>";
3629
+ var $option, j, lang, len, ref;
3630
+ this._tpl = "<div class=\"code-settings\">\n <div class=\"settings-field\">\n <select class=\"select-lang\">\n <option value=\"-1\">" + (this._t('selectLanguage')) + "</option>\n </select>\n </div>\n</div>";
3631
+ this.langs = this.editor.opts.codeLanguages || [
3632
+ {
3633
+ name: 'Bash',
3634
+ value: 'bash'
3635
+ }, {
3636
+ name: 'C++',
3637
+ value: 'c++'
3638
+ }, {
3639
+ name: 'C#',
3640
+ value: 'cs'
3641
+ }, {
3642
+ name: 'CSS',
3643
+ value: 'css'
3644
+ }, {
3645
+ name: 'Erlang',
3646
+ value: 'erlang'
3647
+ }, {
3648
+ name: 'Less',
3649
+ value: 'less'
3650
+ }, {
3651
+ name: 'Sass',
3652
+ value: 'sass'
3653
+ }, {
3654
+ name: 'Diff',
3655
+ value: 'diff'
3656
+ }, {
3657
+ name: 'CoffeeScript',
3658
+ value: 'coffeescript'
3659
+ }, {
3660
+ name: 'HTML,XML',
3661
+ value: 'html'
3662
+ }, {
3663
+ name: 'JSON',
3664
+ value: 'json'
3665
+ }, {
3666
+ name: 'Java',
3667
+ value: 'java'
3668
+ }, {
3669
+ name: 'JavaScript',
3670
+ value: 'js'
3671
+ }, {
3672
+ name: 'Markdown',
3673
+ value: 'markdown'
3674
+ }, {
3675
+ name: 'Objective C',
3676
+ value: 'oc'
3677
+ }, {
3678
+ name: 'PHP',
3679
+ value: 'php'
3680
+ }, {
3681
+ name: 'Perl',
3682
+ value: 'parl'
3683
+ }, {
3684
+ name: 'Python',
3685
+ value: 'python'
3686
+ }, {
3687
+ name: 'Ruby',
3688
+ value: 'ruby'
3689
+ }, {
3690
+ name: 'SQL',
3691
+ value: 'sql'
3692
+ }
3693
+ ];
3602
3694
  this.el.addClass('code-popover').append(this._tpl);
3603
3695
  this.selectEl = this.el.find('.select-lang');
3696
+ ref = this.langs;
3697
+ for (j = 0, len = ref.length; j < len; j++) {
3698
+ lang = ref[j];
3699
+ $option = $('<option/>', {
3700
+ text: lang.name,
3701
+ value: lang.value
3702
+ }).appendTo(this.selectEl);
3703
+ }
3604
3704
  this.selectEl.on('change', (function(_this) {
3605
3705
  return function(e) {
3606
3706
  var selected;
@@ -3611,8 +3711,9 @@ CodePopover = (function(superClass) {
3611
3711
  _this.target.attr('data-lang', _this.lang);
3612
3712
  }
3613
3713
  if (selected) {
3614
- return _this.target.addClass('selected');
3714
+ _this.target.addClass('selected');
3615
3715
  }
3716
+ return _this.editor.trigger('valuechanged');
3616
3717
  };
3617
3718
  })(this));
3618
3719
  return this.editor.on('valuechanged', (function(_this) {
@@ -5166,6 +5267,9 @@ AlignmentButton = (function(superClass) {
5166
5267
  if (align == null) {
5167
5268
  align = 'left';
5168
5269
  }
5270
+ if (align !== 'left' && align !== 'center' && align !== 'right') {
5271
+ align = 'left';
5272
+ }
5169
5273
  if (align === 'left') {
5170
5274
  AlignmentButton.__super__.setActive.call(this, false);
5171
5275
  } else {
@@ -5191,14 +5295,14 @@ AlignmentButton = (function(superClass) {
5191
5295
  this.setActive(false);
5192
5296
  return true;
5193
5297
  }
5194
- this.setActive(true, $node.data("align"));
5298
+ this.setActive(true, $node.css('text-align'));
5195
5299
  return this.active;
5196
5300
  };
5197
5301
 
5198
5302
  AlignmentButton.prototype.command = function(align) {
5199
5303
  var $blockEls, $endBlock, $startBlock, block, endNode, j, len, range, ref, startNode;
5200
5304
  if (['left', 'center', 'right'].indexOf(align) < 0) {
5201
- throw "invalid " + align;
5305
+ throw new Error("invalid " + align);
5202
5306
  }
5203
5307
  range = this.editor.selection.getRange();
5204
5308
  startNode = range.startContainer;
@@ -5210,7 +5314,7 @@ AlignmentButton = (function(superClass) {
5210
5314
  ref = $blockEls.filter(this.htmlTag);
5211
5315
  for (j = 0, len = ref.length; j < len; j++) {
5212
5316
  block = ref[j];
5213
- $(block).attr('data-align', align).data('align', align);
5317
+ $(block).css('text-align', align === 'left' ? '' : align);
5214
5318
  }
5215
5319
  this.editor.selection.restore();
5216
5320
  return this.editor.trigger('valuechanged');
@@ -8,7 +8,7 @@
8
8
  // Node. Does not work with strict CommonJS, but
9
9
  // only CommonJS-like environments that support module.exports,
10
10
  // like Node.
11
- module.exports = factory(require("jquery"),require("simplemodule"));
11
+ module.exports = factory(require("jquery"),require("simple-module"));
12
12
  } else {
13
13
  root.simple = root.simple || {};
14
14
  root.simple['uploader'] = factory(jQuery,SimpleModule);
@@ -682,18 +682,4 @@ $simditor-button-height: 40px;
682
682
  vertical-align: middle;
683
683
  }
684
684
 
685
- @for $i from 0 through 10 {
686
- *[data-indent="#{$i}"] {
687
- margin-left: 40px * $i;
688
- }
689
- }
690
-
691
- @each $align in center, left, right {
692
- p, h1, h2, h3, h4 {
693
- &[data-align="#{$align}"] {
694
- text-align: $align;
695
- }
696
- }
697
- }
698
-
699
685
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.13.0
4
+ version: 2.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wentao Liu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-11 00:00:00.000000000 Z
11
+ date: 2015-06-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rails assets wrapper for https://github.com/mycolorway/simditor
14
14
  email: