From 3db6d2fff90aa578f4c5529e6dad06879e690e3d Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 4 Nov 2020 08:32:14 +0530 Subject: [PATCH 01/14] scroll pad table of contents if necessary --- www/pad/app-pad.less | 1 + 1 file changed, 1 insertion(+) diff --git a/www/pad/app-pad.less b/www/pad/app-pad.less index b413eed6a..489cbb17d 100644 --- a/www/pad/app-pad.less +++ b/www/pad/app-pad.less @@ -27,6 +27,7 @@ body.cp-app-pad { #cp-app-pad-toc { @toc-level-indent: 15px; + overflow-y: auto; margin-top: 10px; margin-left: 10px; width: 200px; From 016bdc73b6cbe02557fbe9cdfb4dd32becd0cce9 Mon Sep 17 00:00:00 2001 From: Weblate Date: Wed, 4 Nov 2020 05:04:22 +0100 Subject: [PATCH 02/14] Translated using Weblate (English) Currently translated at 100.0% (1372 of 1372 strings) Translation: CryptPad/App Translate-URL: http://weblate.cryptpad.fr/projects/cryptpad/app/en/ --- www/common/translations/messages.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/common/translations/messages.json b/www/common/translations/messages.json index fa96fc5a7..c76b9a7c1 100644 --- a/www/common/translations/messages.json +++ b/www/common/translations/messages.json @@ -1467,5 +1467,6 @@ "loading_state_4": "Load Teams", "loading_state_5": "Reconstruct document", "tag_add": "Add", - "tag_edit": "Edit" + "tag_edit": "Edit", + "error_unhelpfulScriptError": "Script Error: See browser console for details" } From 553f29b43163db4b7af20120729c45266faa68f7 Mon Sep 17 00:00:00 2001 From: Weblate Date: Wed, 4 Nov 2020 05:04:23 +0100 Subject: [PATCH 03/14] Translated using Weblate (French) Currently translated at 100.0% (1372 of 1372 strings) Translation: CryptPad/App Translate-URL: http://weblate.cryptpad.fr/projects/cryptpad/app/fr/ --- www/common/translations/messages.fr.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/common/translations/messages.fr.json b/www/common/translations/messages.fr.json index 70909c44d..1d1779035 100644 --- a/www/common/translations/messages.fr.json +++ b/www/common/translations/messages.fr.json @@ -1467,5 +1467,6 @@ "loading_state_1": "Chargement du drive", "loading_state_0": "Construction de l'interface", "tag_edit": "Modifier", - "tag_add": "Ajouter" + "tag_add": "Ajouter", + "error_unhelpfulScriptError": "Erreur de script : consultez la console du navigateur pour plus de détails" } From 59eaf8187c9a097fc0f679da784ed2615e9b1bd8 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 4 Nov 2020 10:28:52 +0530 Subject: [PATCH 04/14] handle unhelpful 'Script error.' message --- customize.dist/loading.js | 16 +++++++++++++--- www/common/sframe-boot2.js | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/customize.dist/loading.js b/customize.dist/loading.js index 4f8b79125..740c66081 100644 --- a/customize.dist/loading.js +++ b/customize.dist/loading.js @@ -312,25 +312,35 @@ button.primary:hover{ return bar; }; + var hasErrored = false; var updateLoadingProgress = function (data) { - if (!built) { return; } + if (!built || !data) { return; } var c = types.indexOf(data.type); if (c < current) { return console.error(data); } try { document.querySelector('.cp-loading-spinner-container').style.display = 'none'; document.querySelector('.cp-loading-progress-list').innerHTML = makeList(data); document.querySelector('.cp-loading-progress-container').innerHTML = makeBar(data); - } catch (e) { console.error(e); } + } catch (e) { + if (!hasErrored) { console.error(e); } + } }; window.CryptPad_updateLoadingProgress = updateLoadingProgress; + window.CryptPad_loadingError = function (err) { if (!built) { return; } + hasErrored = true; + var err2; + if (err === 'Script error.') { + err2 = Messages.error_unhelpfulScriptError; + } + try { var node = document.querySelector('.cp-loading-progress'); if (node.parentNode) { node.parentNode.removeChild(node); } document.querySelector('.cp-loading-spinner-container').setAttribute('style', 'display:none;'); document.querySelector('#cp-loading-message').setAttribute('style', 'display:block;'); - document.querySelector('#cp-loading-message').innerText = err; + document.querySelector('#cp-loading-message').innerText = err2 || err; } catch (e) { console.error(e); } }; return function () { diff --git a/www/common/sframe-boot2.js b/www/common/sframe-boot2.js index 5a68237ad..66a93545f 100644 --- a/www/common/sframe-boot2.js +++ b/www/common/sframe-boot2.js @@ -43,7 +43,7 @@ define([ return void console.log(); } if (window.CryptPad_loadingError) { - window.CryptPad_loadingError(e); + return void window.CryptPad_loadingError(e); } throw e; }; From c4e1b5f7d42ffaf6fd8c931dbb28d562ba53db54 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 4 Nov 2020 10:32:45 +0530 Subject: [PATCH 05/14] refactor two mostly-identical functions --- www/common/cryptpad-common.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 8874871d8..ca65ce77b 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -148,20 +148,19 @@ define([ send(); }; - common.setTabHref = function (href) { - var ohc = window.onhashchange; - window.onhashchange = function () {}; - window.location.href = href; - window.onhashchange = ohc; - ohc({reset: true}); - }; - common.setTabHash = function (hash) { - var ohc = window.onhashchange; - window.onhashchange = function () {}; - window.location.hash = hash; - window.onhashchange = ohc; - ohc({reset: true}); - }; + (function () { + var bypassHashChange = function (key) { + return function (value) { + var ohc = window.onhashchange; + window.onhashchange = function () {}; + window.location[key] = value; + window.onhashchange = ohc; + ohc({reset: true}); + }; + }; + common.setTabHref = bypassHashChange('href'); + common.setTabHash = bypassHashChange('hash'); + }()); // RESTRICTED // Settings only From 0f4013505d2707c226dc223df76ee700f6963a00 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 4 Nov 2020 12:26:53 +0530 Subject: [PATCH 06/14] prevent typeError for undefined button when logged out --- www/common/onlyoffice/inner.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index ce0dbcc3f..28d06dd32 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -2070,7 +2070,9 @@ define([ // Import template var $template = common.createButton('importtemplate', true, {}, openTemplatePicker); - $template.appendTo(toolbar.$drawer); + if ($template && typeof($template.appendTo) === 'function') { + $template.appendTo(toolbar.$drawer); + } })(); } From 9203b88538834cefdd1a89e817c373e862a2607e Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 4 Nov 2020 11:22:31 +0100 Subject: [PATCH 07/14] Fix UI language --- customize.dist/loading.js | 1 + customize.dist/messages.js | 8 +++-- www/admin/inner.html | 2 +- www/admin/main.js | 28 ++---------------- www/code/inner.html | 2 +- www/common/onlyoffice/main.js | 39 +++--------------------- www/common/sframe-app-outer.js | 38 +++--------------------- www/common/sframe-boot.js | 2 +- www/common/sframe-common-outer.js | 49 ++++++++++++++++++++++++++++++- www/contacts/inner.html | 2 +- www/contacts/main.js | 28 ++---------------- www/debug/inner.html | 2 +- www/drive/inner.html | 2 +- www/drive/main.js | 38 +++--------------------- www/file/inner.html | 2 +- www/file/main.js | 38 +++--------------------- www/kanban/inner.html | 2 +- www/notifications/inner.html | 2 +- www/notifications/main.js | 28 ++---------------- www/oodoc/inner.html | 2 +- www/ooslide/inner.html | 2 +- www/pad/inner.html | 2 +- www/poll/inner.html | 2 +- www/poll/main.js | 38 +++--------------------- www/profile/inner.html | 2 +- www/profile/main.js | 28 ++---------------- www/secureiframe/inner.html | 2 +- www/secureiframe/main.js | 7 +++-- www/settings/inner.html | 2 +- www/settings/main.js | 28 ++---------------- www/sheet/inner.html | 2 +- www/slide/inner.html | 2 +- www/support/inner.html | 2 +- www/support/main.js | 28 ++---------------- www/teams/inner.html | 2 +- www/teams/main.js | 38 +++--------------------- www/todo/inner.html | 2 +- www/whiteboard/inner.html | 2 +- www/worker/inner.html | 2 +- www/worker/main.js | 28 ++---------------- 40 files changed, 121 insertions(+), 415 deletions(-) diff --git a/customize.dist/loading.js b/customize.dist/loading.js index 740c66081..edb66ef0a 100644 --- a/customize.dist/loading.js +++ b/customize.dist/loading.js @@ -337,6 +337,7 @@ button.primary:hover{ try { var node = document.querySelector('.cp-loading-progress'); + if (!node) { return; } if (node.parentNode) { node.parentNode.removeChild(node); } document.querySelector('.cp-loading-spinner-container').setAttribute('style', 'display:none;'); document.querySelector('#cp-loading-message').setAttribute('style', 'display:block;'); diff --git a/customize.dist/messages.js b/customize.dist/messages.js index 40dbbfb95..303375e4e 100755 --- a/customize.dist/messages.js +++ b/customize.dist/messages.js @@ -26,7 +26,9 @@ var getStoredLanguage = function () { return localStorage && localStorage.getIte var getBrowserLanguage = function () { return navigator.language || navigator.userLanguage || ''; }; var getLanguage = messages._getLanguage = function () { if (window.cryptpadLanguage) { return window.cryptpadLanguage; } - if (getStoredLanguage()) { return getStoredLanguage(); } + try { + if (getStoredLanguage()) { return getStoredLanguage(); } + } catch (e) { console.log(e); } var l = getBrowserLanguage(); // Edge returns 'fr-FR' --> transform it to 'fr' and check again return map[l] ? l : @@ -65,7 +67,9 @@ define(req, function(AppConfig, Default, Language) { if (AppConfig.availableLanguages.indexOf(language) === -1) { language = defaultLanguage; Language = Default; - localStorage.setItem(LS_LANG, language); + try { + localStorage.setItem(LS_LANG, language); + } catch (e) { console.log(e); } } Object.keys(map).forEach(function (l) { if (l === defaultLanguage) { return; } diff --git a/www/admin/inner.html b/www/admin/inner.html index 01bda5fab..eeb234d0c 100644 --- a/www/admin/inner.html +++ b/www/admin/inner.html @@ -2,7 +2,7 @@ - + diff --git a/www/admin/main.js b/www/admin/main.js index 817d2bd2e..8a6ec7a70 100644 --- a/www/admin/main.js +++ b/www/admin/main.js @@ -3,38 +3,14 @@ define([ '/bower_components/nthen/index.js', '/api/config', '/common/dom-ready.js', - '/common/requireconfig.js', '/common/sframe-common-outer.js', -], function (nThen, ApiConfig, DomReady, RequireConfig, SFCommonO) { - var requireConfig = RequireConfig(); +], function (nThen, ApiConfig, DomReady, SFCommonO) { // Loaded in load #2 nThen(function (waitFor) { DomReady.onReady(waitFor()); }).nThen(function (waitFor) { - var req = { - cfg: requireConfig, - req: [ '/common/loading.js' ], - pfx: window.location.origin - }; - window.rc = requireConfig; - window.apiconf = ApiConfig; - document.getElementById('sbox-iframe').setAttribute('src', - ApiConfig.httpSafeOrigin + '/admin/inner.html?' + requireConfig.urlArgs + - '#' + encodeURIComponent(JSON.stringify(req))); - - // This is a cheap trick to avoid loading sframe-channel in parallel with the - // loading screen setup. - var done = waitFor(); - var onMsg = function (msg) { - var data = JSON.parse(msg.data); - if (data.q !== 'READY') { return; } - window.removeEventListener('message', onMsg); - var _done = done; - done = function () { }; - _done(); - }; - window.addEventListener('message', onMsg); + SFCommonO.initIframe(waitFor); }).nThen(function (/*waitFor*/) { var addRpc = function (sframeChan, Cryptpad/*, Utils*/) { // Adding a new avatar from the profile: pin it and store it in the object diff --git a/www/code/inner.html b/www/code/inner.html index a4ea56206..b25534297 100644 --- a/www/code/inner.html +++ b/www/code/inner.html @@ -2,7 +2,7 @@ - + diff --git a/www/contacts/main.js b/www/contacts/main.js index 38d6c5e71..faf92f94e 100644 --- a/www/contacts/main.js +++ b/www/contacts/main.js @@ -3,38 +3,14 @@ define([ '/bower_components/nthen/index.js', '/api/config', '/common/dom-ready.js', - '/common/requireconfig.js', '/common/sframe-common-outer.js' -], function (nThen, ApiConfig, DomReady, RequireConfig, SFCommonO) { - var requireConfig = RequireConfig(); +], function (nThen, ApiConfig, DomReady, SFCommonO) { // Loaded in load #2 nThen(function (waitFor) { DomReady.onReady(waitFor()); }).nThen(function (waitFor) { - var req = { - cfg: requireConfig, - req: [ '/common/loading.js' ], - pfx: window.location.origin - }; - window.rc = requireConfig; - window.apiconf = ApiConfig; - document.getElementById('sbox-iframe').setAttribute('src', - ApiConfig.httpSafeOrigin + '/contacts/inner.html?' + requireConfig.urlArgs + - '#' + encodeURIComponent(JSON.stringify(req))); - - // This is a cheap trick to avoid loading sframe-channel in parallel with the - // loading screen setup. - var done = waitFor(); - var onMsg = function (msg) { - var data = JSON.parse(msg.data); - if (data.q !== 'READY') { return; } - window.removeEventListener('message', onMsg); - var _done = done; - done = function () { }; - _done(); - }; - window.addEventListener('message', onMsg); + SFCommonO.initIframe(waitFor); }).nThen(function (/*waitFor*/) { SFCommonO.start({ noRealtime: true, diff --git a/www/debug/inner.html b/www/debug/inner.html index 2ac53948c..7936c04f2 100644 --- a/www/debug/inner.html +++ b/www/debug/inner.html @@ -2,7 +2,7 @@ - + diff --git a/www/notifications/main.js b/www/notifications/main.js index 20c8653f9..785fb3b5d 100644 --- a/www/notifications/main.js +++ b/www/notifications/main.js @@ -3,38 +3,14 @@ define([ '/bower_components/nthen/index.js', '/api/config', '/common/dom-ready.js', - '/common/requireconfig.js', '/common/sframe-common-outer.js', -], function (nThen, ApiConfig, DomReady, RequireConfig, SFCommonO) { - var requireConfig = RequireConfig(); +], function (nThen, ApiConfig, DomReady, SFCommonO) { // Loaded in load #2 nThen(function (waitFor) { DomReady.onReady(waitFor()); }).nThen(function (waitFor) { - var req = { - cfg: requireConfig, - req: [ '/common/loading.js' ], - pfx: window.location.origin - }; - window.rc = requireConfig; - window.apiconf = ApiConfig; - document.getElementById('sbox-iframe').setAttribute('src', - ApiConfig.httpSafeOrigin + '/notifications/inner.html?' + requireConfig.urlArgs + - '#' + encodeURIComponent(JSON.stringify(req))); - - // This is a cheap trick to avoid loading sframe-channel in parallel with the - // loading screen setup. - var done = waitFor(); - var onMsg = function (msg) { - var data = JSON.parse(msg.data); - if (data.q !== 'READY') { return; } - window.removeEventListener('message', onMsg); - var _done = done; - done = function () { }; - _done(); - }; - window.addEventListener('message', onMsg); + SFCommonO.initIframe(waitFor); }).nThen(function (/*waitFor*/) { var category; if (window.location.hash) { diff --git a/www/oodoc/inner.html b/www/oodoc/inner.html index 529c5a8d9..884ae5a00 100644 --- a/www/oodoc/inner.html +++ b/www/oodoc/inner.html @@ -2,7 +2,7 @@ - + diff --git a/www/ooslide/inner.html b/www/ooslide/inner.html index d06820db2..e7c4e111f 100644 --- a/www/ooslide/inner.html +++ b/www/ooslide/inner.html @@ -2,7 +2,7 @@ - + diff --git a/www/pad/inner.html b/www/pad/inner.html index e4dbcdf95..17bfec308 100644 --- a/www/pad/inner.html +++ b/www/pad/inner.html @@ -2,7 +2,7 @@ - + diff --git a/www/profile/main.js b/www/profile/main.js index 92b24b3fc..b041d926a 100644 --- a/www/profile/main.js +++ b/www/profile/main.js @@ -3,38 +3,14 @@ define([ '/bower_components/nthen/index.js', '/api/config', '/common/dom-ready.js', - '/common/requireconfig.js', '/common/sframe-common-outer.js', -], function (nThen, ApiConfig, DomReady, RequireConfig, SFCommonO) { - var requireConfig = RequireConfig(); +], function (nThen, ApiConfig, DomReady, SFCommonO) { // Loaded in load #2 nThen(function (waitFor) { DomReady.onReady(waitFor()); }).nThen(function (waitFor) { - var req = { - cfg: requireConfig, - req: [ '/common/loading.js' ], - pfx: window.location.origin - }; - window.rc = requireConfig; - window.apiconf = ApiConfig; - document.getElementById('sbox-iframe').setAttribute('src', - ApiConfig.httpSafeOrigin + '/profile/inner.html?' + requireConfig.urlArgs + - '#' + encodeURIComponent(JSON.stringify(req))); - - // This is a cheap trick to avoid loading sframe-channel in parallel with the - // loading screen setup. - var done = waitFor(); - var onMsg = function (msg) { - var data = JSON.parse(msg.data); - if (data.q !== 'READY') { return; } - window.removeEventListener('message', onMsg); - var _done = done; - done = function () { }; - _done(); - }; - window.addEventListener('message', onMsg); + SFCommonO.initIframe(waitFor); }).nThen(function (/*waitFor*/) { var getSecrets = function (Cryptpad, Utils, cb) { var Hash = Utils.Hash; diff --git a/www/secureiframe/inner.html b/www/secureiframe/inner.html index 29c3cf797..97bfb3930 100644 --- a/www/secureiframe/inner.html +++ b/www/secureiframe/inner.html @@ -2,7 +2,7 @@ - + diff --git a/www/settings/main.js b/www/settings/main.js index bbc0f87d3..750423a1d 100644 --- a/www/settings/main.js +++ b/www/settings/main.js @@ -3,38 +3,14 @@ define([ '/bower_components/nthen/index.js', '/api/config', '/common/dom-ready.js', - '/common/requireconfig.js', '/common/sframe-common-outer.js' -], function (nThen, ApiConfig, DomReady, RequireConfig, SFCommonO) { - var requireConfig = RequireConfig(); +], function (nThen, ApiConfig, DomReady, SFCommonO) { // Loaded in load #2 nThen(function (waitFor) { DomReady.onReady(waitFor()); }).nThen(function (waitFor) { - var req = { - cfg: requireConfig, - req: [ '/common/loading.js' ], - pfx: window.location.origin - }; - window.rc = requireConfig; - window.apiconf = ApiConfig; - document.getElementById('sbox-iframe').setAttribute('src', - ApiConfig.httpSafeOrigin + '/settings/inner.html?' + requireConfig.urlArgs + - '#' + encodeURIComponent(JSON.stringify(req))); - - // This is a cheap trick to avoid loading sframe-channel in parallel with the - // loading screen setup. - var done = waitFor(); - var onMsg = function (msg) { - var data = JSON.parse(msg.data); - if (data.q !== 'READY') { return; } - window.removeEventListener('message', onMsg); - var _done = done; - done = function () { }; - _done(); - }; - window.addEventListener('message', onMsg); + SFCommonO.initIframe(waitFor); }).nThen(function (/*waitFor*/) { var addRpc = function (sframeChan, Cryptpad, Utils) { sframeChan.on('Q_THUMBNAIL_CLEAR', function (d, cb) { diff --git a/www/sheet/inner.html b/www/sheet/inner.html index 07d21904d..68949568f 100644 --- a/www/sheet/inner.html +++ b/www/sheet/inner.html @@ -2,7 +2,7 @@ - + diff --git a/www/slide/inner.html b/www/slide/inner.html index c04091cf7..f067e8a2f 100644 --- a/www/slide/inner.html +++ b/www/slide/inner.html @@ -2,7 +2,7 @@ - + diff --git a/www/support/main.js b/www/support/main.js index b5ca65126..1dc8c0e56 100644 --- a/www/support/main.js +++ b/www/support/main.js @@ -3,40 +3,16 @@ define([ '/bower_components/nthen/index.js', '/api/config', '/common/dom-ready.js', - '/common/requireconfig.js', '/common/sframe-common-outer.js', '/common/outer/local-store.js', '/common/outer/login-block.js', -], function (nThen, ApiConfig, DomReady, RequireConfig, SFCommonO, LocalStore, Block) { - var requireConfig = RequireConfig(); +], function (nThen, ApiConfig, DomReady, SFCommonO, LocalStore, Block) { // Loaded in load #2 nThen(function (waitFor) { DomReady.onReady(waitFor()); }).nThen(function (waitFor) { - var req = { - cfg: requireConfig, - req: [ '/common/loading.js' ], - pfx: window.location.origin - }; - window.rc = requireConfig; - window.apiconf = ApiConfig; - document.getElementById('sbox-iframe').setAttribute('src', - ApiConfig.httpSafeOrigin + '/support/inner.html?' + requireConfig.urlArgs + - '#' + encodeURIComponent(JSON.stringify(req))); - - // This is a cheap trick to avoid loading sframe-channel in parallel with the - // loading screen setup. - var done = waitFor(); - var onMsg = function (msg) { - var data = JSON.parse(msg.data); - if (data.q !== 'READY') { return; } - window.removeEventListener('message', onMsg); - var _done = done; - done = function () { }; - _done(); - }; - window.addEventListener('message', onMsg); + SFCommonO.initIframe(waitFor); }).nThen(function (/*waitFor*/) { var category; if (window.location.hash) { diff --git a/www/teams/inner.html b/www/teams/inner.html index 243a74edf..5ec12c287 100644 --- a/www/teams/inner.html +++ b/www/teams/inner.html @@ -2,7 +2,7 @@ - + diff --git a/www/whiteboard/inner.html b/www/whiteboard/inner.html index 533b4568f..4b56440e3 100644 --- a/www/whiteboard/inner.html +++ b/www/whiteboard/inner.html @@ -2,7 +2,7 @@ - + diff --git a/www/worker/main.js b/www/worker/main.js index 04dffa748..633982146 100644 --- a/www/worker/main.js +++ b/www/worker/main.js @@ -3,38 +3,14 @@ define([ '/bower_components/nthen/index.js', '/api/config', '/common/dom-ready.js', - '/common/requireconfig.js', '/common/sframe-common-outer.js' -], function (nThen, ApiConfig, DomReady, RequireConfig, SFCommonO) { - var requireConfig = RequireConfig(); +], function (nThen, ApiConfig, DomReady, SFCommonO) { // Loaded in load #2 nThen(function (waitFor) { DomReady.onReady(waitFor()); }).nThen(function (waitFor) { - var req = { - cfg: requireConfig, - req: [ '/common/loading.js' ], - pfx: window.location.origin - }; - window.rc = requireConfig; - window.apiconf = ApiConfig; - document.getElementById('sbox-iframe').setAttribute('src', - ApiConfig.httpSafeOrigin + '/worker/inner.html?' + requireConfig.urlArgs + - '#' + encodeURIComponent(JSON.stringify(req))); - - // This is a cheap trick to avoid loading sframe-channel in parallel with the - // loading screen setup. - var done = waitFor(); - var onMsg = function (msg) { - var data = JSON.parse(msg.data); - if (data.q !== 'READY') { return; } - window.removeEventListener('message', onMsg); - var _done = done; - done = function () { }; - _done(); - }; - window.addEventListener('message', onMsg); + SFCommonO.initIframe(waitFor); }).nThen(function (/*waitFor*/) { SFCommonO.start({ noRealtime: true, From 2844505593249b66ad8ef8dcdfe9558e5f02346e Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 4 Nov 2020 13:09:49 +0100 Subject: [PATCH 08/14] Remove double slash in iframe URL --- www/common/sframe-common-outer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 24496dd53..f6f24c5bf 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -31,7 +31,7 @@ define([ } document.getElementById('sbox-iframe').setAttribute('src', - ApiConfig.httpSafeOrigin + window.location.pathname + '/inner.html?' + + ApiConfig.httpSafeOrigin + window.location.pathname + 'inner.html?' + requireConfig.urlArgs + '#' + encodeURIComponent(JSON.stringify(req))); // This is a cheap trick to avoid loading sframe-channel in parallel with the From a63ddb646cdc0f3e923c7daca5664c971d5612fb Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 5 Nov 2020 14:46:46 +0530 Subject: [PATCH 09/14] include anchors in rich text table of contents --- www/pad/inner.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/www/pad/inner.js b/www/pad/inner.js index eeabbb337..235b4fafa 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -650,9 +650,25 @@ define([ }, 500); // 500ms to make sure it is sent after chainpad sync }; + var isAnchor = function (el) { return el.nodeName === 'A'; }; + var getAnchorName = function (el) { + return el.getAttribute('id') || + el.getAttribute('data-cke-saved-name') || + el.getAttribute('name') || + Util.stripTags($(el).text()); + }; + var updateTOC = Util.throttle(function () { var toc = []; - $inner.find('h1, h2, h3').each(function (i, el) { + $inner.find('h1, h2, h3, a[id][data-cke-saved-name]').each(function (i, el) { + if (isAnchor(el)) { + return void toc.push({ + level: 2, + el: el, + title: getAnchorName(el), + }); + } + toc.push({ level: Number(el.tagName.slice(1)), el: el, @@ -661,6 +677,8 @@ define([ }); var content = [h('h2', Messages.markdown_toc)]; toc.forEach(function (obj) { + var title = (obj.title || "").trim(); + if (!title) { return; } // Only include level 2 headings var level = obj.level; var a = h('a.cp-pad-toc-link', { @@ -672,7 +690,7 @@ define([ if (!obj.el || UIElements.isVisible(obj.el, $inner)) { return; } obj.el.scrollIntoView(); }); - a.innerHTML = obj.title; + a.innerHTML = title; content.push(h('p.cp-pad-toc-'+level, a)); }); $toc.html('').append(content); @@ -1098,7 +1116,7 @@ define([ */ Ckeditor.dom.element.prototype.setHtml = function(a){ if (/callFunction/.test(a)) { - a = a.replace(/on(mousedown|blur|keydown|focus|click|dragstart)/g, function (value) { + a = a.replace(/on(mousedown|blur|keydown|focus|click|dragstart|mouseover|mouseout)/g, function (value) { return 'o' + value; }); } From 830739c901aa2623ee4aa0831cebc9443673b4ac Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 5 Nov 2020 11:28:20 +0100 Subject: [PATCH 10/14] Fix teams APP issue after login redirect --- www/common/sframe-common-outer.js | 3 ++- www/teams/main.js | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index f6f24c5bf..ad128db33 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -121,6 +121,7 @@ define([ Utils.Feedback = _Feedback; Utils.LocalStore = _LocalStore; Utils.UserObject = _UserObject; + Utils.currentPad = currentPad; AppConfig = _AppConfig; Test = _Test; @@ -604,7 +605,7 @@ define([ for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; } if (cfg.addData) { - cfg.addData(metaObj.priv, Cryptpad, metaObj.user); + cfg.addData(metaObj.priv, Cryptpad, metaObj.user, Utils); } sframeChan.event('EV_METADATA_UPDATE', metaObj); diff --git a/www/teams/main.js b/www/teams/main.js index 722cd7c1b..044419dfc 100644 --- a/www/teams/main.js +++ b/www/teams/main.js @@ -97,9 +97,12 @@ define([ var secret = Hash.getSecrets('team', hash); cb(null, secret); }; - var addData = function (meta) { - if (!hash) { return; } - meta.teamInviteHash = hash.slice(1); + var addData = function (meta, Cryptpad, user, Utils) { + if (!Utils.currentPad.hash) { return; } + var _hash = Utils.currentPad.hash.replace(/^#/, ''); + var parsed = Utils.Hash.parseTypeHash('invite', _hash); + if (parsed.app !== 'invite') { return; } + meta.teamInviteHash = _hash; }; SFCommonO.start({ getSecrets: getSecrets, From d5b348a366f97b1f5d521c2aa30a183dbb556a1a Mon Sep 17 00:00:00 2001 From: Weblate Date: Wed, 4 Nov 2020 15:25:59 +0100 Subject: [PATCH 11/14] Translated using Weblate (German) Currently translated at 100.0% (1372 of 1372 strings) Translation: CryptPad/App Translate-URL: http://weblate.cryptpad.fr/projects/cryptpad/app/de/ --- www/common/translations/messages.de.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/common/translations/messages.de.json b/www/common/translations/messages.de.json index 6b5046aa0..b8aa108ed 100644 --- a/www/common/translations/messages.de.json +++ b/www/common/translations/messages.de.json @@ -1467,5 +1467,6 @@ "loading_state_2": "Inhalte aktualisieren", "loading_state_1": "Drive laden", "loading_state_0": "Oberfläche vorbereiten", - "loading_state_5": "Dokument rekonstruieren" + "loading_state_5": "Dokument rekonstruieren", + "error_unhelpfulScriptError": "Skriptfehler: Siehe Konsole im Browser für Details" } From 0e08abecb39573c10dbff2ac15fb7fb9e513cacf Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 5 Nov 2020 18:33:17 +0530 Subject: [PATCH 12/14] update changelog for 3.24.0 --- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f649883d..3330eb35b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,40 @@ +# YunnanLakeNewt (3.24.0) + +## Goals + +We are once again working to develop some significant new features. This release is fairly small but includes some significant changes to detect and handle a variety of errors. + +## Update notes + +This release includes some minor corrections the recommended NGINX configuration supplied in `cryptpad/docs/example.nginx.conf`. + +To update from 3.23.2 to 3.24.0: + +1. Update your NGINX config to replicate the most recent changes and reload NGINX to apply them. +2. Stop the nodejs server. +3. Pull the latest code from the `3.24.0` tag or the `main` branch using `git`. +4. Ensure you have the latest clientside and serverside dependencies with `bower update` and `npm install`. +5. Restart the nodejs server. + +## Features + +* A variety of CryptPad's pages now feature a much-improved loading screen which provides a more informative account of what is being loaded. It also implements some generic error handling to detect and report when something has failed in a catastrophic way. This is intended to both inform users that the page is in a broken state as well as to improve the quality of the debugging information they can provide to us so that we can fix the underlying cause. +* It is now possible to create spreadsheets from templates. Template functionality has existed for a long time in our other editors, however, OnlyOffice's architecture differs significantly and required the implementation of a wholly different system. +* One user reported some confusion regarding the use of the Kanban app's _tag_ functionality. We've updated the UI to be a little more informative. +* The "table of contents" in rich text pads now includes "anchors" created via the editor's toolbar. + +## Bug fixes + +* Recent changes to CryptPad's recommended CSP headers enabled Firefox to export spreadsheets to XLSX format, but they also triggered some regressions due to a number of incompatible APIs. + * Our usage of the `sessionStorage` for the purpose of passing important information to editors opened in a new tab stopped working. This meant that when you created a document in a folder, the resulting new tab would not receive the argument describing where it should be stored, and would instead save it to the default location. We've addressed this by replacing our usage of sessionStorage with a new format for passing the same arguments via the hash in the new document's URL. + * The `window.print` API also failed in a variety of cases. We've updated the relevant CSP headers to only be applied on the sheet editor (to support XSLX export) but allow printing elsewhere. We've also updated some print styles to provide more appealing results. +* The table of contents available in rich text pads failed to scroll when there were a sufficient number of heading to flow beyond the length of the page. Now a scrollbar appears when necessary. +* We discovered a number of cases where the presence of an allow list prevented some valid behaviour due to the server incorrectly concluding that users were not authenticated. We've improved the client's ability to detect these cases and re-authenticate when necessary. +* We also found that when the server was under very heavy load some database queries were timing out because they were slow (but not stopped). We've addressed this to only terminate such queries if they have been entirely inactive for several minutes. +* It was possible for "safe links" to include a mode ("edit" or "view") which did not match the rights of the user opening them. For example, if a user loaded a safe link with edit rights though they only had read-only access via their "viewer" role in a team. CryptPad will now recover from such cases and open the document with the closest set of access rights that they possess. +* We found that the server query `"IS_NEW_PAD"` could return an error but that clients would incorrectly interpret such a response as a `false`. This has been corrected. +* Finally, we've modified the "trash" UI for user and team drives such that when users attempt to empty their trash of owned shared folders they are prompted to remove the items or delete them from the server entirely, as they would be with other owned assets. + # XerusDaamsi reloaded (3.23.2) A number of instance administrators reported issues following our 3.23.1 release. We suspect the issues were caused by applying the recommended update steps out of order which would result in the incorrect HTTP header values getting cached for the most recent version of a file. Since the most recently updated headers modified some security settings, this caused a catastrophic error on clients receiving the incorrect headers which caused them to fail to load under certain circumstances. From bc2387256f61b63a4ac85104e34da42e56c78c1d Mon Sep 17 00:00:00 2001 From: Christian Pietsch Date: Thu, 5 Nov 2020 19:23:08 +0100 Subject: [PATCH 13/14] Set reasonable value for $PWD /home/cryptpad/cryptpad/cryptpad seems one cryptpad too many, and it does not match the sample value of WorkingDirectory above --- docs/cryptpad.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cryptpad.service b/docs/cryptpad.service index eee8b2af5..43d8652f6 100644 --- a/docs/cryptpad.service +++ b/docs/cryptpad.service @@ -17,7 +17,7 @@ SyslogIdentifier=cryptpad User=cryptpad Group=cryptpad # modify to match your working directory -Environment='PWD="/home/cryptpad/cryptpad/cryptpad"' +Environment='PWD="/home/cryptpad/cryptpad"' # systemd sets the open file limit to 4000 unless you override it # cryptpad stores its data with the filesystem, so you should increase this to match the value of `ulimit -n` From 7fe1ec14149b153e1d5a6b68f9ad21c4e84f6e62 Mon Sep 17 00:00:00 2001 From: Weblate Date: Thu, 5 Nov 2020 19:52:00 +0100 Subject: [PATCH 14/14] Translated using Weblate (Finnish) Currently translated at 100.0% (1372 of 1372 strings) Translation: CryptPad/App Translate-URL: http://weblate.cryptpad.fr/projects/cryptpad/app/fi/ --- www/common/translations/messages.fi.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/www/common/translations/messages.fi.json b/www/common/translations/messages.fi.json index fe4ee1f64..ac5ace154 100644 --- a/www/common/translations/messages.fi.json +++ b/www/common/translations/messages.fi.json @@ -1459,5 +1459,14 @@ "history_cantRestore": "Palauttaminen epäonnistui. Yhteytesi on katkennut.", "history_close": "Sulje", "history_restore": "Palauta", - "share_bar": "Luo linkki" + "share_bar": "Luo linkki", + "error_unhelpfulScriptError": "Skriptivirhe: Lisätietoja selaimen kehittäjäkonsolissa", + "tag_edit": "Muokkaa", + "tag_add": "Lisää", + "loading_state_5": "Uudelleenrakenna asiakirja", + "loading_state_4": "Lataa Teams", + "loading_state_3": "Lataa jaetut kansiot", + "loading_state_2": "Päivitä sisältö", + "loading_state_1": "Lataa Drive", + "loading_state_0": "Rakenna käyttöliittymä" }