-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,011 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { MonacoDiffEditor } from '@yuntijs/ui'; | ||
|
||
import { original, value } from './data/diff'; | ||
|
||
export default () => { | ||
return ( | ||
<MonacoDiffEditor | ||
height="300px" | ||
language="javascript" | ||
onChange={input => { | ||
// eslint-disable-next-line no-console | ||
console.log(input); | ||
}} | ||
original={original} | ||
value={value} | ||
width="740px" | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { MonacoEditor } from '@yuntijs/ui'; | ||
import { Segmented, Space } from 'antd'; | ||
import { useState } from 'react'; | ||
|
||
export default () => { | ||
const [files, setFiles] = useState< | ||
Record<string, { name: string; language: string; value: string }> | ||
>({ | ||
'a.json': { | ||
name: 'a.json', | ||
language: 'json', | ||
value: '{ "a": 1 }', | ||
}, | ||
'b.js': { | ||
name: 'b.js', | ||
language: 'javascript', | ||
value: 'var a = 1', | ||
}, | ||
'c.sql': { | ||
name: 'c.sql', | ||
language: 'sql', | ||
value: 'SELECT * from table where id = 1', | ||
}, | ||
}); | ||
const [fileName, setFileName] = useState('a.json'); | ||
const file = files[fileName]; | ||
|
||
return ( | ||
<Space direction="vertical" size="large"> | ||
<Segmented | ||
onChange={value => setFileName(value as string)} | ||
options={Object.keys(files)} | ||
value={fileName} | ||
/> | ||
<MonacoEditor | ||
defaultValue={file.value} | ||
height={40} | ||
language={file.language} | ||
onChange={next => { | ||
setFiles(v => ({ | ||
...v, | ||
[file.name]: { | ||
...v[file.name], | ||
value: next, | ||
}, | ||
})); | ||
}} | ||
path={file.name} | ||
saveViewState={true} | ||
width={600} | ||
/> | ||
</Space> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* iframe: true | ||
* compact: true | ||
*/ | ||
import { MonacoEditor } from '@yuntijs/ui'; | ||
|
||
export default () => { | ||
return ( | ||
<div style={{ padding: 24 }}> | ||
<MonacoEditor | ||
defaultValue={`import { MonacoEditor } from '@yuntijs/ui'; | ||
export default () => { | ||
return ( | ||
<MonacoEditor | ||
defaultValue={\`const value = function hello() { | ||
alert('Hello world! Monaco version is 0.33.0'); | ||
}\`} | ||
language="javascript" | ||
onChange={(next) => { | ||
// eslint-disable-next-line no-console | ||
console.log(next); | ||
}} | ||
version="0.33.0" | ||
/> | ||
) | ||
};`} | ||
editorDidMount={(monaco, editor) => { | ||
// eslint-disable-next-line no-console | ||
console.log(monaco, editor); | ||
}} | ||
height={240} | ||
language="javascript" | ||
onChange={next => { | ||
// eslint-disable-next-line no-console | ||
console.log(next); | ||
}} | ||
version="0.19.3" | ||
/> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* iframe: true | ||
* compact: true | ||
*/ | ||
import { MonacoEditor } from '@yuntijs/ui'; | ||
|
||
import { jsValue } from './data'; | ||
|
||
export default () => { | ||
return ( | ||
<div | ||
style={{ | ||
padding: 24, | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
background: '#fff', | ||
height: '100vh', | ||
}} | ||
> | ||
<MonacoEditor | ||
defaultValue={jsValue} | ||
height={200} | ||
language="javascript" | ||
onChange={next => { | ||
// eslint-disable-next-line no-console | ||
console.log(next); | ||
}} | ||
version="0.19.3" | ||
width={740} | ||
/> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.