mirror of
https://github.com/olehomelchenko/astrolabe.git
synced 2026-08-08 02:02:33 +00:00
Editor: composition structure wireframe (read-only)
This commit is contained in:
@@ -384,6 +384,7 @@ export function SpecEditor() {
|
||||
const editorView = useSnippetStore((s) => s.editorView);
|
||||
const bufferEpoch = useSnippetStore((s) => s.bufferEpoch);
|
||||
const uiTheme = useAppStore((s) => s.uiTheme);
|
||||
const revealTarget = useAppStore((s) => s.revealTarget);
|
||||
const error = usePreviewStore((s) => s.error);
|
||||
// Editor preferences (spec §07 → Editor); applied live below as they change.
|
||||
const editorPrefs = useUserSettingsStore((s) => s.saved.editor);
|
||||
@@ -495,6 +496,23 @@ export function SpecEditor() {
|
||||
monaco.editor.setTheme(effective === 'dark' ? 'vs-dark' : 'vs');
|
||||
}, [uiTheme, editorPrefs.theme]);
|
||||
|
||||
// Select + reveal a view's source range when the composition wireframe asks
|
||||
// (arch 08 → composition wireframe). The nonce makes a repeat request re-fire.
|
||||
useEffect(() => {
|
||||
const editor = editorRef.current;
|
||||
if (!editor || !revealTarget) return;
|
||||
const model = editor.getModel();
|
||||
if (!model) return;
|
||||
const range = monaco.Range.fromPositions(
|
||||
model.getPositionAt(revealTarget.offset),
|
||||
model.getPositionAt(revealTarget.offset + revealTarget.length),
|
||||
);
|
||||
editor.setSelection(range);
|
||||
editor.revealRangeInCenterIfOutsideViewport(range);
|
||||
// Deliberately no focus(): the wireframe stays the active surface so the user
|
||||
// can keep browsing blocks while the editor scrolls/selects to follow.
|
||||
}, [revealTarget]);
|
||||
|
||||
return (
|
||||
<div className={styles.editorPane}>
|
||||
<EditorToolbar editorRef={editorRef} />
|
||||
|
||||
Reference in New Issue
Block a user