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

This commit is contained in:
Tai Nguyen authored and GitHub committed 2026-08-15 12:06:22 +00:00
1 parent f075a58119
commit c4556ab237
1 file changed
+11
+11
View File
@@ -301,6 +301,17 @@ export function chatMarkdownClipboardPayload(
if (range.collapsed) continue;
const container = document.createElement("div");
container.appendChild(range.cloneContents());
const ancestor = range.commonAncestorContainer;
const ancestorElement =
ancestor.nodeType === Node.ELEMENT_NODE ? (ancestor as Element) : ancestor.parentElement;
if (ancestorElement?.closest("pre")) {
const text = range.toString();
if (text) {
texts.push(text);
htmls.push(sanitizedHtmlFrom(container));
}
continue;
}
const text = serializeRenderedMarkdownFragment(container);
if (!text) continue;
texts.push(text);