simditor 2.1.5.1 → 2.1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 509551059b35c5be2fd35466e505a0abb60ff663
4
- data.tar.gz: 782ee7fb9bc3f51343bd4dc92610eaf4d40c0e48
3
+ metadata.gz: aad34313602242d3c57b3e66c1cb3875724862d2
4
+ data.tar.gz: 563b7a4c147de9b3acae6499c0414a625e2fc7be
5
5
  SHA512:
6
- metadata.gz: 8dcfdedef8920f531b5e03c8b57fcc5f0d9d8c1e50f6c68a0f62e341bb24d125e331b0cfe8f910df4691779f2e1bff6a0fa3745220138e5aa37aaeca69ecadcf
7
- data.tar.gz: df1cb856fecb9784e10ae2e9847b2244a939b72588066a98d7c783cef944f557d9b4eef60409f1a4fb65e9f8d0a1bb4d0ff99ada4ec0870375fb49135c0a7966
6
+ metadata.gz: 900d43f6655399a9c570d59e6698dfd0698ff696f53370d86eaaeea38eb5cb9ebcca48535ac8c9aae3d187f46c6fe89040f668c8aa2601a294779675ad86a2b3
7
+ data.tar.gz: 9ad53e032294e73ea59c6aab7b3d6af4d3649351d9d85d8457ba6e725a523a72ad3681de8299dadf1fbe92515086067aedcf4f53b0c1c51fe60e10101ecb132c
data/README.md CHANGED
@@ -17,3 +17,19 @@ in application.css
17
17
  ```
18
18
  *= require simditor
19
19
  ```
20
+
21
+ ## Initialization
22
+
23
+ ```coffeescript
24
+ editor = new Simditor(
25
+ textarea: $('#editor')
26
+ toolbar: [
27
+ 'title','bold','italic','underline','strikethrough','color','|'
28
+ 'ol','ul','blockquote','code','table','link','image','hr','|'
29
+ 'indent','outdent','|'
30
+ 'source'
31
+ ]
32
+ pasteImage: true
33
+ defaultImage: '<%= image_path "upload-loading.png" %>'
34
+ upload: url: '/upload')
35
+ ```
@@ -1,5 +1,5 @@
1
1
  module Simditor
2
2
  module Version
3
- EDITOR = "2.1.5.1"
3
+ EDITOR = "2.1.6.0"
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * Simditor v2.1.5
2
+ * Simditor v2.1.6
3
3
  * http://simditor.tower.im/
4
- * 2015-07-03
4
+ * 2015-10-04
5
5
  */
6
6
  (function (root, factory) {
7
7
  if (typeof define === 'function' && define.amd) {
@@ -19,7 +19,7 @@
19
19
  }
20
20
  }(this, function ($, SimpleModule, simpleHotkeys, simpleUploader) {
21
21
 
22
- var BlockquoteButton, BoldButton, Button, CodeButton, CodePopover, ColorButton, Formatter, HrButton, ImageButton, ImagePopover, IndentButton, InputManager, ItalicButton, Keystroke, LinkButton, LinkPopover, ListButton, OrderListButton, OutdentButton, Popover, Selection, Simditor, SourceButton, StrikethroughButton, TableButton, TitleButton, Toolbar, UnderlineButton, UndoManager, UnorderListButton, Util,
22
+ var BlockquoteButton, BoldButton, Button, CodeButton, CodePopover, ColorButton, Formatter, HrButton, ImageButton, ImagePopover, IndentButton, Indentation, InputManager, ItalicButton, Keystroke, LinkButton, LinkPopover, ListButton, OrderListButton, OutdentButton, Popover, Selection, Simditor, SourceButton, StrikethroughButton, TableButton, TitleButton, Toolbar, UnderlineButton, UndoManager, UnorderListButton, Util,
23
23
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
24
24
  hasProp = {}.hasOwnProperty,
25
25
  indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
@@ -1076,21 +1076,6 @@ Keystroke = (function(superClass) {
1076
1076
  }
1077
1077
  };
1078
1078
  })(this));
