From 22317f0a7eb323245dba68dd6d060fe9c053ea44 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 03:27:13 +0800 Subject: [PATCH] fix --- .../LunaTranslator/rendertext/webview.html | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/LunaTranslator/LunaTranslator/rendertext/webview.html b/LunaTranslator/LunaTranslator/rendertext/webview.html index c34592be..3a06810e 100644 --- a/LunaTranslator/LunaTranslator/rendertext/webview.html +++ b/LunaTranslator/LunaTranslator/rendertext/webview.html @@ -147,7 +147,7 @@ miaobian0: miaobian0_create_internal, miaobian1: miaobian12_common, } - function dispatch_text_style(style, styleargs, text, args) { + function dispatch_text_style_line(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 = ""; @@ -155,7 +155,6 @@ 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" @@ -183,6 +182,23 @@ return wrap } + function dispatch_text_style_inlineblock(style, styleargs, text, args) { + let l = dispatch_text_style_line(style, styleargs, text, args) + let div = document.createElement('div') + div.style.display = 'inline-block' + div.appendChild(l) + return div + } + function dispatch_text_style(style, styleargs, text, args) { + if (!text.includes('\n')) + return dispatch_text_style_line(style, styleargs, text, args) + let lines = text.split('\n') + let wrap = document.createElement('div') + lines.forEach(line => { + wrap.appendChild(dispatch_text_style_line(style, styleargs, text, args)) + }) + return wrap + }