Update `printWidth` to 100

pull/2748/head
Alex Dima 2020-09-21 14:31:41 +02:00
parent 365af6fa65
commit c5586a25cf
No known key found for this signature in database
GPG Key ID: 6E58D7B045760DA0
24 changed files with 81 additions and 207 deletions

7
.prettierignore 100644
View File

@ -0,0 +1,7 @@
/browser-esm-parcel/.cache/
/browser-esm-parcel/dist/
/browser-esm-webpack/dist/*.js
/browser-esm-webpack-monaco-plugin/dist/*.js
/browser-esm-webpack-small/dist/*.js
/browser-esm-webpack-typescript/dist/*.js
/browser-esm-webpack-typescript-react/dist/*.js

View File

@ -3,5 +3,6 @@
"singleQuote": true,
"trailingComma": "none",
"semi": true,
"useTabs": true
"useTabs": true,
"printWidth": 100
}

View File

@ -5,23 +5,16 @@
</head>
<body>
<h2>Monaco Diff Editor Sample</h2>
<div
id="container"
style="width: 800px; height: 600px; border: 1px solid grey"
></div>
<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
<script>
require.config({ paths: { vs: '../node_modules/monaco-editor/min/vs' } });
require(['vs/editor/editor.main'], function () {
var diffEditor = monaco.editor.createDiffEditor(
document.getElementById('container')
);
var diffEditor = monaco.editor.createDiffEditor(document.getElementById('container'));
Promise.all([xhr('original.txt'), xhr('modified.txt')]).then(function (
r
) {
Promise.all([xhr('original.txt'), xhr('modified.txt')]).then(function (r) {
var originalTxt = r[0].responseText;
var modifiedTxt = r[1].responseText;
@ -44,10 +37,7 @@
}
if (req.readyState === 4) {
if (
(req.status >= 200 && req.status < 300) ||
req.status === 1223
) {
if ((req.status >= 200 && req.status < 300) || req.status === 1223) {
c(req);
} else {
e(req);

View File

@ -6,10 +6,7 @@
</head>
<body>
<h2>Monaco Editor Sample</h2>
<div
id="container"
style="width: 800px; height: 600px; border: 1px solid grey"
></div>
<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
<!-- OR ANY OTHER AMD LOADER HERE INSTEAD OF loader.js -->
<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
@ -17,17 +14,10 @@
require.config({ paths: { vs: '../node_modules/monaco-editor/min/vs' } });
require(['vs/editor/editor.main'], function () {
var editor = monaco.editor.create(
document.getElementById('container'),
{
value: [
'function x() {',
'\tconsole.log("Hello world!");',
'}'
].join('\n'),
language: 'javascript'
}
);
var editor = monaco.editor.create(document.getElementById('container'), {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'javascript'
});
});
</script>
</body>

View File

@ -20,17 +20,10 @@
require.config({ paths: { vs: '../node_modules/monaco-editor/min/vs' } });
require(['vs/editor/editor.main'], function () {
var editor = monaco.editor.create(
document.getElementById('container'),
{
value: [
'function x() {',
'\tconsole.log("Hello world!");',
'}'
].join('\n'),
language: 'javascript'
}
);
var editor = monaco.editor.create(document.getElementById('container'), {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'javascript'
});
window.onresize = function () {
editor.layout();

View File

@ -5,10 +5,7 @@
</head>
<body>
<h2>Monaco Editor Localization Sample</h2>
<div
id="container"
style="width: 800px; height: 600px; border: 1px solid grey"
></div>
<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
<script>
@ -23,17 +20,10 @@
});
require(['vs/editor/editor.main'], function () {
var editor = monaco.editor.create(
document.getElementById('container'),
{
value: [
'function x() {',
'\tconsole.log("Hello world!");',
'}'
].join('\n'),
language: 'javascript'
}
);
var editor = monaco.editor.create(document.getElementById('container'), {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'javascript'
});
});
</script>
</body>

View File

@ -5,10 +5,7 @@
</head>
<body>
<h2>Monarch Tokenizer Sample</h2>
<div
id="container"
style="width: 800px; height: 600px; border: 1px solid grey"
></div>
<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
<script>
@ -41,14 +38,11 @@
]
});
var editor = monaco.editor.create(
document.getElementById('container'),
{
theme: 'myCoolTheme',
value: getCode(),
language: 'myCustomLanguage'
}
);
var editor = monaco.editor.create(document.getElementById('container'), {
theme: 'myCoolTheme',
value: getCode(),
language: 'myCustomLanguage'
});
});
function getCode() {

View File

@ -5,10 +5,7 @@
</head>
<body>
<h2>Monaco Editor Sample - Loading with requirejs</h2>
<div
id="container"
style="width: 800px; height: 600px; border: 1px solid grey"
></div>
<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.min.js"
@ -19,17 +16,10 @@
require.config({ paths: { vs: '../node_modules/monaco-editor/min/vs' } });
require(['vs/editor/editor.main'], function () {
var editor = monaco.editor.create(
document.getElementById('container'),
{
value: [
'function x() {',
'\tconsole.log("Hello world!");',
'}'
].join('\n'),
language: 'javascript'
}
);
var editor = monaco.editor.create(document.getElementById('container'), {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'javascript'
});
});
</script>
</body>

View File

@ -14,10 +14,7 @@
</head>
<body>
<h2>Monaco Editor Sample</h2>
<div
id="container"
style="width: 800px; height: 600px; border: 1px solid grey"
></div>
<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
<!-- OR ANY OTHER AMD LOADER HERE INSTEAD OF loader.js -->
<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
@ -44,9 +41,7 @@
require(['vs/editor/editor.main'], function () {
const editor = monaco.editor.create(innerContainer, {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join(
'\n'
),
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'javascript'
});
});

View File

@ -5,14 +5,8 @@
</head>
<body>
<h2>Monaco Editor Shared Models Sample</h2>
<div
id="container1"
style="width: 400px; height: 200px; border: 1px solid grey"
></div>
<div
id="container2"
style="width: 400px; height: 200px; border: 1px solid grey"
></div>
<div id="container1" style="width: 400px; height: 200px; border: 1px solid grey"></div>
<div id="container2" style="width: 400px; height: 200px; border: 1px solid grey"></div>
<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
<script>
@ -23,18 +17,12 @@
['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
'javascript'
);
var editor1 = monaco.editor.create(
document.getElementById('container1'),
{
model: model
}
);
var editor2 = monaco.editor.create(
document.getElementById('container2'),
{
model: model
}
);
var editor1 = monaco.editor.create(document.getElementById('container1'), {
model: model
});
var editor2 = monaco.editor.create(document.getElementById('container2'), {
model: model
});
});
</script>
</body>

View File

@ -4,10 +4,7 @@
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<div
id="container"
style="width: 800px; height: 600px; border: 1px solid #ccc"
></div>
<div id="container" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
<script src="index.js"></script>
</body>

View File

@ -4,10 +4,7 @@
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<div
id="container"
style="width: 800px; height: 600px; border: 1px solid #ccc"
></div>
<div id="container" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
<script src="./app.bundle.js"></script>
</body>

View File

@ -27,9 +27,7 @@ function getBasicLanguages() {
resolve(
files.map((file) => {
return file
.substring('./node_modules/monaco-editor/esm/'.length)
.replace(/\.js$/, '');
return file.substring('./node_modules/monaco-editor/esm/'.length).replace(/\.js$/, '');
})
);
}
@ -53,14 +51,8 @@ function getAdvancedLanguages() {
resolve(
files
.map((file) =>
file.substring(
'./node_modules/monaco-editor/esm/vs/language/'.length
)
)
.map((file) =>
file.substring(0, file.length - '/monaco.contribution.js'.length)
)
.map((file) => file.substring('./node_modules/monaco-editor/esm/vs/language/'.length))
.map((file) => file.substring(0, file.length - '/monaco.contribution.js'.length))
.map((lang) => `vs/language/${lang}/monaco.contribution`)
);
}
@ -115,18 +107,12 @@ function generateFeatures() {
const files =
fs
.readFileSync(
path.join(
__dirname,
'../node_modules/monaco-editor/esm/vs/editor/edcore.main.js'
)
path.join(__dirname, '../node_modules/monaco-editor/esm/vs/editor/edcore.main.js')
)
.toString() +
fs
.readFileSync(
path.join(
__dirname,
'../node_modules/monaco-editor/esm/vs/editor/editor.all.js'
)
path.join(__dirname, '../node_modules/monaco-editor/esm/vs/editor/editor.all.js')
)
.toString();
files.split(/\r\n|\n/).forEach((line) => {

View File

@ -26,9 +26,7 @@ export const Editor: React.FC = () => {
useEffect(() => {
if (divEl.current) {
editor = monaco.editor.create(divEl.current, {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join(
'\n'
),
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'typescript'
});
}

View File

@ -34,14 +34,8 @@ module.exports = {
{
loader: require.resolve('babel-loader'),
options: {
presets: [
'@babel/preset-env',
'@babel/preset-typescript',
'@babel/preset-react'
],
plugins: [
isDevelopment && require.resolve('react-refresh/babel')
].filter(Boolean)
presets: ['@babel/preset-env', '@babel/preset-typescript', '@babel/preset-react'],
plugins: [isDevelopment && require.resolve('react-refresh/babel')].filter(Boolean)
}
}
]

View File

@ -4,10 +4,7 @@
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<div
id="container"
style="width: 800px; height: 600px; border: 1px solid #ccc"
></div>
<div id="container" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
<script src="./app.bundle.js"></script>
</body>

View File

@ -10,10 +10,7 @@
</head>
<body>
<h2>Monaco Editor Sync Loading Sample</h2>
<div
id="container"
style="width: 800px; height: 600px; border: 1px solid grey"
></div>
<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
<script>
var require = { paths: { vs: '../node_modules/monaco-editor/min/vs' } };
@ -24,9 +21,7 @@
<script>
var editor = monaco.editor.create(document.getElementById('container'), {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join(
'\n'
),
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'javascript'
});
</script>

View File

@ -4,16 +4,13 @@
<meta charset="UTF-8" />
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none'; script-src file: 'sha256-TtwXDwNf27AqcsOrUpfkC3hkt80RRVrp7Xlab9b0ZVk='; style-src 'unsafe-inline' file:; font-src file:"
content="default-src 'none'; script-src file: 'sha256-RtE3AqQ1tBhtcwykhJsEKY7jjCqiGy5yH1mRDwu6gEE='; style-src 'unsafe-inline' file:; font-src file:"
/>
<title>Monaco Editor!</title>
</head>
<body>
<h1>Monaco Editor in Electron!</h1>
<div
id="container"
style="width: 500px; height: 300px; border: 1px solid #ccc"
></div>
<div id="container" style="width: 500px; height: 300px; border: 1px solid #ccc"></div>
</body>
<script>
@ -32,26 +29,17 @@
}
amdRequire.config({
baseUrl: uriFromPath(
path.join(__dirname, '../node_modules/monaco-editor/min')
)
baseUrl: uriFromPath(path.join(__dirname, '../node_modules/monaco-editor/min'))
});
// workaround monaco-css not understanding the environment
self.module = undefined;
amdRequire(['vs/editor/editor.main'], function () {
var editor = monaco.editor.create(
document.getElementById('container'),
{
value: [
'function x() {',
'\tconsole.log("Hello world!");',
'}'
].join('\n'),
language: 'javascript'
}
);
var editor = monaco.editor.create(document.getElementById('container'), {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'javascript'
});
});
})();
</script>

View File

@ -7,9 +7,7 @@
<h2>Monaco Editor Electron Sample</h2>
To run this sample, you need to
<a href="https://github.com/electron/electron/releases"
>download Electron</a
>
<a href="https://github.com/electron/electron/releases">download Electron</a>
and then execute:
<pre>

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none'; script-src file: 'sha256-eUe9D+bk6Fb37s7QPlaxhnIImIQEcnZ1gE7aRcB3yOM='; style-src 'unsafe-inline' file:; font-src file:"
content="default-src 'none'; script-src file: 'sha256-AcqnkP3xWRYJaQ27hijK3b831+qsxvzEoSYt6PfGrRE='; style-src 'unsafe-inline' file:; font-src file:"
/>
<title>Monaco Editor!</title>
<style>
@ -18,9 +18,8 @@
<body>
<h1>Monaco Editor in Electron (without nodeIntegration)!</h1>
Note: Since Electron without nodeIntegration is very similar to a browser,
you can have a look at all the other `browser-` samples, as they should work
just fine. <br /><br />
Note: Since Electron without nodeIntegration is very similar to a browser, you can have a look
at all the other `browser-` samples, as they should work just fine. <br /><br />
<div id="container"></div>
</body>
@ -29,15 +28,10 @@
require.config({ paths: { vs: '../node_modules/monaco-editor/min/vs' } });
require(['vs/editor/editor.main'], function () {
const editor = monaco.editor.create(
document.getElementById('container'),
{
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join(
'\n'
),
language: 'javascript'
}
);
const editor = monaco.editor.create(document.getElementById('container'), {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'javascript'
});
});
</script>
</html>

View File

@ -7,9 +7,7 @@
<h2>Monaco Editor Electron Sample</h2>
To run this sample, you need to
<a href="https://github.com/electron/electron/releases"
>download Electron</a
>
<a href="https://github.com/electron/electron/releases">download Electron</a>
and then execute:
<pre>

View File

@ -48,9 +48,7 @@
self.process.browser = true;
ERequire(['vs/editor/editor.main'], function () {
var editor = monaco.editor.create(document.getElementById('container'), {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join(
'\n'
),
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'javascript',
theme: 'vs-dark'
});

View File

@ -11,10 +11,7 @@
</head>
<body>
<h1>Hello World!</h1>
<div
id="container"
style="width: 500px; height: 300px; border: 1px solid #ccc"
></div>
<div id="container" style="width: 500px; height: 300px; border: 1px solid #ccc"></div>
</body>
<script>
@ -43,9 +40,7 @@
amdRequire(['vs/editor/editor.main'], function () {
var editor = monaco.editor.create(document.getElementById('container'), {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join(
'\n'
),
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'javascript'
});
});

View File

@ -4,6 +4,7 @@
"description": "Samples for using the Monaco Editor",
"main": "index.js",
"scripts": {
"prettier": "prettier --write .",
"simpleserver": "yaserver --root ./ --port 8888"
},
"author": "Microsoft Corporation",