text edit dialog shows parser errors
This commit is contained in:
parent
88dee7e3b9
commit
ff32e6d000
3 changed files with 22 additions and 11 deletions
|
|
@ -1,11 +1,10 @@
|
||||||
import logo from "../../artwork/logo.svg";
|
import logo from "../../artwork/logo.svg";
|
||||||
|
|
||||||
export function About() {
|
export function About() {
|
||||||
return <div style={{display: 'inline-block', backgroundColor: 'white', width: 500, padding: 4}}>
|
return <div style={{backgroundColor: 'white', width: 500, padding: 4}}>
|
||||||
<p><img src={logo}/></p>
|
<p><img src={logo}/></p>
|
||||||
<p>StateBuddy is a <a href="https://dl.acm.org/doi/10.1016/0167-6423(87)90035-9">statechart</a> editing, simulation, debugging and testing environment inspired by <a href="https://dl.acm.org/doi/10.1145/3417990.3421401">CouchEdit</a>.</p>
|
<p>StateBuddy is an <a target="_blank" href="https://deemz.org/git/research/statebuddy">open source</a> tool for <a target="_blank" href="https://dl.acm.org/doi/10.1016/0167-6423(87)90035-9">Statechart</a> editing, simulation, debugging and testing environment, inspired by <a target="_blank" href="https://dl.acm.org/doi/10.1145/3417990.3421401">CouchEdit</a>.</p>
|
||||||
<p>It was originally created for teaching Statecharts to university students, but likely is a useful tool for other purposes as well.</p>
|
<p>It was originally created for teaching Statecharts to university students, but likely is a useful tool for other purposes as well.</p>
|
||||||
<p>StateBuddy is <a href="https://deemz.org/git/research/statebuddy">open source</a>.</p>
|
<p>Commercial use: <a href="mailto:joeri.exelmans@gmail.com">e‑mail me</a> for permission.</p>
|
||||||
<p>For commerical use, <a href="mailto:joeri.exelmans@gmail.com">e‑mail me</a> for permission.</p>
|
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ export function App() {
|
||||||
onMouseDown={() => setModal(null)}
|
onMouseDown={() => setModal(null)}
|
||||||
style={{width: '100%', height: '100%', position:'absolute', textAlign: 'center', backgroundColor: 'rgba(127,127,127,0.5)' }}>
|
style={{width: '100%', height: '100%', position:'absolute', textAlign: 'center', backgroundColor: 'rgba(127,127,127,0.5)' }}>
|
||||||
<div
|
<div
|
||||||
style={{position: 'relative', top: '50%', transform: 'translateY(-50%)'}}>
|
style={{position: 'relative', top: '50%', transform: 'translateY(-50%)', textAlign: 'center', display: 'inline-block'}}>
|
||||||
<span onMouseDown={e => e.stopPropagation()}>
|
<span onMouseDown={e => e.stopPropagation()}>
|
||||||
{modal}
|
{modal}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { Dispatch, ReactElement, SetStateAction, useState } from "react";
|
import { Dispatch, ReactElement, SetStateAction, useState } from "react";
|
||||||
|
|
||||||
|
import { parse as parseLabel, SyntaxError } from "../statecharts/label_parser";
|
||||||
|
|
||||||
export function TextDialog(props: {setModal: Dispatch<SetStateAction<ReactElement|null>>, text: string, done: (newText: string|undefined) => void}) {
|
export function TextDialog(props: {setModal: Dispatch<SetStateAction<ReactElement|null>>, text: string, done: (newText: string|undefined) => void}) {
|
||||||
const [text, setText] = useState(props.text);
|
const [text, setText] = useState(props.text);
|
||||||
function onKeyDown(e: KeyboardEvent) {
|
function onKeyDown(e: KeyboardEvent) {
|
||||||
|
|
@ -16,11 +18,21 @@ export function TextDialog(props: {setModal: Dispatch<SetStateAction<ReactElemen
|
||||||
}
|
}
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
return <span onKeyDown={onKeyDown} style={{backgroundColor:'white'}}>
|
|
||||||
<textarea style={{fontFamily: 'Roboto', width:500, height: 100}} onChange={e=>setText(e.target.value)}>{text}</textarea>
|
let error = "";
|
||||||
|
try {
|
||||||
|
const parsed = parseLabel(text);
|
||||||
|
} catch (e) {
|
||||||
|
error = e.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <div onKeyDown={onKeyDown} style={{backgroundColor:'white', padding: 4, width: 520}}>
|
||||||
|
Edit text label:<br/>
|
||||||
|
<textarea autoFocus style={{fontFamily: 'Roboto', width:500, height: 100}} onChange={e=>setText(e.target.value)}>{text}</textarea>
|
||||||
<br/>
|
<br/>
|
||||||
<span style={{backgroundColor:'lightyellow'}}>
|
<span style={{color: 'var(--error-color)'}}>{error}</span><br/>
|
||||||
Tip: <kbd>Shift</kbd>+<kbd>Enter</kbd> to insert newline.
|
<p><kbd>Enter</kbd> to confirm. <kbd>Escape</kbd> to cancel.
|
||||||
</span>
|
</p>
|
||||||
</span>;
|
(Tip: <kbd>Shift</kbd>+<kbd>Enter</kbd> to insert newline.)
|
||||||
|
</div>;
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue