fix script body not loading in editor. Fix slow unload times for monaco editor
This commit is contained in:
		@@ -4,9 +4,9 @@
 | 
				
			|||||||
    persistent
 | 
					    persistent
 | 
				
			||||||
    @keydown.esc.stop="onDialogHide"
 | 
					    @keydown.esc.stop="onDialogHide"
 | 
				
			||||||
    :maximized="maximized"
 | 
					    :maximized="maximized"
 | 
				
			||||||
    @keydown.esc="unloadEditor"
 | 
					    @hide="onDialogHide"
 | 
				
			||||||
    @hide="unloadEditor"
 | 
					 | 
				
			||||||
    @show="loadEditor"
 | 
					    @show="loadEditor"
 | 
				
			||||||
 | 
					    @before-hide="unloadEditor"
 | 
				
			||||||
  >
 | 
					  >
 | 
				
			||||||
    <q-card
 | 
					    <q-card
 | 
				
			||||||
      class="q-dialog-plugin"
 | 
					      class="q-dialog-plugin"
 | 
				
			||||||
@@ -329,12 +329,6 @@ const lang = computed(() => {
 | 
				
			|||||||
  else return "";
 | 
					  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() {
 | 
					async function submit() {
 | 
				
			||||||
  loading.value = true;
 | 
					  loading.value = true;
 | 
				
			||||||
  let result = "";
 | 
					  let result = "";
 | 
				
			||||||
@@ -391,6 +385,13 @@ function loadEditor() {
 | 
				
			|||||||
  editor.onDidChangeModelContent(() => {
 | 
					  editor.onDidChangeModelContent(() => {
 | 
				
			||||||
    script.script_body = editor.getValue();
 | 
					    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() {
 | 
					function unloadEditor() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,10 +2,11 @@
 | 
				
			|||||||
  <q-dialog
 | 
					  <q-dialog
 | 
				
			||||||
    ref="dialogRef"
 | 
					    ref="dialogRef"
 | 
				
			||||||
    persistent
 | 
					    persistent
 | 
				
			||||||
    @keydown.esc="unloadEditor"
 | 
					    @keydown.esc.stop="onDialogHide"
 | 
				
			||||||
    :maximized="maximized"
 | 
					    :maximized="maximized"
 | 
				
			||||||
    @hide="unloadEditor"
 | 
					    @hide="onDialogHide"
 | 
				
			||||||
    @show="loadEditor"
 | 
					    @show="loadEditor"
 | 
				
			||||||
 | 
					    @before-hide="unloadEditor"
 | 
				
			||||||
  >
 | 
					  >
 | 
				
			||||||
    <q-card
 | 
					    <q-card
 | 
				
			||||||
      class="q-dialog-plugin"
 | 
					      class="q-dialog-plugin"
 | 
				
			||||||
@@ -177,7 +178,7 @@ const snippetEditor = ref<HTMLElement | null>(null);
 | 
				
			|||||||
let editor: monaco.editor.IStandaloneCodeEditor;
 | 
					let editor: monaco.editor.IStandaloneCodeEditor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function loadEditor() {
 | 
					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);
 | 
					  var model = monaco.editor.createModel(snippet.code, lang.value, modelUri);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const theme = $q.dark.isActive ? "vs-dark" : "vs-light";
 | 
					  const theme = $q.dark.isActive ? "vs-dark" : "vs-light";
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user