Просмотр исходного кода

More cleanup in manual test cases

Alex Dima 3 лет назад
Родитель
Сommit
f012a2aeee

+ 0 - 35
test/manual/2264/iframe.html

@@ -1,35 +0,0 @@
-<!DOCTYPE html>
-<html>
-	<head>
-		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-		<style>
-			html,
-			body {
-				height: 100%;
-			}
-
-			body {
-				margin: 0;
-				overflow: hidden;
-			}
-
-			#container {
-				position: fixed;
-				top: 0;
-				left: 0;
-				bottom: 0;
-				right: 0;
-			}
-
-			.dev-setup-control {
-				display: none;
-			}
-		</style>
-	</head>
-	<body>
-		<div id="container"></div>
-		<script src="../../../metadata.js"></script>
-		<script src="../dev-setup.js"></script>
-		<script src="iframe.js"></script>
-	</body>
-</html>

+ 0 - 22
test/manual/2264/iframe.js

@@ -1,22 +0,0 @@
-const init = () => {
-	loadEditor(function () {
-		// create the editor
-		const target = document.getElementById('container');
-		const editor = monaco.editor.create(target, { language: 'html' });
-
-		// load some sample data
-		(async () => {
-			const response = await fetch('https://microsoft.github.io/monaco-editor/');
-			const html = await response.text();
-			editor.getModel().setValue(html);
-		})();
-	});
-};
-
-window.addEventListener('DOMContentLoaded', () => {
-	if (!window.innerWidth || !window.innerHeight) {
-		window.addEventListener('resize', init, { once: true });
-	} else {
-		init();
-	}
-});

+ 0 - 11
test/manual/2264/index.html

@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<html>
-	<head> </head>
-	<body>
-		<iframe
-			src="http://localhost:8088/monaco-editor/test/manual/2264/iframe.html?editor=src"
-			style="width: 800px; height: 600px"
-			sandbox="allow-same-origin allow-scripts allow-popups allow-modals allow-forms allow-downloads"
-		></iframe>
-	</body>
-</html>

+ 0 - 54
test/manual/colorize.html

@@ -1,54 +0,0 @@
-<!DOCTYPE html>
-<html>
-	<head>
-		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-	</head>
-	<body>
-		<h2>Colorize example</h2>
-
-		<pre id="code" data-lang="text/css" style="width: 500px">
-/* Some example CSS */
-
-@import url("something.css");
-
-body {
-  margin: 0;
-  padding: 3em 6em;
-  font-family: tahoma, arial, sans-serif;
-  color: #000;
-}
-
-#navigation a {
-  font-weight: bold;
-  text-decoration: none !important;
-}
-
-h1 {
-  font-size: 2.5em;
-}
-
-h2 {
-  font-size: 1.7em;
-}
-
-h1:before, h2:before {
-  content: "some contents";
-}
-
-code {
-  font-family: courier, monospace;
-  font-size: 80%;
-  color: #418A8A;
-}
-</pre
-		>
-
-		<script src="../../metadata.js"></script>
-		<script src="dev-setup.js"></script>
-		<script>
-			loadEditor(function () {
-				monaco.editor.colorizeElement(document.getElementById('code'));
-			});
-		</script>
-	</body>
-</html>

+ 10 - 15
test/manual/index.html

@@ -6,21 +6,16 @@
 	</head>
 	</head>
 	<body>
 	<body>
 		Jump to:
 		Jump to:
