From d14c5bdc9cabf632262067466ef02374cee496cd Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Thu, 16 Jul 2015 22:46:06 +0800 Subject: Added document max length limit, enforceMaxLength on change and show modal when reach the limit. --- lib/ot/editor-socketio-server.js | 1 + lib/ot/server.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/ot') diff --git a/lib/ot/editor-socketio-server.js b/lib/ot/editor-socketio-server.js index ade8fc52..67920cbf 100755 --- a/lib/ot/editor-socketio-server.js +++ b/lib/ot/editor-socketio-server.js @@ -95,6 +95,7 @@ EditorSocketIOServer.prototype.onOperation = function (socket, revision, operati try { var clientId = socket.id; var wrappedPrime = this.receiveOperation(revision, wrapped); + if(!wrappedPrime) return; //console.log("new operation: " + JSON.stringify(wrapped)); this.getClient(clientId).selection = wrappedPrime.meta; revision = this.operations.length; 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); -- cgit v1.2.3