Skip to content

Commit

Permalink
fix: international build (#1843)
Browse files Browse the repository at this point in the history
  • Loading branch information
gagdiez authored Mar 25, 2024
1 parent 73854a6 commit 87e153f
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions website/src/components/social-widget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React, { useState, useEffect } from "react";
import { useWallet } from '@theme/scripts/wallet-selector';
import BrowserOnly from '@docusaurus/BrowserOnly';
import "react-bootstrap-typeahead/css/Typeahead.css";
import "react-bootstrap-typeahead/css/Typeahead.bs5.css";

export function WidgetEditor({ children, id = 1, height = "160px" }) {

return (
<BrowserOnly fallback={<div> Loading... </div>}>
{() => {
let startCode = '';
try {
if (!children.length) children = [children]
startCode = children[0].props.children.props.children;
} catch (e) { }
const { Widget, useInitNear } = require('near-social-vm');
const MonacoEditor = require('react-monaco-editor').default;

const [code, setCode] = useState(startCode);
const { initNear } = useInitNear();
const { selector } = useWallet();

useEffect(() => {
initNear && selector && initNear({ networkId: 'testnet', selector });
}, [initNear, selector]);

return <div>
<div className="monaco">
<MonacoEditor
height={height}
value={code}
options={{
minimap: { enabled: false },
wordWrap: 'on',
scrollBeyondLastLine: false,
fontSize: '14px',
renderLineHighlight: false,
hideMargin: true,
glyphMargin: false,
folding: false,
lineNumbers: false,
lineDecorationsWidth: 0,
lineNumbersMinChars: 0,
scrollBars: false,
}}
onChange={(newValue, event) => setCode(newValue)}
/>
</div>

<div className="code_iframe">
<div className="bootstrap-scope">
<div className="vm-widget">
<Widget code={code} key={id} />
</div>
</div>
</div>
{children[1]}
</div>
}}
</BrowserOnly>
)
}

export default WidgetEditor;

0 comments on commit 87e153f

Please sign in to comment.