From aff206ca9592f194cd41a36c63cba0a3416fe638 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sat, 24 Dec 2016 17:02:03 +0800 Subject: Fix js-url not import correctly --- public/js/index.js | 1 - 1 file changed, 1 deletion(-) (limited to 'public/js') diff --git a/public/js/index.js b/public/js/index.js index 96580fe3..e0f6bd6b 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -11,7 +11,6 @@ require('highlight.js/styles/github-gist.css'); var toMarkdown = require('to-markdown'); var saveAs = require('file-saver').saveAs; -var url = require('js-url'); var randomColor = require('randomcolor'); var _ = require("lodash"); -- cgit v1.2.3 From c904083d1f5064d2e786e0bc6ee3804b91805d24 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 2 Jan 2017 10:52:47 +0800 Subject: Remove manual LZString compression for partial socket io event data --- public/js/index.js | 8 -------- 1 file changed, 8 deletions(-) (limited to 'public/js') diff --git a/public/js/index.js b/public/js/index.js index e0f6bd6b..328b67fe 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -2645,8 +2645,6 @@ editor.on('update', function () { }); }); socket.on('check', function (data) { - data = LZString.decompressFromUTF16(data); - data = JSON.parse(data); //console.log(data); updateInfo(data); }); @@ -2656,8 +2654,6 @@ socket.on('permission', function (data) { var docmaxlength = null; var permission = null; socket.on('refresh', function (data) { - data = LZString.decompressFromUTF16(data); - data = JSON.parse(data); //console.log(data); docmaxlength = data.docmaxlength; editor.setOption("maxLength", docmaxlength); @@ -2704,8 +2700,6 @@ var CodeMirrorAdapter = ot.CodeMirrorAdapter; var cmClient = null; socket.on('doc', function (obj) { - obj = LZString.decompressFromUTF16(obj); - obj = JSON.parse(obj); var body = obj.str; var bodyMismatch = editor.getValue() !== body; var havePendingOperation = cmClient && Object.keys(cmClient.state).length > 0; @@ -2766,8 +2760,6 @@ socket.on('operation', function () { }); socket.on('online users', function (data) { - data = LZString.decompressFromUTF16(data); - data = JSON.parse(data); if (debug) console.debug(data); onlineUsers = data.users; -- cgit v1.2.3 From d9e19b602968551fcda4ee806d767a04f6a11490 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 2 Jan 2017 11:05:05 +0800 Subject: Update to remove null byte before saving to DB and remove null byte on changes --- public/js/index.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'public/js') diff --git a/public/js/index.js b/public/js/index.js index 328b67fe..e62d1dcb 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -3207,6 +3207,12 @@ function buildCursor(user) { } //editor actions +function removeNullByte(cm, change) { + var str = change.text.join("\n"); + if (/\u0000/g.test(str) && change.update) { + change.update(change.from, change.to, str.replace(/\u0000/g, "").split("\n")); + } +} function enforceMaxLength(cm, change) { var maxLength = cm.getOption("maxLength"); if (maxLength && change.update) { @@ -3228,6 +3234,7 @@ var ignoreEmitEvents = ['setValue', 'ignoreHistory']; editor.on('beforeChange', function (cm, change) { if (debug) console.debug(change); + removeNullByte(cm, change); if (enforceMaxLength(cm, change)) { $('.limit-modal').modal('show'); } -- cgit v1.2.3 From 0db4358adb12b2df1051874829f658496df6910c Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 2 Jan 2017 11:05:49 +0800 Subject: Fix authorship might losing update event because of throttling --- public/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'public/js') diff --git a/public/js/index.js b/public/js/index.js index e62d1dcb..2e0513c2 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -2443,7 +2443,7 @@ function updateInfo(data) { updateAuthorship(); } } -var updateAuthorship = _.throttle(function () { +var updateAuthorship = _.debounce(function () { editor.operation(updateAuthorshipInner); }, 50); function initMark() { -- cgit v1.2.3 From db0ea715c61c1b82794403cd045f6ccac5aa66c9 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 2 Jan 2017 11:06:02 +0800 Subject: Update to improve editor performance by debounce checkEditorScrollbar event --- public/js/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'public/js') diff --git a/public/js/index.js b/public/js/index.js index 2e0513c2..56766657 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1223,7 +1223,11 @@ function checkSyncToggle() { } } -function checkEditorScrollbar() { +var checkEditorScrollbar = _.debounce(function () { + editor.operation(checkEditorScrollbarInner); +}, 50); + +function checkEditorScrollbarInner() { // workaround simple scroll bar knob // will get wrong position when editor height changed var scrollInfo = editor.getScrollInfo(); -- cgit v1.2.3 From bd4335964d678dbde153946a4998a47fed63d48e Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 2 Jan 2017 11:19:01 +0800 Subject: Mark as 0.5.0 --- public/js/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'public/js') diff --git a/public/js/common.js b/public/js/common.js index 52839caf..f5bfc8ec 100644 --- a/public/js/common.js +++ b/public/js/common.js @@ -12,7 +12,7 @@ window.serverurl = window.location.protocol + '//' + (domain ? domain : window.l var noteid = urlpath ? window.location.pathname.slice(urlpath.length + 1, window.location.pathname.length).split('/')[1] : window.location.pathname.split('/')[1]; var noteurl = serverurl + '/' + noteid; -var version = '0.4.6'; +var version = '0.5.0'; var checkAuth = false; var profile = null; -- cgit v1.2.3