vendor/assets/javascripts/simditor/simditor.js in simditor-2.3.5 vs vendor/assets/javascripts/simditor/simditor.js in simditor-2.3.6
- old
+ new
@@ -1,9 +1,9 @@
/*!
-* Simditor v2.3.5
+* Simditor v2.3.6
* http://simditor.tower.im/
-* 2015-11-19
+* 2015-12-21
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module unless amdModuleId is set
define('simditor', ["jquery","simple-module","simple-hotkeys","simple-uploader"], function ($, SimpleModule, simpleHotkeys, simpleUploader) {
@@ -1346,11 +1346,12 @@
return _this.throttledPushState();
};
})(this));
this.editor.on('selectionchanged', (function(_this) {
return function(e) {
- return _this.resetCaretPosition();
+ _this.resetCaretPosition();
+ return _this.update();
};
})(this));
this.editor.on('focus', (function(_this) {
return function(e) {
if (_this._stack.length === 0) {
@@ -1428,11 +1429,11 @@
return;
}
this.editor.hidePopover();
this._index -= 1;
state = this._stack[this._index];
- this.editor.body.html(state.html);
+ this.editor.body.get(0).innerHTML = state.html;
this.caretPosition(state.caret);
this.editor.body.find('.selected').removeClass('selected');
this.editor.sync();
return this.editor.trigger('valuechanged', ['undo']);
};
@@ -1443,25 +1444,24 @@
return;
}
this.editor.hidePopover();
this._index += 1;
state = this._stack[this._index];
- this.editor.body.html(state.html);
+ this.editor.body.get(0).innerHTML = state.html;
this.caretPosition(state.caret);
this.editor.body.find('.selected').removeClass('selected');
this.editor.sync();
return this.editor.trigger('valuechanged', ['redo']);
};
UndoManager.prototype.update = function() {
- var currentState, html;
+ var currentState;
currentState = this.currentState();
if (!currentState) {
return;
}
- html = this.editor.body.html();
- currentState.html = html;
+ currentState.html = this.editor.body.html();
return currentState.caret = this.caretPosition();
};
UndoManager.prototype._getNodeOffset = function(node, index) {
var $parent, merging, offset;
@@ -2209,11 +2209,12 @@
}
Clipboard.pluginName = 'Clipboard';
Clipboard.prototype.opts = {
- pasteImage: false
+ pasteImage: false,
+ cleanPaste: false
};
Clipboard.prototype._init = function() {
this.editor = this._module;
if (this.opts.pasteImage && typeof this.opts.pasteImage !== 'string') {
@@ -2294,17 +2295,17 @@
this._pasteBin.focus();
return setTimeout((function(_this) {
return function() {
var pasteContent;
_this.editor.hidePopover();
- _this.editor.body.html(state.html);
+ _this.editor.body.get(0).innerHTML = state.html;
_this.editor.undoManager.caretPosition(state.caret);
_this.editor.body.focus();
_this.editor.selection.reset();
_this.editor.selection.range();
_this._pasteInBlockEl = _this.editor.selection.blockNodes().last();
- _this._pastePlainText = _this._pasteInBlockEl.is('pre, table');
+ _this._pastePlainText = _this.opts.cleanPaste || _this._pasteInBlockEl.is('pre, table');
if (_this._pastePlainText) {
pasteContent = _this.editor.formatter.clearHtml(_this._pasteBin.html(), true);
} else {
pasteContent = $('<div/>').append(_this._pasteBin.contents());
pasteContent.find('table colgroup').remove();
@@ -2567,10 +2568,10 @@
};
Simditor.prototype.setValue = function(val) {
this.hidePopover();
this.textarea.val(val);
- this.body.html(val);
+ this.body.get(0).innerHTML = val;
this.formatter.format();
this.formatter.decorate();
this.util.reflow(this.body);
this.inputManager.lastCaretPosition = null;
return this.trigger('valuechanged');