Skip to content

Commit

Permalink
fix script body not loading in editor. Fix slow unload times for mona…
Browse files Browse the repository at this point in the history
…co editor
  • Loading branch information
sadnub committed Oct 29, 2023
1 parent be37e89 commit 076ab0c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
17 changes: 9 additions & 8 deletions src/components/scripts/ScriptFormModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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() {
Expand Down
7 changes: 4 additions & 3 deletions src/components/scripts/ScriptSnippetFormModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 076ab0c

Please sign in to comment.