-		<a class="loading-opts" href="./generated/playground/index.html">[PLAYGROUND]</a>
-		&#160;|&#160;
-		<a class="loading-opts" href="./mouse-fixed.html">[fixed element]</a>
-		&#160;|&#160;
-		<a class="loading-opts" href="./mouse-scrollable-body.html">[scrollable body]</a>
-		&#160;|&#160;
-		<a class="loading-opts" href="./mouse-scrollable-element.html">[scrollable element]</a><br />
-		&#160;|&#160;
-		<a class="loading-opts" href="./shadow-dom.html">[Shadow DOM]</a>
-		&#160;|&#160;
-		<a class="loading-opts" href="./colorize.html">[colorize element]</a>
-		&#160;|&#160;
-		<a class="loading-opts" href="./cross-origin.html">[cross origin]</a>
-		&#160;|&#160;
-		<a class="loading-opts" href="./diff.html">[diff]</a>
+		<a class="loading-opts" href="./generated/playground/index.html">[PLAYGROUND]</a> &#160;|&#160;
+		<a class="loading-opts" href="./shadow-dom.html">[Shadow DOM]</a> &#160;|&#160;
+		<a class="loading-opts" href="./diff.html">[Diff]</a> &#160;|&#160;
+		<a class="loading-opts" href="./typescript/index.html">[TypeScript]</a> &#160;|&#160;
+		<a class="loading-opts" href="./typescript/custom-worker.html">[TS Worker]</a>
+		<br />&#160;|&#160;
+		<a class="loading-opts" href="./cross-origin.html">[cross origin]</a> &#160;|&#160;
+		<a class="loading-opts" href="./mouse-fixed.html">[fixed element]</a> &#160;|&#160;
+		<a class="loading-opts" href="./mouse-scrollable-body.html">[scrollable body]</a> &#160;|&#160;
+		<a class="loading-opts" href="./mouse-scrollable-element.html">[scrollable element]</a>
 		<br /><br />
 		<br /><br />
 
 
 		<div id="bar" style="margin-bottom: 6px"></div>
 		<div id="bar" style="margin-bottom: 6px"></div>

+ 0 - 19
test/manual/out-editor-esm-bundle.html

@@ -1,19 +0,0 @@
-<!DOCTYPE html>
-<html>
-	<head>
-		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-		<base href="../../vscode-prs/out-editor-esm-bundle/" />
-	</head>
-	<body>
-		<h2>Monaco Editor ESM Bundle</h2>
-
-		<div style="clear: both"></div>
-		<div
-			id="container"
-			style="float: left; width: 800px; height: 450px; border: 1px solid grey"
-		></div>
-		<div style="clear: both"></div>
-
-		<script src="core.bundle.js"></script>
-	</body>
-</html>

+ 3 - 33
test/manual/typescript/custom-worker.html

@@ -9,13 +9,7 @@
 <!DOCTYPE html>
 <!DOCTYPE html>
 <html>
 <html>
 	<head>
 	<head>
-		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
 		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-		<link
-			rel="stylesheet"
-			data-name="vs/editor/editor.main"
-			href="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.css"
-		/>
 	</head>
 	</head>
 	<body>
 	<body>
 		<h2>Monaco Editor TypeScript test page</h2>
 		<h2>Monaco Editor TypeScript test page</h2>
@@ -25,29 +19,8 @@
 		<button id="logDTS">Log DTS</button>
 		<button id="logDTS">Log DTS</button>
 		<button id="getAST">Print AST to console</button>
 		<button id="getAST">Print AST to console</button>
 
 
