fix: copy + paste
This commit is contained in:
@@ -47,7 +47,7 @@
|
|||||||
>
|
>
|
||||||
{{ $t("environment.nested_overflow") }}
|
{{ $t("environment.nested_overflow") }}
|
||||||
</div>
|
</div>
|
||||||
<div class="border divide-y rounded divide-dividerLight border-divider">
|
<div class="border rounded divide-y divide-dividerLight border-divider">
|
||||||
<div
|
<div
|
||||||
v-for="(variable, index) in vars"
|
v-for="(variable, index) in vars"
|
||||||
:key="`variable-${index}`"
|
:key="`variable-${index}`"
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="flex flex-1 overflow-auto border-l rounded-r border-divider transition bg-primaryLight whitespace-nowrap hide-scrollbar"
|
class="flex flex-1 overflow-auto border-l rounded-r transition border-divider bg-primaryLight whitespace-nowrap hide-scrollbar"
|
||||||
>
|
>
|
||||||
<SmartEnvInput
|
<SmartEnvInput
|
||||||
v-model="newEndpoint"
|
v-model="newEndpoint"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
class="hide-scrollbar !overflow-auto flex flex-col"
|
class="hide-scrollbar !overflow-auto flex flex-col"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="sticky top-0 z-10 flex flex-shrink-0 p-4 space-x-2 overflow-x-auto bg-primary hide-scrollbar"
|
class="sticky top-0 z-10 flex flex-shrink-0 p-4 overflow-x-auto space-x-2 bg-primary hide-scrollbar"
|
||||||
>
|
>
|
||||||
<div class="inline-flex flex-1 space-x-2">
|
<div class="inline-flex flex-1 space-x-2">
|
||||||
<div class="flex flex-1">
|
<div class="flex flex-1">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="flex flex-1 flex-shrink-0 items-center whitespace-nowrap overflow-auto hide-scrollbar"
|
class="flex items-center flex-1 flex-shrink-0 overflow-visible whitespace-nowrap hide-scrollbar"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
ref="editor"
|
ref="editor"
|
||||||
@@ -32,6 +32,7 @@ import {
|
|||||||
} from "@codemirror/view"
|
} from "@codemirror/view"
|
||||||
import { EditorState, Extension } from "@codemirror/state"
|
import { EditorState, Extension } from "@codemirror/state"
|
||||||
import clone from "lodash/clone"
|
import clone from "lodash/clone"
|
||||||
|
import { tooltips } from "@codemirror/tooltip"
|
||||||
import { inputTheme } from "~/helpers/editor/themes/baseTheme"
|
import { inputTheme } from "~/helpers/editor/themes/baseTheme"
|
||||||
import { HoppReactiveEnvPlugin } from "~/helpers/editor/extensions/HoppEnvironment"
|
import { HoppReactiveEnvPlugin } from "~/helpers/editor/extensions/HoppEnvironment"
|
||||||
import { useReadonlyStream } from "~/helpers/utils/composables"
|
import { useReadonlyStream } from "~/helpers/utils/composables"
|
||||||
@@ -92,10 +93,12 @@ watch(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
|
flush: "sync",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
let clipboardEv: ClipboardEvent | null = null
|
let clipboardEv: ClipboardEvent | null = null
|
||||||
|
let pastedValue: string | null = null
|
||||||
|
|
||||||
const aggregateEnvs = useReadonlyStream(aggregateEnvs$, []) as Ref<
|
const aggregateEnvs = useReadonlyStream(aggregateEnvs$, []) as Ref<
|
||||||
AggregateEnvironment[]
|
AggregateEnvironment[]
|
||||||
@@ -116,11 +119,15 @@ const envTooltipPlugin = new HoppReactiveEnvPlugin(envVars, view)
|
|||||||
const initView = (el: any) => {
|
const initView = (el: any) => {
|
||||||
const extensions: Extension = [
|
const extensions: Extension = [
|
||||||
inputTheme,
|
inputTheme,
|
||||||
|
tooltips({
|
||||||
|
position: "absolute",
|
||||||
|
}),
|
||||||
envTooltipPlugin,
|
envTooltipPlugin,
|
||||||
placeholderExt(props.placeholder),
|
placeholderExt(props.placeholder),
|
||||||
EditorView.domEventHandlers({
|
EditorView.domEventHandlers({
|
||||||
paste(ev) {
|
paste(ev) {
|
||||||
clipboardEv = ev
|
clipboardEv = ev
|
||||||
|
pastedValue = ev.clipboardData?.getData("text") ?? ""
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
ViewPlugin.fromClass(
|
ViewPlugin.fromClass(
|
||||||
@@ -145,15 +152,16 @@ const initView = (el: any) => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (pasted && clipboardEv) {
|
if (pasted && clipboardEv) {
|
||||||
const evHandle = clipboardEv
|
const pastedVal = pastedValue
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
emit("paste", {
|
emit("paste", {
|
||||||
pastedValue: evHandle.clipboardData?.getData("text") ?? "",
|
pastedValue: pastedVal!,
|
||||||
prevValue,
|
prevValue,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
clipboardEv = null
|
clipboardEv = null
|
||||||
|
pastedValue = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ import {
|
|||||||
MatchDecorator,
|
MatchDecorator,
|
||||||
ViewPlugin,
|
ViewPlugin,
|
||||||
} from "@codemirror/view"
|
} from "@codemirror/view"
|
||||||
|
import * as E from "fp-ts/Either"
|
||||||
import { StreamSubscriberFunc } from "~/helpers/utils/composables"
|
import { StreamSubscriberFunc } from "~/helpers/utils/composables"
|
||||||
import {
|
import {
|
||||||
AggregateEnvironment,
|
AggregateEnvironment,
|
||||||
aggregateEnvs$,
|
aggregateEnvs$,
|
||||||
getAggregateEnvs,
|
getAggregateEnvs,
|
||||||
} from "~/newstore/environments"
|
} from "~/newstore/environments"
|
||||||
|
import { parseTemplateStringE } from "~/helpers/templating"
|
||||||
|
|
||||||
const HOPP_ENVIRONMENT_REGEX = /(<<\w+>>)/g
|
const HOPP_ENVIRONMENT_REGEX = /(<<\w+>>)/g
|
||||||
|
|
||||||
@@ -59,22 +61,27 @@ const cursorTooltipField = (aggregateEnvs: AggregateEnvironment[]) =>
|
|||||||
// env.key === word.slice(wordSelection.from + 2, wordSelection.to - 2)
|
// env.key === word.slice(wordSelection.from + 2, wordSelection.to - 2)
|
||||||
)?.sourceEnv ?? "choose an environment"
|
)?.sourceEnv ?? "choose an environment"
|
||||||
|
|
||||||
const envValue = (
|
const envValue =
|
||||||
aggregateEnvs.find(
|
aggregateEnvs.find(
|
||||||
(env) => env.key === text.slice(start - from, end - from)
|
(env) => env.key === text.slice(start - from, end - from)
|
||||||
// env.key === word.slice(wordSelection.from + 2, wordSelection.to - 2)
|
// env.key === word.slice(wordSelection.from + 2, wordSelection.to - 2)
|
||||||
)?.value ?? "not found"
|
)?.value ?? "not found"
|
||||||
).replace(/"/g, """)
|
|
||||||
|
|
||||||
const textContent = `${envName} <xmp>${envValue}</xmp>`
|
const result = parseTemplateStringE(envValue, aggregateEnvs)
|
||||||
|
|
||||||
|
const finalEnv = E.isLeft(result) ? "error" : result.right
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pos: start,
|
pos: start,
|
||||||
end: to,
|
end: to,
|
||||||
above: true,
|
above: true,
|
||||||
|
arrow: true,
|
||||||
create() {
|
create() {
|
||||||
const dom = document.createElement("span")
|
const dom = document.createElement("span")
|
||||||
dom.innerHTML = textContent
|
const xmp = document.createElement("xmp")
|
||||||
|
xmp.textContent = finalEnv
|
||||||
|
dom.appendChild(document.createTextNode(`${envName} `))
|
||||||
|
dom.appendChild(xmp)
|
||||||
dom.className = "tooltip-theme"
|
dom.className = "tooltip-theme"
|
||||||
return { dom }
|
return { dom }
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user