ai #1
@@ -61,6 +61,25 @@ export function ConfigTemplate(props: ConfigTemplateProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleKeyDown(e: React.KeyboardEvent<HTMLTextAreaElement>) {
|
||||||
|
if (e.key === 'Tab') {
|
||||||
|
e.preventDefault();
|
||||||
|
const textarea = e.currentTarget;
|
||||||
|
const start = textarea.selectionStart;
|
||||||
|
const end = textarea.selectionEnd;
|
||||||
|
const value = textarea.value;
|
||||||
|
|
||||||
|
// Insert 2 spaces at cursor position
|
||||||
|
const newValue = value.substring(0, start) + ' ' + value.substring(end);
|
||||||
|
handleDraftChange(newValue);
|
||||||
|
|
||||||
|
// Move cursor after the inserted spaces
|
||||||
|
setTimeout(() => {
|
||||||
|
textarea.selectionStart = textarea.selectionEnd = start + 2;
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const isValidJson = jsonError === null;
|
const isValidJson = jsonError === null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -105,8 +124,9 @@ export function ConfigTemplate(props: ConfigTemplateProps) {
|
|||||||
className={`form-control font-monospace ${isValidJson ? 'border-success' : 'border-danger'}`}
|
className={`form-control font-monospace ${isValidJson ? 'border-success' : 'border-danger'}`}
|
||||||
value={draftContent}
|
value={draftContent}
|
||||||
onChange={(e) => handleDraftChange(e.target.value)}
|
onChange={(e) => handleDraftChange(e.target.value)}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
rows={20}
|
rows={20}
|
||||||
style={{
|
style={{
|
||||||
fontFamily: 'monospace',
|
fontFamily: 'monospace',
|
||||||
whiteSpace: 'pre',
|
whiteSpace: 'pre',
|
||||||
overflowX: 'auto'
|
overflowX: 'auto'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.highlihgt-scrolled {
|
.highlihgt-scrolled {
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
max-width: 90%;
|
/ max-width: 90%;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user