diff --git a/.changes/unreleased/Fixed-20251211-135111.yaml b/.changes/unreleased/Fixed-20251211-135111.yaml new file mode 100644 index 000000000..0a179d649 --- /dev/null +++ b/.changes/unreleased/Fixed-20251211-135111.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Tentatively fix usage of CTRL+C in collabora editor with chrome / edge browser +time: 2025-12-11T13:51:11.425545012+01:00 +custom: + Issue: "483" + SchemaChange: No schema change diff --git a/config/bundles.php b/config/bundles.php index 989338f3e..72b5e22f5 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -37,5 +37,4 @@ return [ Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], Symfony\UX\Translator\UxTranslatorBundle::class => ['all' => true], loophp\PsrHttpMessageBridgeBundle\PsrHttpMessageBridgeBundle::class => ['all' => true], - Chill\ZimbraBundle\ChillZimbraBundle::class => ['all' => true], ]; diff --git a/config/services.yaml b/config/services.yaml index 11c095d99..037b57f6d 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -11,3 +11,6 @@ services: autowire: true # Automatically injects dependencies in your services. autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. +when@dev: + services: + ChampsLibres\WopiLib\Contract\Service\ProofValidatorInterface: '@Chill\WopiBundle\Service\Wopi\NullProofValidator' diff --git a/phpstan.dist.neon b/phpstan.dist.neon index 38c3f7b61..60c36771e 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -3,7 +3,6 @@ parameters: paths: - src/ - utils/ - - packages/ tmpDir: var/cache/phpstan reportUnmatchedIgnoredErrors: false excludePaths: diff --git a/src/Bundle/ChillWopiBundle/chill.webpack.config.js b/src/Bundle/ChillWopiBundle/chill.webpack.config.js index 05c231f68..8580597cc 100644 --- a/src/Bundle/ChillWopiBundle/chill.webpack.config.js +++ b/src/Bundle/ChillWopiBundle/chill.webpack.config.js @@ -2,7 +2,7 @@ module.exports = function (encore, entries) { encore.addEntry( "page_wopi_editor", - __dirname + "/src/Resources/public/page/editor/index.js", + __dirname + "/src/Resources/public/page/editor/index.ts", ); encore.addEntry( "mod_reload_page", diff --git a/src/Bundle/ChillWopiBundle/src/Resources/public/page/editor/index.js b/src/Bundle/ChillWopiBundle/src/Resources/public/page/editor/index.js deleted file mode 100644 index d946977df..000000000 --- a/src/Bundle/ChillWopiBundle/src/Resources/public/page/editor/index.js +++ /dev/null @@ -1,46 +0,0 @@ -require("./index.scss"); - -window.addEventListener("DOMContentLoaded", function () { - let frameholder = document.getElementById("frameholder"); - let office_frame = document.createElement("iframe"); - office_frame.name = "office_frame"; - office_frame.id = "office_frame"; - - // The title should be set for accessibility - office_frame.title = "Office Frame"; - - // This attribute allows true fullscreen mode in slideshow view - // when using PowerPoint's 'view' action. - office_frame.setAttribute("allowfullscreen", "true"); - - // The sandbox attribute is needed to allow automatic redirection to the O365 sign-in page in the business user flow - office_frame.setAttribute( - "sandbox", - "allow-downloads allow-scripts allow-same-origin allow-forms allow-modals allow-popups allow-top-navigation allow-popups-to-escape-sandbox", - ); - frameholder.appendChild(office_frame); - - document.getElementById("office_form").submit(); - - const url = new URL(editor_url); - const editor_domain = url.origin; - - window.addEventListener("message", function (message) { - if (message.origin !== editor_domain) { - return; - } - - let data = JSON.parse(message.data); - - if ("UI_Close" === data.MessageId) { - closeEditor(); - } - }); -}); - -function closeEditor() { - let params = new URLSearchParams(window.location.search), - returnPath = params.get("returnPath"); - - window.location.assign(returnPath); -} diff --git a/src/Bundle/ChillWopiBundle/src/Resources/public/page/editor/index.ts b/src/Bundle/ChillWopiBundle/src/Resources/public/page/editor/index.ts new file mode 100644 index 000000000..01ddad995 --- /dev/null +++ b/src/Bundle/ChillWopiBundle/src/Resources/public/page/editor/index.ts @@ -0,0 +1,68 @@ +import "./index.scss"; + +// Provided by the server-side template +declare const editor_url: string; + +window.addEventListener("DOMContentLoaded", function () { + const frameholder = document.getElementById("frameholder"); + const office_frame = document.createElement("iframe"); + office_frame.name = "office_frame"; + office_frame.id = "office_frame"; + + // The title should be set for accessibility + office_frame.title = "Office Frame"; + + // This attribute allows true fullscreen mode in slideshow view + // when using PowerPoint's 'view' action. + office_frame.setAttribute("allowfullscreen", "true"); + + // The sandbox attribute is needed to allow automatic redirection to the O365 sign-in page in the business user flow + office_frame.setAttribute( + "sandbox", + "allow-downloads allow-scripts allow-same-origin allow-forms allow-modals allow-popups allow-top-navigation allow-popups-to-escape-sandbox", + ); + + office_frame.setAttribute( + "allow", + "clipboard-read *; clipboard-write *; fullscreen *", + ); + if (frameholder) { + frameholder.appendChild(office_frame); + } + + const officeForm = document.getElementById( + "office_form", + ) as HTMLFormElement | null; + officeForm?.submit(); + + const url = new URL(editor_url); + const editor_domain = url.origin; + + window.addEventListener("message", function (message: MessageEvent) { + if (message.origin !== editor_domain) { + return; + } + + let data: { MessageId: "UI_Close" | null; data: string }; + try { + data = + typeof message.data === "string" + ? JSON.parse(message.data) + : message.data; + } catch (e: unknown) { + console.error("error while parsing data from message UI_CLOSE", e); + return; + } + + if ("UI_Close" === data.MessageId) { + closeEditor(); + } + }); +}); + +function closeEditor(): void { + const params = new URLSearchParams(window.location.search); + const returnPath = params.get("returnPath") ?? "/"; + + window.location.assign(returnPath); +} diff --git a/symfony.lock b/symfony.lock index 5724d23b9..532c9ec98 100644 --- a/symfony.lock +++ b/symfony.lock @@ -2,9 +2,6 @@ "champs-libres/wopi-bundle": { "version": "dev-master" }, - "chill-project/chill-zimbra-bundle": { - "version": "dev-472-zimbra-connector" - }, "doctrine/annotations": { "version": "1.14", "recipe": {