Skip to content

Commit

Permalink
fix: codeEditor error
Browse files Browse the repository at this point in the history
  • Loading branch information
echoxyc committed Nov 17, 2022
1 parent 0b0eb95 commit b033b7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const Evaluate: FC<{ type: string; data?: any }> = (props) => {
<Trigger
_css={css`
padding-right: 4px;
z-index: 10;
`}
content={
<div css={evaluationTriggerStyle}>
Expand All @@ -68,8 +69,9 @@ const Evaluate: FC<{ type: string; data?: any }> = (props) => {

const handleTernCompletions = (data: TypeQueryResult): TransQuery => {
const result: TransQuery = data ?? {}
if (data.doc?.slice(0, 1) === "{") {
const format = JSON.parse(data.doc)
const doc = atob(data?.doc ?? "")
if (doc?.slice(0, 1) === "{") {
const format = JSON.parse(doc)
result["data"] = format.data
result["path"] = format.path
result["name"] = format.path
Expand Down
8 changes: 4 additions & 4 deletions apps/builder/src/components/CodeEditor/TernSever/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const transDataToDefs = (
const def: Record<string, any> = {}
if (current) {
path = path ? path + "." + current : current
def["!doc"] = JSON.stringify({ path, data })
def["!doc"] = btoa(JSON.stringify({ path, data }))
}
for (const dataKey in data) {
let newPath = path ? path + "." + dataKey : dataKey
Expand All @@ -84,12 +84,12 @@ const transDataToDefs = (
def[dataKey] = {
...d,
...transDataToDefs(d),
"!doc": JSON.stringify({ path: newPath, data: data[dataKey] }),
"!doc": btoa(JSON.stringify({ path: newPath, data: data[dataKey] })),
}
} else {
def[dataKey] = {
"!type": transTernTypeName(data[dataKey]),
"!doc": JSON.stringify({ path: newPath, data: data[dataKey] }),
"!doc": btoa(JSON.stringify({ path: newPath, data: data[dataKey] })),
}
}
}
Expand Down Expand Up @@ -134,7 +134,7 @@ const filterDataWithCallBack = (
callback?: (key: string) => boolean,
) => {
return JSON.parse(
JSON.stringify(data, function(key, value) {
JSON.stringify(data, function (key, value) {
if (callback && callback(key)) {
return undefined
} else {
Expand Down

0 comments on commit b033b7a

Please sign in to comment.