Fix: Refactor Collabora iframe setup for improved readability and maintainability
This commit is contained in:
@@ -406,10 +406,11 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
|
|||||||
// Build Collabora Online viewer URL with WOPISrc
|
// Build Collabora Online viewer URL with WOPISrc
|
||||||
// The WOPISrc must be URL-encoded and kept encoded
|
// The WOPISrc must be URL-encoded and kept encoded
|
||||||
// We use a double-encoding approach: encodeComponent keeps it encoded through iframe.src
|
// We use a double-encoding approach: encodeComponent keeps it encoded through iframe.src
|
||||||
final baseUrl = 'https://of.b0esche.cloud/loleaflet/dist/loleaflet.html';
|
final baseUrl =
|
||||||
final collaboraUrl = Uri.parse(baseUrl)
|
'https://of.b0esche.cloud/loleaflet/dist/loleaflet.html';
|
||||||
.replace(queryParameters: {'WOPISrc': wopiSession.wopisrc})
|
final collaboraUrl = Uri.parse(
|
||||||
.toString();
|
baseUrl,
|
||||||
|
).replace(queryParameters: {'WOPISrc': wopiSession.wopisrc}).toString();
|
||||||
|
|
||||||
// Use WebView to display Collabora Online
|
// Use WebView to display Collabora Online
|
||||||
return _buildWebView(collaboraUrl);
|
return _buildWebView(collaboraUrl);
|
||||||
@@ -461,9 +462,7 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
|
|||||||
// Create an iframe and submit a form to load the document
|
// Create an iframe and submit a form to load the document
|
||||||
const String viewType = 'collabora-form';
|
const String viewType = 'collabora-form';
|
||||||
|
|
||||||
ui.platformViewRegistry.registerViewFactory(
|
ui.platformViewRegistry.registerViewFactory(viewType, (int viewId) {
|
||||||
viewType,
|
|
||||||
(int viewId) {
|
|
||||||
// Extract the WOPISrc from the URL
|
// Extract the WOPISrc from the URL
|
||||||
final uri = Uri.parse(collaboraUrl);
|
final uri = Uri.parse(collaboraUrl);
|
||||||
final wopisrc = uri.queryParameters['WOPISrc'] ?? '';
|
final wopisrc = uri.queryParameters['WOPISrc'] ?? '';
|
||||||
@@ -517,8 +516,7 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
return HtmlElementView(viewType: viewType);
|
return HtmlElementView(viewType: viewType);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user