1079
- this.editor.inputManager.addKeystrokeHandler('9', '*', (function(_this) {
1080
- return function(e) {
1081
- var codeButton;
1082
- codeButton = _this.editor.toolbar.findButton('code');
1083
- if (!(_this.editor.opts.tabIndent || (codeButton && codeButton.active))) {
1084
- return;
1085
- }
1086
- if (e.shiftKey) {
1087
- _this.editor.util.outdent();
1088
- } else {
1089
- _this.editor.util.indent();
1090
- }
1091
- return true;
1092
- };
1093
- })(this));
1094
1079
  this.editor.inputManager.addKeystrokeHandler('13', 'li', (function(_this) {
1095
1080
  return function(e, $node) {
1096
1081
  var $cloneNode, listEl, newBlockEl, newListEl;
@@ -1733,107 +1718,6 @@ Util = (function(superClass) {
1733
1718
  return results1;
1734
1719
  };
1735
1720
 
1736
- Util.prototype.indent = function() {
1737
- var $blockEl, $childList, $nextTd, $parentLi, $td, indentLevel, range, ref, spaceNode, tagName;
1738
- $blockEl = this.editor.util.closestBlockEl();
1739
- if (!($blockEl && $blockEl.length > 0)) {
1740
- return false;
1741
- }
1742
- if ($blockEl.is('pre')) {
1743
- spaceNode = document.createTextNode('\u00A0\u00A0');
1744
- this.editor.selection.insertNode(spaceNode);
1745
- } else if ($blockEl.is('li')) {
1746
- $parentLi = $blockEl.prev('li');
1747
- if ($parentLi.length < 1) {
1748
- return false;
1749
- }
1750
- this.editor.selection.save();
1751
- tagName = $blockEl.parent()[0].tagName;
1752
- $childList = $parentLi.children('ul, ol');
1753
- if ($childList.length > 0) {
1754
- $childList.append($blockEl);
1755
- } else {
1756
- $('<' + tagName + '/>').append($blockEl).appendTo($parentLi);
1757
- }
1758
- this.editor.selection.restore();
1759
- } else if ($blockEl.is('p, h1, h2, h3, h4')) {
1760
- indentLevel = (ref = $blockEl.attr('data-indent')) != null ? ref : 0;
1761
- indentLevel = indentLevel * 1 + 1;
1762
- if (indentLevel > 10) {
1763
- indentLevel = 10;
1764
- }
1765
- $blockEl.attr('data-indent', indentLevel);
1766
- } else if ($blockEl.is('table')) {
1767
- range = this.editor.selection.getRange();
1768
- $td = $(range.commonAncestorContainer).closest('td');
1769
- $nextTd = $td.next('td');
1770
- if (!($nextTd.length > 0)) {
1771
- $nextTd = $td.parent('tr').next('tr').find('td:first');
1772
- }
1773
- if (!($td.length > 0 && $nextTd.length > 0)) {
1774
- return false;
1775
- }
1776
- this.editor.selection.setRangeAtEndOf($nextTd);
1777
- } else {
1778
- spaceNode = document.createTextNode('\u00A0\u00A0\u00A0\u00A0');
1779
- this.editor.selection.insertNode(spaceNode);
1780
- }
1781
- this.editor.trigger('valuechanged');
1782
- return true;
1783
- };
1784
-
1785
- Util.prototype.outdent = function() {
1786
- var $blockEl, $parent, $parentLi, $prevTd, $td, button, indentLevel, range, ref;
1787
- $blockEl = this.editor.util.closestBlockEl();
1788
- if (!($blockEl && $blockEl.length > 0)) {
1789
- return false;
1790
- }
1791
- if ($blockEl.is('pre')) {
1792
- return false;
1793
- } else if ($blockEl.is('li')) {
1794
- $parent = $blockEl.parent();
1795
- $parentLi = $parent.parent('li');
1796
- if ($parentLi.length < 1) {
1797
- button = this.editor.toolbar.findButton($parent[0].tagName.toLowerCase());
1798
- if (button != null) {
1799
- button.command();
1800
- }
1801
- return false;
1802
- }
1803
- this.editor.selection.save();
1804
- if ($blockEl.next('li').length > 0) {
1805
- $('<' + $parent[0].tagName + '/>').append($blockEl.nextAll('li')).appendTo($blockEl);
1806
- }
1807
- $blockEl.insertAfter($parentLi);
1808
- if ($parent.children('li').length < 1) {
1809
- $parent.remove();
1810
- }
1811
- this.editor.selection.restore();
1812
- } else if ($blockEl.is('p, h1, h2, h3, h4')) {
1813
- indentLevel = (ref = $blockEl.attr('data-indent')) != null ? ref : 0;
1814
- indentLevel = indentLevel * 1 - 1;
1815
- if (indentLevel < 0) {
1816
- indentLevel = 0;
1817
- }
1818
- $blockEl.attr('data-indent', indentLevel);
1819
- } else if ($blockEl.is('table')) {
1820
- range = this.editor.selection.getRange();
1821
- $td = $(range.commonAncestorContainer).closest('td');
1822
- $prevTd = $td.prev('td');
1823
- if (!($prevTd.length > 0)) {
1824
- $prevTd = $td.parent('tr').prev('tr').find('td:last');
1825
- }
1826
- if (!($td.length > 0 && $prevTd.length > 0)) {
1827
- return false;
1828
- }
1829
- this.editor.selection.setRangeAtEndOf($prevTd);
1830
- } else {
1831
- return false;
1832
- }
1833
- this.editor.trigger('valuechanged');
1834
- return true;
1835
- };
1836
-
1837
1721
  Util.prototype.dataURLtoBlob = function(dataURL) {
1838
1722
  var BlobBuilder, arrayBuffer, bb, byteString, hasArrayBufferViewSupport, hasBlobConstructor, i, intArray, j, mimeString, ref;
1839
1723
  hasBlobConstructor = window.Blob && (function() {
@@ -2129,6 +2013,179 @@ Toolbar = (function(superClass) {
2129
2013
 
2130
2014
  })(SimpleModule);
2131
2015
 
2016
+ Indentation = (function(superClass) {
2017
+ extend(Indentation, superClass);
2018
+
2019
+ function Indentation() {
2020
+ return Indentation.__super__.constructor.apply(this, arguments);
2021
+ }
2022
+
2023
+ Indentation.pluginName = 'Indentation';
2024
+
2025
+ Indentation.prototype.opts = {
2026
+ tabIndent: true
2027
+ };
2028
+
2029
+ Indentation.prototype._init = function() {
2030
+ this.editor = this._module;
2031
+ return this.editor.inputManager.addKeystrokeHandler('9', '*', (function(_this) {
2032
+ return function(e) {
2033
+ var codeButton;
2034
+ codeButton = _this.editor.toolbar.findButton('code');
2035
+ if (!(_this.opts.tabIndent || (codeButton && codeButton.active))) {
2036
+ return;
2037
+ }
2038
+ return _this.indent(e.shiftKey);
2039
+ };
2040
+ })(this));
2041
+ };
2042
+
2043
+ Indentation.prototype.indent = function(isBackward) {
2044
+ var $blockEls, $endBlock, $startBlock, range, result;
2045
+ range = this.editor.selection.getRange();
2046
+ if (!range) {
2047
+ return;
2048
+ }
2049
+ $startBlock = this.editor.util.closestBlockEl(range.startContainer);
2050
+ $endBlock = this.editor.util.closestBlockEl(range.endContainer);
2051
+ if (!($startBlock.is('li') && $endBlock.is('li') && $startBlock.parent().is($endBlock.parent()))) {
2052
+ $startBlock = this.editor.util.furthestBlockEl($startBlock);
2053
+ $endBlock = this.editor.util.furthestBlockEl($endBlock);
2054
+ }
2055
+ if ($startBlock.is($endBlock)) {
2056
+ $blockEls = $startBlock;
2057
+ } else {
2058
+ $blockEls = $startBlock.nextUntil($endBlock).add($startBlock).add($endBlock);
2059
+ }
2060
+ result = false;
2061
+ $blockEls.each((function(_this) {
2062
+ return function(i, blockEl) {
2063
+ return result = isBackward ? _this.outdentBlock(blockEl) : _this.indentBlock(blockEl);
2064
+ };
2065
+ })(this));
2066
+ return result;
2067
+ };
2068
+
2069
+ Indentation.prototype.indentBlock = function(blockEl) {
2070
+ var $blockEl, $childList, $nextTd, $parentLi, $pre, $td, indentLevel, range, tagName;
2071
+ $blockEl = $(blockEl);
2072
+ if (!$blockEl.length) {
2073
+ return;
2074
+ }
2075
+ if ($blockEl.is('pre')) {
2076
+ range = this.editor.selection.getRange();
2077
+ $pre = $(range.commonAncestorContainer);
2078
+ if (!($pre.is($blockEl) || $pre.closest('pre').is($blockEl))) {
2079
+ return;
2080
+ }
2081
+ this.indentText(range);
2082
+ } else if ($blockEl.is('li')) {
2083
+ $parentLi = $blockEl.prev('li');
2084
+ if ($parentLi.length < 1) {
2085
+ return;
2086
+ }
2087
+ this.editor.selection.save();
2088
+ tagName = $blockEl.parent()[0].tagName;
2089
+ $childList = $parentLi.children('ul, ol');
2090
+ if ($childList.length > 0) {
2091
+ $childList.append($blockEl);
2092
+ } else {
2093
+ $('<' + tagName + '/>').append($blockEl).appendTo($parentLi);
2094
+ }
2095
+ this.editor.selection.restore();
2096
+ } 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);
2100
+ } else if ($blockEl.is('table')) {
2101
+ range = this.editor.selection.getRange();
2102
+ $td = $(range.commonAncestorContainer).closest('td');
2103
+ $nextTd = $td.next('td');
2104
+ if (!($nextTd.length > 0)) {
2105
+ $nextTd = $td.parent('tr').next('tr').find('td:first');
2106
+ }
2107
+ if (!($td.length > 0 && $nextTd.length > 0)) {
2108
+ return false;
2109
+ }
2110
+ this.editor.selection.setRangeAtEndOf($nextTd);
2111
+ }
2112
+ return true;
2113
+ };
2114
+
2115
+ Indentation.prototype.indentText = function(range) {
2116
+ var text, textNode;
2117
+ text = range.toString().replace(/^(?=.+)/mg, '\u00A0\u00A0');
2118
+ textNode = document.createTextNode(text || '\u00A0\u00A0');
2119
+ range.deleteContents();
2120
+ range.insertNode(textNode);
2121
+ if (text) {
2122
+ range.selectNode(textNode);
2123
+ return this.editor.selection.selectRange(range);
2124
+ } else {
2125
+ return this.editor.selection.setRangeAfter(textNode);
2126
+ }
2127
+ };
2128
+
2129
+ Indentation.prototype.outdentBlock = function(blockEl) {
2130
+ var $blockEl, $parent, $parentLi, $pre, $prevTd, $td, button, indentLevel, range, ref;
2131
+ $blockEl = $(blockEl);
2132
+ if (!($blockEl && $blockEl.length > 0)) {
2133
+ return;
2134
+ }
2135
+ if ($blockEl.is('pre')) {
2136
+ range = this.editor.selection.getRange();
2137
+ $pre = $(range.commonAncestorContainer);
2138
+ if (!($pre.is($blockEl) || $pre.closest('pre').is($blockEl))) {
2139
+ return;
2140
+ }
2141
+ this.outdentText(range);
2142
+ } else if ($blockEl.is('li')) {
2143
+ $parent = $blockEl.parent();
2144
+ $parentLi = $parent.parent('li');
2145
+ if ($parentLi.length < 1) {
2146
+ button = this.editor.toolbar.findButton($parent[0].tagName.toLowerCase());
2147
+ if (button != null) {
2148
+ button.command();
2149
+ }
2150
+ return;
2151
+ }
2152
+ this.editor.selection.save();
2153
+ if ($blockEl.next('li').length > 0) {
2154
+ $('<' + $parent[0].tagName + '/>').append($blockEl.nextAll('li')).appendTo($blockEl);
2155
+ }
2156
+ $blockEl.insertAfter($parentLi);
2157
+ if ($parent.children('li').length < 1) {
2158
+ $parent.remove();
2159
+ }
2160
+ this.editor.selection.restore();
2161
+ } else if ($blockEl.is('p, h1, h2, h3, h4')) {
2162
+ indentLevel = (ref = $blockEl.attr('data-indent')) != null ? ref : 0;
2163
+ indentLevel = indentLevel * 1 - 1;
2164
+ if (indentLevel < 0) {
2165
+ indentLevel = 0;
2166
+ }
2167
+ $blockEl.attr('data-indent', indentLevel);
2168
+ } else if ($blockEl.is('table')) {
2169
+ range = this.editor.selection.getRange();
2170
+ $td = $(range.commonAncestorContainer).closest('td');
2171
+ $prevTd = $td.prev('td');
2172
+ if (!($prevTd.length > 0)) {
2173
+ $prevTd = $td.parent('tr').prev('tr').find('td:last');
2174
+ }
2175
+ if (!($td.length > 0 && $prevTd.length > 0)) {
2176
+ return;
2177
+ }
2178
+ this.editor.selection.setRangeAtEndOf($prevTd);
2179
+ }
2180
+ return true;
2181
+ };
2182
+
2183
+ Indentation.prototype.outdentText = function(range) {};
2184
+
2185
+ return Indentation;
2186
+
2187
+ })(SimpleModule);
2188
+
2132
2189
  Simditor = (function(superClass) {
2133
2190
  extend(Simditor, superClass);
2134
2191
 
@@ -2150,6 +2207,8 @@ Simditor = (function(superClass) {
2150
2207
 
2151
2208
  Simditor.connect(Toolbar);
2152
2209
 
2210
+ Simditor.connect(Indentation);
2211
+
2153
2212
  Simditor.count = 0;
2154
2213
 
2155
2214
  Simditor.prototype.opts = {
@@ -2157,8 +2216,7 @@ Simditor = (function(superClass) {
2157
2216
  placeholder: '',
2158
2217
  defaultImage: 'images/image.png',
2159
2218
  params: {},
2160
- upload: false,
2161
- tabIndent: true
2219
+ upload: false
2162
2220
  };
2163
2221
 
2164
2222
  Simditor.prototype._init = function() {
@@ -2366,6 +2424,7 @@ Simditor.i18n = {
2366
2424
  'uploadError': '上传出错了',
2367
2425
  'imageUrl': '图片地址',
2368
2426
  'imageSize': '图片尺寸',
2427
+ 'imageAlt': '图片描述',
2369
2428
  'restoreImageSize': '还原图片尺寸',
2370
2429
  'uploading': '正在上传',
2371
2430
  'indent': '向右缩进',
@@ -4231,51 +4290,28 @@ ImagePopover = (function(superClass) {
4231
4290
 
4232
4291
  ImagePopover.prototype.render = function() {
4233
4292
  var tpl;
4234
- tpl = "<div class=\"link-settings\">\n <div class=\"settings-field\">\n <label>" + (this._t('imageUrl')) + "</label>\n <input class=\"image-src\" type=\"text\" tabindex=\"1\" />\n <a class=\"btn-upload\" href=\"javascript:;\" title=\"" + (this._t('uploadImage')) + "\" tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-upload\"></span>\n </a>\n </div>\n <div class=\"settings-field\">\n <label>" + (this._t('imageSize')) + "</label>\n <input class=\"image-size\" id=\"image-width\" type=\"text\" tabindex=\"2\" />\n <span class=\"times\">×</span>\n <input class=\"image-size\" id=\"image-height\" type=\"text\" tabindex=\"3\" />\n <a class=\"btn-restore\" href=\"javascript:;\" title=\"" + (this._t('restoreImageSize')) + "\" tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-undo\"></span>\n </a>\n </div>\n</div>";
4293
+ tpl = "<div class=\"link-settings\">\n <div class=\"settings-field\">\n <label>" + (this._t('imageUrl')) + "</label>\n <input class=\"image-src\" type=\"text\" tabindex=\"1\" />\n <a class=\"btn-upload\" href=\"javascript:;\" title=\"" + (this._t('uploadImage')) + "\" tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-upload\"></span>\n </a>\n </div>\n <div class='settings-field'>\n <label>" + (this._t('imageAlt')) + "</label>\n <input class=\"image-alt\" id=\"image-alt\" type=\"text\" tabindex=\"1\" />\n </div>\n <div class=\"settings-field\">\n <label>" + (this._t('imageSize')) + "</label>\n <input class=\"image-size\" id=\"image-width\" type=\"text\" tabindex=\"2\" />\n <span class=\"times\">×</span>\n <input class=\"image-size\" id=\"image-height\" type=\"text\" tabindex=\"3\" />\n <a class=\"btn-restore\" href=\"javascript:;\" title=\"" + (this._t('restoreImageSize')) + "\" tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-undo\"></span>\n </a>\n </div>\n</div>";
4235
4294
  this.el.addClass('image-popover').append(tpl);
4236
4295
  this.srcEl = this.el.find('.image-src');
4296
+ this.widthEl = this.el.find('#image-width');
4297
+ this.heightEl = this.el.find('#image-height');
4298
+ this.altEl = this.el.find('#image-alt');
4237
4299
  this.srcEl.on('keydown', (function(_this) {
4238
4300
  return function(e) {
4239
- var hideAndFocus, src;
4240
- if (!(e.which === 13 || e.which === 27)) {
4301
+ if (!(e.which === 13 && !_this.target.hasClass('uploading'))) {
4241
4302
  return;
4242
4303
  }
4243
4304
  e.preventDefault();
4244
- hideAndFocus = function() {
4245
- _this.button.editor.body.focus();
4246
- _this.button.editor.selection.setRangeAfter(_this.target);
4247
- return _this.hide();
4248
- };
4249
- if (e.which === 13 && !_this.target.hasClass('uploading')) {
4250
- src = _this.srcEl.val();
4251
- if (/^data:image/.test(src) && !_this.editor.uploader) {
4252
- hideAndFocus();
4253
- return;
4254
- }
4255
- return _this.button.loadImage(_this.target, src, function(success) {
4256
- var blob;
4257
- if (!success) {
4258
- return;
4259
- }
4260
- if (/^data:image/.test(src)) {
4261
- blob = _this.editor.util.dataURLtoBlob(src);
4262
- blob.name = "Base64 Image.png";
4263
- return _this.editor.uploader.upload(blob, {
4264
- inline: true,
4265
- img: _this.target
4266
- });
4267
- } else {
4268
- hideAndFocus();
4269
- return _this.editor.trigger('valuechanged');
4270
- }
4271
- });
4272
- } else {
4273
- return hideAndFocus();
4274
- }
4305
+ _this.button.editor.body.focus();
4306
+ _this.button.editor.selection.setRangeAfter(_this.target);
4307
+ return _this.hide();
4308
+ };
4309
+ })(this));
4310
+ this.srcEl.on('blur', (function(_this) {
4311
+ return function(e) {
4312
+ return _this._loadImage(_this.srcEl.val());
4275
4313
  };
4276
4314
  })(this));
4277
- this.widthEl = this.el.find('#image-width');
4278
- this.heightEl = this.el.find('#image-height');
4279
4315
  this.el.find('.image-size').on('blur', (function(_this) {
4280
4316
  return function(e) {
4281
4317
  _this._resizeImg($(e.currentTarget));
@@ -4310,6 +4346,25 @@ ImagePopover = (function(superClass) {
4310
4346
  }
4311
4347
  };
4312
4348
  })(this));
4349
+ this.altEl.on('keydown', (function(_this) {
4350
+ return function(e) {
4351
+ if (e.which === 13) {
4352
+ e.preventDefault();
4353
+ _this.button.editor.body.focus();
4354
+ _this.button.editor.selection.setRangeAfter(_this.target);
4355
+ return _this.hide();
4356
+ }
4357
+ };
4358
+ })(this));
4359
+ this.altEl.on('keyup', (function(_this) {
4360
+ return function(e) {
4361
+ if (e.which === 13 || e.which === 27 || e.which === 9) {
4362
+ return;
4363
+ }
4364
+ _this.alt = _this.altEl.val();
4365
+ return _this.target.attr('alt', _this.alt);
4366
+ };
4367
+ })(this));
4313
4368
  this.el.find('.btn-restore').on('click', (function(_this) {
4314
4369
  return function(e) {
4315
4370
  _this._restoreImg();
@@ -4375,11 +4430,12 @@ ImagePopover = (function(superClass) {
4375
4430
  this.widthEl.val(width);
4376
4431
  }
4377
4432
  if (!onlySetVal) {
4378
- return this.target.attr({
4433
+ this.target.attr({
4379
4434
  width: width || value,
4380
4435
  height: height || value
4381
4436
  });
4382
4437
  }
4438
+ return this.editor.trigger('valuechanged');
4383
4439
  };
4384
4440
 
4385
4441
  ImagePopover.prototype._restoreImg = function() {
@@ -4390,7 +4446,45 @@ ImagePopover = (function(superClass) {
4390
4446
  height: size[1] * 1
4391
4447
  });
4392
4448
  this.widthEl.val(size[0]);
4393
- return this.heightEl.val(size[1]);
4449
+ this.heightEl.val(size[1]);
4450
+ return this.editor.trigger('valuechanged');
4451
+ };
4452
+
4453
+ ImagePopover.prototype._loadImage = function(src, callback) {
4454
+ if (/^data:image/.test(src) && !this.editor.uploader) {
4455
+ if (callback) {
4456
+ callback(false);
4457
+ }
4458
+ return;
4459
+ }
4460
+ return this.button.loadImage(this.target, src, (function(_this) {
4461
+ return function(img) {
4462
+ var blob;
4463
+ if (!img) {
4464
+ return;
4465
+ }
4466
+ if (_this.active) {
4467
+ _this.width = img.width;
4468
+ _this.height = img.height;
4469
+ _this.widthEl.val(_this.width);
4470
+ _this.heightEl.val(_this.height);
4471
+ _this.target.removeAttr('width').removeAttr('height');
4472
+ }
4473
+ if (/^data:image/.test(src)) {
4474
+ blob = _this.editor.util.dataURLtoBlob(src);
4475
+ blob.name = "Base64 Image.png";
4476
+ _this.editor.uploader.upload(blob, {
4477
+ inline: true,
4478
+ img: _this.target
4479
+ });
4480
+ } else {
4481
+ _this.editor.trigger('valuechanged');
4482
+ }
4483
+ if (callback) {
4484
+ return callback(img);
4485
+ }
4486
+ };
4487
+ })(this));
4394
4488
  };
4395
4489
 
4396
4490
  ImagePopover.prototype.show = function() {
@@ -4400,12 +4494,14 @@ ImagePopover = (function(superClass) {
4400
4494
  $img = this.target;
4401
4495
  this.width = $img.width();
4402
4496
  this.height = $img.height();
4497
+ this.alt = $img.attr('alt');
4403
4498
  if ($img.hasClass('uploading')) {
4404
4499
  return this.srcEl.val(this._t('uploading')).prop('disabled', true);
4405
4500
  } else {
4406
4501
  this.srcEl.val($img.attr('src')).prop('disabled', false);
4407
4502
  this.widthEl.val(this.width);
4408
- return this.heightEl.val(this.height);
4503
+ this.heightEl.val(this.height);
4504
+ return this.altEl.val(this.alt);
4409
4505
  }
4410
4506
  };
4411
4507
 
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.5.1
4
+ version: 2.1.6.0
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-03-07 00:00:00.000000000 Z
11
+ date: 2015-04-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rails assets wrapper for https://github.com/mycolorway/simditor
14
14
  email:
@@ -22,7 +22,6 @@ files:
22
22
  - lib/simditor.rb
23
23
  - lib/simditor/engine.rb
24
24
  - lib/simditor/version.rb
25
- - lib/simditor/version.rb~
26
25
  - vendor/assets/images/upload-loading.png
27
26
  - vendor/assets/javascripts/simditor.js
28
27
  - vendor/assets/javascripts/simditor/hotkeys.js
@@ -52,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
51
  version: '0'
53
52
  requirements: []
54
53
  rubyforge_project:
55
- rubygems_version: 2.4.5
54
+ rubygems_version: 2.4.6
56
55
  signing_key:
57
56
  specification_version: 4
58
57
  summary: A simple editor designed by mycolorway http://mycolorway.github.io/simditor/demo.html
@@ -1,5 +0,0 @@
1
- module Simditor
2
- module Version
3
- EDITOR = "2.1.5"
4
- end
5
- end