Add an appendText API

This commit is contained in:
Ted Mielczarek 2015-10-19 12:58:47 -04:00
parent 504cc102a0
commit a675659dc2
4 changed files with 126 additions and 3 deletions

View file

@ -303,6 +303,19 @@ Pad.prototype.setText = function setText(newText) {
this.appendRevision(changeset);
};
Pad.prototype.appendText = function appendText(newText) {
//clean the new text
newText = exports.cleanText(newText);
var oldText = this.text();
//create the changeset
var changeset = Changeset.makeSplice(oldText, oldText.length, 0, newText);
//append the changeset
this.appendRevision(changeset);
};
Pad.prototype.appendChatMessage = function appendChatMessage(text, userId, time) {
this.chatHead++;
//save the chat entry in the database