Skip to content

Commit

Permalink
feat(expressions): expose editor (#1876)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leopoldthecoder authored Jan 9, 2025
1 parent f78b4c7 commit 6eabc32
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import type { ParseResult, ParseResultOk, Schema as AtcSchema } from '@kong/atc-
import { Parser } from '@kong/atc-router'
import type * as Monaco from 'monaco-editor'
import * as monaco from 'monaco-editor'
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { computed, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue'
import { createSchema, type Schema } from '../schema'
import { registerLanguage, registerTheme, theme } from '../monaco'
let editor: Monaco.editor.IStandaloneCodeEditor | undefined
let editorModel: Monaco.editor.ITextModel
const editorRef = shallowRef<Monaco.editor.IStandaloneCodeEditor>()
const { debounce } = useDebounce()
Expand Down Expand Up @@ -81,6 +82,8 @@ onMounted(() => {
...props.editorOptions,
})
editorRef.value = editor
if (props.defaultShowDetails) {
editor.getContribution<Record<string, any> & Monaco.editor.IEditorContribution>('editor.contrib.suggestController')
?.widget?.value._setDetailsVisible(true)
Expand Down Expand Up @@ -208,6 +211,10 @@ watch(() => parseResult.value, (result?: ParseResult) => {
monaco.editor.setModelMarkers(editorModel, 'kong-expressions-editor', markers)
})
defineExpose({
editor: editorRef,
})
</script>

<style lang="scss" scoped>
Expand Down

0 comments on commit 6eabc32

Please sign in to comment.