simditor 2.3.0 → 2.3.2

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: 9e33c8a152c1ce8e7848a79dea866dc97e8a0720
4
- data.tar.gz: 145e99e3c36d6595e9bffbcf04476024315bdadf
3
+ metadata.gz: d7d7b2dc726e8cd0affd2b1c21be60c45ac71d00
4
+ data.tar.gz: c8ff4b003b3b1dde07780a79da0c29f1e8dbcf51
5
5
  SHA512:
6
- metadata.gz: bffdd4d399f8630ab1a43781145e762cf98412d18626b11ca85c74b48af5e5723617cc22b2b6651536355341dd5141465bbb52cc505ed6f36b54155cccc52af6
7
- data.tar.gz: 4d48fc3bf0f9dc2c583cc77bb2a8321634faa1444cfe2e0b36d4e3ea7b42e08f291bcddc0e4196466e558c4e7a579adfc11ad45139daa4eb72fdfe5830022291
6
+ metadata.gz: 22ab34fa9559687c031cf01a63746547d411596d810abad32cacb5966afa94308938d56acc16e4838fefa74b4777064d3da93a3800c14ddac7c2dbf4e5766a75
7
+ data.tar.gz: 3c9f0d1ae154e3ddd53e721c9847aa7d48486561b459fb522b9f08d51e80170e7c0ee3f922a6ee93576476fbe62b1c8cfc13b983ab194bbe9f6ae28966e4aac3
@@ -1,5 +1,5 @@
1
1
  module Simditor
2
2
  module Version
3
- EDITOR = "2.3.0"
3
+ EDITOR = "2.3.2"
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * Simditor v2.3.0
2
+ * Simditor v2.3.2
3
3
  * http://simditor.tower.im/
4
- * 2015-10-08
4
+ * 2015-10-15
5
5
  */
