mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-04-07 14:09:12 +08:00
[se] Paste
Use function _addChars to paste text in cell editor
This commit is contained in:
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user