diff --git a/src/ui/Controls/WebBrowser/WebBrowserEditBox.cs b/src/ui/Controls/WebBrowser/WebBrowserEditBox.cs index d0bb11a47..d225a8d5f 100644 --- a/src/ui/Controls/WebBrowser/WebBrowserEditBox.cs +++ b/src/ui/Controls/WebBrowser/WebBrowserEditBox.cs @@ -115,20 +115,13 @@ namespace Nikse.SubtitleEdit.Controls.WebBrowser Thread.Sleep(5); Application.DoEvents(); - _rightToLeft = Configuration.Settings.General.RightToLeftMode; _center = Configuration.Settings.General.CenterSubtitleInTextBox; + _rightToLeft = Configuration.Settings.General.RightToLeftMode; - var code = "left"; - if (_rightToLeft) - { - code = "rtl"; - } - else if (_center) - { - code = "center"; - } + var align = _center ? "text-align:center" : string.Empty; + var dir = _rightToLeft ? "rtl" : string.Empty; - Document.InvokeScript("setTextDirection", new object[] { code }); + Document.InvokeScript("setTextDirection", new object[] { align, dir }); } Document.InvokeScript("setText", new object[] { value }); diff --git a/src/ui/Controls/WebBrowser/WebBrowserEditBox.html b/src/ui/Controls/WebBrowser/WebBrowserEditBox.html index 9fb205cb6..a92b28b54 100644 --- a/src/ui/Controls/WebBrowser/WebBrowserEditBox.html +++ b/src/ui/Controls/WebBrowser/WebBrowserEditBox.html @@ -260,19 +260,11 @@ } } - // Call with: rtl / center / left - function setTextDirection(dir) { + // Call with: center / rtl + function setTextDirection(align, dir) { var element = document.getElementById("myContent"); - if (dir === "rtl") { - element.setAttribute("dir", "rtl"); - element.setAttribute("style", ""); - } else if (dir === "center") { - element.setAttribute("style", "text-align:center"); - element.setAttribute("dir", ""); - } else { - element.setAttribute("style", ""); - element.setAttribute("dir", ""); - } + element.setAttribute("style", align); + element.setAttribute("dir", dir); } function getText() {