6
6
  (function (root, factory) {
7
7
  if (typeof define === 'function' && define.amd) {
@@ -53,7 +53,7 @@ Selection = (function(superClass) {
53
53
  this._selection = document.getSelection();
54
54
  this.editor.on('selectionchanged', (function(_this) {
55
55
  return function(e) {
56
- _this._reset();
56
+ _this.reset();
57
57
  return _this._range = _this._selection.getRangeAt(0);
58
58
  };
59
59
  })(this));
@@ -64,7 +64,7 @@ Selection = (function(superClass) {
64
64
  })(this));
65
65
  };
66
66
 
67
- Selection.prototype._reset = function() {
67
+ Selection.prototype.reset = function() {
68
68
  this._range = null;
69
69
  this._startNodes = null;
70
70
  this._endNodes = null;
@@ -81,7 +81,7 @@ Selection = (function(superClass) {
81
81
  } catch (_error) {
82
82
  e = _error;
83
83
  }
84
- return this._reset();
84
+ return this.reset();
85
85
  };
86
86
 
87
87
  Selection.prototype.range = function(range) {
@@ -1689,7 +1689,7 @@ Util = (function(superClass) {
1689
1689
  return $(node).is('[class^="simditor-"]');
1690
1690
  };
1691
1691
 
1692
- Util.prototype.blockNodes = ["div", "p", "ul", "ol", "li", "blockquote", "hr", "pre", "h1", "h2", "h3", "h4", "table"];
1692
+ Util.prototype.blockNodes = ["div", "p", "ul", "ol", "li", "blockquote", "hr", "pre", "h1", "h2", "h3", "h4", "h5", "table"];
1693
1693
 
1694
1694
  Util.prototype.isBlockNode = function(node) {
1695
1695
  node = $(node)[0];
@@ -2195,29 +2195,33 @@ Clipboard = (function(superClass) {
2195
2195
  }
2196
2196
  return this.editor.body.on('paste', (function(_this) {
2197
2197
  return function(e) {
2198
- var $blockEl, isPlainText, range;
2198
+ var range;
2199
+ if (_this.pasting || _this._pasteBin) {
2200
+ return;
2201
+ }
2199
2202
  if (_this.editor.triggerHandler(e) === false) {
2200
2203
  return false;
2201
2204
  }
2202
2205
  range = _this.editor.selection.deleteRangeContents();
2203
- if (!range.collapsed) {
2204
- range.collapse(true);
2205
- }
2206
- _this.editor.selection.range(range);
2207
- $blockEl = _this.editor.selection.blockNodes().last();
2208
- isPlainText = $blockEl.is('pre, table');
2209
- if (!isPlainText && _this._processPasteByClipboardApi(e)) {
2210
- return false;
2206
+ if (_this.editor.body.html()) {
2207
+ if (!range.collapsed) {
2208
+ range.collapse(true);
2209
+ }
2210
+ } else {
2211
+ _this.editor.formatter.format();
2212
+ _this.editor.selection.setRangeAtStartOf(_this.editor.body.find('p:first'));
2211
2213
  }
2212
- if (_this._pasteBin) {
2214
+ if (_this._processPasteByClipboardApi(e)) {
2213
2215
  return false;
2214
2216
  }
2215
2217
  _this.editor.inputManager.throttledValueChanged.clear();
2216
2218
  _this.editor.inputManager.throttledSelectionChanged.clear();
2217
2219
  _this.editor.undoManager.throttledPushState.clear();
2218
2220
  _this.pasting = true;
2219
- return _this._getPasteContent(isPlainText, function(pasteContent) {
2220
- _this._processPasteContent(isPlainText, $blockEl, pasteContent);
2221
+ return _this._getPasteContent(function(pasteContent) {
2222
+ _this._processPasteContent(pasteContent);
2223
+ _this._pasteInBlockEl = null;
2224
+ _this._pastePlainText = null;
2221
2225
  return _this.pasting = false;
2222
2226
  });
2223
2227
  };
@@ -2252,7 +2256,7 @@ Clipboard = (function(superClass) {
2252
2256
  }
2253
2257
  };
2254
2258
 
2255
- Clipboard.prototype._getPasteContent = function(isPlainText, callback) {
2259
+ Clipboard.prototype._getPasteContent = function(callback) {
2256
2260
  var state;
2257
2261
  this._pasteBin = $('<div contenteditable="true" />').addClass('simditor-paste-bin').attr('tabIndex', '-1').appendTo(this.editor.el);
2258
2262
  state = {
@@ -2267,8 +2271,11 @@ Clipboard = (function(superClass) {
2267
2271
  _this.editor.body.html(state.html);
2268
2272
  _this.editor.undoManager.caretPosition(state.caret);
2269
2273
  _this.editor.body.focus();
2270
- _this.editor.selection._reset();
2271
- if (isPlainText) {
2274
+ _this.editor.selection.reset();
2275
+ _this.editor.selection.range();
2276
+ _this._pasteInBlockEl = _this.editor.selection.blockNodes().last();
2277
+ _this._pastePlainText = _this._pasteInBlockEl.is('pre, table');
2278
+ if (_this._pastePlainText) {
2272
2279
  pasteContent = _this.editor.formatter.clearHtml(_this._pasteBin.html(), true);
2273
2280
  } else {
2274
2281
  pasteContent = $('<div/>').append(_this._pasteBin.contents());
@@ -2285,14 +2292,15 @@ Clipboard = (function(superClass) {
2285
2292
  })(this), 0);
2286
2293
  };
2287
2294
 
2288
- Clipboard.prototype._processPasteContent = function(isPlainText, $blockEl, pasteContent) {
2289
- var $img, blob, children, insertPosition, k, l, lastLine, len, len1, len2, len3, len4, line, lines, m, node, o, q, ref, ref1, ref2, uploadOpt;
2295
+ Clipboard.prototype._processPasteContent = function(pasteContent) {
2296
+ var $blockEl, $img, blob, children, insertPosition, k, l, lastLine, len, len1, len2, len3, len4, line, lines, m, node, o, q, ref, ref1, ref2, uploadOpt;
2290
2297
  if (this.editor.triggerHandler('pasting', [pasteContent]) === false) {
2291
2298
  return;
2292
2299
  }
2300
+ $blockEl = this._pasteInBlockEl;
2293
2301
  if (!pasteContent) {
2294
2302
  return;
2295
- } else if (isPlainText) {
2303
+ } else if (this._pastePlainText) {
2296
2304
  if ($blockEl.is('table')) {
2297
2305
  lines = pasteContent.split('\n');
2298
2306
  lastLine = lines.pop();
@@ -3089,7 +3097,7 @@ TitleButton = (function(superClass) {
3089
3097
 
3090
3098
  TitleButton.prototype.name = 'title';
3091
3099
 
3092
- TitleButton.prototype.htmlTag = 'h1, h2, h3, h4';
3100
+ TitleButton.prototype.htmlTag = 'h1, h2, h3, h4, h5';
3093
3101
 
3094
3102
  TitleButton.prototype.disableTag = 'pre, table';
3095
3103
 
@@ -3129,7 +3137,7 @@ TitleButton = (function(superClass) {
3129
3137
  if (active) {
3130
3138
  param || (param = this.node[0].tagName.toLowerCase());
3131
3139
  }
3132
- this.el.removeClass('active-p active-h1 active-h2 active-h3');
3140
+ this.el.removeClass('active-p active-h1 active-h2 active-h3 active-h4 active-h5');
3133
3141
  if (active) {
3134
3142
  return this.el.addClass('active active-' + param);
3135
3143
  }
@@ -5327,7 +5335,8 @@ AlignmentButton = (function(superClass) {
5327
5335
  this.nodes.css({
5328
5336
  'text-align': align === 'left' ? '' : align
5329
5337
  });
5330
- return this.editor.trigger('valuechanged');
5338
+ this.editor.trigger('valuechanged');
5339
+ return this.editor.inputManager.throttledSelectionChanged();
5331
5340
  };
5332
5341
 
5333
5342
  return AlignmentButton;
@@ -1,6 +1,7 @@
1
1
  @charset "UTF-8";
2
2
 
3
3
  $simditor-button-height: 40px;
4
+ $simditor-button-width: 46px;
4
5
 
5
6
  .simditor {
6
7
  position: relative;
@@ -9,7 +10,6 @@ $simditor-button-height: 40px;
9
10
  .simditor-wrapper {
10
11
  position: relative;
11
12
  background: #ffffff;
12
- overflow: hidden;
13
13
 
14
14
  & > textarea {
15
15
  display: none !important;
@@ -120,15 +120,16 @@ $simditor-button-height: 40px;
120
120
 
121
121
  .simditor-paste-bin {
122
122
  position: fixed;
123
- bottom: 100px;
124
- right: 100px;
125
- width: 100px;
126
- height: 100px;
123
+ bottom: 10px;
124
+ right: 10px;
125
+ width: 1px;
126
+ height: 20px;
127
127
  font-size: 1px;
128
128
  line-height: 1px;
129
129
  overflow: hidden;
130
130
  padding: 0;
131
131
  margin: 0;
132
+ opacity: 0;
132
133
  -webkit-user-select: text;
133
134
  }
134
135
 
@@ -142,34 +143,29 @@ $simditor-button-height: 40px;
142
143
  padding: 0 0 0 6px;
143
144
  list-style: none;
144
145
 
145
- &:after {
146
- content:"";
147
- display:table;
148
- clear:both;
149
- }
150
-
151
146
  & > li {
152
147
  position: relative;
153
- float: left;
148
+ display: inline-block;
149
+ font-size: 0;
154
150
 
155
151
  & > span.separator {
156
- display: block;
157
- float: left;
152
+ display: inline-block;
158
153
  background: #cfcfcf;
159
154
  width: 1px;
160
155
  height: 18px;
161
156
  margin: ($simditor-button-height - 18px) / 2 15px;
157
+ vertical-align: middle;
162
158
  }
163
159
 
164
160
  & > .toolbar-item {
165
- display: block;
166
- float: left;
167
- width: 46px;
161
+ display: inline-block;
162
+ width: $simditor-button-width;
168
163
  height: $simditor-button-height;
169
164
  outline: none;
170
165
  color: #333333;
171
166
  font-size: 15px;
172
167
  line-height: $simditor-button-height;
168
+ vertical-align: middle;
173
169
  text-align: center;
174
170
  text-decoration: none;
175
171
 
@@ -244,9 +240,9 @@ $simditor-button-height: 40px;
244
240
  &.menu-on {
245
241
  .toolbar-item {
246
242
  position: relative;
247
- z-index: 21;
243
+ z-index: 20;
248
244
  background: #ffffff;
249
- box-shadow: 0 -3px 3px rgba(0,0,0,0.2);
245
+ box-shadow: 0 1px 4px rgba(0,0,0,0.3);
250
246
 
251
247
  span {
252
248
  opacity: 1;
@@ -265,10 +261,21 @@ $simditor-button-height: 40px;
265
261
  position: absolute;
266
262
  top: $simditor-button-height;
267
263
  left: 0;
268
- z-index: 20;
264
+ z-index: 21;
269
265
  background: #ffffff;
270
266
  text-align: left;
271
- box-shadow: 0 0 3px rgba(0,0,0,0.2);
267
+ box-shadow: 0 0 4px rgba(0,0,0,0.3);
268
+
269
+ &:before {
270
+ content: '';
271
+ display: block;
272
+ width: $simditor-button-width;
273
+ height: 4px;
274
+ background: #ffffff;
275
+ position: absolute;
276
+ top: -3px;
277
+ left: 0;
278
+ }
272
279
 
273
280
  ul {
274
281
  min-width: 160px;
@@ -373,6 +380,7 @@ $simditor-button-height: 40px;
373
380
  &.toolbar-menu-table {
374
381
  .menu-create-table {
375
382
  background: #ffffff;
383
+ padding: 1px;
376
384
 
377
385
  table {
378
386
  border: none;
@@ -381,19 +389,19 @@ $simditor-button-height: 40px;
381
389
  table-layout: fixed;
382
390
 
383
391
  td {
384
- height: 16px;
385
392
  padding: 0;
386
- border: 2px solid #ffffff;
387
- background: #f3f3f3;
388
393
  cursor: pointer;
389
394
 
390
395
  &:before {
391
396
  width: 16px;
397
+ height: 16px;
398
+ border: 1px solid #ffffff;
399
+ background: #f3f3f3;
392
400
  display: block;
393
401
  content: ''
394
402
  }
395
403
 
396
- &.selected {
404
+ &.selected:before {
397
405
  background: #cfcfcf;
398
406
  }
399
407
  }
@@ -513,10 +521,6 @@ $simditor-button-height: 40px;
513
521
  }
514
522
 
515
523
  &.simditor-mobile {
516
- .simditor-toolbar > ul > li > .toolbar-item {
517
- width: 46px;
518
- }
519
-
520
524
  .simditor-wrapper.toolbar-floating .simditor-toolbar {
521
525
  position: absolute;
522
526
  top: 0;
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.3.0
4
+ version: 2.3.2
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-10-09 00:00:00.000000000 Z
11
+ date: 2015-10-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rails assets wrapper for https://github.com/mycolorway/simditor
14
14
  email: