mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 05:09:51 +08:00
- Promote "Answer now" to a universal escape hatch via answer_now_context; orchestrator re-routes any capability to chat._stage_answer_now. - Co-Writer: draggable split + persistent ratio + line-anchored bidirectional scroll sync using a hidden mirror for wrap-aware editor y. - SaveToNotebookModal: optional message-selection mode with quick presets; rebuild transcript / userQuery from the selected subset. - Adopt the real notebook API (/api/v1/notebook/*) across Knowledge tab, guide notebook picker, and save-to-notebook flow; new typed helpers in web/lib/notebook-api.ts (listNotebooks/getNotebook/createNotebook/...). - Extract CollapsibleConfigSection; unify Quiz / Math Animator / Visualize / Deep Research panels behind one collapsed-summary header. - Replace streaming spinner with a dedicated Stop button; persistent composer header; mask-gradient on messages container. - TutorBotManager: public load/save/merge API; atomic write via temp + Path.replace; merge_bot_config with explicit-clear semantics; new tests/services/tutorbot/test_manager_config.py. - MarkdownRenderer: trackSourceLines passes data-source-line through; RichCodeBlock skips Prism for unlabeled/plaintext fences; mermaid detection includes flow/seq/sequence editor.md fences. - UI/theme: deeper foregrounds + warmer borders for light/Snow themes; /guide migrated off hardcoded slate/indigo to design tokens; HistorySessionPicker themed and timestamp-seconds bug fixed. - Filter system messages out of UnifiedChatContext.hydrateMessages and ChatMessageList so backend grounding context never renders as a bubble. - Bug fixes (already merged earlier in dev): * tutorbot config wipe on restart (#332) * selective_access_log middleware unpack crash (#334/#335) * 15 npm security vulnerabilities — jspdf/next/mermaid (#330) - Drive-by: remove "// README" typo from .env.example_CN. - Add v1.1.1 release notes and update README. Made-with: Cursor
71 lines
2.0 KiB
TypeScript
71 lines
2.0 KiB
TypeScript
"use client";
|
|
|
|
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
|
import { oneDark } from "react-syntax-highlighter/dist/esm/styles/prism";
|
|
|
|
const MONOSPACE =
|
|
'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
|
|
const PLAIN_LANGS = new Set(["", "text", "txt", "plain", "plaintext", "none"]);
|
|
|
|
export default function RichCodeBlock({
|
|
raw,
|
|
lang,
|
|
className,
|
|
}: {
|
|
raw: string;
|
|
lang: string;
|
|
className?: string;
|
|
}) {
|
|
const normalizedLang = (lang || "").toLowerCase();
|
|
const isPlain = PLAIN_LANGS.has(normalizedLang);
|
|
|
|
return (
|
|
<div
|
|
className={`md-code-block overflow-hidden rounded-xl border border-[var(--border)] bg-[#1f2937] ${
|
|
className || ""
|
|
}`}
|
|
>
|
|
{!isPlain ? (
|
|
<div className="border-b border-white/10 px-3 py-2 text-[11px] font-medium uppercase tracking-wider text-[#9ca3af]">
|
|
{normalizedLang}
|
|
</div>
|
|
) : null}
|
|
{isPlain ? (
|
|
// Skip the highlighter entirely for unlabeled / plain blocks so we
|
|
// don't trigger Prism "unknown language" warnings and keep a tidy
|
|
// monospace presentation that matches the highlighted variant.
|
|
<pre
|
|
className="overflow-x-auto p-4 text-sm leading-[1.7] text-[#e5e7eb]"
|
|
style={{ margin: 0, fontFamily: MONOSPACE }}
|
|
>
|
|
<code className="md-code-block__code" style={{ fontFamily: MONOSPACE }}>
|
|
{raw}
|
|
</code>
|
|
</pre>
|
|
) : (
|
|
<SyntaxHighlighter
|
|
language={normalizedLang}
|
|
style={oneDark}
|
|
PreTag="pre"
|
|
customStyle={{
|
|
margin: 0,
|
|
borderRadius: 0,
|
|
background: "#1f2937",
|
|
padding: "1rem",
|
|
fontSize: "0.875rem",
|
|
lineHeight: "1.7",
|
|
}}
|
|
codeTagProps={{
|
|
className: "md-code-block__code",
|
|
style: { fontFamily: MONOSPACE },
|
|
}}
|
|
wrapLongLines={false}
|
|
>
|
|
{raw}
|
|
</SyntaxHighlighter>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|