Skip to content

Commit

Permalink
httpsnippet 하이라이팅 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
CirnoV committed Apr 20, 2024
1 parent 7033507 commit 05dc57a
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/layouts/rest-api/endpoint/playground/try/ReqSample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,32 @@ export interface ReqSampleProps {
harRequestSignal: Signal<HarRequest | undefined>;
}

const availableTargets = _availableTargets();
const httpSnippetLanguageMap = new Map(
Object.entries({
c: "c",
clojure: "clojure",
csharp: "csharp",
go: "go",
java: "java",
javascript: "javascript",
kotlin: "kotlin",
node: "javascript",
objc: "objective-c",
php: "php",
powershell: "powershell",
python: "python",
r: "r",
ruby: "ruby",
shell: "shell",
swift: "swift",
}),
);
const availableTargets = _availableTargets()
.map((target) => ({
...target,
language: httpSnippetLanguageMap.get(target.key),
}))
.filter((target) => target.language);
type AvailableTarget = (typeof availableTargets)[number];
type ClientInfo = AvailableTarget["clients"][number];

Expand Down Expand Up @@ -79,7 +104,7 @@ export default function ReqSample({ harRequestSignal }: ReqSampleProps) {
monaco.editor.create(domElement, {
...commonEditorConfig,
value: snippetSignal.value || "",
language: targetInfoSignal.value?.key || "plaintext",
language: targetInfoSignal.value?.language ?? "plaintext",
readOnly: true,
})
}
Expand Down

0 comments on commit 05dc57a

Please sign in to comment.