Skip to content

feat(prose): configurable heading anchors and copy button#6735

Merged
benjamincanac merged 2 commits into
v4from
feat/prose-heading-anchor
Jul 15, 2026
Merged

feat(prose): configurable heading anchors and copy button#6735
benjamincanac merged 2 commits into
v4from
feat/prose-heading-anchor

Conversation

@benjamincanac

@benjamincanac benjamincanac commented Jul 15, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

N/A

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Two related additions that make prose components configurable through props and <UTheme :props>, plus the shared plumbing to support it.

Prose heading anchor generation was reading useRuntimeConfig().public.mdc.headings.anchorLinks, which ties the components to @nuxtjs/mdc. As we move toward Comark (Vite friendly, no global runtime config) this needs to become framework agnostic. This adds an anchor prop to ProseH1 through ProseH4 with the priority chain explicit prop / <UTheme :props> / app.config defaultVariants, then the mdc config as a deprecated fallback, then a built in default of off. The fallback keeps @nuxt/content and @nuxtjs/mdc users on their current behavior (H2 to H4 enabled) with zero change, while content free Comark and plain Vue apps stay quiet by default. It also fixes a case where a boolean anchorLinks: true was ignored because only the object form was handled.

ProsePre gets a copy prop (boolean | ButtonProps) so the code copy button can be hidden or customized, mirroring the close prop on Alert. It defaults to true, so current behavior is unchanged.

To make these props controllable the way they are meant to be used (prose is rendered by the markdown renderer, not written by hand), a prose namespace is exposed on <UTheme :props> covering the prose components that have overridable props, so anchors, the copy button and similar can be toggled for a subtree. The docs AI chat uses this to keep heading anchors out of assistant messages.

The typography docs are updated for both props.

@github-actions github-actions Bot added the v4 #4488 label Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Heading prose components H1–H4 now accept an anchor prop and support legacy runtime configuration fallbacks. ThemeDefaults adds typed prose component defaults, with corresponding type checks. Typography documentation covers heading anchors and configurable code-block copy buttons. ProsePre supports disabling or customizing its copy button, while the chat theme disables heading anchors. Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title accurately summarizes the main changes: configurable heading anchors and the copy button.
Description check ✅ Passed The description is clearly related to the changeset and covers the heading anchors, copy button, and theme plumbing.
✨ 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 feat/prose-heading-anchor

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.

@pkg-pr-new

pkg-pr-new Bot commented Jul 15, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxt/ui@6735

commit: 69b6d89

@benjamincanac benjamincanac changed the title feat(prose): add anchor prop to headings feat(prose): add anchor and copy props Jul 15, 2026
@benjamincanac benjamincanac changed the title feat(prose): add anchor and copy props feat(prose): add anchor and copy props Jul 15, 2026
@benjamincanac benjamincanac changed the title feat(prose): add anchor and copy props feat(prose): configurable heading anchors and copy button Jul 15, 2026
@benjamincanac benjamincanac merged commit f419731 into v4 Jul 15, 2026
24 checks passed
@benjamincanac benjamincanac deleted the feat/prose-heading-anchor branch July 15, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant