From 299b61bd56fdab7df900b269e5874a5931ad49fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sun, 23 Jun 2024 02:18:01 +0800 Subject: [PATCH] space --- .../LunaTranslator/rendertext/webview.html | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/LunaTranslator/LunaTranslator/rendertext/webview.html b/LunaTranslator/LunaTranslator/rendertext/webview.html index 4cf40dec..6518c6c7 100644 --- a/LunaTranslator/LunaTranslator/rendertext/webview.html +++ b/LunaTranslator/LunaTranslator/rendertext/webview.html @@ -50,6 +50,7 @@ } function normal_create_internal(styleargs, text, args) { let ele = document.createElement('div') + ele.innerText = text ele.style.color = args.color commoninit_font_align_height(ele, args) @@ -145,6 +146,41 @@ miaobian0: miaobian0_create_internal, miaobian1: miaobian12_common, } + function dispatch_text_style(style, styleargs, text, args) { + let ele = regist_style_imp[style](styleargs, text, args); + let begin = 0; let begin1 = ""; + let end = text.length - 1; let end1 = ""; + for (; (begin < text.length) && (text[begin] == ' '); begin++) { begin1 += " " } + for (; (end >= 0) && (text[end] == ' '); end--) { end1 += " "; } + if ((end == (text.length - 1)) && (begin == 0)) + return ele + + let wrap = document.createElement('div') + if (args.atcenter) { + wrap.style.textAlign = "center" + } + if (begin != 0) { + let __1 = document.createElement('div') + __1.innerHTML = begin1 + __1.style.display = 'inline-block' + + commoninit_font_align_height(__1, args) + wrap.appendChild(__1) + } + let _ww = document.createElement('div') + _ww.appendChild(ele) + _ww.style.display = 'inline-block' + wrap.appendChild(_ww) + if ((end != -1) && (end != (text.length - 1))) { + //全是空格 + let __1 = document.createElement('div') + __1.innerHTML = end1 + __1.style.display = 'inline-block' + commoninit_font_align_height(__1, args) + wrap.appendChild(__1) + } + return wrap + }