-		<script>
-			const paths = {
-				'vs/basic-languages': '../node_modules/monaco-languages/release/dev',
-				'vs/language/typescript/fillers/monaco-editor-core':
-					'../out/amd/fillers/monaco-editor-core-amd',
-				'vs/language/typescript': '../out/amd',
-				vs: '../node_modules/monaco-editor-core/dev/vs'
-			};
-			if (document.location.protocol === 'http:') {
-				// Add support for running local http server
-				let testIndex = document.location.pathname.indexOf('/test/');
-				if (testIndex !== -1) {
-					let prefix = document.location.pathname.substr(0, testIndex);
-					paths['vs/language/typescript'] = prefix + '/out/amd';
-				}
-			}
-			self.require = {
-				paths: paths
-			};
-		</script>
-		<script src="../node_modules/monaco-editor-core/dev/vs/loader.js"></script>
-		<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.nls.js"></script>
-		<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.js"></script>
+		<script src="../../../metadata.js"></script>
+		<script src="../dev-setup.js"></script>
 
 
 		<script>
 		<script>
 			function getDefaultCode() {
 			function getDefaultCode() {
@@ -182,10 +155,7 @@
 			function getDefaultComplierOpts() {
 			function getDefaultComplierOpts() {
 				return { target: 99, jsx: 1, allowNonTsExtensions: true };
 				return { target: 99, jsx: 1, allowNonTsExtensions: true };
 			}
 			}
-			require([
-				'vs/basic-languages/monaco.contribution',
-				'vs/language/typescript/monaco.contribution'
-			], () => {
+			loadEditor(() => {
 				const dirname = (path) => {
 				const dirname = (path) => {
 					const slashIndex = path.lastIndexOf('/');
 					const slashIndex = path.lastIndexOf('/');
 					if (slashIndex >= 0) {
 					if (slashIndex >= 0) {

+ 4 - 34
test/manual/typescript/index.html

@@ -1,13 +1,7 @@
 <!DOCTYPE html>
 <!DOCTYPE html>
 <html>
 <html>
 	<head>
 	<head>
-		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
 		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-		<link
-			rel="stylesheet"
-			data-name="vs/editor/editor.main"
-			href="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.css"
-		/>
 	</head>
 	</head>
 	<body>
 	<body>
 		<h2>Monaco Editor TypeScript test page</h2>
 		<h2>Monaco Editor TypeScript test page</h2>
@@ -17,30 +11,8 @@
 		<textarea style="font-family: monospace" id="compilerOpts" cols="60" rows="30"></textarea><br />
 		<textarea style="font-family: monospace" id="compilerOpts" cols="60" rows="30"></textarea><br />
 		<button id="updateCompilerSettingsBtn">Update compiler settings</button>
 		<button id="updateCompilerSettingsBtn">Update compiler settings</button>
 
 
-		<script>
-			const paths = {
-				'vs/basic-languages': '../node_modules/monaco-languages/release/dev',
-				'vs/language/typescript/fillers/monaco-editor-core':
-					'../out/amd/fillers/monaco-editor-core-amd',
-				'vs/language/typescript': '../out/amd',
-				vs: '../node_modules/monaco-editor-core/dev/vs'
-			};
-			if (document.location.protocol === 'http:') {
-				// Add support for running local http server
-				let testIndex = document.location.pathname.indexOf('/test/');
-				if (testIndex !== -1) {
-					let prefix = document.location.pathname.substr(0, testIndex);
-					paths['vs/language/typescript'] = prefix + '/out/amd';
-				}
-			}
-			self.require = {
-				paths: paths
-			};
-		</script>
-		<script src="../node_modules/monaco-editor-core/dev/vs/loader.js"></script>
-		<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.nls.js"></script>
-		<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.js"></script>
-
+		<script src="../../../metadata.js"></script>
+		<script src="../dev-setup.js"></script>
 		<script>
 		<script>
 			function getDefaultCode() {
 			function getDefaultCode() {
 				return [
 				return [
@@ -174,10 +146,8 @@
 			function getDefaultComplierOpts() {
 			function getDefaultComplierOpts() {
 				return { target: 99, jsx: 1, allowNonTsExtensions: true };
 				return { target: 99, jsx: 1, allowNonTsExtensions: true };
 			}
 			}
-			require([
-				'vs/basic-languages/monaco.contribution',
-				'vs/language/typescript/monaco.contribution'
-			], () => {
+
+			loadEditor(() => {
 				const editor = monaco.editor.create(document.getElementById('container'), {
 				const editor = monaco.editor.create(document.getElementById('container'), {
 					value: localStorage.getItem('code') || getDefaultCode(),
 					value: localStorage.getItem('code') || getDefaultCode(),
 					language: 'typescript',
 					language: 'typescript',

+ 0 - 219
test/manual/typescript/inlayHints.html

@@ -1,219 +0,0 @@
-<!DOCTYPE html>
-<html>
-	<head>
-		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
-		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-		<link
-			rel="stylesheet"
-			data-name="vs/editor/editor.main"
-			href="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.css"
-		/>
-	</head>
-	<body>
-		<h2>Monaco Editor TypeScript test page</h2>
-		<button id="resetBtn">Reset Sample</button>
-		<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
-		<h3>Inlay Hints options</h3>
-		<textarea style="font-family: monospace" id="inlayHintsOpts" cols="60" rows="30"></textarea
-		><br />
-		<button id="updateInlayHintsOptionsBtn">Update Inaly Hints options</button>
-
-		<script>
-			const paths = {
-				'vs/basic-languages': '../node_modules/monaco-languages/release/dev',
-				'vs/language/typescript/fillers/monaco-editor-core':
-					'../out/amd/fillers/monaco-editor-core-amd',
-				'vs/language/typescript': '../out/amd',
-				vs: '../node_modules/monaco-editor-core/dev/vs'
-			};
-			if (document.location.protocol === 'http:') {
-				// Add support for running local http server
-				let testIndex = document.location.pathname.indexOf('/test/');
-				if (testIndex !== -1) {
-					let prefix = document.location.pathname.substr(0, testIndex);
-					paths['vs/language/typescript'] = prefix + '/out/amd';
-				}
-			}
-			self.require = {
-				paths: paths
-			};
-		</script>
-		<script src="../node_modules/monaco-editor-core/dev/vs/loader.js"></script>
-		<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.nls.js"></script>
-		<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.js"></script>
-
-		<script>
-			function getDefaultCode() {
-				return [
-					'/* Game of Life',
-					' * Implemented in TypeScript',
-					' * To learn more about TypeScript, please visit http://www.typescriptlang.org/',
-					' */',
-					'',
-					'module Conway {',
-					'',
-					'	export class Cell {',
-					'		public row: number;',
-					'		public col: number;',
-					'		public live: boolean;',
-					'',
-					'		constructor(row: number, col: number, live: boolean) {',
-					'			this.row = row;',
-					'			this.col = col;',
-					'			this.live = live',
-					'		}',
-					'	}',
-					'',
-					'	export class GameOfLife {',
-					'		private gridSize: number;',
-					'		private canvasSize: number;',
-					'		private lineColor: string;',
-					'		private liveColor: string;',
-					'		private deadColor: string;',
-					'		private initialLifeProbability: number;',
-					'		private animationRate: number;',
-					'		private cellSize: number;',
-					'		private context: CanvasRenderingContext2D;',
-					'		private world;',
-					'',
-					'',
-					'		constructor() {',
-					'			this.gridSize = 50;',
-					'			this.canvasSize = 600;',
-					"			this.lineColor = '#cdcdcd';",
-					"			this.liveColor = '#666';",
-					"			this.deadColor = '#eee';",
-					'			this.initialLifeProbability = 0.5;',
-					'			this.animationRate = 60;',
-					'			this.cellSize = 0;',
-					'			this.world = this.createWorld();',
-					'			this.circleOfLife();',
-					'		}',
-					'',
-					'		public createWorld() {',
-					'			return this.travelWorld( (cell : Cell) =>  {',
-					'				cell.live = Math.random() < this.initialLifeProbability;',
-					'				return cell;',
-					'			});',
-					'		}',
-					'',
-					'		public circleOfLife() : void {',
-					'			this.world = this.travelWorld( (cell: Cell) => {',
-					'				cell = this.world[cell.row][cell.col];',
-					'				this.draw(cell);',
-					'				return this.resolveNextGeneration(cell);',
-					'			});',
-					'			setTimeout( () => {this.circleOfLife()}, this.animationRate);',
-					'		}',
-					'',
-					'		public resolveNextGeneration(cell : Cell) {',
-					'			var count = this.countNeighbors(cell);',
-					'			var newCell = new Cell(cell.row, cell.col, cell.live);',
-					'			if(count < 2 || count > 3) newCell.live = false;',
-					'			else if(count == 3) newCell.live = true;',
-					'			return newCell;',
-					'		}',
-					'',
-					'		public countNeighbors(cell : Cell) {',
-					'			var neighbors = 0;',
-					'			for(var row = -1; row <=1; row++) {',
-					'				for(var col = -1; col <= 1; col++) {',
-					'					if(row == 0 && col == 0) continue;',
-					'					if(this.isAlive(cell.row + row, cell.col + col)) {',
-					'						neighbors++;',
-					'					}',
-					'				}',
-					'			}',
-					'			return neighbors;',
-					'		}',
-					'',
-					'		public isAlive(row : number, col : number) {',
-					'			if(row < 0 || col < 0 || row >= this.gridSize || col >= this.gridSize) return false;',
-					'			return this.world[row][col].live;',
-					'		}',
-					'',
-					'		public travelWorld(callback) {',
-					'			var result = [];',
-					'			for(var row = 0; row < this.gridSize; row++) {',
-					'				var rowData = [];',
-					'				for(var col = 0; col < this.gridSize; col++) {',
-					'					rowData.push(callback(new Cell(row, col, false)));',
-					'				}',
-					'				result.push(rowData);',
-					'			}',
-					'			return result;',
-					'		}',
-					'',
-					'		public draw(cell : Cell) {',
-					'			if(this.context == null) this.context = this.createDrawingContext();',
-					'			if(this.cellSize == 0) this.cellSize = this.canvasSize/this.gridSize;',
-					'',
-					'			this.context.strokeStyle = this.lineColor;',
-					'			this.context.strokeRect(cell.row * this.cellSize, cell.col*this.cellSize, this.cellSize, this.cellSize);',
-					'			this.context.fillStyle = cell.live ? this.liveColor : this.deadColor;',
-					'			this.context.fillRect(cell.row * this.cellSize, cell.col*this.cellSize, this.cellSize, this.cellSize);',
-					'		}',
-					'',
-					'		public createDrawingContext() {',
-					"			var canvas = <HTMLCanvasElement> document.getElementById('conway-canvas');",
-					'			if(canvas == null) {',
-					"					canvas = document.createElement('canvas');",
-					"					canvas.id = 'conway-canvas';",
-					'					canvas.width = this.canvasSize;',
-					'					canvas.height = this.canvasSize;',
-					'					document.body.appendChild(canvas);',
-					'			}',
-					"			return canvas.getContext('2d');",
-					'		}',
-					'	}',
-					'}',
-					'',
-					'var game = new Conway.GameOfLife();'
-				].join('\n');
-			}
-
-			function getDefaultInlayHintsOpts() {
-				return {
-					includeInlayParameterNameHints: 'all',
-					includeInlayParameterNameHintsWhenArgumentMatchesName: true,
-					includeInlayFunctionParameterTypeHints: true,
-					includeInlayVariableTypeHints: true,
-					includeInlayPropertyDeclarationTypeHints: true,
-					includeInlayFunctionLikeReturnTypeHints: true,
-					includeInlayEnumMemberValueHints: true
-				};
-			}
-			require([
-				'vs/basic-languages/monaco.contribution',
-				'vs/language/typescript/monaco.contribution'
-			], () => {
-				const editor = monaco.editor.create(document.getElementById('container'), {
-					value: localStorage.getItem('code') || getDefaultCode(),
-					language: 'typescript',
-					lightbulb: { enabled: true }
-				});
-
-				editor.onDidChangeModelContent(() => {
-					const code = editor.getModel().getValue();
-					localStorage.setItem('code', code);
-				});
-
-				document.getElementById('resetBtn').onclick = () => {
-					editor.setValue(getDefaultCode());
-				};
-
-				const optsString =
-					localStorage.getItem('inlay-hints-opts') ||
-					JSON.stringify(getDefaultInlayHintsOpts(), null, 4);
-				document.getElementById('inlayHintsOpts').textContent = optsString;
-				monaco.languages.typescript.typescriptDefaults.setInlayHintsOptions(JSON.parse(optsString));
-
-				document.getElementById('updateInlayHintsOptionsBtn').onclick = () => {
-					const newOpts = document.getElementById('inlayHintsOpts').value;
-					monaco.languages.typescript.typescriptDefaults.setInlayHintsOptions(JSON.parse(newOpts));
-					localStorage.setItem('inlay-hints-opts', newOpts);
-				};
-			});
-		</script>
-	</body>
-</html>