fix script body not loading in editor. Fix slow unload times for monaco editor

This commit is contained in:
sadnub
2023-10-29 10:24:16 -04:00
parent be37e89e16
commit 076ab0c465
2 changed files with 13 additions and 11 deletions

View File

@@ -4,9 +4,9 @@
persistent
@keydown.esc.stop="onDialogHide"
:maximized="maximized"
@keydown.esc="unloadEditor"
@hide="unloadEditor"
@hide="onDialogHide"
@show="loadEditor"
@before-hide="unloadEditor"
>
<q-card
class="q-dialog-plugin"
@@ -329,12 +329,6 @@ const lang = computed(() => {
else return "";
});
// get code if editing or cloning script
if (props.script)
downloadScript(script.id, { with_snippets: props.readonly }).then((r) => {
script.script_body = r.code;
});
async function submit() {
loading.value = true;
let result = "";
@@ -391,6 +385,13 @@ function loadEditor() {
editor.onDidChangeModelContent(() => {
script.script_body = editor.getValue();
});
// get code if editing or cloning script
if (props.script)
downloadScript(script.id, { with_snippets: props.readonly }).then((r) => {
script.script_body = r.code;
editor.setValue(r.code);
});
}
function unloadEditor() {

View File

@@ -2,10 +2,11 @@
<q-dialog
ref="dialogRef"
persistent
@keydown.esc="unloadEditor"
@keydown.esc.stop="onDialogHide"
:maximized="maximized"
@hide="unloadEditor"
@hide="onDialogHide"
@show="loadEditor"
@before-hide="unloadEditor"
>
<q-card
class="q-dialog-plugin"
@@ -177,7 +178,7 @@ const snippetEditor = ref<HTMLElement | null>(null);
let editor: monaco.editor.IStandaloneCodeEditor;
function loadEditor() {
var modelUri = monaco.Uri.parse("model://new"); // a made up unique URI for our model
var modelUri = monaco.Uri.parse("model://snippet"); // a made up unique URI for our model
var model = monaco.editor.createModel(snippet.code, lang.value, modelUri);
const theme = $q.dark.isActive ? "vs-dark" : "vs-light";