Skip to content

fix: prevent list marker in copied code blocks#340

Open
youyongsong wants to merge 2 commits into
mainfrom
codex/fix-codeblock-copy-list-prefix
Open

fix: prevent list marker in copied code blocks#340
youyongsong wants to merge 2 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: ed1ac6c

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

This PR includes changesets to release 1 package
Name Type
@alauda/doom 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: ed1ac6c

@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 (ed1ac6c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #340   +/-   ##
=======================================
  Coverage   52.93%   52.93%           
=======================================
  Files          60       60           
  Lines        1483     1483           
  Branches      461      460    -1     
=======================================
  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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3de2d5b2-acd2-4363-8eba-4c1a233082e2

📥 Commits

Reviewing files that changed from the base of the PR and between 8341ec2 and ed1ac6c.

📒 Files selected for processing (3)
  • .changeset/fix-codeblock-copy-list-prefix.md
  • AGENTS.md
  • packages/doom/src/theme/CodeBlock.tsx

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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-codeblock-copy-list-prefix

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.

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
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