authorgravatar for 87302343+JoeJoeflyn@users.noreply.github.comTai Nguyen <87302343+JoeJoeflyn@users.noreply.github.com> 2026-08-15 19:06:22+07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-08-15 12:06:22+00:00
logc4556ab237515cea8ec6f482351c58da730ad495
tree194b0466e9b602e92deef0bb17440a3cab01a187
parentf075a58119f392137d699cefe5290b2aa6e55935
signature Signed by PGP key B5690EEEBB952194

fix(web): stop wrapping partial code block selections in markdown fences (#5069)


1 files changed, 11 insertions(+), 0 deletions(-)

apps/web/src/markdown-clipboard.ts+11
...@@ -301,6 +301,17 @@ export function chatMarkdownClipboardPayload(...@@ -301,6 +301,17 @@ export function chatMarkdownClipboardPayload(
301 if (range.collapsed) continue;301 if (range.collapsed) continue;
302 const container = document.createElement("div");302 const container = document.createElement("div");
303 container.appendChild(range.cloneContents());303 container.appendChild(range.cloneContents());
304 const ancestor = range.commonAncestorContainer;
305 const ancestorElement =
306 ancestor.nodeType === Node.ELEMENT_NODE ? (ancestor as Element) : ancestor.parentElement;
307 if (ancestorElement?.closest("pre")) {
308 const text = range.toString();
309 if (text) {
310 texts.push(text);
311 htmls.push(sanitizedHtmlFrom(container));
312 }
313 continue;
314 }
304 const text = serializeRenderedMarkdownFragment(container);315 const text = serializeRenderedMarkdownFragment(container);
305 if (!text) continue;316 if (!text) continue;
306 texts.push(text);317 texts.push(text);