Skip to content

Commit 318fdee

Browse files
committed
add "Use linted code" option to playground; update editor to apply linted code conditionally based on user selection
1 parent c825f50 commit 318fdee

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

public/playground.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ public function hasPermission(string $perm): bool
104104
<label for="editor" class="block text-xl font-bold mb-2">PHP Script</label>
105105
<div id="editor" style="height: 400px;" class="border-gray-300"></div>
106106
<div id="messages" class="text-red-400"></div>
107-
<button type="button" id="run-button" class="mt-4 px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600">Run</button>
107+
<div class="flex items-center mt-4 gap-4">
108+
<button type="button" id="run-button" class="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600">Run</button>
109+
<label class="flex items-center gap-1">
110+
<input type="checkbox" id="apply-linted-code" class="size-4 text-blue-600 bg-gray-100 border-gray-300 rounded-sm focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
111+
Use the linted code from engine
112+
</label>
113+
</div>
108114
</form>
109115
</div>
110116
<div>
@@ -297,6 +303,7 @@ function createSuggestion(item, range) {
297303
const code = editor.getValue();
298304
const outputContainer = document.getElementById('output-container');
299305
const runButton = document.getElementById('run-button');
306+
const applyLintedCode = document.getElementById('apply-linted-code');
300307

301308
// Button-Zustand
302309
runButton.disabled = true;
@@ -320,8 +327,10 @@ function createSuggestion(item, range) {
320327

321328
if (result.success) {
322329
outputContainer.innerHTML = result.output.replace(/\n/g, '<br>');
323-
editor.getModel().setValue(result.linted);
324330
outputContainer.classList.remove('text-red-400');
331+
if (applyLintedCode.checked) {
332+
editor.getModel().setValue(result.linted);
333+
}
325334
} else {
326335
// Das ist der Fehlerfall vom Backend
327336
outputContainer.textContent = result.error.message;

0 commit comments

Comments
 (0)