mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -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);
|
||||
};
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
// clean the new text
|
||||
newText = exports.cleanText(newText);
|
||||
|
||||
const oldText = this.text();
|
||||
|
||||
// create the changeset
|
||||
const changeset = Changeset.makeSplice(oldText, oldText.length, 0, newText);
|
||||
|
||||
// append the changeset
|
||||
const orig = this.text();
|
||||
assert(orig.endsWith('\n'));
|
||||
const changeset = Changeset.makeSplice(orig, orig.length - 1, 0, newText);
|
||||
await this.appendRevision(changeset);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue