Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,26 @@ interface InlineLuEditorProps {

const InlineLuEditor: React.FC<InlineLuEditorProps> = props => {
const { file, onSave, errorMsg } = props;
const [content, setContent] = useState(file.content || '');
const [localContent, setLocalContent] = useState('');
const [localErrorMsg, setLocalErrorMsg] = useState('');

// save on mount to trigger validation
useEffect(() => {
if (content) {
onSave(content);
}
}, []);
setLocalContent(file.content || '');
const errorMsgText = file.diagnostics
.map(item => {
return item.text;
})
.join('\n');

setLocalErrorMsg(errorMsgText || errorMsg || '');
}, [file]);

const commitChanges = value => {
setContent(value);
setLocalContent(value);
onSave(value);
};

return <LuEditor value={content} onChange={commitChanges} errorMsg={errorMsg} height={450} />;
return <LuEditor value={localContent} onChange={commitChanges} errorMsg={localErrorMsg} height={450} />;
};

export default InlineLuEditor;