Added document max length limit, enforceMaxLength on change and show modal when reach the limit.

This commit is contained in:
Wu Cheng-Han 2015-07-16 22:46:06 +08:00
parent 57253d28a7
commit d14c5bdc9c
6 changed files with 59 additions and 9 deletions

View file

@ -1,3 +1,5 @@
var config = require('../../config');
if (typeof ot === 'undefined') {
var ot = {};
}
@ -28,7 +30,10 @@ ot.Server = (function (global) {
}
// ... and apply that on the document.
this.document = operation.apply(this.document);
var newDocument = operation.apply(this.document);
// ignore if exceed the max length of document
if(newDocument.length > config.documentmaxlength) return;
this.document = newDocument;
// Store operation in history.
this.operations.push(operation);