import { TextDialog } from "@/App/TextDialog"; import { TraceableError } from "..//statecharts/parser"; import {Text} from "../statecharts/concrete_syntax"; import { Dispatch, ReactElement, SetStateAction } from "react"; export function TextSVG(props: {text: Text, error: TraceableError|undefined, selected: boolean, highlight: boolean, onEdit: (newText: string) => void, setModal: Dispatch>}) { const commonProps = { "data-uid": props.text.uid, "data-parts": "text", textAnchor: "middle" as "middle", className: "draggableText" + (props.selected ? " selected":"") + (props.highlight ? " highlight":""), style: {whiteSpace: "preserve"}, } let textNode; if (props.error?.data?.location) { const {start,end} = props.error.data.location; textNode = <> {props.text.text.slice(0, start.offset)} {props.text.text.slice(start.offset, end.offset)} {start.offset === end.offset && <>_} {props.text.text.slice(end.offset)} {props.error.message}; } else { textNode = {props.text.text}; } return { props.setModal( { if (newText) { props.onEdit(newText); } }} />) }}> {textNode} {props.text.text} ; }