Browse Source

Restore manual running from the repository (#4150)

Alexandru Dima 1 year ago
parent
commit
c4fa782fc2
2 changed files with 5 additions and 113 deletions
  1. 0 102
      build/simpleserver.ts
  2. 5 11
      test/manual/index.js

+ 0 - 102
build/simpleserver.ts

@@ -10,8 +10,6 @@ import yaserver = require('yaserver');
 import { REPO_ROOT } from './utils';
 import { ensureDir } from './fs';
 
-const WEBSITE_GENERATED_PATH = path.join(REPO_ROOT, 'website/playground/new-samples');
-
 generateTestSamplesTask();
 
 const SERVER_ROOT = path.normalize(path.join(REPO_ROOT, '../'));
@@ -53,106 +51,6 @@ function generateTestSamplesTask() {
 	const destination = path.join(REPO_ROOT, 'test/manual/generated/all-samples.js');
 	ensureDir(path.dirname(destination));
 	fs.writeFileSync(destination, prefix + JSON.stringify(samples, null, '\t') + suffix);
-
-	/** @type {{ chapter: string; name: string; id: string; path: string; }[]} */
-	const PLAY_SAMPLES = require(path.join(WEBSITE_GENERATED_PATH, 'all.js')).PLAY_SAMPLES;
-	/** @type {{ path: string; name: string; }[]} */
-	const locations = [];
-	for (let i = 0; i < PLAY_SAMPLES.length; i++) {
-		const sample = PLAY_SAMPLES[i];
-		const sampleId = sample.id;
-		const samplePath = path.join(WEBSITE_GENERATED_PATH, sample.path);
-
-		const html = fs.readFileSync(path.join(samplePath, 'sample.html'));
-		const js = fs.readFileSync(path.join(samplePath, 'sample.js'));
-		const css = fs.readFileSync(path.join(samplePath, 'sample.css'));
-
-		const result = [
-			'<!DOCTYPE html>',
-			'<!-- THIS IS A GENERATED FILE VIA `npm run simpleserver` -->',
-			'<html>',
-			'<head>',
-			'	<base href="../..">',
-			'	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />',
-			'</head>',
-			'<body>',
-			'<style>',
-			'/*----------------------------------------SAMPLE CSS START*/',
-			'',
-			css,
-			'',
-			'/*----------------------------------------SAMPLE CSS END*/',
-			'</style>',
-			'<a class="loading-opts" href="generated/playground/index.html">[&lt;&lt; BACK]</a> <br/>',
-			'THIS IS A GENERATED FILE VIA `npm run simpleserver`',
-			'',
-			'<div id="bar" style="margin-bottom: 6px;"></div>',
-			'',
-			'<div style="clear:both"></div>',
-			'<div id="outer-container" style="width:800px;height:450px;border: 1px solid grey">',
-			'<!-- ----------------------------------------SAMPLE HTML START-->',
-			'',
-			html,
-			'',
-			'<!-- ----------------------------------------SAMPLE HTML END-->',
-			'</div>',
-			'<div style="clear:both"></div>',
-			'',
-			'<script src="dev-setup.js"></script>',
-			'<script>',
-			'loadEditor(function() {',
-			'/*----------------------------------------SAMPLE JS START*/',
-			'',
-			js,
-			'',
-			'/*----------------------------------------SAMPLE JS END*/',
-			'});',
-			'</script>',
-			'</body>',
-			'</html>'
-		];
-
-		const destination = path.join(
-			REPO_ROOT,
-			'test/manual/generated/playground/' + sampleId + '.html'
-		);
-		ensureDir(path.dirname(destination));
-		fs.writeFileSync(destination, result.join('\n'));
-		locations.push({
-			path: sampleId + '.html',
-			name: sample.chapter + ' &gt; ' + sample.name
-		});
-	}
-
-	const index = [
-		'<!DOCTYPE html>',
-		'<!-- THIS IS A GENERATED FILE VIA `npm run simpleserver` -->',
-		'<html>',
-		'<head>',
-		'	<base href="../..">',
-		'</head>',
-		'<body>',
-		'<a class="loading-opts" href="index.html">[&lt;&lt; BACK]</a><br/>',
-		'THIS IS A GENERATED FILE VIA `npm run simpleserver`<br/><br/>',
-		locations
-			.map(function (location) {
-				return (
-					'<a class="loading-opts" href="generated/playground/' +
-					location.path +
-					'">' +
-					location.name +
-					'</a>'
-				);
-			})
-			.join('<br/>\n'),
-		'<script src="dev-setup.js"></script>',
-		'</body>',
-		'</html>'
-	];
-	fs.writeFileSync(
-		path.join(REPO_ROOT, 'test/manual/generated/playground/index.html'),
-		index.join('\n')
-	);
 }
 
 function createSimpleServer(rootDir: string, port: number) {

+ 5 - 11
test/manual/index.js

@@ -1,4 +1,4 @@
-/// <reference path="../../release/monaco.d.ts" />
+/// <reference path="../../out/monaco-editor/monaco.d.ts" />
 define(['require', './samples'], function (require, SAMPLES) {
 	const domutils = require('vs/base/browser/dom');
 
@@ -20,16 +20,10 @@ define(['require', './samples'], function (require, SAMPLES) {
 		renderWhitespace: true
 	});
 
-	editor.addCommand(
-		{
-			ctrlCmd: true,
-			key: 'F9'
-		},
-		function (ctx, args) {
-			alert('Command Running!!');
-			console.log(ctx);
-		}
-	);
+	editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.F9, function (ctx, args) {
+		alert('Command Running!!');
+		console.log(ctx);
+	});
 
 	editor.addAction({
 		id: 'my-unique-id',