diff --git a/embark-ui/public/index.html b/embark-ui/public/index.html index 4a59b05c..b4e9f3a8 100644 --- a/embark-ui/public/index.html +++ b/embark-ui/public/index.html @@ -37,5 +37,20 @@ To begin the development, run `npm start` or `yarn start`. To create a production bundle, use `npm run build` or `yarn build`. --> + + + diff --git a/embark-ui/public/monaco-editor-worker-loader-proxy.js b/embark-ui/public/monaco-editor-worker-loader-proxy.js new file mode 100644 index 00000000..0585b5c0 --- /dev/null +++ b/embark-ui/public/monaco-editor-worker-loader-proxy.js @@ -0,0 +1,5 @@ +self.MonacoEnvironment = { + baseUrl: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.13.1/min/' +}; + +importScripts('https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.13.1/min/vs/base/worker/workerMain.js'); // eslint-disable-line diff --git a/embark-ui/src/actions/index.js b/embark-ui/src/actions/index.js index 2836ce33..130e7a13 100644 --- a/embark-ui/src/actions/index.js +++ b/embark-ui/src/actions/index.js @@ -20,6 +20,8 @@ export const accounts = { failure: (error) => action(ACCOUNTS[FAILURE], {error}) }; +// Fiddle +export const FIDDLE_CODE_CHANGE = 'FIDDLE_CODE_CHANGE'; export const ACCOUNT = createRequestTypes('ACCOUNT'); export const account = { request: (address) => action(ACCOUNT[REQUEST], {address}), @@ -143,8 +145,8 @@ export function listenToContractLogs() { }; } -export function initBlockHeader(){ +export function fiddleCodeChange(){ return { - type: INIT_BLOCK_HEADER + type: FIDDLE_CODE_CHANGE }; } diff --git a/embark-ui/src/components/Fiddle.js b/embark-ui/src/components/Fiddle.js index f57fcdcc..b364b416 100644 --- a/embark-ui/src/components/Fiddle.js +++ b/embark-ui/src/components/Fiddle.js @@ -1,11 +1,26 @@ import React from 'react'; +import MonacoEditor from 'react-monaco-editor'; -const Fiddle = () => ( - -

Fiddle

-

Play around with contract code and deploy against your running node.

-
+const Fiddle = ({code, options, editorDidMount, onChange}) => { + options = options || { + selectOnLineNumbers: true + }; + return ( + +

Fiddle

+

Play around with contract code and deploy against your running node.

+
-); + ); +}; + export default Fiddle; diff --git a/embark-ui/src/containers/FiddleContainer.js b/embark-ui/src/containers/FiddleContainer.js index 8ab5a6e7..d3fb17b3 100644 --- a/embark-ui/src/containers/FiddleContainer.js +++ b/embark-ui/src/containers/FiddleContainer.js @@ -1,44 +1,54 @@ -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { fetchAccounts } from '../actions'; +import React, {Component} from 'react'; +import {connect} from 'react-redux'; +import {fiddleCodeChange} from '../actions'; import Fiddle from '../components/Fiddle'; class FiddleContainer extends Component { componentWillMount() { - this.props.fetchAccounts(); + //this.props.fetchAccounts(); } render() { - const { accounts } = this.props; - if (!accounts.data) { - return ( -

- Loading accounts... -

- ) - } + // const { accounts } = this.props; + // if (!accounts.data) { + // return ( + //

+ // Loading accounts... + //

+ // ) + // } - if (accounts.error) { - return ( -

- Error API... -

- ) - } + // if (accounts.error) { + // return ( + //

+ // Error API... + //

+ // ) + // } + const options = { + selectOnLineNumbers: true, + roundedSelection: false, + readOnly: false, + cursorStyle: 'line', + automaticLayout: false, + }; + const code = 'hello world'; return ( - + ); } -}; - +} function mapStateToProps(state) { - return { accounts: state.accounts } + return { + code: state.code, + options: state.options + }; } export default connect( mapStateToProps, { - fetchAccounts + fiddleCodeChange }, -)(FiddleContainer) +)(FiddleContainer); diff --git a/package-lock.json b/package-lock.json index 47379b1d..b290c330 100644 --- a/package-lock.json +++ b/package-lock.json @@ -989,6 +989,15 @@ "@types/node": "*" } }, + "@types/react": { + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.4.7.tgz", + "integrity": "sha512-tHpSs7HMyjnpyfzka1G0pYh7rBNdpwGgcIDT4vfV6jUaR69yOHo/vNH2H+d9iYHo9xnX4qDe7UalPe9HiGRkLw==", + "dev": true, + "requires": { + "csstype": "^2.2.0" + } + }, "@types/semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-5.5.0.tgz", @@ -3514,6 +3523,12 @@ "source-map": "^0.5.3" } }, + "csstype": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.5.6.tgz", + "integrity": "sha512-tKPyhy0FmfYD2KQYXD5GzkvAYLYj96cMLXr648CKGd3wBe0QqoPipImjGiLze9c8leJK8J3n7ap90tpk3E6HGQ==", + "dev": true + }, "cyclist": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-0.2.2.tgz", @@ -7897,6 +7912,12 @@ "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-4.5.0.tgz", "integrity": "sha512-qqudNfOX7ZmX9vm1WIAU+gWlmxVNAnwY6UG3RkFutNywmRCUGP83tujP6IxX2DS1TmcaEZBOhYwDuYEmJYE+3w==" }, + "monaco-editor": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.13.1.tgz", + "integrity": "sha512-0Kssg/O3cl1tXP0qAIxhrtMbRnzusFUEvFyt5/fpUbmuVeY3z+TnUx13+3kW16pgacFPXGUTEO/hOPlDeFU/dw==", + "dev": true + }, "mout": { "version": "0.11.1", "resolved": "https://registry.npmjs.org/mout/-/mout-0.11.1.tgz", @@ -9893,6 +9914,17 @@ } } }, + "react-monaco-editor": { + "version": "0.17.2", + "resolved": "https://registry.npmjs.org/react-monaco-editor/-/react-monaco-editor-0.17.2.tgz", + "integrity": "sha512-/Zm0xJRxu66pCdz6Pth3oUq6g4rE/RD7bFh4rKywS8wLl2uzsKdftK5GqlCPepx0sRR2BXPN+EG/Nl0Pr+BpjA==", + "dev": true, + "requires": { + "@types/react": "*", + "monaco-editor": "^0.13.1", + "prop-types": "^15.6.1" + } + }, "read": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz", diff --git a/package.json b/package.json index 9195ccfd..08d97f48 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "parse-json": "^4.0.0", "promptly": "^2.1.0", "propose": "0.0.5", + "react-scripts": "^1.1.4", "request": "^2.85.0", "serve-static": "^1.11.1", "shelljs": "^0.5.0", @@ -107,6 +108,7 @@ "eslint": "4.13.1", "eslint-plugin-react": "^7.10.0", "mocha-sinon": "^1.1.4", + "react-monaco-editor": "^0.17.2", "sinon": "^4.5.0" } }