diff --git a/core/lib/utils/html/html_utils.dart b/core/lib/utils/html/html_utils.dart index 71207d99f..c2fda6341 100644 --- a/core/lib/utils/html/html_utils.dart +++ b/core/lib/utils/html/html_utils.dart @@ -7,6 +7,15 @@ import 'package:flutter/material.dart'; import 'package:universal_html/html.dart' as html; class HtmlUtils { + static const lineHeight100Percent = ( + script: ''' + document.querySelectorAll("*") + .forEach((element) => { + if (element.style.lineHeight !== "normal") + element.style.lineHeight = "100%"; + });''', + name: 'lineHeight100Percent'); + static String customCssStyleHtmlEditor({TextDirection direction = TextDirection.ltr}) { if (PlatformInfo.isWeb) { return ''' diff --git a/lib/features/composer/presentation/widgets/web/web_editor_widget.dart b/lib/features/composer/presentation/widgets/web/web_editor_widget.dart index 462dfbae8..a1a3543cf 100644 --- a/lib/features/composer/presentation/widgets/web/web_editor_widget.dart +++ b/lib/features/composer/presentation/widgets/web/web_editor_widget.dart @@ -1,4 +1,5 @@ +import 'package:collection/collection.dart'; import 'package:core/utils/app_logger.dart'; import 'package:core/utils/html/html_utils.dart'; import 'package:flutter/material.dart'; @@ -113,6 +114,12 @@ class _WebEditorState extends State { initialText: widget.content, customBodyCssStyle: HtmlUtils.customCssStyleHtmlEditor(direction: widget.direction), spellCheck: true, + webInitialScripts: UnmodifiableListView([ + WebScript( + name: HtmlUtils.lineHeight100Percent.name, + script: HtmlUtils.lineHeight100Percent.script, + ) + ]) ), htmlToolbarOptions: const HtmlToolbarOptions( toolbarType: ToolbarType.hide, @@ -135,6 +142,9 @@ class _WebEditorState extends State { onImageUpload: widget.onImageUploadSuccessAction, onImageUploadError: widget.onImageUploadFailureAction, onTextFontSizeChanged: widget.onEditorTextSizeChanged, + onPaste: () => _editorController.evaluateJavascriptWeb( + HtmlUtils.lineHeight100Percent.name + ), ), ); }