fix script body not loading in editor. Fix slow unload times for monaco editor
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user