mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
fix(editor): scope Mermaid diagram scroll position per pane (#34983)
Key MermaidViewer's scroll cache with the pane-scoped editorViewStateKey, matching IpynbViewer, so split panes showing the same .mmd file no longer overwrite each other's saved diagram position. Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -274,7 +274,11 @@ export function EditorEditFileSurface({
|
||||
monacoEditor={monacoEditor}
|
||||
/>
|
||||
) : isMermaid && mdViewMode === 'rich' ? (
|
||||
<MermaidViewer key={activeFile.id} content={currentContent} filePath={activeFile.filePath} />
|
||||
<MermaidViewer
|
||||
key={activeFile.id}
|
||||
content={currentContent}
|
||||
scrollCacheKey={`${editorViewStateKey}:mermaid-diagram`}
|
||||
/>
|
||||
) : isCsv && mdViewMode === 'rich' ? (
|
||||
<CsvViewer
|
||||
key={activeFile.id}
|
||||
|
||||
@@ -5,20 +5,17 @@ import { useDocumentDarkTheme } from '@/hooks/use-document-dark-theme'
|
||||
|
||||
type MermaidViewerProps = {
|
||||
content: string
|
||||
filePath: string
|
||||
scrollCacheKey: string
|
||||
}
|
||||
|
||||
// Render full .mmd/.mermaid files directly as diagram source.
|
||||
export default function MermaidViewer({
|
||||
content,
|
||||
filePath
|
||||
scrollCacheKey
|
||||
}: MermaidViewerProps): React.JSX.Element {
|
||||
const rootRef = useRef<HTMLDivElement>(null)
|
||||
const isDark = useDocumentDarkTheme()
|
||||
|
||||
// Source and diagram heights differ; keep their scroll positions separate.
|
||||
const scrollCacheKey = `${filePath}:mermaid-diagram`
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const container = rootRef.current
|
||||
if (!container) {
|
||||
|
||||
Reference in New Issue
Block a user