mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-04 01:44:44 -06:00
Remove leftover usages of loader.js (#287084)
This commit is contained in:
parent
88d1700608
commit
cacd748219
@ -53,7 +53,7 @@
|
||||
"Other"
|
||||
],
|
||||
"activationEvents": [
|
||||
"workspaceContains:src/vs/loader.js"
|
||||
"workspaceContains:src/vscode-dts/vscode.d.ts"
|
||||
],
|
||||
"workspaceTrust": {
|
||||
"request": "onDemand",
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<style>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button id="startRecording" type="button">Start Recording</button>
|
||||
<button id="endRecording" type="button">End Recording</button>
|
||||
<script src="../../../../loader.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
baseUrl: '../../../../../../out'
|
||||
});
|
||||
|
||||
require(['vs/editor/test/browser/controller/imeRecorder'], function() {
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,180 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { DisposableStore, toDisposable } from '../../../../base/common/lifecycle.js';
|
||||
import { IRecorded, IRecordedCompositionEvent, IRecordedEvent, IRecordedInputEvent, IRecordedKeyboardEvent, IRecordedTextareaState } from './imeRecordedTypes.js';
|
||||
import * as browser from '../../../../base/browser/browser.js';
|
||||
import * as platform from '../../../../base/common/platform.js';
|
||||
import { mainWindow } from '../../../../base/browser/window.js';
|
||||
import { TextAreaWrapper } from '../../../browser/controller/editContext/textArea/textAreaEditContextInput.js';
|
||||
|
||||
(() => {
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
const startButton = <HTMLButtonElement>mainWindow.document.getElementById('startRecording')!;
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
const endButton = <HTMLButtonElement>mainWindow.document.getElementById('endRecording')!;
|
||||
|
||||
let inputarea: HTMLTextAreaElement;
|
||||
const disposables = new DisposableStore();
|
||||
let originTimeStamp = 0;
|
||||
let recorded: IRecorded = {
|
||||
env: null!,
|
||||
initial: null!,
|
||||
events: [],
|
||||
final: null!
|
||||
};
|
||||
|
||||
const readTextareaState = (): IRecordedTextareaState => {
|
||||
return {
|
||||
selectionDirection: inputarea.selectionDirection,
|
||||
selectionEnd: inputarea.selectionEnd,
|
||||
selectionStart: inputarea.selectionStart,
|
||||
value: inputarea.value,
|
||||
};
|
||||
};
|
||||
|
||||
startButton.onclick = () => {
|
||||
disposables.clear();
|
||||
startTest();
|
||||
originTimeStamp = 0;
|
||||
recorded = {
|
||||
env: {
|
||||
OS: platform.OS,
|
||||
browser: {
|
||||
isAndroid: browser.isAndroid,
|
||||
isFirefox: browser.isFirefox,
|
||||
isChrome: browser.isChrome,
|
||||
isSafari: browser.isSafari
|
||||
}
|
||||
},
|
||||
initial: readTextareaState(),
|
||||
events: [],
|
||||
final: null!
|
||||
};
|
||||
};
|
||||
endButton.onclick = () => {
|
||||
recorded.final = readTextareaState();
|
||||
console.log(printRecordedData());
|
||||
};
|
||||
|
||||
function printRecordedData() {
|
||||
const lines = [];
|
||||
lines.push(`const recorded: IRecorded = {`);
|
||||
lines.push(`\tenv: ${JSON.stringify(recorded.env)}, `);
|
||||
lines.push(`\tinitial: ${printState(recorded.initial)}, `);
|
||||
lines.push(`\tevents: [\n\t\t${recorded.events.map(ev => printEvent(ev)).join(',\n\t\t')}\n\t],`);
|
||||
lines.push(`\tfinal: ${printState(recorded.final)},`);
|
||||
lines.push(`}`);
|
||||
|
||||
return lines.join('\n');
|
||||
|
||||
function printString(str: string) {
|
||||
return str.replace(/\\/g, '\\\\').replace(/'/g, '\\\'');
|
||||
}
|
||||
function printState(state: IRecordedTextareaState) {
|
||||
return `{ value: '${printString(state.value)}', selectionStart: ${state.selectionStart}, selectionEnd: ${state.selectionEnd}, selectionDirection: '${state.selectionDirection}' }`;
|
||||
}
|
||||
function printEvent(ev: IRecordedEvent) {
|
||||
if (ev.type === 'keydown' || ev.type === 'keypress' || ev.type === 'keyup') {
|
||||
return `{ timeStamp: ${ev.timeStamp.toFixed(2)}, state: ${printState(ev.state)}, type: '${ev.type}', altKey: ${ev.altKey}, charCode: ${ev.charCode}, code: '${ev.code}', ctrlKey: ${ev.ctrlKey}, isComposing: ${ev.isComposing}, key: '${ev.key}', keyCode: ${ev.keyCode}, location: ${ev.location}, metaKey: ${ev.metaKey}, repeat: ${ev.repeat}, shiftKey: ${ev.shiftKey} }`;
|
||||
}
|
||||
if (ev.type === 'compositionstart' || ev.type === 'compositionupdate' || ev.type === 'compositionend') {
|
||||
return `{ timeStamp: ${ev.timeStamp.toFixed(2)}, state: ${printState(ev.state)}, type: '${ev.type}', data: '${printString(ev.data)}' }`;
|
||||
}
|
||||
if (ev.type === 'beforeinput' || ev.type === 'input') {
|
||||
return `{ timeStamp: ${ev.timeStamp.toFixed(2)}, state: ${printState(ev.state)}, type: '${ev.type}', data: ${ev.data === null ? 'null' : `'${printString(ev.data)}'`}, inputType: '${ev.inputType}', isComposing: ${ev.isComposing} }`;
|
||||
}
|
||||
return JSON.stringify(ev);
|
||||
}
|
||||
}
|
||||
|
||||
function startTest() {
|
||||
inputarea = document.createElement('textarea');
|
||||
mainWindow.document.body.appendChild(inputarea);
|
||||
inputarea.focus();
|
||||
disposables.add(toDisposable(() => {
|
||||
inputarea.remove();
|
||||
}));
|
||||
const wrapper = disposables.add(new TextAreaWrapper(inputarea));
|
||||
|
||||
wrapper.setValue('', `aaaa`);
|
||||
wrapper.setSelectionRange('', 2, 2);
|
||||
|
||||
const recordEvent = (e: IRecordedEvent) => {
|
||||
recorded.events.push(e);
|
||||
};
|
||||
|
||||
const recordKeyboardEvent = (e: KeyboardEvent): void => {
|
||||
if (e.type !== 'keydown' && e.type !== 'keypress' && e.type !== 'keyup') {
|
||||
throw new Error(`Not supported!`);
|
||||
}
|
||||
if (originTimeStamp === 0) {
|
||||
originTimeStamp = e.timeStamp;
|
||||
}
|
||||
const ev: IRecordedKeyboardEvent = {
|
||||
timeStamp: e.timeStamp - originTimeStamp,
|
||||
state: readTextareaState(),
|
||||
type: e.type,
|
||||
altKey: e.altKey,
|
||||
charCode: e.charCode,
|
||||
code: e.code,
|
||||
ctrlKey: e.ctrlKey,
|
||||
isComposing: e.isComposing,
|
||||
key: e.key,
|
||||
keyCode: e.keyCode,
|
||||
location: e.location,
|
||||
metaKey: e.metaKey,
|
||||
repeat: e.repeat,
|
||||
shiftKey: e.shiftKey
|
||||
};
|
||||
recordEvent(ev);
|
||||
};
|
||||
|
||||
const recordCompositionEvent = (e: CompositionEvent): void => {
|
||||
if (e.type !== 'compositionstart' && e.type !== 'compositionupdate' && e.type !== 'compositionend') {
|
||||
throw new Error(`Not supported!`);
|
||||
}
|
||||
if (originTimeStamp === 0) {
|
||||
originTimeStamp = e.timeStamp;
|
||||
}
|
||||
const ev: IRecordedCompositionEvent = {
|
||||
timeStamp: e.timeStamp - originTimeStamp,
|
||||
state: readTextareaState(),
|
||||
type: e.type,
|
||||
data: e.data,
|
||||
};
|
||||
recordEvent(ev);
|
||||
};
|
||||
|
||||
const recordInputEvent = (e: InputEvent): void => {
|
||||
if (e.type !== 'beforeinput' && e.type !== 'input') {
|
||||
throw new Error(`Not supported!`);
|
||||
}
|
||||
if (originTimeStamp === 0) {
|
||||
originTimeStamp = e.timeStamp;
|
||||
}
|
||||
const ev: IRecordedInputEvent = {
|
||||
timeStamp: e.timeStamp - originTimeStamp,
|
||||
state: readTextareaState(),
|
||||
type: e.type,
|
||||
data: e.data,
|
||||
inputType: e.inputType,
|
||||
isComposing: e.isComposing,
|
||||
};
|
||||
recordEvent(ev);
|
||||
};
|
||||
|
||||
wrapper.onKeyDown(recordKeyboardEvent);
|
||||
wrapper.onKeyPress(recordKeyboardEvent);
|
||||
wrapper.onKeyUp(recordKeyboardEvent);
|
||||
wrapper.onCompositionStart(recordCompositionEvent);
|
||||
wrapper.onCompositionUpdate(recordCompositionEvent);
|
||||
wrapper.onCompositionEnd(recordCompositionEvent);
|
||||
wrapper.onBeforeInput(recordInputEvent);
|
||||
wrapper.onInput(recordInputEvent);
|
||||
}
|
||||
|
||||
})();
|
||||
@ -1,56 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<style>
|
||||
.container {
|
||||
border-top: 1px solid #ccc;
|
||||
padding-top: 5px;
|
||||
clear: both;
|
||||
margin-top: 30px;
|
||||
}
|
||||
.container .title {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.container button {
|
||||
float: left;
|
||||
}
|
||||
.container textarea {
|
||||
float: left;
|
||||
width: 200px;
|
||||
height: 100px;
|
||||
margin-left: 50px;
|
||||
}
|
||||
.container .output {
|
||||
float: left;
|
||||
background: lightblue;
|
||||
margin: 0;
|
||||
margin-left: 50px;
|
||||
}
|
||||
|
||||
.container .check {
|
||||
float: left;
|
||||
background: grey;
|
||||
margin: 0;
|
||||
margin-left: 50px;
|
||||
}
|
||||
.container .check.good {
|
||||
background: lightgreen;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Detailed setup steps at https://github.com/microsoft/vscode/wiki/IME-Test</h3>
|
||||
<script src="../../../../loader.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
baseUrl: '../../../../../../out'
|
||||
});
|
||||
|
||||
require(['vs/editor/test/browser/controller/imeTester'], function(imeTester) {
|
||||
// console.log('loaded', imeTester);
|
||||
// imeTester.createTest();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,205 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Position } from '../../../common/core/position.js';
|
||||
import { IRange, Range } from '../../../common/core/range.js';
|
||||
import { EndOfLinePreference } from '../../../common/model.js';
|
||||
import * as dom from '../../../../base/browser/dom.js';
|
||||
import * as browser from '../../../../base/browser/browser.js';
|
||||
import * as platform from '../../../../base/common/platform.js';
|
||||
import { mainWindow } from '../../../../base/browser/window.js';
|
||||
import { TestAccessibilityService } from '../../../../platform/accessibility/test/common/testAccessibilityService.js';
|
||||
import { NullLogService } from '../../../../platform/log/common/log.js';
|
||||
import { SimplePagedScreenReaderStrategy } from '../../../browser/controller/editContext/screenReaderUtils.js';
|
||||
import { ISimpleModel } from '../../../common/viewModel/screenReaderSimpleModel.js';
|
||||
import { TextAreaState } from '../../../browser/controller/editContext/textArea/textAreaEditContextState.js';
|
||||
import { ITextAreaInputHost, TextAreaInput, TextAreaWrapper } from '../../../browser/controller/editContext/textArea/textAreaEditContextInput.js';
|
||||
import { Selection } from '../../../common/core/selection.js';
|
||||
|
||||
// To run this test, open imeTester.html
|
||||
|
||||
class SingleLineTestModel implements ISimpleModel {
|
||||
|
||||
private _line: string;
|
||||
|
||||
constructor(line: string) {
|
||||
this._line = line;
|
||||
}
|
||||
|
||||
_setText(text: string) {
|
||||
this._line = text;
|
||||
}
|
||||
|
||||
getLineContent(lineNumber: number): string {
|
||||
return this._line;
|
||||
}
|
||||
|
||||
getLineMaxColumn(lineNumber: number): number {
|
||||
return this._line.length + 1;
|
||||
}
|
||||
|
||||
getValueInRange(range: IRange, eol: EndOfLinePreference): string {
|
||||
return this._line.substring(range.startColumn - 1, range.endColumn - 1);
|
||||
}
|
||||
|
||||
getValueLengthInRange(range: Range, eol: EndOfLinePreference): number {
|
||||
return this.getValueInRange(range, eol).length;
|
||||
}
|
||||
|
||||
modifyPosition(position: Position, offset: number): Position {
|
||||
const column = Math.min(this.getLineMaxColumn(position.lineNumber), Math.max(1, position.column + offset));
|
||||
return new Position(position.lineNumber, column);
|
||||
}
|
||||
|
||||
getModelLineContent(lineNumber: number): string {
|
||||
return this._line;
|
||||
}
|
||||
|
||||
getLineCount(): number {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
class TestView {
|
||||
|
||||
private readonly _model: SingleLineTestModel;
|
||||
|
||||
constructor(model: SingleLineTestModel) {
|
||||
this._model = model;
|
||||
}
|
||||
|
||||
public paint(output: HTMLElement) {
|
||||
dom.clearNode(output);
|
||||
for (let i = 1; i <= this._model.getLineCount(); i++) {
|
||||
const textNode = document.createTextNode(this._model.getModelLineContent(i));
|
||||
output.appendChild(textNode);
|
||||
const br = document.createElement('br');
|
||||
output.appendChild(br);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function doCreateTest(description: string, inputStr: string, expectedStr: string): HTMLElement {
|
||||
let cursorOffset: number = 0;
|
||||
let cursorLength: number = 0;
|
||||
|
||||
const container = document.createElement('div');
|
||||
container.className = 'container';
|
||||
|
||||
const title = document.createElement('div');
|
||||
title.className = 'title';
|
||||
|
||||
const inputStrStrong = document.createElement('strong');
|
||||
inputStrStrong.innerText = inputStr;
|
||||
|
||||
title.innerText = description + '. Type ';
|
||||
title.appendChild(inputStrStrong);
|
||||
|
||||
container.appendChild(title);
|
||||
|
||||
const startBtn = document.createElement('button');
|
||||
startBtn.innerText = 'Start';
|
||||
container.appendChild(startBtn);
|
||||
|
||||
|
||||
const input = document.createElement('textarea');
|
||||
input.setAttribute('rows', '10');
|
||||
input.setAttribute('cols', '40');
|
||||
container.appendChild(input);
|
||||
|
||||
const model = new SingleLineTestModel('some text');
|
||||
const screenReaderStrategy = new SimplePagedScreenReaderStrategy();
|
||||
const textAreaInputHost: ITextAreaInputHost = {
|
||||
context: null,
|
||||
getScreenReaderContent: (): TextAreaState => {
|
||||
const selection = new Selection(1, 1 + cursorOffset, 1, 1 + cursorOffset + cursorLength);
|
||||
|
||||
const screenReaderContentState = screenReaderStrategy.fromEditorSelection(model, selection, 10, true);
|
||||
return TextAreaState.fromScreenReaderContentState(screenReaderContentState);
|
||||
},
|
||||
deduceModelPosition: (viewAnchorPosition: Position, deltaOffset: number, lineFeedCnt: number): Position => {
|
||||
return null!;
|
||||
}
|
||||
};
|
||||
|
||||
const handler = new TextAreaInput(textAreaInputHost, new TextAreaWrapper(input), platform.OS, {
|
||||
isAndroid: browser.isAndroid,
|
||||
isFirefox: browser.isFirefox,
|
||||
isChrome: browser.isChrome,
|
||||
isSafari: browser.isSafari,
|
||||
}, new TestAccessibilityService(), new NullLogService());
|
||||
|
||||
const output = document.createElement('pre');
|
||||
output.className = 'output';
|
||||
container.appendChild(output);
|
||||
|
||||
const check = document.createElement('pre');
|
||||
check.className = 'check';
|
||||
container.appendChild(check);
|
||||
|
||||
const br = document.createElement('br');
|
||||
br.style.clear = 'both';
|
||||
container.appendChild(br);
|
||||
|
||||
const view = new TestView(model);
|
||||
|
||||
const updatePosition = (off: number, len: number) => {
|
||||
cursorOffset = off;
|
||||
cursorLength = len;
|
||||
handler.writeNativeTextAreaContent('selection changed');
|
||||
handler.focusTextArea();
|
||||
};
|
||||
|
||||
const updateModelAndPosition = (text: string, off: number, len: number) => {
|
||||
model._setText(text);
|
||||
updatePosition(off, len);
|
||||
view.paint(output);
|
||||
|
||||
const expected = 'some ' + expectedStr + ' text';
|
||||
if (text === expected) {
|
||||
check.innerText = '[GOOD]';
|
||||
check.className = 'check good';
|
||||
} else {
|
||||
check.innerText = '[BAD]';
|
||||
check.className = 'check bad';
|
||||
}
|
||||
check.appendChild(document.createTextNode(expected));
|
||||
};
|
||||
|
||||
handler.onType((e) => {
|
||||
console.log('type text: ' + e.text + ', replaceCharCnt: ' + e.replacePrevCharCnt);
|
||||
const text = model.getModelLineContent(1);
|
||||
const preText = text.substring(0, cursorOffset - e.replacePrevCharCnt);
|
||||
const postText = text.substring(cursorOffset + cursorLength);
|
||||
const midText = e.text;
|
||||
|
||||
updateModelAndPosition(preText + midText + postText, (preText + midText).length, 0);
|
||||
});
|
||||
|
||||
view.paint(output);
|
||||
|
||||
startBtn.onclick = function () {
|
||||
updateModelAndPosition('some text', 5, 0);
|
||||
input.focus();
|
||||
};
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
const TESTS = [
|
||||
{ description: 'Japanese IME 1', in: 'sennsei [Enter]', out: 'せんせい' },
|
||||
{ description: 'Japanese IME 2', in: 'konnichiha [Enter]', out: 'こんいちは' },
|
||||
{ description: 'Japanese IME 3', in: 'mikann [Enter]', out: 'みかん' },
|
||||
{ description: 'Korean IME 1', in: 'gksrmf [Space]', out: '한글 ' },
|
||||
{ description: 'Chinese IME 1', in: '.,', out: '。,' },
|
||||
{ description: 'Chinese IME 2', in: 'ni [Space] hao [Space]', out: '你好' },
|
||||
{ description: 'Chinese IME 3', in: 'hazni [Space]', out: '哈祝你' },
|
||||
{ description: 'Mac dead key 1', in: '`.', out: '`.' },
|
||||
{ description: 'Mac hold key 1', in: 'e long press and 1', out: 'é' }
|
||||
];
|
||||
|
||||
TESTS.forEach((t) => {
|
||||
mainWindow.document.body.appendChild(doCreateTest(t.description, t.in, t.out));
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user