| ... | ... | @@ -301,6 +301,17 @@ export function chatMarkdownClipboardPayload( |
| 301 | 301 | if (range.collapsed) continue; |
| 302 | 302 | const container = document.createElement("div"); |
| 303 | 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 | 315 | const text = serializeRenderedMarkdownFragment(container); |
| 305 | 316 | if (!text) continue; |
| 306 | 317 | texts.push(text); |