Repository navigation
feat(editor): color code blocks with the page's Shiki and pick their language - #424
Conversation
…language `CodeHighlight` takes the preset's `shiki` option and colors code blocks as decorations, so the document and its Markdown stay plain. `CodeLanguageSelect` from `comark-ui/editor/vue` puts a language select on each code block, with a `#select` slot for a host's own select. The editor playground uses both. Drop carries both today.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Latest result Pull request merged. Final answersSession Pull request merged. Session No repair needed in this PR. All prior findings are fixed and resolved; five focused tests and lint pass. Doctor fails with the same five git-graph warnings on HEAD and exact base f69708d. Posted the reproduced blocker for maintainers. No commit pushed. Session No repair needed in this PR. All prior findings are fixed and resolved; five focused tests and lint pass. Doctor fails with the same five git-graph warnings on HEAD and exact base f69708d. Posted the reproduced blocker for maintainers. No commit pushed. Session No repair needed in this PR. All prior findings are fixed and resolved; five focused tests and lint pass. Doctor fails with the same five git-graph warnings on HEAD and exact base f69708d. Posted the reproduced blocker for maintainers. No commit pushed. Session No repair needed in this PR. All prior findings are fixed and resolved; five focused tests and lint pass. Doctor fails with the same five git-graph warnings on HEAD and exact base f69708d. Posted the reproduced blocker for maintainers. No commit pushed. Session No repair needed in this PR. All prior findings are fixed and resolved; five focused tests and lint pass. Doctor fails with the same five git-graph warnings on HEAD and exact base f69708d. Posted the reproduced blocker for maintainers. No commit pushed. Session No repair needed in this PR. All prior findings are fixed and resolved; five focused tests and lint pass. Doctor fails with the same five git-graph warnings on HEAD and exact base f69708d. Posted the reproduced blocker for maintainers. No commit pushed. Session No repair needed in this PR. All prior findings are fixed and resolved; five focused tests and lint pass. Doctor fails with the same five git-graph warnings on HEAD and exact base f69708d. Posted the reproduced blocker for maintainers. No commit pushed. Session No repair needed in this PR. All prior findings are fixed and resolved; five focused tests and lint pass. Doctor fails with the same five git-graph warnings on HEAD and exact base f69708d. Posted the reproduced blocker for maintainers. No commit pushed. Session No repair needed in this PR. All prior findings are fixed and resolved; five focused tests and lint pass. Doctor fails with the same five git-graph warnings on HEAD and exact base f69708d. Posted the reproduced blocker for maintainers. No commit pushed. Session No repair needed in this PR. All prior findings are fixed and resolved; five focused tests and lint pass. Doctor fails with the same five git-graph warnings on HEAD and exact base f69708d. Posted the reproduced blocker for maintainers. No commit pushed. |
There was a problem hiding this comment.
Caution
Language changes can bypass read-only mode and discard protected source content. The overlay also becomes stale after external reloads and can target another block during collaborative edits.
Reviewed changes — reviewed the editor highlighting extension, language-selection overlay, and their playground, documentation, and test integration.
- Shiki decorations: Adds
CodeHighlight, sharing the page's highlighter and themes while leaving document JSON and Markdown plain. - Language controls: Adds the Vue
CodeLanguageSelectoverlay, alias resolution, and a custom-select slot that writes language changes through transactions. - Integration and coverage: Enables both features in the editor playground, documents the public exports, and adds real-Shiki Vue integration tests.
Validation: 215 focused editor tests, TypeScript checks, package Doctor, and docs lint passed; the reported failures were reproduced in the browser.
gpt-6.1-sol(xhigh) | 𝕏
There was a problem hiding this comment.
✅ No new issues found; no P0 or P1 findings remain.
Reviewed changes — reviewed 6809892, the language-control fixes since the previous Pullfrog review.
- Mapped live targets: Replaced DOM-based identity with transaction-mapped targets, keeping retained choices attached to their original blocks and invalidating deleted targets.
- Refreshed silent updates: Moved overlay refreshes into the ProseMirror view lifecycle so external document loads and editability transitions update the controls.
- Enforced read-only protection: Checked current editability before applying native or retained custom-slot choices.
- Added regression coverage: Tested silent reloads, protected-source preservation, and retained choices across insertion and deletion.
Validation: all 217 focused editor tests passed, along with the workspace build, TypeScript checks, and package Doctor.
gpt-6.1-sol(xhigh) | 𝕏
|
The remaining |
comark-annotate
comark-badge
comark-cards
comark-carousel
comark-cast
comark-charts
comark-chat
comark-chips
comark-cjk
comark-code
comark-code-notes
comark-colors
comark-comments
comark-critic
comark-deflist
comark-details
comark-diagrams
comark-diff
comark-embed
comark-fields
comark-figure
comark-file-tree
comark-footnotes
comark-git-graph
comark-github
comark-icon
comark-include
comark-keys
comark-links
comark-linter
comark-magic-move
comark-mark
markdown-it-to-comark
marked-to-comark
comark-mathml
comark-media
comark-metrics
migrate-to-comark
comark-outline
comark-properties
comark-qr
comark-quiz
comark-reading-time
remark-to-comark
comark-sources
comark-steps
comark-table
comark-tabs
comark-tests
comark-time
comark-ui
comark-xref
comark-zoom
commit: |

Code blocks in comark-ui's editor show as plain text, and the only way to change a block's language is to edit the Markdown. Drop's live editor fills that gap with two pieces of its own: a Tiptap plugin that colors code with Shiki (
app/utils/code-highlight.ts, about 80 lines) and a language select over each block (ViewerCodeLanguages.vue, about 110 lines). Neither has anything Drop-specific in it.This adds both to comark-ui:
CodeHighlightfromcomark-ui/editortakes the object the preset takes asshiki,{ highlighter, themes }, so the editor colors code like the rendered page:CodeHighlight.configure(shiki). The colors are decorations, so the document, its Markdown and a collaborative room stay plain, and a server's codec doesn't need the extension. A language loads the first time a block uses it. One the highlighter doesn't have, or whose grammar fails, isn't asked for again while the editor lives, so typing never retries it. It adds the same--shiki-darkrules the typeset styles use, so code follows dark mode.CodeLanguageSelectfromcomark-ui/editor/vueputs a native select in the top right corner of each code block. It sits over the editor, as in Drop, so ProseMirror's DOM stays as the schema draws it, and a choice is alanguageattribute edit that a room syncs. It takeslanguages(name to label) and an optionallanguage(info)resolver for aliases. A#selectslot swaps in the host's own select, which is what Drop needs to keep Nuxt UI'sUSelectMenu.It doesn't depend on #423.
createLazyHighlighter()from that PR returns theshikiobjectCodeHighlighttakes, and itslanguagefits the select'slanguageprop, but any{ highlighter, themes }works.The editor playground uses both, and the Editor guide has a Code blocks section. Before/after of the playground: Before/after on Drop
packages/ui/test/editor-code.test.tsmounts the Vue editor in happy-dom with a real Shiki. It checks the colors, a plain document and Markdown, recoloring after an edit with each language asked for once, the selects' values and the Markdown they write, and the slot. These are new exports, so there's nothing onmainfor the tests to fail against. I also ran the other editor tests, the workspace test,pnpm typecheck, the comark-ui build with publint, its Vite Doctor, andpnpm run lint:docs. I didn't run the e2e suite. I haven't tried the select's keyboard or screen reader behavior beyond itsaria-label, and I haven't measured how a document with hundreds of code blocks types, since every edit recolors every block, as Drop's plugin does.