This commit is contained in:
Timothy J. Baek 2024-10-05 16:16:51 -07:00
parent 2e067b0541
commit bbbd94f69c
2 changed files with 10 additions and 4 deletions

View File

@ -1,5 +1,5 @@
<script> <script>
import { getContext, createEventDispatcher, onMount } from 'svelte'; import { getContext, createEventDispatcher, onMount, tick } from 'svelte';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
@ -263,10 +263,14 @@ class Pipe:
const submitHandler = async () => { const submitHandler = async () => {
if (codeEditor) { if (codeEditor) {
content = _content;
await tick();
const res = await codeEditor.formatPythonCodeHandler(); const res = await codeEditor.formatPythonCodeHandler();
if (res) { if (res) {
console.log('Code formatted successfully'); console.log('Code formatted successfully');
saveHandler(); saveHandler();
} }
} }
@ -352,8 +356,7 @@ class Pipe:
on:change={(e) => { on:change={(e) => {
_content = e.detail.value; _content = e.detail.value;
}} }}
on:save={() => { on:save={async () => {
content = _content;
if (formElement) { if (formElement) {
formElement.requestSubmit(); formElement.requestSubmit();
} }

View File

@ -151,10 +151,14 @@ class Tools:
const submitHandler = async () => { const submitHandler = async () => {
if (codeEditor) { if (codeEditor) {
content = _content;
await tick();
const res = await codeEditor.formatPythonCodeHandler(); const res = await codeEditor.formatPythonCodeHandler();
if (res) { if (res) {
console.log('Code formatted successfully'); console.log('Code formatted successfully');
saveHandler(); saveHandler();
} }
} }
@ -241,7 +245,6 @@ class Tools:
_content = e.detail.value; _content = e.detail.value;
}} }}
on:save={() => { on:save={() => {
content = _content;
if (formElement) { if (formElement) {
formElement.requestSubmit(); formElement.requestSubmit();
} }