feat: focus codemirror view when ImportCurl component launched (#3911)
Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
This commit is contained in:
@@ -98,6 +98,7 @@ import { RESTTabService } from "~/services/tab/rest"
|
||||
import { useService } from "dioc/vue"
|
||||
import { useNestedSetting } from "~/composables/settings"
|
||||
import { toggleNestedSetting } from "~/newstore/settings"
|
||||
import { EditorView } from "@codemirror/view"
|
||||
|
||||
const t = useI18n()
|
||||
|
||||
@@ -124,6 +125,7 @@ useCodemirror(
|
||||
linter: null,
|
||||
completer: null,
|
||||
environmentHighlights: false,
|
||||
onInit: (view: EditorView) => view.focus(),
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
@@ -68,6 +68,9 @@ type CodeMirrorOptions = {
|
||||
|
||||
// callback on editor update
|
||||
onUpdate?: (view: ViewUpdate) => void
|
||||
|
||||
// callback on view initialization
|
||||
onInit?: (view: EditorView) => void
|
||||
}
|
||||
|
||||
const hoppCompleterExt = (completer: Completer): Extension => {
|
||||
@@ -208,7 +211,9 @@ export function useCodemirror(
|
||||
el: Ref<any | null>,
|
||||
value: Ref<string | undefined>,
|
||||
options: CodeMirrorOptions
|
||||
): { cursor: Ref<{ line: number; ch: number }> } {
|
||||
): {
|
||||
cursor: Ref<{ line: number; ch: number }>
|
||||
} {
|
||||
const { subscribeToStream } = useStreamSubscriber()
|
||||
|
||||
// Set default value for contextMenuEnabled if not provided
|
||||
@@ -383,6 +388,8 @@ export function useCodemirror(
|
||||
extensions,
|
||||
}),
|
||||
})
|
||||
|
||||
options.onInit?.(view.value)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user