mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 00:16:15 -04:00
Pad: Improve readability of appendText
This commit is contained in:
parent
a6bf7816ce
commit
b1d0848701
1 changed files with 8 additions and 8 deletions
|
@ -264,16 +264,16 @@ Pad.prototype.setText = async function (newText) {
|
||||||
await this.appendRevision(changeset);
|
await this.appendRevision(changeset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends text to the pad.
|
||||||
|
*
|
||||||
|
* @param {string} newText - Text to insert just BEFORE the pad's existing terminating newline.
|
||||||
|
*/
|
||||||
Pad.prototype.appendText = async function (newText) {
|
Pad.prototype.appendText = async function (newText) {
|
||||||
// clean the new text
|
|
||||||
newText = exports.cleanText(newText);
|
newText = exports.cleanText(newText);
|
||||||
|
const orig = this.text();
|
||||||
const oldText = this.text();
|
assert(orig.endsWith('\n'));
|
||||||
|
const changeset = Changeset.makeSplice(orig, orig.length - 1, 0, newText);
|
||||||
// create the changeset
|
|
||||||
const changeset = Changeset.makeSplice(oldText, oldText.length, 0, newText);
|
|
||||||
|
|
||||||
// append the changeset
|
|
||||||
await this.appendRevision(changeset);
|
await this.appendRevision(changeset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue