From ff32e6d00008d5c73be06b3db9938cd39449f7ac Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Sun, 19 Oct 2025 20:54:56 +0200 Subject: [PATCH] text edit dialog shows parser errors --- src/App/About.tsx | 7 +++---- src/App/App.tsx | 2 +- src/App/TextDialog.tsx | 24 ++++++++++++++++++------ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/App/About.tsx b/src/App/About.tsx index 104e114..61c1f51 100644 --- a/src/App/About.tsx +++ b/src/App/About.tsx @@ -1,11 +1,10 @@ import logo from "../../artwork/logo.svg"; export function About() { - return
+ return

-

StateBuddy is a statechart editing, simulation, debugging and testing environment inspired by CouchEdit.

+

StateBuddy is an open source tool for Statechart editing, simulation, debugging and testing environment, inspired by CouchEdit.

It was originally created for teaching Statecharts to university students, but likely is a useful tool for other purposes as well.

-

StateBuddy is open source.

-

For commerical use, e‑mail me for permission.

+

Commercial use: e‑mail me for permission.

; } diff --git a/src/App/App.tsx b/src/App/App.tsx index 47743f3..282fd09 100644 --- a/src/App/App.tsx +++ b/src/App/App.tsx @@ -152,7 +152,7 @@ export function App() { onMouseDown={() => setModal(null)} style={{width: '100%', height: '100%', position:'absolute', textAlign: 'center', backgroundColor: 'rgba(127,127,127,0.5)' }}>
+ style={{position: 'relative', top: '50%', transform: 'translateY(-50%)', textAlign: 'center', display: 'inline-block'}}> e.stopPropagation()}> {modal} diff --git a/src/App/TextDialog.tsx b/src/App/TextDialog.tsx index 110a789..4dfd45c 100644 --- a/src/App/TextDialog.tsx +++ b/src/App/TextDialog.tsx @@ -1,5 +1,7 @@ import { Dispatch, ReactElement, SetStateAction, useState } from "react"; +import { parse as parseLabel, SyntaxError } from "../statecharts/label_parser"; + export function TextDialog(props: {setModal: Dispatch>, text: string, done: (newText: string|undefined) => void}) { const [text, setText] = useState(props.text); function onKeyDown(e: KeyboardEvent) { @@ -16,11 +18,21 @@ export function TextDialog(props: {setModal: Dispatch - + + let error = ""; + try { + const parsed = parseLabel(text); + } catch (e) { + error = e.message; + } + + return
+ Edit text label:
+
- - Tip: Shift+Enter to insert newline. - - ; + {error}
+

Enter to confirm. Escape to cancel. +

+ (Tip: Shift+Enter to insert newline.) +
; } \ No newline at end of file