Giter Club home page Giter Club logo

base-editor's Introduction

monaco-base-ide

如何使用

安装

npm install yuzai-base-editor

使用

import { MultiEditor } from 'yuzai-base-editor';

function IDE() {
    const defaultFiles = {
        '/src/app.jsx': `
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';

(async () => {
  const {Button} = await import('./Button.jsx');
  const root = document.getElementById('root');
  ReactDOM.render((
    <div>
      <Button>Direct</Button>
    </div>
  ), root);
})();
`,
        '/src/app.css': 'body { background: #fff }',
        '/index.html': `
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="root"></div>
<script type="importmap">
    {
    "imports": {
        "react": "https://cdn.skypack.dev/react",
        "react-dom": "https://cdn.skypack.dev/react-dom",
        "lodash": "https://cdn.skypack.dev/lodash"
    }
    }
</script>
<script type="module">
    import './app/index.jsx';
    import './index.js';
</script>
</body>
</html>
                    `,
        '/src/test.ts': `
import { add } from './cc';

const App = () => {
    console.log(add(1, 2));
};

export default App;
`,
        '/src/cc.ts': `
export function add(a, b) {
    return a + b;
}

export function minus(a, b) {
    return a - b;
}
`
    }
    return (
        <div style={{ width: '800px', height: '600px' }}>
            <MultiEditor 
                defaultFiles={defaultFiles}
                options={{
                    fontSize: 14,
                    automaticLayout: true,
                }} />
        </div>
    )
}

export default IDE;

组件参数及方法

查看此文档

base-editor's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

base-editor's Issues

Code Navigation not working from one file to another

Scenario:

File1.js -



<line:10> export const isOdd(n: number) : boolean {
                   return n%2 ===1;
          } 

File2.js -

<line:1> export {isOdd} from ./File1.js;

<line:2> const repsonse = isOdd(5);

Current behavior - Clicking on line:2 in File2.js takes us to line 1 in the same file i.e. File2.js

Expected/Right behavior - Clicking on line:2 in File2.js leads us to File1.js line:10. This is identical to the Visual Studio editor or any online multi-file editor, such as codesandbox, stackblitz, etc.

We are planning to use your repo in our organization code so can you please fix this asap?

Many thanks in advance!!!

多文件编辑时,文件路径有中文或者特殊字符会被转义,应该怎么处理

function App() {
const defaultFiles = {
'/src/app.jsx': `
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';

(async () => {
const {Button} = await import('./Button.jsx');
const root = document.getElementById('root');
ReactDOM.render((

Direct
), root); })(); `, '/src/app.css': 'body { background: #fff }', '/index.html': `
<script type="importmap"> { "imports": { "react": "https://cdn.skypack.dev/react", "react-dom": "https://cdn.skypack.dev/react-dom", "lodash": "https://cdn.skypack.dev/lodash" } } </script> <script type="module"> import './app/index.jsx'; import './index.js'; </script> `, '/src/@test.ts': ` import { add } from './index/cc';

const App = () => {
console.log(add(1, 2));
};

export default App;
, '/src/@index/cc.ts':
export function add(a, b) {
return a + b;
}

export function minus(a, b) {
return a - b;
}
`
}
return (
<div style={{ width: '800px', height: '600px' }}>
<MultiEditor

          defaultFiles={defaultFiles}
          options={{
              fontSize: 14,
              automaticLayout: true,

          }} />
  </div>

)
}

export default App;

image

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.