From 78957817e2b548137fa614dbf21df755338346ad Mon Sep 17 00:00:00 2001 From: Ahmed Mazen Date: Sat, 1 Jul 2023 08:20:29 +0800 Subject: [PATCH 1/3] add " (copy)" to copied OpenOffice files Normally, copied CryptPad files have a " (copy)" suffixed to them but OnlyOffice doesn't because it has different internal architechture. Copied OnlyOffice files can be identified by two attributes: a non-empty title and template data. Since OnlyOffice files cannot be just copy and pasted, I resorted to modifying their metadata through metadataMgr in `./common/onlyoffice/inner.js` Essentially, this commit check if a file is a copied file. If it is, it updates the title. It doesn't actually copy the file but merely modifies the title after it has been copied. --- www/common/onlyoffice/inner.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 96842f99c..b7326b244 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -241,6 +241,11 @@ define([ type = APP.downloadType; title = "download"; } + if(title === "" && APP.startWithTemplate) { + var copyTitle = Messages._getKey('copy_title', [APP.startWithTemplate.content.metadata.title]); + common.getMetadataMgr().updateTitle(copyTitle); + title = copyTitle + } var file = {}; switch(type) { case 'doc': From ce577e1a07c96f705549f5ada2b5ba77f96f6208 Mon Sep 17 00:00:00 2001 From: Ahmed Mazen Date: Mon, 10 Jul 2023 17:47:20 +0800 Subject: [PATCH 2/3] make `npm run lint` happy --- www/common/onlyoffice/inner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index b7326b244..46a33b7d9 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -244,7 +244,7 @@ define([ if(title === "" && APP.startWithTemplate) { var copyTitle = Messages._getKey('copy_title', [APP.startWithTemplate.content.metadata.title]); common.getMetadataMgr().updateTitle(copyTitle); - title = copyTitle + title = copyTitle; } var file = {}; switch(type) { From 4b3cd9484c23ee426928bae1e670bca8a9010fb3 Mon Sep 17 00:00:00 2001 From: Ahmed Mazen Date: Mon, 10 Jul 2023 18:01:45 +0800 Subject: [PATCH 3/3] add "(copy)" to implicitily titled documents Normally, documents that are created get a title similar to this: "Sheet - Mon, July 10, 2023". This commit adds " (copy)" to those documents when copied. --- www/common/onlyoffice/inner.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 46a33b7d9..64716c7e1 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -242,7 +242,8 @@ define([ title = "download"; } if(title === "" && APP.startWithTemplate) { - var copyTitle = Messages._getKey('copy_title', [APP.startWithTemplate.content.metadata.title]); + var metadata = APP.startWithTemplate.content.metadata; + var copyTitle = Messages._getKey('copy_title', [metadata.title || metadata.defaultTitle]); common.getMetadataMgr().updateTitle(copyTitle); title = copyTitle; }