mirror of
https://github.com/microsoft/monaco-editor.git
synced 2024-11-25 16:35:44 +08:00
Run prettier
This commit is contained in:
parent
a66f20ee2e
commit
edb439d4f6
@ -1,6 +1,7 @@
|
||||
/out/
|
||||
/monaco-editor-samples/browser-esm-parcel/.cache/
|
||||
/monaco-editor-samples/browser-esm-parcel/dist/
|
||||
/monaco-editor-samples/browser-esm-vite-react/dist/**/*.js
|
||||
/monaco-editor-samples/browser-esm-webpack/dist/*.js
|
||||
/monaco-editor-samples/browser-esm-webpack-monaco-plugin/dist/*.js
|
||||
/monaco-editor-samples/browser-esm-webpack-small/dist/*.js
|
||||
@ -12,5 +13,6 @@
|
||||
/monaco-editor/typedoc/monaco.d.ts
|
||||
/monaco-editor/website/lib/
|
||||
/monaco-editor-webpack-plugin/test/dist/*.js
|
||||
/monaco-editor-webpack-plugin/out/
|
||||
/release/
|
||||
/src/typescript/lib/
|
||||
|
@ -167,7 +167,10 @@ glob('../src/basic-languages/*/*.contribution.ts', { cwd: __dirname }, function
|
||||
// ESM
|
||||
{
|
||||
/** @type {string[]} */
|
||||
const entryPoints = ['src/basic-languages/monaco.contribution.ts', 'src/basic-languages/_.contribution.ts'];
|
||||
const entryPoints = [
|
||||
'src/basic-languages/monaco.contribution.ts',
|
||||
'src/basic-languages/_.contribution.ts'
|
||||
];
|
||||
const external = ['monaco-editor-core', '*/_.contribution'];
|
||||
for (const language of languages) {
|
||||
entryPoints.push(`src/basic-languages/${language}/${language}.contribution.ts`);
|
||||
|
@ -1,12 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>browser-esm-vite-react</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>browser-esm-vite-react</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,19 +1,19 @@
|
||||
{
|
||||
"name": "browser-esm-vite-react",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"monaco-editor": "^0.30.1",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.0",
|
||||
"@types/react": "^17.0.0",
|
||||
"@types/react-dom": "^17.0.0",
|
||||
"@vitejs/plugin-react": "^1.0.0",
|
||||
"typescript": "^4.4.4",
|
||||
"vite": "^2.6.14"
|
||||
}
|
||||
"name": "browser-esm-vite-react",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"monaco-editor": "^0.30.1",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.0",
|
||||
"@types/react": "^17.0.0",
|
||||
"@types/react-dom": "^17.0.0",
|
||||
"@vitejs/plugin-react": "^1.0.0",
|
||||
"typescript": "^4.4.4",
|
||||
"vite": "^2.6.14"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
.Editor {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
|
@ -1,24 +1,23 @@
|
||||
import { VFC, useRef, useState, useEffect } from "react";
|
||||
import * as monaco from "monaco-editor/esm/vs/editor/editor.api";
|
||||
import styles from "./Editor.module.css";
|
||||
import { VFC, useRef, useState, useEffect } from 'react';
|
||||
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
||||
import styles from './Editor.module.css';
|
||||
|
||||
export const Editor: VFC = () => {
|
||||
const [editor, setEditor] =
|
||||
useState<monaco.editor.IStandaloneCodeEditor | null>(null);
|
||||
const monacoEl = useRef(null);
|
||||
const [editor, setEditor] = useState<monaco.editor.IStandaloneCodeEditor | null>(null);
|
||||
const monacoEl = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (monacoEl && !editor) {
|
||||
setEditor(
|
||||
monaco.editor.create(monacoEl.current!, {
|
||||
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
|
||||
language: "typescript",
|
||||
})
|
||||
);
|
||||
}
|
||||
useEffect(() => {
|
||||
if (monacoEl && !editor) {
|
||||
setEditor(
|
||||
monaco.editor.create(monacoEl.current!, {
|
||||
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
|
||||
language: 'typescript'
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return () => editor?.dispose();
|
||||
}, [monacoEl.current]);
|
||||
return () => editor?.dispose();
|
||||
}, [monacoEl.current]);
|
||||
|
||||
return <div className={styles.Editor} ref={monacoEl}></div>;
|
||||
return <div className={styles.Editor} ref={monacoEl}></div>;
|
||||
};
|
||||
|
@ -1,11 +1,11 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import {Editor} from './components/Editor'
|
||||
import "./userWorker";
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { Editor } from './components/Editor';
|
||||
import './userWorker';
|
||||
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<Editor />
|
||||
</React.StrictMode>,
|
||||
document.getElementById('root')
|
||||
)
|
||||
<React.StrictMode>
|
||||
<Editor />
|
||||
</React.StrictMode>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
|
@ -1,27 +1,27 @@
|
||||
import * as monaco from "monaco-editor";
|
||||
import editorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
|
||||
import jsonWorker from "monaco-editor/esm/vs/language/json/json.worker?worker";
|
||||
import cssWorker from "monaco-editor/esm/vs/language/css/css.worker?worker";
|
||||
import htmlWorker from "monaco-editor/esm/vs/language/html/html.worker?worker";
|
||||
import tsWorker from "monaco-editor/esm/vs/language/typescript/ts.worker?worker";
|
||||
import * as monaco from 'monaco-editor';
|
||||
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
||||
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
||||
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
|
||||
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
|
||||
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
||||
|
||||
// @ts-ignore
|
||||
self.MonacoEnvironment = {
|
||||
getWorker(_: any, label: string) {
|
||||
if (label === "json") {
|
||||
return new jsonWorker();
|
||||
}
|
||||
if (label === "css" || label === "scss" || label === "less") {
|
||||
return new cssWorker();
|
||||
}
|
||||
if (label === "html" || label === "handlebars" || label === "razor") {
|
||||
return new htmlWorker();
|
||||
}
|
||||
if (label === "typescript" || label === "javascript") {
|
||||
return new tsWorker();
|
||||
}
|
||||
return new editorWorker();
|
||||
},
|
||||
getWorker(_: any, label: string) {
|
||||
if (label === 'json') {
|
||||
return new jsonWorker();
|
||||
}
|
||||
if (label === 'css' || label === 'scss' || label === 'less') {
|
||||
return new cssWorker();
|
||||
}
|
||||
if (label === 'html' || label === 'handlebars' || label === 'razor') {
|
||||
return new htmlWorker();
|
||||
}
|
||||
if (label === 'typescript' || label === 'javascript') {
|
||||
return new tsWorker();
|
||||
}
|
||||
return new editorWorker();
|
||||
}
|
||||
};
|
||||
|
||||
monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
|
||||
|
@ -1,11 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"strict": true,
|
||||
"module": "ESNext",
|
||||
"jsx": "react-jsx",
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["./src"]
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"strict": true,
|
||||
"module": "ESNext",
|
||||
"jsx": "react-jsx",
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["./src"]
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()]
|
||||
})
|
||||
plugins: [react()]
|
||||
});
|
||||
|
@ -383,7 +383,8 @@ export class CompletionAdapter implements languages.CompletionItemProvider {
|
||||
item.insertText = entry.textEdit.newText;
|
||||
}
|
||||
if (entry.additionalTextEdits) {
|
||||
item.additionalTextEdits = entry.additionalTextEdits.map<languages.TextEdit>(toTextEdit);
|
||||
item.additionalTextEdits =
|
||||
entry.additionalTextEdits.map<languages.TextEdit>(toTextEdit);
|
||||
}
|
||||
if (entry.insertTextFormat === lsTypes.InsertTextFormat.Snippet) {
|
||||
item.insertTextRules = languages.CompletionItemInsertTextRule.InsertAsSnippet;
|
||||
@ -649,7 +650,8 @@ export class DocumentColorAdapter implements languages.DocumentColorProvider {
|
||||
item.textEdit = toTextEdit(presentation.textEdit);
|
||||
}
|
||||
if (presentation.additionalTextEdits) {
|
||||
item.additionalTextEdits = presentation.additionalTextEdits.map<languages.TextEdit>(toTextEdit);
|
||||
item.additionalTextEdits =
|
||||
presentation.additionalTextEdits.map<languages.TextEdit>(toTextEdit);
|
||||
}
|
||||
return item;
|
||||
});
|
||||
@ -687,7 +689,9 @@ export class FoldingRangeAdapter implements languages.FoldingRangeProvider {
|
||||
}
|
||||
}
|
||||
|
||||
function toFoldingRangeKind(kind: lsTypes.FoldingRangeKind): languages.FoldingRangeKind | undefined {
|
||||
function toFoldingRangeKind(
|
||||
kind: lsTypes.FoldingRangeKind
|
||||
): languages.FoldingRangeKind | undefined {
|
||||
switch (kind) {
|
||||
case lsTypes.FoldingRangeKind.Comment:
|
||||
return languages.FoldingRangeKind.Comment;
|
||||
@ -710,7 +714,12 @@ export class SelectionRangeAdapter implements languages.SelectionRangeProvider {
|
||||
const resource = model.uri;
|
||||
|
||||
return this._worker(resource)
|
||||
.then((worker) => worker.getSelectionRanges(resource.toString(), positions.map<lsTypes.Position>(fromPosition)))
|
||||
.then((worker) =>
|
||||
worker.getSelectionRanges(
|
||||
resource.toString(),
|
||||
positions.map<lsTypes.Position>(fromPosition)
|
||||
)
|
||||
)
|
||||
.then((selectionRanges) => {
|
||||
if (!selectionRanges) {
|
||||
return;
|
||||
|
@ -9,8 +9,7 @@ import { languages } from '../fillers/monaco-editor-core';
|
||||
export function createTokenizationSupport(supportComments: boolean): languages.TokensProvider {
|
||||
return {
|
||||
getInitialState: () => new JSONState(null, null, false, null),
|
||||
tokenize: (line, state?) =>
|
||||
tokenize(supportComments, line, <JSONState>state)
|
||||
tokenize: (line, state?) => tokenize(supportComments, line, <JSONState>state)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -35,21 +35,25 @@ global.window = {
|
||||
requirejs(
|
||||
['test/unit/setup'],
|
||||
function () {
|
||||
glob('out/amd/basic-languages/*/*.test.js', { cwd: path.join(__dirname, '../../') }, function (err, files) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
requirejs(
|
||||
files.map((f) => f.replace(/^out\/amd/, 'vs').replace(/\.js$/, '')),
|
||||
function () {
|
||||
// We can launch the tests!
|
||||
},
|
||||
function (err) {
|
||||
glob(
|
||||
'out/amd/basic-languages/*/*.test.js',
|
||||
{ cwd: path.join(__dirname, '../../') },
|
||||
function (err, files) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
);
|
||||
});
|
||||
requirejs(
|
||||
files.map((f) => f.replace(/^out\/amd/, 'vs').replace(/\.js$/, '')),
|
||||
function () {
|
||||
// We can launch the tests!
|
||||
},
|
||||
function (err) {
|
||||
console.log(err);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
function (err) {
|
||||
console.log(err);
|
||||
|
Loading…
Reference in New Issue
Block a user