Skip to content

Commit

Permalink
feat: add side editor link
Browse files Browse the repository at this point in the history
  • Loading branch information
JeelRajodiya committed Jul 30, 2024
1 parent db6451b commit 93c0c37
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/components/Mdx/Mdx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import InfoBox from "../InfoBox";
import GoodToKnowBox from "../GoodToKnowBox/GoodToKnowBox";
import rehypeExternalLinks from "rehype-external-links";
import styles from "./Mdx.module.css";
import SideEditorLink from "../SideEditorLink";

function createHeading(level: number): any {
const headingSizes: {
Expand Down Expand Up @@ -86,6 +87,7 @@ const customComponents = {
InfoBox,
GoodToKnowBox,
CodeSnippet,
SideEditorLink,
};
export function CustomMDX(props: MDXRemoteProps) {
return (
Expand Down
7 changes: 7 additions & 0 deletions app/components/SideEditorLink/SideEditorLink.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.main {
cursor: pointer;
color: hsl(var(--link-color));
}
.main:hover {
text-decoration: underline;
}
22 changes: 22 additions & 0 deletions app/components/SideEditorLink/SideEditorLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use client";

import { useEditorStore } from "@/lib/stores";
import React from "react";
import styles from "./SideEditorLink.module.css";

export default function SideEditorLink() {
const editorStore = useEditorStore();
return (
<span
className={styles.main}
onClick={() => {
const range = editorStore.editor.getModel().getFullModelRange();
console.log(range);
editorStore.editor.setSelection(range);
editorStore.editor.focus();
}}
>
side editor
</span>
);
}
1 change: 1 addition & 0 deletions app/components/SideEditorLink/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as default } from "./SideEditorLink";
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Consider you have a JSON document of an employee:
- `age` with value `25` (integer)


You are given an incomplete *schema* for this data on side editor.
You are given an incomplete *schema* for this data on the <SideEditorLink/>

Now, try to Add an `age` property to the *schema* and, using the type [keyword](https://json-schema.org/learn/glossary#keyword) and set it `type` to `integer`.

Expand Down

0 comments on commit 93c0c37

Please sign in to comment.