Merge pull request #1813 from ethereum/monacolocal

run monaco from assets
pull/5370/head
bunsenstraat 3 years ago committed by GitHub
commit edd13ea7c7
  1. 12
      apps/remix-ide/webpack.config.js
  2. 10
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
  3. 5
      package-lock.json
  4. 1
      package.json

@ -1,5 +1,7 @@
const nxWebpack = require('@nrwl/react/plugins/webpack') const nxWebpack = require('@nrwl/react/plugins/webpack')
const TerserPlugin = require('terser-webpack-plugin') const TerserPlugin = require('terser-webpack-plugin')
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = config => { module.exports = config => {
const nxWebpackConfig = nxWebpack(config) const nxWebpackConfig = nxWebpack(config)
@ -12,7 +14,15 @@ module.exports = config => {
net: 'empty', net: 'empty',
module: 'empty', module: 'empty',
child_process: 'empty' child_process: 'empty'
} },
plugins: [
...nxWebpackConfig.plugins,
new CopyWebpackPlugin({
patterns: [
{ from: "../../../node_modules/monaco-editor/dev/vs/", to: "assets/js/monaco-editor/dev/vs" },
].filter(Boolean)
})
]
} }
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {

@ -1,5 +1,5 @@
import React, { useState, useRef, useEffect, useReducer } from 'react' // eslint-disable-line import React, { useState, useRef, useEffect, useReducer } from 'react' // eslint-disable-line
import Editor from '@monaco-editor/react' import Editor, { loader } from '@monaco-editor/react'
import { reducerActions, reducerListener, initialState } from './actions/editor' import { reducerActions, reducerListener, initialState } from './actions/editor'
import { language, conf } from './syntax' import { language, conf } from './syntax'
@ -44,6 +44,8 @@ type sourceMarkerMap = {
[key: string]: [sourceMarker]; [key: string]: [sourceMarker];
} }
loader.config({ paths: { vs: 'assets/js/monaco-editor/dev/vs' } })
/* eslint-disable-next-line */ /* eslint-disable-next-line */
export interface EditorUIProps { export interface EditorUIProps {
activated: boolean activated: boolean
@ -288,7 +290,7 @@ export const EditorUI = (props: EditorUIProps) => {
props.editorAPI.getFontSize = () => { props.editorAPI.getFontSize = () => {
if (!editorRef.current) return if (!editorRef.current) return
return editorRef.current.getOption(42).fontSize return editorRef.current.getOption(43).fontSize
} }
(window as any).addRemixBreakpoint = (position) => { // make it available from e2e testing... (window as any).addRemixBreakpoint = (position) => { // make it available from e2e testing...
@ -329,10 +331,10 @@ export const EditorUI = (props: EditorUIProps) => {
} }
}) })
editor.addCommand(monacoRef.current.KeyMod.CtrlCmd | monacoRef.current.KeyCode.US_EQUAL, () => { editor.addCommand(monacoRef.current.KeyMod.CtrlCmd | monacoRef.current.KeyCode.US_EQUAL, () => {
editor.updateOptions({ fontSize: editor.getOption(42).fontSize + 1 }) editor.updateOptions({ fontSize: editor.getOption(43).fontSize + 1 })
}) })
editor.addCommand(monacoRef.current.KeyMod.CtrlCmd | monacoRef.current.KeyCode.US_MINUS, () => { editor.addCommand(monacoRef.current.KeyMod.CtrlCmd | monacoRef.current.KeyCode.US_MINUS, () => {
editor.updateOptions({ fontSize: editor.getOption(42).fontSize - 1 }) editor.updateOptions({ fontSize: editor.getOption(43).fontSize - 1 })
}) })
} }

5
package-lock.json generated

@ -30329,6 +30329,11 @@
} }
} }
}, },
"monaco-editor": {
"version": "0.30.1",
"resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.30.1.tgz",
"integrity": "sha512-B/y4+b2O5G2gjuxIFtCE2EkM17R2NM7/3F8x0qcPsqy4V83bitJTIO4TIeZpYlzu/xy6INiY/+84BEm6+7Cmzg=="
},
"morphdom": { "morphdom": {
"version": "2.6.1", "version": "2.6.1",
"resolved": "https://registry.npmjs.org/morphdom/-/morphdom-2.6.1.tgz", "resolved": "https://registry.npmjs.org/morphdom/-/morphdom-2.6.1.tgz",

@ -179,6 +179,7 @@
"jszip": "^3.6.0", "jszip": "^3.6.0",
"latest-version": "^5.1.0", "latest-version": "^5.1.0",
"merge": "^2.1.1", "merge": "^2.1.1",
"monaco-editor": "^0.30.1",
"npm-install-version": "^6.0.2", "npm-install-version": "^6.0.2",
"react": "^17.0.2", "react": "^17.0.2",
"react-beautiful-dnd": "^13.1.0", "react-beautiful-dnd": "^13.1.0",

Loading…
Cancel
Save