Skip to content

feat(editor): color code blocks with the page's Shiki and pick their language - #424

Merged
vite-hub[bot] merged 3 commits into
mainfrom
feat/editor-code-highlight
Nov 13, 2026
Merged

vite-hub[bot] merged 3 commits into
mainfrom
feat/editor-code-highlight

Conversation

@onmax

@onmax onmax commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

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:

  • CodeHighlight from comark-ui/editor takes the object the preset takes as shiki, { 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-dark rules the typeset styles use, so code follows dark mode.
  • CodeLanguageSelect from comark-ui/editor/vue puts 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 a language attribute edit that a room syncs. It takes languages (name to label) and an optional language(info) resolver for aliases. A #select slot swaps in the host's own select, which is what Drop needs to keep Nuxt UI's USelectMenu.

It doesn't depend on #423. createLazyHighlighter() from that PR returns the shiki object CodeHighlight takes, and its language fits the select's language prop, 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.ts mounts 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 on main for 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, and pnpm run lint:docs. I didn't run the e2e suite. I haven't tried the select's keyboard or screen reader behavior beyond its aria-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.

…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.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-13T17:56:37.260402Z
We couldn’t complete this review. Comment @codex review to try again.
abd74b8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vite-hub

vite-hub Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —

Latest result

Pull request merged.

Final answers

Session

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CodeLanguageSelect overlay, 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol(xhigh) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Pullfrog  | View workflow run | Using gpt-6.1-sol(xhigh) | 𝕏

@vite-hub

vite-hub Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

The remaining check / check failure is inherited from exact base f69708dcdeff39dacc48c5569cc31205f622b0e1: vite-doctor . --no-cache --max-warnings 0 --format text in packages/git-graph exits 1 on both base and PR with the same five warnings (TS0012 at src/read.ts:363; TS0008 at src/draw.ts:201 and src/index.ts:128,138,140). This PR does not change those files. Please repair these warnings on main and comment here after the fix lands. All five editor-code tests and lint pass locally; the three previous review findings are fixed and resolved.

@pkg-pr-new

pkg-pr-new Bot commented Nov 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

comark-annotate

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-annotate@424

comark-badge

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-badge@424

comark-cards

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-cards@424

comark-carousel

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-carousel@424

comark-cast

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-cast@424

comark-charts

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-charts@424

comark-chat

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-chat@424

comark-chips

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-chips@424

comark-cjk

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-cjk@424

comark-code

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-code@424

comark-code-notes

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-code-notes@424

comark-colors

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-colors@424

comark-comments

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-comments@424

comark-critic

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-critic@424

comark-deflist

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-deflist@424

comark-details

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-details@424

comark-diagrams

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-diagrams@424

comark-diff

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-diff@424

comark-embed

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-embed@424

comark-fields

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-fields@424

comark-figure

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-figure@424

comark-file-tree

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-file-tree@424

comark-footnotes

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-footnotes@424

comark-git-graph

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-git-graph@424

comark-github

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-github@424

comark-icon

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-icon@424

comark-include

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-include@424

comark-keys

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-keys@424

comark-links

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-links@424

comark-linter

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-linter@424

comark-magic-move

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-magic-move@424

comark-mark

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-mark@424

markdown-it-to-comark

pnpm add https://pkg.pr.new/onmax/comark-ui/markdown-it-to-comark@424

marked-to-comark

pnpm add https://pkg.pr.new/onmax/comark-ui/marked-to-comark@424

comark-mathml

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-mathml@424

comark-media

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-media@424

comark-metrics

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-metrics@424

migrate-to-comark

pnpm add https://pkg.pr.new/onmax/comark-ui/migrate-to-comark@424

comark-outline

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-outline@424

comark-properties

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-properties@424

comark-qr

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-qr@424

comark-quiz

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-quiz@424

comark-reading-time

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-reading-time@424

remark-to-comark

pnpm add https://pkg.pr.new/onmax/comark-ui/remark-to-comark@424

comark-sources

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-sources@424

comark-steps

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-steps@424

comark-table

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-table@424

comark-tabs

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-tabs@424

comark-tests

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-tests@424

comark-time

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-time@424

comark-ui

pnpm add https://pkg.pr.new/onmax/comark-ui@424

comark-xref

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-xref@424

comark-zoom

pnpm add https://pkg.pr.new/onmax/comark-ui/comark-zoom@424

commit: 8c8e10e

@vite-hub
vite-hub Bot merged commit 8429945 into main Nov 13, 2026
7 checks passed
@vite-hub
vite-hub Bot deleted the feat/editor-code-highlight branch November 13, 2026 20:51
@github-actions github-actions Bot mentioned this pull request Nov 13, 2026
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