From c2300059a67a505e0483a2004bc294d8c9d7c463 Mon Sep 17 00:00:00 2001
From: roboin <50550561+Robot-Inventor@users.noreply.github.com>
Date: Thu, 25 Sep 2025 12:33:39 +0900
Subject: [PATCH] fix(richtext-lexical): remove unexpected spaces in link html
converter (#13924)
### What?
Fixes a bug that inserted unexpected spaces before and after link text
when converting Lexical links to HTML. The extra spaces came from
indentation in the template literal used to build the anchor markup.
### Why?
The whitespace was largely unnoticed in space-delimited languages like
English but produced visible, incorrect gaps in languages without
inter-word spacing such as Japanese.
### How?
Remove the line breaks and indentations from the link-to-HTML conversion
so the anchor markup is constructed without surrounding spaces.
---
.../converters/lexicalToHtml/async/converters/link.ts | 8 ++------
.../converters/lexicalToHtml/sync/converters/link.ts | 8 ++------
2 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/packages/richtext-lexical/src/features/converters/lexicalToHtml/async/converters/link.ts b/packages/richtext-lexical/src/features/converters/lexicalToHtml/async/converters/link.ts
index 402976203..c2d3851fc 100644
--- a/packages/richtext-lexical/src/features/converters/lexicalToHtml/async/converters/link.ts
+++ b/packages/richtext-lexical/src/features/converters/lexicalToHtml/async/converters/link.ts
@@ -16,9 +16,7 @@ export const LinkHTMLConverterAsync: (args: {
})
).join('')
- return `
- ${children}
- `
+ return `${children}`
},
link: async ({ node, nodesToHTML, populate, providedStyleTag }) => {
const children = (
@@ -39,8 +37,6 @@ export const LinkHTMLConverterAsync: (args: {
}
}
- return `
- ${children}
- `
+ return `${children}`
},
})
diff --git a/packages/richtext-lexical/src/features/converters/lexicalToHtml/sync/converters/link.ts b/packages/richtext-lexical/src/features/converters/lexicalToHtml/sync/converters/link.ts
index b186fd565..cc686fedc 100644
--- a/packages/richtext-lexical/src/features/converters/lexicalToHtml/sync/converters/link.ts
+++ b/packages/richtext-lexical/src/features/converters/lexicalToHtml/sync/converters/link.ts
@@ -9,9 +9,7 @@ export const LinkHTMLConverter: (args: {
nodes: node.children,
}).join('')
- return `
- ${children}
- `
+ return `${children}`
},
link: ({ node, nodesToHTML, providedStyleTag }) => {
const children = nodesToHTML({
@@ -30,8 +28,6 @@ export const LinkHTMLConverter: (args: {
}
}
- return `
- ${children}
- `
+ return `${children}`
},
})