From 64690231c2dc19d012e5d287c854381d086625ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6sche?= Date: Mon, 12 Jan 2026 15:44:57 +0100 Subject: [PATCH] Fix: Refactor Collabora iframe creation for improved readability and maintainability --- b0esche_cloud/lib/pages/document_viewer.dart | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/b0esche_cloud/lib/pages/document_viewer.dart b/b0esche_cloud/lib/pages/document_viewer.dart index 6dc0a8a..a4b1afc 100644 --- a/b0esche_cloud/lib/pages/document_viewer.dart +++ b/b0esche_cloud/lib/pages/document_viewer.dart @@ -451,10 +451,11 @@ class _DocumentViewerModalState extends State { Widget _buildCollaboraIframe(String wopisrc) { // For Collabora Online, we need to POST the WOPISrc, not GET it // Create an HTML page with auto-submitting form and set as iframe src - final String viewType = 'collabora-form-${DateTime.now().millisecondsSinceEpoch}'; + final String viewType = + 'collabora-form-${DateTime.now().millisecondsSinceEpoch}'; ui.platformViewRegistry.registerViewFactory(viewType, (int viewId) { - // Create the iframe + // Create the iframe final iframe = html.IFrameElement() ..style.border = 'none' ..style.width = '100%' @@ -467,11 +468,12 @@ class _DocumentViewerModalState extends State { ) ..setAttribute( 'sandbox', - 'allow-scripts allow-popups allow-forms allow-pointer-lock allow-presentation allow-modals allow-downloads allow-popups-to-escape-sandbox', + 'allow-same-origin allow-scripts allow-popups allow-forms', ); // Create an HTML page with an auto-submitting form - final htmlContent = ''' + final htmlContent = + ''' @@ -489,7 +491,8 @@ class _DocumentViewerModalState extends State { '''; // Set iframe src to a data URL with the form - final dataUrl = 'data:text/html;charset=utf-8,${Uri.encodeComponent(htmlContent)}'; + final dataUrl = + 'data:text/html;charset=utf-8,${Uri.encodeComponent(htmlContent)}'; iframe.src = dataUrl; // Create a container