Files
nanobot/webui/src/components/CodeTokens.tsx
T
chengyongru 3a37269f3f refactor(webui): unify code and diff highlighting (#6412)
* refactor(webui): unify code and diff highlighting

Replace Prism with shared Highlights tokens and Pierre read-only diffs, retaining rare grammars through lazy Shiki and preserving source, copy, preview and diff controls.

Restore single-session Composer ownership inside the conversation column while retaining the shared multi-pane footer. Keep the measured large-diff scroll regression explicit during review.

* fix(webui): contain highlighting errors and retain diff selections

Refs NAN-343

* test(webui): align pane fixtures after main rebase

* chore(webui): update highlighting dependencies

Keep grammar fallback coverage on a language that still requires Shiki, and align reading-size assertions with main.
2026-11-06 16:41:12 +08:00

15 lines
678 B
TypeScript

import { Fragment } from "react";
import type { CodeLine } from "@/lib/code-tokens";
export function CodeTokens({ lines }: { lines: CodeLine[] }) {
return <>{lines.map((line, lineIndex) => <Fragment key={lineIndex}>
{line.tokens.map((token, index) => token.color || token.fontStyle ? <span key={index} data-code-token="" style={{
color: token.color,
fontStyle: token.fontStyle && token.fontStyle & 1 ? "italic" : undefined,
fontWeight: token.fontStyle && token.fontStyle & 2 ? 700 : undefined,
textDecoration: token.fontStyle && token.fontStyle & 4 ? "underline" : undefined,
}}>{token.content}</span> : token.content)}
</Fragment>)}</>;
}