This commit is contained in:
Liyas Thomas
2020-02-23 06:58:13 +05:30
parent 16779d496e
commit 9c09a8128a

View File

@@ -48,10 +48,10 @@ export default {
}
},
theme() {
this.editor.setTheme("ace/theme/" + this.defineTheme());
this.editor.setTheme(`ace/theme/${this.defineTheme()}`);
},
lang(value) {
this.editor.getSession().setMode("ace/mode/" + value);
this.editor.getSession().setMode(`ace/mode/${value}`);
},
options(value) {
this.editor.setOptions(value);
@@ -62,27 +62,36 @@ export default {
let langTools = ace.require("ace/ext/language_tools");
const editor = ace.edit(this.$refs.editor, {
theme: "ace/theme/" + this.defineTheme(),
mode: "ace/mode/" + this.lang,
theme: `ace/theme/${this.defineTheme()}`,
mode: `ace/mode/${this.lang}`,
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
...this.options
});
const completer = {
getCompletions: (editor, _session, pos, _prefix, callback) => {
getCompletions: (
editor,
_session,
{ row, column },
_prefix,
callback
) => {
if (this.validationSchema) {
const completions = getAutocompleteSuggestions(this.validationSchema, editor.getValue(), { line: pos.row, character: pos.column });
const completions = getAutocompleteSuggestions(
this.validationSchema,
editor.getValue(),
{ line: row, character: column }
);
callback(null,
completions.map((completion) => {
return {
name: completion.label,
value: completion.label,
score: 1.0,
meta: completion.detail
};
})
callback(
null,
completions.map(({ label, detail }) => ({
name: label,
value: label,
score: 1.0,
meta: detail
}))
);
} else {
callback(null, []);
@@ -130,14 +139,14 @@ export default {
if (this.validationSchema) {
this.editor.session.setAnnotations(
gql.validate(this.validationSchema, doc).map(err => {
return {
row: err.locations[0].line - 1,
column: err.locations[0].column - 1,
text: err.message,
gql
.validate(this.validationSchema, doc)
.map(({ locations, message }) => ({
row: locations[0].line - 1,
column: locations[0].column - 1,
text: message,
type: "error"
};
})
}))
);
}
} catch (e) {