github.com/microsoft/m…
github.com/microsoft/m…
<template>
<div :id="'codeEditBox' + index" class="codeEditBox" v-if="isChange"></div>
</template>
let editors
let editor
onBeforeUnmount(() => {
editor.dispose()
editors.dispose()
})
onUnmounted(() => {
editor.dispose()
editors.dispose()
})
nextTick(() => {
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
noSemanticValidation: true,
noSyntaxValidation: false
})
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.ES2016,
allowNonTsExtensions: true
})
let a = 'codeEditBox' + props.index
!editor
? (editor = monaco.editor.create(document.getElementById(a) as HTMLElement, {
value: props.inputList.script1,
language: 'python' || 'sql',
automaticLayout: true,
theme: 'hc-dark',
foldingStrategy: 'indentation',
renderLineHighlight: 'all',
selectOnLineNumbers: true,
minimap: {
enabled: false
},
readOnly: false,
fontSize: 12,
scrollBeyondLastLine: false,
overviewRulerBorder: false
}))
: editor.setValue('')
editor.onDidChangeModelContent((val: any) => {
text.value = editor.getValue()
})
editors = monaco.languages.registerCompletionItemProvider('python', {
provideCompletionItems: function () {
let suggestions = []
pythonLanguage.keywords.forEach((item) => {
suggestions.push({
label: item,
kind: monaco.languages.CompletionItemKind.Keyword,
insertText: item
})
})
return {
suggestions: suggestions
}
}
})
})