Problem in word wrapping in the templates (#3136)

Co-authored-by: santino cantale <sopor@ARBA-TSM-WS020.tsm.local>
This commit is contained in:
Cantale08
2026-06-17 08:28:19 -03:00
committed by GitHub
parent 1be75240dd
commit a523e13bfd
2 changed files with 7 additions and 19 deletions
@@ -156,24 +156,8 @@ describe("registerFonts", () => {
const hyphenationCallback = registerHyphenationSpy.mock.calls.at(-1)?.[0];
expect(hyphenationCallback?.("翠翠红红处处")).toEqual(["翠", "", "翠", "", "红", "", "红", "", "处", "", "处", ""]);
expect(hyphenationCallback?.("Reactive")).toEqual([
"R",
"",
"e",
"",
"a",
"",
"c",
"",
"t",
"",
"i",
"",
"v",
"",
"e",
"",
]);
// Latin words must stay intact even in CJK mode — no character-level breaking.
expect(hyphenationCallback?.("Reactive")).toEqual(["Reactive"]);
});
it("returns typography with font weights sorted ascending", async () => {
+5 -1
View File
@@ -163,7 +163,11 @@ export const registerFonts = (typography: Typography, locale: Locale, hasCjkCont
Font.registerHyphenationCallback((word) => {
if (needsCjkTextSupport) {
if (word === " ") return ["\u200C "];
return [...word].flatMap((l) => [l, ""]);
// Only break at every character for words that contain CJK characters.
// Latin/non-CJK words must stay intact even in a CJK-locale resume.
if (cjkLetterRegex.test(word)) {
return [...word].flatMap((l) => [l, ""]);
}
}
return [word];