diff --git a/core/lib/utils/html/html_utils.dart b/core/lib/utils/html/html_utils.dart index 6a690836c..68b553af2 100644 --- a/core/lib/utils/html/html_utils.dart +++ b/core/lib/utils/html/html_utils.dart @@ -17,14 +17,14 @@ class HtmlUtils { static final random = Random(); static final htmlUnescape = HtmlUnescape(); - static const lineHeight100Percent = ( + static const removeLineHeight1px = ( script: ''' - document.querySelectorAll("*") - .forEach((element) => { - if (element.style.lineHeight !== "normal") - element.style.lineHeight = "100%"; - });''', - name: 'lineHeight100Percent'); + document.querySelectorAll('[style*="line-height"]').forEach(el => { + if (el.style.lineHeight === "1px") { + el.style.removeProperty("line-height"); + } + });''', + name: 'removeLineHeight1px'); static const registerDropListener = ( script: ''' 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 ea381728d..43ecf7f72 100644 --- a/lib/features/composer/presentation/widgets/web/web_editor_widget.dart +++ b/lib/features/composer/presentation/widgets/web/web_editor_widget.dart @@ -89,7 +89,7 @@ class _WebEditorState extends State { _dropListener = (event) { if (event is MessageEvent) { if (jsonDecode(event.data)['name'] == HtmlUtils.registerDropListener.name) { - _editorController.evaluateJavascriptWeb(HtmlUtils.lineHeight100Percent.name); + _editorController.evaluateJavascriptWeb(HtmlUtils.removeLineHeight1px.name); } } }; @@ -143,8 +143,8 @@ class _WebEditorState extends State { normalizeHtmlTextWhenPasting: true, webInitialScripts: UnmodifiableListView([ WebScript( - name: HtmlUtils.lineHeight100Percent.name, - script: HtmlUtils.lineHeight100Percent.script, + name: HtmlUtils.removeLineHeight1px.name, + script: HtmlUtils.removeLineHeight1px.script, ), WebScript( name: HtmlUtils.registerDropListener.name, @@ -181,7 +181,7 @@ class _WebEditorState extends State { onChangeCodeview: widget.onChangeContent, onTextFontSizeChanged: widget.onEditorTextSizeChanged, onPaste: () => _editorController.evaluateJavascriptWeb( - HtmlUtils.lineHeight100Percent.name + HtmlUtils.removeLineHeight1px.name ), onDragEnter: widget.onDragEnter, onDragOver: widget.onDragOver,