Skip to content

Commit

Permalink
REST API 페이지에서 새 창으로 열기 동작(ctrl + click) 허용
Browse files Browse the repository at this point in the history
  • Loading branch information
CirnoV committed Dec 19, 2024
1 parent 9f1a843 commit cb4ecd7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/layouts/rest-api/category/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ export function Category(props: CategoryProps) {
"opacity-50": endpoint.deprecated || endpoint.unstable,
}}
onClick={(e) => {
if (
e.ctrlKey ||
e.metaKey ||
e.shiftKey ||
e.button !== 0
)
return;
e.preventDefault();
expandAndScrollTo({
section: props.section,
Expand Down
3 changes: 3 additions & 0 deletions src/layouts/rest-api/category/type-def.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export function TypeDefinitions(props: TypeDefinitionsProps) {
class="underline-offset-4 transition-colors hover:text-orange-5 hover:underline"
href={href}
onClick={(e) => {
if (e.ctrlKey || e.metaKey || e.shiftKey || e.button !== 0)
return;
e.preventDefault();
expandAndScrollTo({
section: "type-def",
Expand Down Expand Up @@ -510,6 +512,7 @@ function TypeReprDoc(props: TypeReprDocProps) {
class="inline-block text-green-6 font-bold underline-offset-4 transition-colors hover:text-orange-5 hover:underline"
href={href()}
onClick={(e) => {
if (e.ctrlKey || e.metaKey || e.shiftKey || e.button !== 0) return;
e.preventDefault();
expandAndScrollTo({
section: "type-def",
Expand Down
5 changes: 2 additions & 3 deletions src/layouts/rest-api/misc/ApiLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ export default function ApiLink({
}: ApiLinkProps) {
const id = getEndpointRepr({ method, path });
const href = `${basepath}/${section}#${encodeURIComponent(id)}`;
const className =
"hover:text-orange-5 hover:border-orange-2 border-b-2 transition-colors";
return (
<a
className={className}
class="border-b-2 transition-colors hover:border-orange-2 hover:text-orange-5"
href={href}
onClick={(e) => {
if (e.ctrlKey || e.metaKey || e.shiftKey || e.button !== 0) return;
e.preventDefault();
expandAndScrollTo({ section, href, id });
}}
Expand Down

0 comments on commit cb4ecd7

Please sign in to comment.