feat(theme-classic): Add CodeBlockToken component for swizzling#11022
Closed
Danielku15 wants to merge 11 commits intofacebook:mainfrom
Closed
feat(theme-classic): Add CodeBlockToken component for swizzling#11022Danielku15 wants to merge 11 commits intofacebook:mainfrom
Danielku15 wants to merge 11 commits intofacebook:mainfrom
Conversation
This was referenced Mar 23, 2025
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
This was referenced Mar 23, 2025
slorber
reviewed
Mar 28, 2025
Collaborator
slorber
left a comment
There was a problem hiding this comment.
Can't this change be merged independently from other PRs if you removed all the unrelated things?
|
|
||
| export default function CodeBlockToken(props: Props): ReactNode { | ||
| // We omit the "line" information in the default rendering, | ||
| // but its meant for devs who devs who Swizzle this component. |
8f90795 to
2acb5bd
Compare
Collaborator
|
Added, see #11017 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-flight checklist
Motivation
This PR is part of a series related to #11008 and it superceeds #11011 in the goal to splitup the work into more isolated refactoring/feature parts.
Note that this PR also includes the changes of previous steps and therefore the overall diff can be misleading. The best approach will be to review and merge every step individually and then rebase accordingly.
Intermediately the specific changes can be checked here: Danielku15/docusaurus@feature/codeblock-meta-3...Danielku15:docusaurus:feature/codeblock-meta-4
Step 1 (#11017): Splitup current parseLines logic (separation of concerns)
Step 2 (#11019): Parse metastring into metaOptions and use it across components.
Step 3 (#11021): Add parsing of any options specified in the metastring.
Step 4 (this PR): Add CodeBlockToken component to customize DOM of highlighted tokens.
Step 5: Pass
metaOptionsto whole codeblock component tree.The motivation of this part is to allow users to customize the rendering of the individual tokens rendered on the syntax highlighting. The component receives the props of the parent
Linewhich already allows some degree of customization based on the data available.This change will unleash its full potential with Step 5 when we pass down
metaOptionsto all components.Test Plan
Automatic testing relies on existing integration tests.
Manual testing by checking
/docs/markdown-features/code-blocksshowed no impact of the change.If more testing is expected I'd need some guidance on how to typically such tests are written for Swizzled components.
Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Code Blocks: https://deploy-preview-_____--docusaurus-2.netlify.app/docs/markdown-features/code-blocks/
Related issues/PRs