simditor 2.3.2 → 2.3.3

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: d7d7b2dc726e8cd0affd2b1c21be60c45ac71d00
4
- data.tar.gz: c8ff4b003b3b1dde07780a79da0c29f1e8dbcf51
3
+ metadata.gz: a61682a517164bfe3f1b80ca3a66b3f9dfe88ecf
4
+ data.tar.gz: ac805da42d5c91e87d4dc417ad52093c5f73b259
5
5
  SHA512:
6
- metadata.gz: 22ab34fa9559687c031cf01a63746547d411596d810abad32cacb5966afa94308938d56acc16e4838fefa74b4777064d3da93a3800c14ddac7c2dbf4e5766a75
7
- data.tar.gz: 3c9f0d1ae154e3ddd53e721c9847aa7d48486561b459fb522b9f08d51e80170e7c0ee3f922a6ee93576476fbe62b1c8cfc13b983ab194bbe9f6ae28966e4aac3
6
+ metadata.gz: b8f856c710f083c793db827cdc58babf051746757110de3c77aef70f91096833ae06a1f13a6f130a531867211c746feebe64c041daf7c0c3bd6dc072b604011b
7
+ data.tar.gz: 0cfc93f4cc6a01b7e5e9a6d51ff0d1313b39b335f5501e5b5f9c48a2b1fd85d5e65357a6784d062948f2e4da857357435afa0464e3a335a4c1413ace1cb77a61
@@ -1,5 +1,5 @@
1
1
  module Simditor
2
2
  module Version
3
- EDITOR = "2.3.2"
3
+ EDITOR = "2.3.3"
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * Simditor v2.3.2
2
+ * Simditor v2.3.3
3
3
  * http://simditor.tower.im/
4
- * 2015-10-15
4
+ * 2015-10-20
5
5
  */
6
6
  (function (root, factory) {
7
7
  if (typeof define === 'function' && define.amd) {
@@ -594,6 +594,9 @@ Formatter = (function(superClass) {
594
594
  blockNode = $('<p/>').insertBefore(node);
595
595
  }
596
596
  blockNode.append(node);
597
+ if (this.editor.util.isEmptyNode(blockNode)) {
598
+ blockNode.append(this.editor.util.phBr);
599
+ }
597
600
  }
598
601
  }
599
602
  return $el;
@@ -878,19 +881,12 @@ InputManager = (function(superClass) {
878
881
  })(this));
879
882
  }
880
883
  submitKey = this.editor.util.os.mac ? 'cmd+enter' : 'ctrl+enter';
881
- this.editor.hotkeys.add(submitKey, (function(_this) {
884
+ return this.editor.hotkeys.add(submitKey, (function(_this) {
882
885
  return function(e) {
883
886
  _this.editor.el.closest('form').find('button:submit').click();
884
887
  return false;
885
888
  };
886
889
  })(this));
887
- if (this.editor.textarea.attr('autofocus')) {
888
- return setTimeout((function(_this) {
889
- return function() {
890
- return _this.editor.focus();
891
- };
892
- })(this), 0);
893
- }
894
890
  };
895
891
 
896
892
  InputManager.prototype._onFocus = function(e) {
@@ -899,9 +895,20 @@ InputManager = (function(superClass) {
899
895
  }
900
896
  this.editor.el.addClass('focus').removeClass('error');
901
897
  this.focused = true;
902
- this.lastCaretPosition = null;
903
898
  return setTimeout((function(_this) {
904
899
  return function() {
900
+ var $blockEl, range;
901
+ range = _this.editor.selection._selection.getRangeAt(0);
902
+ if (range.startContainer === _this.editor.body[0]) {
903
+ if (_this.lastCaretPosition) {
904
+ _this.editor.undoManager.caretPosition(_this.lastCaretPosition);
905
+ } else {
906
+ $blockEl = _this.body.children.first();
907
+ range = document.createRange();
908
+ _this.selection.setRangeAtStartOf($blockEl, range);
909
+ }
910
+ }
911
+ _this.lastCaretPosition = null;
905
912
  _this.editor.triggerHandler('focus');
906
913
  if (!_this.editor.util.support.onselectionchange) {
907
914
  return _this.throttledSelectionChanged();
@@ -1333,19 +1340,22 @@ UndoManager = (function(superClass) {
1333
1340
  })(this));
1334
1341
  this.editor.on('selectionchanged', (function(_this) {
1335
1342
  return function(e) {
1336
- _this._startPosition = null;
1337
- _this._endPosition = null;
1343
+ _this.resetCaretPosition();
1338
1344
  return _this.update();
1339
1345
  };
1340
1346
  })(this));
1341
1347
  return this.editor.on('blur', (function(_this) {
1342
1348
  return function(e) {
1343
- _this._startPosition = null;
1344
- return _this._endPosition = null;
1349
+ return _this.resetCaretPosition();
1345
1350
  };
1346
1351
  })(this));
1347
1352
  };
1348
1353
 
1354
+ UndoManager.prototype.resetCaretPosition = function() {
1355
+ this._startPosition = null;
1356
+ return this._endPosition = null;
1357
+ };
1358
+
1349
1359
  UndoManager.prototype.startPosition = function() {
1350
1360
  if (this.editor.selection._range) {
1351
1361
  this._startPosition || (this._startPosition = this._getPosition('start'));
@@ -1547,7 +1557,11 @@ UndoManager = (function(superClass) {
1547
1557
  endOffset = caret.start[caret.start.length - 1];
1548
1558
  }
1549
1559
  if (!startContainer || !endContainer) {
1550
- throw new Error('simditor: invalid caret state');
1560
+ if (typeof console !== "undefined" && console !== null) {
1561
+ if (typeof console.warn === "function") {
1562
+ console.warn('simditor: invalid caret state');
1563
+ }
1564
+ }
1551
1565
  return;
1552
1566
  }
1553
1567
  range = document.createRange();
@@ -2217,6 +2231,8 @@ Clipboard = (function(superClass) {
2217
2231
  _this.editor.inputManager.throttledValueChanged.clear();
2218
2232
  _this.editor.inputManager.throttledSelectionChanged.clear();
2219
2233
  _this.editor.undoManager.throttledPushState.clear();
2234
+ _this.editor.selection.reset();
2235
+ _this.editor.undoManager.resetCaretPosition();
2220
2236
  _this.pasting = true;
2221
2237
  return _this._getPasteContent(function(pasteContent) {
2222
2238
  _this._processPasteContent(pasteContent);
@@ -2476,7 +2492,10 @@ Simditor = (function(superClass) {
2476
2492
  return _this._placeholder();
2477
2493
  });
2478
2494
  }
2479
- return _this.setValue(_this.textarea.val().trim() || '');
2495
+ _this.setValue(_this.textarea.val().trim() || '');
2496
+ if (_this.textarea.attr('autofocus')) {
2497
+ return _this.focus();
2498
+ }
2480
2499
  };
2481
2500
  })(this));
2482
2501
  if (this.util.browser.mozilla) {
@@ -2582,15 +2601,15 @@ Simditor = (function(superClass) {
2582
2601
  return;
2583
2602
  }
2584
2603
  if (this.inputManager.lastCaretPosition) {
2585
- return this.undoManager.caretPosition(this.inputManager.lastCaretPosition);
2604
+ this.undoManager.caretPosition(this.inputManager.lastCaretPosition);
2605
+ return this.inputManager.lastCaretPosition = null;
2586
2606
  } else {
2587
2607
  $blockEl = this.body.children().last();
2588
2608
  if (!$blockEl.is('p')) {
2589
2609
  $blockEl = $('<p/>').append(this.util.phBr).appendTo(this.body);
2590
2610
  }
2591
2611
  range = document.createRange();
2592
- this.selection.setRangeAtEndOf($blockEl, range);
2593
- return this.body.focus();
2612
+ return this.selection.setRangeAtEndOf($blockEl, range);
2594
2613
  }
2595
2614
  };
2596
2615
 
@@ -4227,15 +4246,15 @@ ImageButton = (function(superClass) {
4227
4246
  if ($mask) {
4228
4247
  $mask.remove();
4229
4248
  }
4230
- return $img.removeData('mask');
4249
+ $img.removeData('mask');
4250
+ _this.editor.trigger('valuechanged');
4251
+ if (_this.editor.body.find('img.uploading').length < 1) {
4252
+ return _this.editor.uploader.trigger('uploadready', [file, result]);
4253
+ }
4231
4254
  });
4232
4255
  if (_this.popover.active) {
4233
4256
  _this.popover.srcEl.prop('disabled', false);
4234
- _this.popover.srcEl.val(result.file_path);
4235
- }
4236
- _this.editor.trigger('valuechanged');
4237
- if (_this.editor.body.find('img.uploading').length < 1) {
4238
- return _this.editor.uploader.trigger('uploadready', [file, result]);
4257
+ return _this.popover.srcEl.val(result.file_path);
4239
4258
  }
4240
4259
  };
4241
4260
  })(this));
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.2
4
+ version: 2.3.3
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-16 00:00:00.000000000 Z
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rails assets wrapper for https://github.com/mycolorway/simditor
14
14
  email: