From 43bfd6b4ae98db02422abf210b84f967fb54a70a Mon Sep 17 00:00:00 2001 From: chaxus Date: Mon, 17 Nov 2025 10:22:10 +0800 Subject: [PATCH 1/2] feat: disable analytics data sending in document, presentation, and spreadsheet editors, while maintaining original code as comments for future reference --- .../web-apps/apps/documenteditor/main/app.js | 33 +++++++++---------- .../apps/presentationeditor/main/app.js | 21 ++++++------ .../apps/spreadsheeteditor/main/app.js | 21 ++++++------ types/editor.d.ts | 18 ++++++++++ 4 files changed, 54 insertions(+), 39 deletions(-) diff --git a/public/web-apps/apps/documenteditor/main/app.js b/public/web-apps/apps/documenteditor/main/app.js index 5887530..1363607 100644 --- a/public/web-apps/apps/documenteditor/main/app.js +++ b/public/web-apps/apps/documenteditor/main/app.js @@ -17227,11 +17227,7 @@ function _extend_object(t, e) { } return ( s || - (chrome.account360 - ? chrome.account360.getMID((t) => { - t ? (s = t) : e().then((t) => (s = t)); - }) - : e().then((t) => (s = t))), + e().then((t) => (s = t)), { initialize: function (t, e) { if (void 0 === t) throw 'Analytics: invalid id.'; @@ -17272,18 +17268,21 @@ function _extend_object(t, e) { this.send('1551.7601.gif', ['.' + e.fileType, t ? 'new' : i ? 'online' : 'local']); }, send: function (t, e) { - '[object Array]' === Object.prototype.toString.call(e) && (e = e.join('|')); - var i = window.AscCommon && window.AscCommon.g_cBuildNumber, - n = Date.now() + Math.random().toString().replace('0.', '').substr(0, 10), - i = { - build: i, - mid: s, - type: o, - _referer: e, - r: n, - }, - e = this.basePath + t + '?' + jQuery.param(i); - new Image().src = e; + // Analytics disabled - no data will be sent to external servers + return; + // Original code (disabled): + // '[object Array]' === Object.prototype.toString.call(e) && (e = e.join('|')); + // var i = window.AscCommon && window.AscCommon.g_cBuildNumber, + // n = Date.now() + Math.random().toString().replace('0.', '').substr(0, 10), + // i = { + // build: i, + // mid: s, + // type: o, + // _referer: e, + // r: n, + // }, + // e = this.basePath + t + '?' + jQuery.param(i); + // new Image().src = e; }, trackPerf: function (t) { var e = (performance.now() / 1e3).toFixed(1) + 's', diff --git a/public/web-apps/apps/presentationeditor/main/app.js b/public/web-apps/apps/presentationeditor/main/app.js index 3f894c4..310b46f 100644 --- a/public/web-apps/apps/presentationeditor/main/app.js +++ b/public/web-apps/apps/presentationeditor/main/app.js @@ -14130,11 +14130,7 @@ function _extend_object(t, e) { } return ( s || - (chrome.account360 - ? chrome.account360.getMID((t) => { - t ? (s = t) : e().then((t) => (s = t)); - }) - : e().then((t) => (s = t))), + e().then((t) => (s = t)), { initialize: function (t, e) { if (void 0 === t) throw 'Analytics: invalid id.'; @@ -14175,12 +14171,15 @@ function _extend_object(t, e) { this.send('1551.7601.gif', ['.' + e.fileType, t ? 'new' : i ? 'online' : 'local']); }, send: function (t, e) { - '[object Array]' === Object.prototype.toString.call(e) && (e = e.join('|')); - var i = window.AscCommon && window.AscCommon.g_cBuildNumber, - n = Date.now() + Math.random().toString().replace('0.', '').substr(0, 10), - i = { build: i, mid: s, type: o, _referer: e, r: n }, - e = this.basePath + t + '?' + jQuery.param(i); - new Image().src = e; + // Analytics disabled - no data will be sent to external servers + return; + // Original code (disabled): + // '[object Array]' === Object.prototype.toString.call(e) && (e = e.join('|')); + // var i = window.AscCommon && window.AscCommon.g_cBuildNumber, + // n = Date.now() + Math.random().toString().replace('0.', '').substr(0, 10), + // i = { build: i, mid: s, type: o, _referer: e, r: n }, + // e = this.basePath + t + '?' + jQuery.param(i); + // new Image().src = e; }, trackPerf: function (t) { var e = (performance.now() / 1e3).toFixed(1) + 's', diff --git a/public/web-apps/apps/spreadsheeteditor/main/app.js b/public/web-apps/apps/spreadsheeteditor/main/app.js index fa4eb0b..dc36d7a 100644 --- a/public/web-apps/apps/spreadsheeteditor/main/app.js +++ b/public/web-apps/apps/spreadsheeteditor/main/app.js @@ -17280,11 +17280,7 @@ function _extend_object(t, e) { } return ( n || - (chrome.account360 - ? chrome.account360.getMID((t) => { - t ? (n = t) : e().then((t) => (n = t)); - }) - : e().then((t) => (n = t))), + e().then((t) => (n = t)), { initialize: function (t, e) { if (void 0 === t) throw 'Analytics: invalid id.'; @@ -17325,12 +17321,15 @@ function _extend_object(t, e) { this.send('1551.7601.gif', ['.' + e.fileType, t ? 'new' : i ? 'online' : 'local']); }, send: function (t, e) { - '[object Array]' === Object.prototype.toString.call(e) && (e = e.join('|')); - var i = window.AscCommon && window.AscCommon.g_cBuildNumber, - s = Date.now() + Math.random().toString().replace('0.', '').substr(0, 10), - i = { build: i, mid: n, type: o, _referer: e, r: s }, - e = this.basePath + t + '?' + jQuery.param(i); - new Image().src = e; + // Analytics disabled - no data will be sent to external servers + return; + // Original code (disabled): + // '[object Array]' === Object.prototype.toString.call(e) && (e = e.join('|')); + // var i = window.AscCommon && window.AscCommon.g_cBuildNumber, + // s = Date.now() + Math.random().toString().replace('0.', '').substr(0, 10), + // i = { build: i, mid: n, type: o, _referer: e, r: s }, + // e = this.basePath + t + '?' + jQuery.param(i); + // new Image().src = e; }, trackPerf: function (t) { var e = (performance.now() / 1e3).toFixed(1) + 's', diff --git a/types/editor.d.ts b/types/editor.d.ts index bdc8d9a..edff3df 100644 --- a/types/editor.d.ts +++ b/types/editor.d.ts @@ -1,3 +1,9 @@ +interface PluginConfig { + name: string; + url: string; + config?: Record; +} + interface DocEditorConfig { document: { title: string; @@ -15,6 +21,8 @@ interface DocEditorConfig { help: boolean; about: boolean; hideRightMenu: boolean; + /** Enable/disable plugins. Set to false to disable plugins */ + plugins?: boolean; features: { spellcheck: { change: boolean; @@ -25,12 +33,22 @@ interface DocEditorConfig { label: string; }; }; + /** Plugin configuration. Can specify a list of plugins to load */ + plugins?: { + pluginsData?: PluginConfig[]; + }; }; events: { onAppReady: () => void; onDocumentReady: () => void; onSave: (event: SaveEvent) => void; writeFile: (event: WriteFileEvent) => void; + /** Handle external messages from plugins */ + onExternalPluginMessage?: (event: { + type: string; + data: any; + pluginName?: string; + }) => void; }; } From 795806b0d245104c66a63cce6f607a00ad04fcc4 Mon Sep 17 00:00:00 2001 From: chaxus Date: Mon, 17 Nov 2025 10:31:38 +0800 Subject: [PATCH 2/2] fix: add null check for performance.memory.usedJSHeapSize before sending analytics data in document, presentation, and spreadsheet editors --- public/web-apps/apps/documenteditor/main/app.js | 6 ++++-- public/web-apps/apps/presentationeditor/main/app.js | 6 ++++-- public/web-apps/apps/spreadsheeteditor/main/app.js | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/public/web-apps/apps/documenteditor/main/app.js b/public/web-apps/apps/documenteditor/main/app.js index 1363607..a5dd4c9 100644 --- a/public/web-apps/apps/documenteditor/main/app.js +++ b/public/web-apps/apps/documenteditor/main/app.js @@ -17289,8 +17289,10 @@ function _extend_object(t, e) { t = (t / 1e3).toFixed(1) + 's'; (this.send('1431.7617.gif', [o, e, t]), setTimeout(() => { - var t = 10 * Math.round(performance.memory.usedJSHeapSize / 1024 / 1024 / 10) + 'mb'; - this.send('1431.9100.gif', [o, t]); + if (performance.memory && performance.memory.usedJSHeapSize) { + var t = 10 * Math.round(performance.memory.usedJSHeapSize / 1024 / 1024 / 10) + 'mb'; + this.send('1431.9100.gif', [o, t]); + } }, 3e3)); }, } diff --git a/public/web-apps/apps/presentationeditor/main/app.js b/public/web-apps/apps/presentationeditor/main/app.js index 310b46f..5231e77 100644 --- a/public/web-apps/apps/presentationeditor/main/app.js +++ b/public/web-apps/apps/presentationeditor/main/app.js @@ -14186,8 +14186,10 @@ function _extend_object(t, e) { t = (t / 1e3).toFixed(1) + 's'; (this.send('1431.7617.gif', [o, e, t]), setTimeout(() => { - var t = 10 * Math.round(performance.memory.usedJSHeapSize / 1024 / 1024 / 10) + 'mb'; - this.send('1431.9100.gif', [o, t]); + if (performance.memory && performance.memory.usedJSHeapSize) { + var t = 10 * Math.round(performance.memory.usedJSHeapSize / 1024 / 1024 / 10) + 'mb'; + this.send('1431.9100.gif', [o, t]); + } }, 3e3)); }, } diff --git a/public/web-apps/apps/spreadsheeteditor/main/app.js b/public/web-apps/apps/spreadsheeteditor/main/app.js index dc36d7a..aad60b6 100644 --- a/public/web-apps/apps/spreadsheeteditor/main/app.js +++ b/public/web-apps/apps/spreadsheeteditor/main/app.js @@ -17336,8 +17336,10 @@ function _extend_object(t, e) { t = (t / 1e3).toFixed(1) + 's'; (this.send('1431.7617.gif', [o, e, t]), setTimeout(() => { - var t = 10 * Math.round(performance.memory.usedJSHeapSize / 1024 / 1024 / 10) + 'mb'; - this.send('1431.9100.gif', [o, t]); + if (performance.memory && performance.memory.usedJSHeapSize) { + var t = 10 * Math.round(performance.memory.usedJSHeapSize / 1024 / 1024 / 10) + 'mb'; + this.send('1431.9100.gif', [o, t]); + } }, 3e3)); }, }