Spaces:
Paused
Paused
Update flare-ui/src/app/dialogs/api-edit-dialog/api-edit-dialog.component.ts
Browse files
flare-ui/src/app/dialogs/api-edit-dialog/api-edit-dialog.component.ts
CHANGED
|
@@ -119,6 +119,83 @@ export default class ApiEditDialogComponent implements OnInit {
|
|
| 119 |
});
|
| 120 |
}
|
| 121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
initializeForm() {
|
| 123 |
this.form = this.fb.group({
|
| 124 |
// General Tab
|
|
|
|
| 119 |
});
|
| 120 |
}
|
| 121 |
|
| 122 |
+
// Tab tuşu handler
|
| 123 |
+
handleTabKey(event: KeyboardEvent, field: string): void {
|
| 124 |
+
if (event.key === 'Tab') {
|
| 125 |
+
event.preventDefault();
|
| 126 |
+
|
| 127 |
+
const textarea = event.target as HTMLTextAreaElement;
|
| 128 |
+
const start = textarea.selectionStart;
|
| 129 |
+
const end = textarea.selectionEnd;
|
| 130 |
+
const value = textarea.value;
|
| 131 |
+
|
| 132 |
+
// Tab karakteri ekle
|
| 133 |
+
const newValue = value.substring(0, start) + '\t' + value.substring(end);
|
| 134 |
+
|
| 135 |
+
// Form kontrolünü güncelle
|
| 136 |
+
const control = this.form.get(field);
|
| 137 |
+
if (control) {
|
| 138 |
+
control.setValue(newValue);
|
| 139 |
+
|
| 140 |
+
// Cursor pozisyonunu ayarla
|
| 141 |
+
setTimeout(() => {
|
| 142 |
+
textarea.selectionStart = textarea.selectionEnd = start + 1;
|
| 143 |
+
textarea.focus();
|
| 144 |
+
}, 0);
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
// Shift+Tab için outdent (opsiyonel)
|
| 150 |
+
handleShiftTab(event: KeyboardEvent, field: string): void {
|
| 151 |
+
if (event.key === 'Tab' && event.shiftKey) {
|
| 152 |
+
event.preventDefault();
|
| 153 |
+
|
| 154 |
+
const textarea = event.target as HTMLTextAreaElement;
|
| 155 |
+
const start = textarea.selectionStart;
|
| 156 |
+
const value = textarea.value;
|
| 157 |
+
|
| 158 |
+
// Cursor'dan önceki en yakın tab'ı bul ve sil
|
| 159 |
+
const beforeCursor = value.substring(0, start);
|
| 160 |
+
const lastTabIndex = beforeCursor.lastIndexOf('\t');
|
| 161 |
+
|
| 162 |
+
if (lastTabIndex !== -1 && start - lastTabIndex <= 4) { // Tab'a yakınsa
|
| 163 |
+
const newValue = value.substring(0, lastTabIndex) + value.substring(lastTabIndex + 1);
|
| 164 |
+
|
| 165 |
+
const control = this.form.get(field);
|
| 166 |
+
if (control) {
|
| 167 |
+
control.setValue(newValue);
|
| 168 |
+
|
| 169 |
+
setTimeout(() => {
|
| 170 |
+
textarea.selectionStart = textarea.selectionEnd = lastTabIndex;
|
| 171 |
+
textarea.focus();
|
| 172 |
+
}, 0);
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
// Test request için özel tab handler
|
| 179 |
+
handleTestRequestTab(event: KeyboardEvent): void {
|
| 180 |
+
if (event.key === 'Tab') {
|
| 181 |
+
event.preventDefault();
|
| 182 |
+
|
| 183 |
+
const textarea = event.target as HTMLTextAreaElement;
|
| 184 |
+
const start = textarea.selectionStart;
|
| 185 |
+
const end = textarea.selectionEnd;
|
| 186 |
+
const value = textarea.value;
|
| 187 |
+
|
| 188 |
+
// Tab karakteri ekle
|
| 189 |
+
this.testRequestJson = value.substring(0, start) + '\t' + value.substring(end);
|
| 190 |
+
|
| 191 |
+
// Cursor pozisyonunu ayarla
|
| 192 |
+
setTimeout(() => {
|
| 193 |
+
textarea.selectionStart = textarea.selectionEnd = start + 1;
|
| 194 |
+
textarea.focus();
|
| 195 |
+
}, 0);
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
initializeForm() {
|
| 200 |
this.form = this.fb.group({
|
| 201 |
// General Tab
|