added files to start parsing functionality of path variables
This commit is contained in:
@@ -35,10 +35,13 @@ import { EditorState, Extension } from "@codemirror/state"
|
||||
import clone from "lodash/clone"
|
||||
import { tooltips } from "@codemirror/tooltip"
|
||||
import { history, historyKeymap } from "@codemirror/history"
|
||||
import { HoppRESTVar } from "@hoppscotch/data"
|
||||
import { inputTheme } from "~/helpers/editor/themes/baseTheme"
|
||||
import { HoppReactiveEnvPlugin } from "~/helpers/editor/extensions/HoppEnvironment"
|
||||
import { useReadonlyStream } from "~/helpers/utils/composables"
|
||||
import { AggregateEnvironment, aggregateEnvs$ } from "~/newstore/environments"
|
||||
import { HoppReactiveVarPlugin } from "~/helpers/editor/extensions/HoppVariable"
|
||||
import { restVars$ } from "~/newstore/RESTSession"
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -46,6 +49,7 @@ const props = withDefaults(
|
||||
placeholder: string
|
||||
styles: string
|
||||
envs: { key: string; value: string; source: string }[] | null
|
||||
vars: { key: string; value: string }[] | null
|
||||
focus: boolean
|
||||
readonly: boolean
|
||||
}>(),
|
||||
@@ -54,6 +58,7 @@ const props = withDefaults(
|
||||
placeholder: "",
|
||||
styles: "",
|
||||
envs: null,
|
||||
vars: null,
|
||||
focus: false,
|
||||
readonly: false,
|
||||
}
|
||||
@@ -109,6 +114,7 @@ let pastedValue: string | null = null
|
||||
const aggregateEnvs = useReadonlyStream(aggregateEnvs$, []) as Ref<
|
||||
AggregateEnvironment[]
|
||||
>
|
||||
const aggregateVars = useReadonlyStream(restVars$, []) as Ref<HoppRESTVar[]>
|
||||
|
||||
const envVars = computed(() =>
|
||||
props.envs
|
||||
@@ -120,7 +126,17 @@ const envVars = computed(() =>
|
||||
: aggregateEnvs.value
|
||||
)
|
||||
|
||||
const varVars = computed(() =>
|
||||
props.vars
|
||||
? props.vars.map((x) => ({
|
||||
key: x.key,
|
||||
value: x.value,
|
||||
}))
|
||||
: aggregateVars.value
|
||||
)
|
||||
|
||||
const envTooltipPlugin = new HoppReactiveEnvPlugin(envVars, view)
|
||||
const varTooltipPlugin = new HoppReactiveVarPlugin(varVars, view)
|
||||
|
||||
const initView = (el: any) => {
|
||||
const extensions: Extension = [
|
||||
@@ -146,6 +162,7 @@ const initView = (el: any) => {
|
||||
position: "absolute",
|
||||
}),
|
||||
envTooltipPlugin,
|
||||
varTooltipPlugin,
|
||||
placeholderExt(props.placeholder),
|
||||
EditorView.domEventHandlers({
|
||||
paste(ev) {
|
||||
|
||||
Reference in New Issue
Block a user