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.
This commit is contained in:
1 parent
f5c359476b
commit
3a37269f3f
44 files changed
+2261
-1072
No files matched your search
@@ -1,13 +1,9 @@
|
||||
import { act, render, screen } from "@testing-library/react";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import SyntaxHighlighter from "react-syntax-highlighter/dist/esm/prism-light";
|
||||
import markup from "react-syntax-highlighter/dist/esm/languages/prism/markup";
|
||||
import oneLight from "react-syntax-highlighter/dist/esm/styles/prism/one-light";
|
||||
import { codeHighlight } from "@/lib/code-highlighter";
|
||||
|
||||
import { ViewportCodeRows } from "@/components/ViewportCodeRows";
|
||||
|
||||
SyntaxHighlighter.registerLanguage("markup", markup);
|
||||
|
||||
let notify: (entries: IntersectionObserverEntry[]) => void;
|
||||
const disconnect = vi.fn();
|
||||
const observe = vi.fn();
|
||||
@@ -25,8 +21,7 @@ function sourceText() {
|
||||
return [...document.querySelectorAll("[data-highlighted]")].map(node => node.textContent).join("");
|
||||
}
|
||||
function preview(code: string) {
|
||||
return <div data-file-preview-scroll><SyntaxHighlighter language="markup" style={oneLight}
|
||||
renderer={props => <ViewportCodeRows {...props} />}>{code}</SyntaxHighlighter></div>;
|
||||
return <div data-file-preview-scroll><ViewportCodeRows lines={codeHighlight(code, "markup").read()} /></div>;
|
||||
}
|
||||
|
||||
describe("viewport code highlighting", () => {
|
||||
|
||||
Reference in new issue
Block a user