summaryrefslogtreecommitdiff
path: root/lib/ot/server.js
diff options
context:
space:
mode:
authorWu Cheng-Han2015-07-16 22:46:06 +0800
committerWu Cheng-Han2015-07-16 22:46:06 +0800
commitd14c5bdc9cabf632262067466ef02374cee496cd (patch)
tree63baaaa8c0205f55cb30f7e353e0727f14543851 /lib/ot/server.js
parent57253d28a7ad2037ba4d5da69d69f653e651c49b (diff)
Added document max length limit, enforceMaxLength on change and show modal when reach the limit.
Diffstat (limited to 'lib/ot/server.js')
-rw-r--r--lib/ot/server.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/ot/server.js b/lib/ot/server.js
index 608d434b..fec3b6f0 100644
--- a/lib/ot/server.js
+++ b/lib/ot/server.js
@@ -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);