diff --git a/cell/view/CellEditorView.js b/cell/view/CellEditorView.js index 8658dce027..3d13223479 100644 --- a/cell/view/CellEditorView.js +++ b/cell/view/CellEditorView.js @@ -619,45 +619,11 @@ text = text.replace(/\r/g, ""); text = text.replace(/^\n+|\n+$/g, ""); - var length = text.length; - if (!(length > 0)) { - return; - } - if (!this._checkMaxCellLength(length)) { + if (0 === text.length) { return; } - var wrap = -1 !== text.indexOf(kNewLine); - if (this.selectionBegin !== this.selectionEnd) { - this._removeChars(); - } - - // save info to undo/redo - this.undoList.push({fn: this._removeChars, args: [this.cursorPos, length]}); - this.redoList = []; - - var opt = this.options; - var nInsertPos = this.cursorPos; - var fr; - fr = this._findFragmentToInsertInto(nInsertPos - (nInsertPos > 0 ? 1 : 0)); - if (fr) { - var oCurFragment = opt.fragments[fr.index]; - if (fr.end <= nInsertPos) { - oCurFragment.text += text; - } else { - var sNewText = oCurFragment.text.substring(0, nInsertPos); - sNewText += text; - sNewText += oCurFragment.text.substring(nInsertPos); - oCurFragment.text = sNewText; - } - this.cursorPos = nInsertPos + length; - this._update(); - } - - if (wrap) { - this._wrapText(); - this._update(); - } + this._addChars(text); }; CellEditor.prototype.paste = function (fragments, cursorPos) {