fix(custom-widgets): stabilize authoring flows

This commit is contained in:
Thomas Camlong committed 2026-07-20 17:55:57 +02:00
1 parent e4388b0712
commit 091eca3192
22 files changed
+454 -203

No files matched your search

@@ -1,4 +1,3 @@
import type { EditorView } from "@codemirror/view";
import { Alert, Stack, Text, UnstyledButton } from "@mantine/core";
import { IconAlertTriangle } from "@tabler/icons-react";
@@ -8,12 +7,12 @@ import classes from "./code-editor.module.css";
export function EditorDiagnostics({
diagnostics,
editorView,
messages,
onSelect,
}: {
diagnostics: EditorDiagnostic[];
editorView: EditorView | null;
messages: CustomWidgetEditorMessages;
onSelect(diagnostic: EditorDiagnostic): void;
}) {
if (diagnostics.length === 0) return null;
return (
@@ -24,12 +23,7 @@ export function EditorDiagnostics({
type="button"
w="100%"
className={classes.diagnosticButton}
onClick={() => {
if (!editorView || diagnostic.index === undefined) return;
const anchor = Math.min(diagnostic.index, editorView.state.doc.length);
editorView.dispatch({ selection: { anchor }, scrollIntoView: true });
editorView.focus();
}}
onClick={() => onSelect(diagnostic)}
>
<Alert
color={diagnostic.severity === "error" ? "red" : "yellow"}