feat: support custom code block renderers - #546
Conversation
|
@mariomile is attempting to deploy a commit to the ocavue's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (12)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe PR adds an ChangesCode block insertion and rendering
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to No concrete correctness, integration, or availability risk remains; the PR is ready for normal merge checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 7.69% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 11 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
packages/core/src/extensions/commands.test.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. packages/core/src/extensions/commands.tsESLint skipped: the matched ESLint configuration already failed (missing-dependency). packages/core/src/index.tsESLint skipped: the matched ESLint configuration already failed (missing-dependency).
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. Comment |
commit: |
| /** | ||
| * Where the caret lands after a code-block fragment. `after-block` keeps | ||
| * any paragraph suffix outside the inserted block and creates an ordinary | ||
| * following paragraph when needed. | ||
| */ | ||
| selection?: 'end' | 'after-block' |
There was a problem hiding this comment.
I feel this is not the correct way to add "an ordinary following paragraph" after a code block. We probably should provide a more general way, like a ProseMirror command.
|
#548 might provide better flexibility if you want to customize the code block React component |
Code-block consumers currently cannot render host-owned widgets in the document while keeping fenced Markdown as the source of truth. This adds an optional
renderCodeBlockcallback that receives the fence language, body, and an undoableupdateCodetransaction.Custom content renders at the code block's document position. The source stays hidden while the caret is elsewhere, reappears for keyboard editing when the caret enters the block, and falls back to the existing source/toolbar/preview whenever the callback returns
null. Host widget lists are isolated from the outer editor's prose list styles while nested Markdown editors keep their own styling.This also adds the opt-in
insertMarkdown(markdown, { selection: 'after-block' })path used by hosts inserting rendered fences from dialogs. It inserts a closed block slice, preserves any paragraph suffix, creates an ordinary following paragraph when needed, and places the caret there in the same undoable transaction.Validation:
pnpm vitest run packages/core/src/extensions/commands.test.ts packages/react/src/components/code-block-view.test.tsx(53 tests)pnpm typecheckpnpm --filter @meowdown/core buildpnpm --filter @meowdown/react buildpnpm lintSummary by CodeRabbit
New Features
Bug Fixes