Skip to content

Commit

Permalink
fix: monaco-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
isordo committed Oct 12, 2023
1 parent 085b3b2 commit f955d94
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Generated files
.docusaurus
.cache-loader
.yarn

# Misc
.DS_Store
Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
6 changes: 1 addition & 5 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ const config = {
docId: "wallet/getting-started/web/getting-started",
label: "Wallets",
},
{
href: "https://stackblitz.com/edit/vitejs-vite-71wsul?file=src%2Fmain.ts&terminal=dev",
label: "Playground",
position: "right",
},
{ to: "playground/", label: "Playground", position: "right" },
{
href: "https://debug.walletbeacon.io",
label: "Debug Wallet",
Expand Down
75 changes: 52 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"@docusaurus/preset-classic": "2.4.3",
"@docusaurus/theme-live-codeblock": "^2.4.3",
"@mdx-js/react": "^1.6.22",
"@monaco-editor/react": "^4.6.0",
"@taquito/beacon-wallet": "^17.3.1",
"@taquito/taquito": "^17.3.1",
"clsx": "^1.2.1",
"mermaid": "^10.4.0",
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-monaco-editor": "^0.54.0"
"react-dom": "^17.0.2"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.4.3",
Expand Down
18 changes: 10 additions & 8 deletions src/components/Monaco.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Suspense, lazy } from "react";
import { useColorMode } from "@docusaurus/theme-common";
import { libs } from "./monaco-types";

const MonacoEditor = lazy(() => import("react-monaco-editor"));
import Editor from "@monaco-editor/react";

function Monaco(props) {
let monacoRef;
Expand Down Expand Up @@ -45,18 +45,20 @@ function Monaco(props) {
monacoRef.editor.createModel(
props.value,
"typescript",
monacoRef.Uri.parse(`file:///main-${Math.random()}.ts`),
),
monacoRef.Uri.parse(`file:///main-${Math.random()}.ts`)
)
);
}

return (
<Suspense fallback={<div>Loading</div>}>
<MonacoEditor
{...props}
editorWillMount={onEditorWillMount}
editorDidMount={onEditorDidMount}
theme={colorMode === "dark" ? "vs-dark" : "vs-light"}
<Editor
height="90vh"
defaultLanguage="typescript"
defaultValue="// some comment"
beforeMount={onEditorWillMount}
onMount={onEditorDidMount}
theme={colorMode === "dark" ? "vs-dark" : "light"}
/>
</Suspense>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/RunnableCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import BrowserOnly from "@docusaurus/BrowserOnly";
const Child = ({ code }) => {
const { DAppClient } = require("../node_modules/beacon-sdk/dist/cjs");

const Monaco = require("./Monaco");
const Monaco = require("./Monaco").default;

const { copyShareUrl, runBeaconCode } = require("../utils");

Expand Down
2 changes: 1 addition & 1 deletion src/pages/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function Playground() {
<BrowserOnly fallback={<></>}>
{() => {
const { DAppClient } = require("@airgap/beacon-sdk");
const { Monaco } = require("@site/src/components/Monaco");
const Monaco = require("@site/src/components/Monaco").default;
const { copyShareUrl, runBeaconCode } = require("../utils");

const execute = async () => {
Expand Down

0 comments on commit f955d94

Please sign in to comment.