Skip to content

fix: prevent list marker in copied code blocks#340

Merged
youyongsong merged 6 commits into
mainfrom
codex/fix-codeblock-copy-list-prefix
Jun 22, 2026
Merged

fix: prevent list marker in copied code blocks#340
youyongsong merged 6 commits into
mainfrom
codex/fix-codeblock-copy-list-prefix

Conversation

@youyongsong

@youyongsong youyongsong commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • intercept Rspress code-block copy button clicks in the Doom theme wrapper
  • copy from the nearest code-block source only, removing line numbers and copy-ignore elements
  • preserve copied-state feedback after using the custom copy path

Verification

  • yarn eslint packages/doom/src/theme/CodeBlock.tsx
  • yarn prettier --check packages/doom/src/theme/CodeBlock.tsx
  • yarn lint:tsc
  • yarn typecov
  • yarn build
  • local AML docs preview: target YAML copy no longer starts with 7.

Note: full yarn test was not completed locally because the test server hit sandbox listener permissions: listen EPERM ::1:3000.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed code block copying inside ordered lists to no longer include list markers.

@changeset-bot

changeset-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0bceb73

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@alauda/doom Patch
@alauda/doom-export Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

yarn add https://pkg.pr.new/@alauda/doom@340.tgz
yarn add https://pkg.pr.new/@alauda/doom-export@340.tgz

commit: 0bceb73

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.93%. Comparing base (8341ec2) to head (0bceb73).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #340   +/-   ##
=======================================
  Coverage   52.93%   52.93%           
=======================================
  Files          60       60           
  Lines        1483     1483           
  Branches      461      461           
=======================================
  Hits          785      785           
  Misses        539      539           
  Partials      159      159           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@youyongsong youyongsong self-assigned this Jun 17, 2026
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@youyongsong, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 21 minutes and 17 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fd51e8b7-8a79-4b9e-a7c3-f76adfc2503f

📥 Commits

Reviewing files that changed from the base of the PR and between ed1ac6c and 0bceb73.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • .changeset/update-playwright-node-24.md
  • .env.yarn
  • .gitignore
  • packages/export/package.json
  • packages/export/src/html-export-pdf/core/printer.ts

Walkthrough

CodeBlock gains click-to-copy behavior via an onClickCapture handler that locates .rp-code-copy-button clicks, extracts clipboard text using new DOM utilities (getCopySourceElement, removeIgnoredElements, getCodeBlockCopyText), and toggles a "copied" CSS class for 2 seconds. A changeset and an AGENTS.md convention note accompany the fix.

Changes

CodeBlock Click-to-Copy with List Marker Fix

Layer / File(s) Summary
DOM utilities, copy state, and CodeBlock component update
packages/doom/src/theme/CodeBlock.tsx
Adds selector constants, a WeakMap-backed timeout store, getCopySourceElement, removeIgnoredElements, and the exported getCodeBlockCopyText for deriving clipboard text (stripping .rp-copy-ignore and .linenumber elements, preferring .line text). Adds markCopied for per-button "copied" class toggling with a 2-second timeout. Updates CodeBlock to use onClickCapture, delegating to copyCodeBlock with the nearest .rp-codeblock container.
Changeset and AGENTS convention note
.changeset/fix-codeblock-copy-list-prefix.md, AGENTS.md
Adds a patch changeset for @alauda/doom describing the ordered-list copy-marker fix, and adds a convention bullet to AGENTS.md requiring changesets for user-facing fixes that must propagate via the published package.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hop hop, the list marks are gone,
No "1." or "2." when you copy along,
A WeakMap holds timeouts with care,
"Copied!" flashes bright in the air,
The rabbit clips code, clean and right! ✂️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main fix: preventing list markers from appearing in copied code block content, which aligns with the primary changeset objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-codeblock-copy-list-prefix

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@youyongsong youyongsong marked this pull request as ready for review June 17, 2026 09:05
@youyongsong youyongsong merged commit ad8af04 into main Jun 22, 2026
17 checks passed
@youyongsong youyongsong deleted the codex/fix-codeblock-copy-list-prefix branch June 22, 2026 09:47
github-actions Bot pushed a commit that referenced this pull request Jun 22, 2026
* fix code block copy in lists

* chore: add changeset for code block copy fix

* ci: install playwright browsers with node 22

* ci: use default playwright download host

* ci: update playwright for node 24

* fix: align init script type with playwright
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant