fix(web): copy code block selections without markdown #9175
Closedflamboh(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/9175/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
flamboh(GitHub profile, opens in a new tab) changed the title
- apps/web/src/markdown-clipboard.ts line 340OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -311,0 +320,21 @@320+ for (321+ let child = last ? node.lastChild : node.firstChild;322+ child !== null;323+ child = last ? child.previousSibling : child.nextSibling324+ ) {325+ const boundary = selectedTextBoundary(range, child, last);326+ if (boundary !== null) return boundary;327+ }328+ return null;329+}330+331+/**332+ * Browser selections can end at an empty wrapper boundary outside `<pre>`,333+ * even when every selected character belongs to one code block.334+ */335+function isSelectionInsideSingleCodeBlock(range: Range): boolean {336+ const first = selectedTextBoundary(range, range.commonAncestorContainer, false);337+ const last = selectedTextBoundary(range, range.commonAncestorContainer, true);338+ if (first === null || last === null) return false;339+ const firstCodeBlock = first.parentElement?.closest("pre");340+ return Boolean(firstCodeBlock) && firstCodeBlock === last.parentElement?.closest("pre");
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
flamboh(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed