Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

Merge branch 'master' into feature/prettier-formatting

James George19bfa3a7c360
diff --cc components/ace-editor.vue
index d38b94f4e,be1917c08..47553b7d7
--- a/components/ace-editor.vue
+++ b/components/ace-editor.vue
@@@ -78,33 -78,41 +78,39 @@@ export default
mounted() {
const editor = ace.edit(this.$refs.editor, {
mode: `ace/mode/${this.lang}`,
- ...this.options
- });
+ ...this.options,
+ })
+ // Set the theme and show the editor only after it's been set to prevent FOUC.
+ editor.setTheme(`ace/theme/${this.defineTheme()}`, () => {
+ this.$nextTick().then(() => {
+ this.initialized = true;
+ });
+ });
+
if (this.value) editor.setValue(this.value, 1);
- this.editor = editor;
- this.cacheValue = this.value;
+ this.editor = editor
+ this.cacheValue = this.value
editor.on("change", () => {
- const content = editor.getValue();
- this.$emit("input", content);
- this.cacheValue = content;
- });
+ const content = editor.getValue()
+ this.$emit("input", content)
+ this.cacheValue = content
+ })
},
methods: {
defineTheme() {
if (this.theme) {
- return this.theme;
+ return this.theme
}
- return (
- this.$store.state.postwoman.settings.THEME_ACE_EDITOR || DEFAULT_THEME
- );
- }
+ return this.$store.state.postwoman.settings.THEME_ACE_EDITOR || DEFAULT_THEME
+ },
},
- beforeDestroy() {
+ destroyed() {
this.editor.destroy();
- this.editor.container.remove();
}
};
</script>
diff --cc components/graphql/queryeditor.vue
index bc58ceddd,459b2deee..c76ba02d7
--- a/components/graphql/queryeditor.vue
+++ b/components/graphql/queryeditor.vue
@@@ -87,23 -87,30 +87,30 @@@ export default
mode: `ace/mode/${this.lang}`,
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
- ...this.options
+ ...this.options,
+ })
+
+ // Set the theme and show the editor only after it's been set to prevent FOUC.
+ editor.setTheme(`ace/theme/${this.defineTheme()}`, () => {
+ this.$nextTick().then(() => {
+ this.initialized = true;
+ });
});
+ // Set the theme and show the editor only after it's been set to prevent FOUC.
+ editor.setTheme(`ace/theme/${this.defineTheme()}`, () => {
+ this.$nextTick().then(() => {
+ this.initialized = true;
+ });
+ });
+
const completer = {
- getCompletions: (
- editor,
- _session,
- { row, column },
- _prefix,
- callback
- ) => {
+ getCompletions: (editor, _session, { row, column }, _prefix, callback) => {
if (this.validationSchema) {
- const completions = getAutocompleteSuggestions(
- this.validationSchema,
- editor.getValue(),
- { line: row, character: column }
- );
+ const completions = getAutocompleteSuggestions(this.validationSchema, editor.getValue(), {
+ line: row,
+ character: column,
+ })
callback(
null,