Skip to content

Commit

Permalink
add botbuilderlg lang
Browse files Browse the repository at this point in the history
  • Loading branch information
zhixzhan committed Aug 29, 2019
1 parent fe7b292 commit 3697f71
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 128 deletions.
118 changes: 2 additions & 116 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { render } from "react-dom";
import MonacoEditor, { MonacoDiffEditor } from "../src/index";
import MonacoEditor from "../src/index";

class CodeEditor extends React.Component {
constructor() {
Expand Down Expand Up @@ -67,7 +67,7 @@ class CodeEditor extends React.Component {
<hr />
<MonacoEditor
height="400"
language="typescript"
language="botbuilderlg"
value={code}
options={options}
onChange={this.onChange}
Expand All @@ -79,124 +79,10 @@ class CodeEditor extends React.Component {
}
}

class AnotherEditor extends React.Component {
constructor() {
super();
this.state = {
code: ["{", ' "$schema": "http://myserver/foo-schema.json"', "}"].join(
"\n"
),
language: "json"
};
}

changeLanguage = () => {
this.setState(prev => ({
language: prev.language === "json" ? "javascript" : "json"
}));
};

editorWillMount = monaco => {
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
validate: true,
schemas: [
{
uri: "http://myserver/foo-schema.json",
schema: {
type: "object",
properties: {
p1: {
enum: ["v1", "v2"]
},
p2: {
$ref: "http://myserver/bar-schema.json"
}
}
}
},
{
uri: "http://myserver/bar-schema.json",
schema: {
type: "object",
properties: {
q1: {
enum: ["x1", "x2"]
}
}
}
}
]
});
};

render() {
const { code, language } = this.state;
return (
<div>
<div>
<button onClick={this.changeLanguage} type="button">
Change by setState
</button>
<span style={{ marginLeft: "3em" }}>
Language:
{this.state.language}
</span>
</div>
<hr />
<div>
<MonacoEditor
width="800"
height="300"
language={language}
defaultValue={code}
editorWillMount={this.editorWillMount}
/>
</div>
</div>
);
}
}

class DiffEditor extends React.Component {
constructor() {
super();
this.state = {
code: 'const a = "Hello Monaco"',
original: 'const a = "Hello World"'
};
}

onChange = newValue => {
console.log("onChange", newValue); // eslint-disable-line no-console
};

render() {
const { code, original } = this.state;
return (
<div>
<MonacoDiffEditor
width="800"
height="300"
language="javascript"
value={code}
original={original}
onChange={this.onChange}
/>
</div>
);
}
}

const App = () => (
<div>
<h2>Monaco Editor Sample (controlled mode)</h2>
<CodeEditor />
<hr />
<h2>Another editor (uncontrolled mode)</h2>
<AnotherEditor />
<hr />
<h2>Another editor (showing a diff)</h2>
<DiffEditor />
</div>
);

Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"babel-loader": "^8.0.6",
"css-loader": "^3.1.0",
"file-loader": "^4.1.0",
"monaco-editor-webpack-plugin": "^1.7.0",
"monaco-editor-webpack-plugin": "https://github.com/zhixzhan/monaco-editor-webpack-plugin/releases/download/11.7.1/monaco-editor-webpack-plugin-11.7.1.tgz",
"style-loader": "^0.23.1",
"webpack": "^4.36.1",
"webpack-cli": "^3.3.6",
Expand Down
2 changes: 1 addition & 1 deletion example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = {
},
plugins: [
new MonacoWebpackPlugin({
languages: ["json", "javascript", "typescript"]
languages: ["json", "javascript", "typescript", "botbuilderlg"]
})
],
devServer: { contentBase: "./" },
Expand Down
7 changes: 3 additions & 4 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3121,10 +3121,9 @@ mkdirp@0.5.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0:
dependencies:
minimist "0.0.8"

monaco-editor-webpack-plugin@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/monaco-editor-webpack-plugin/-/monaco-editor-webpack-plugin-1.7.0.tgz#920cbeecca25f15d70d568a7e11b0ba4daf1ae83"
integrity sha512-oItymcnlL14Sjd7EF7q+CMhucfwR/2BxsqrXIBrWL6LQplFfAfV+grLEQRmVHeGSBZ/Gk9ptzfueXnWcoEcFuA==
"monaco-editor-webpack-plugin@https://github.com/zhixzhan/monaco-editor-webpack-plugin/releases/download/11.7.1/monaco-editor-webpack-plugin-11.7.1.tgz":
version "11.7.1"
resolved "https://github.com/zhixzhan/monaco-editor-webpack-plugin/releases/download/11.7.1/monaco-editor-webpack-plugin-11.7.1.tgz#7e085f0c61adb6d912284e235a53cb015e6cb56f"
dependencies:
"@types/webpack" "^4.4.19"

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-monaco-editor",
"version": "1.30.1",
"version": "1.30.5",
"description": "Monaco Editor for React",
"main": "lib/index.js",
"module": "lib/index",
Expand All @@ -9,7 +9,6 @@
"scripts": {
"preversion": "npm run lint",
"build": "babel src --out-dir lib",
"compress": "rimraf release && mkdir release && cp -R lib src package.json README.md LICENSE.md yarn.lock ./release && cd release && tar -cf archive.tar.gz ./",
"clean": "rimraf lib",
"format": "eslint --fix '{src,test,example}/**/*.{ts,js}'",
"lint": "eslint '{src,test,example}/**/*.{ts,js}'",
Expand Down Expand Up @@ -59,7 +58,7 @@
},
"dependencies": {
"@types/react": "^16.9.2",
"monaco-editor": "https://github.com/zhixzhan/monaco-editor/releases/download/1.17.1/archive.tar.gz",
"monaco-editor": "https://github.com/zhixzhan/monaco-editor/releases/download/1.17.5/monaco-editor-1.17.5.tgz",
"prop-types": "^15.7.2"
}
}
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2255,9 +2255,9 @@ mkdirp@^0.5.0, mkdirp@^0.5.1:
dependencies:
minimist "0.0.8"

"monaco-editor@https://github.com/zhixzhan/monaco-editor/releases/download/1.17.1/archive.tar":
version "1.17.1"
resolved "https://github.com/zhixzhan/monaco-editor/releases/download/1.17.1/archive.tar#b64a94e86c25f4540e0d365bcd60ebe7ba84c686"
"monaco-editor@https://github.com/zhixzhan/monaco-editor/releases/download/1.17.5/monaco-editor-1.17.5.tgz":
version "1.17.5"
resolved "https://github.com/zhixzhan/monaco-editor/releases/download/1.17.5/monaco-editor-1.17.5.tgz#d8561c7bf37dce78e9aed87d788bebc8872daca4"

ms@2.0.0:
version "2.0.0"
Expand Down

0 comments on commit 3697f71

Please sign in to comment.