Added document max length limit, enforceMaxLength on change and show modal when reach the limit.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user