@codingame/monaco-vscode-walkthrough-service-override 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/assets/commandPalette.svg +50 -0
  2. package/assets/dark-hc.png +0 -0
  3. package/assets/dark.png +0 -0
  4. package/assets/debug.svg +87 -0
  5. package/assets/extensions-web.svg +216 -0
  6. package/assets/extensions.svg +236 -0
  7. package/assets/git.svg +105 -0
  8. package/assets/languages.svg +88 -0
  9. package/assets/learn.svg +85 -0
  10. package/assets/light-hc.png +0 -0
  11. package/assets/light.png +0 -0
  12. package/assets/menuBar.svg +100 -0
  13. package/assets/openFolder.svg +91 -0
  14. package/assets/profiles.svg +47 -0
  15. package/assets/runTask.svg +42 -0
  16. package/assets/search.svg +48 -0
  17. package/assets/settings.svg +53 -0
  18. package/assets/settingsSync.svg +148 -0
  19. package/assets/shortcuts.svg +180 -0
  20. package/assets/terminal.svg +42 -0
  21. package/assets/workspaceTrust.svg +43 -0
  22. package/index.d.ts +1 -0
  23. package/index.js +1 -0
  24. package/package.json +23 -0
  25. package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.contribution.js +421 -0
  26. package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.js +1528 -0
  27. package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedColors.js +48 -0
  28. package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedDetailsRenderer.js +263 -0
  29. package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedIcons.js +16 -0
  30. package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedInput.js +53 -0
  31. package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedList.js +97 -0
  32. package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/media/gettingStarted.css.js +6 -0
  33. package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/startupPage.js +218 -0
  34. package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/common/media/all.png.js +8 -0
  35. package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/common/media/all.svg.js +21 -0
  36. package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/common/media/notebookProfile.js +37 -0
  37. package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/common/media/theme_picker.js +53 -0
  38. package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/browser/editor/editorWalkThrough.js +63 -0
  39. package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/browser/editor/vs_code_editor_walkthrough.js +190 -0
  40. package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/browser/media/walkThroughPart.css.js +6 -0
  41. package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/browser/walkThrough.contribution.js +39 -0
  42. package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/browser/walkThroughActions.js +59 -0
  43. package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/browser/walkThroughInput.js +115 -0
  44. package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/browser/walkThroughPart.js +431 -0
  45. package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/common/walkThroughContentProvider.js +76 -0
  46. package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/common/walkThroughUtils.js +19 -0
  47. package/walkthrough.d.ts +5 -0
  48. package/walkthrough.js +21 -0
@@ -0,0 +1,39 @@
1
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
2
+ import { WalkThroughInput } from './walkThroughInput.js';
3
+ import { WalkThroughPart } from './walkThroughPart.js';
4
+ import { WalkThroughArrowUp, WalkThroughArrowDown, WalkThroughPageUp, WalkThroughPageDown } from './walkThroughActions.js';
5
+ import { WalkThroughSnippetContentProvider } from '../common/walkThroughContentProvider.js';
6
+ import { EditorWalkThroughAction, EditorWalkThroughInputSerializer } from './editor/editorWalkThrough.js';
7
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
8
+ import { EditorExtensions } from 'vscode/vscode/vs/workbench/common/editor';
9
+ import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
10
+ import { registerAction2, MenuRegistry, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
11
+ import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
12
+ import { EditorPaneDescriptor } from 'vscode/vscode/vs/workbench/browser/editor';
13
+ import { KeybindingsRegistry } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
14
+
15
+ ( Registry.as(EditorExtensions.EditorPane))
16
+ .registerEditorPane(EditorPaneDescriptor.create(WalkThroughPart, WalkThroughPart.ID, ( localizeWithPath(
17
+ 'vs/workbench/contrib/welcomeWalkthrough/browser/walkThrough.contribution',
18
+ 'walkThrough.editor.label',
19
+ "Playground"
20
+ ))), [( new SyncDescriptor(WalkThroughInput))]);
21
+ registerAction2(EditorWalkThroughAction);
22
+ ( Registry.as(EditorExtensions.EditorFactory)).registerEditorSerializer(EditorWalkThroughInputSerializer.ID, EditorWalkThroughInputSerializer);
23
+ registerWorkbenchContribution2(WalkThroughSnippetContentProvider.ID, WalkThroughSnippetContentProvider, { editorTypeId: WalkThroughPart.ID });
24
+ KeybindingsRegistry.registerCommandAndKeybindingRule(WalkThroughArrowUp);
25
+ KeybindingsRegistry.registerCommandAndKeybindingRule(WalkThroughArrowDown);
26
+ KeybindingsRegistry.registerCommandAndKeybindingRule(WalkThroughPageUp);
27
+ KeybindingsRegistry.registerCommandAndKeybindingRule(WalkThroughPageDown);
28
+ MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
29
+ group: '1_welcome',
30
+ command: {
31
+ id: 'workbench.action.showInteractivePlayground',
32
+ title: ( localizeWithPath(
33
+ 'vs/workbench/contrib/welcomeWalkthrough/browser/walkThrough.contribution',
34
+ { key: 'miPlayground', comment: ['&& denotes a mnemonic'] },
35
+ "Editor Playgrou&&nd"
36
+ ))
37
+ },
38
+ order: 3
39
+ });
@@ -0,0 +1,59 @@
1
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
2
+ import { WALK_THROUGH_FOCUS, WalkThroughPart } from './walkThroughPart.js';
3
+ import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
4
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
5
+
6
+ const WalkThroughArrowUp = {
7
+ id: 'workbench.action.interactivePlayground.arrowUp',
8
+ weight: 200 ,
9
+ when: ( ContextKeyExpr.and(WALK_THROUGH_FOCUS, ( EditorContextKeys.editorTextFocus.toNegated()))),
10
+ primary: 16 ,
11
+ handler: accessor => {
12
+ const editorService = accessor.get(IEditorService);
13
+ const activeEditorPane = editorService.activeEditorPane;
14
+ if (activeEditorPane instanceof WalkThroughPart) {
15
+ activeEditorPane.arrowUp();
16
+ }
17
+ }
18
+ };
19
+ const WalkThroughArrowDown = {
20
+ id: 'workbench.action.interactivePlayground.arrowDown',
21
+ weight: 200 ,
22
+ when: ( ContextKeyExpr.and(WALK_THROUGH_FOCUS, ( EditorContextKeys.editorTextFocus.toNegated()))),
23
+ primary: 18 ,
24
+ handler: accessor => {
25
+ const editorService = accessor.get(IEditorService);
26
+ const activeEditorPane = editorService.activeEditorPane;
27
+ if (activeEditorPane instanceof WalkThroughPart) {
28
+ activeEditorPane.arrowDown();
29
+ }
30
+ }
31
+ };
32
+ const WalkThroughPageUp = {
33
+ id: 'workbench.action.interactivePlayground.pageUp',
34
+ weight: 200 ,
35
+ when: ( ContextKeyExpr.and(WALK_THROUGH_FOCUS, ( EditorContextKeys.editorTextFocus.toNegated()))),
36
+ primary: 11 ,
37
+ handler: accessor => {
38
+ const editorService = accessor.get(IEditorService);
39
+ const activeEditorPane = editorService.activeEditorPane;
40
+ if (activeEditorPane instanceof WalkThroughPart) {
41
+ activeEditorPane.pageUp();
42
+ }
43
+ }
44
+ };
45
+ const WalkThroughPageDown = {
46
+ id: 'workbench.action.interactivePlayground.pageDown',
47
+ weight: 200 ,
48
+ when: ( ContextKeyExpr.and(WALK_THROUGH_FOCUS, ( EditorContextKeys.editorTextFocus.toNegated()))),
49
+ primary: 12 ,
50
+ handler: accessor => {
51
+ const editorService = accessor.get(IEditorService);
52
+ const activeEditorPane = editorService.activeEditorPane;
53
+ if (activeEditorPane instanceof WalkThroughPart) {
54
+ activeEditorPane.pageDown();
55
+ }
56
+ }
57
+ };
58
+
59
+ export { WalkThroughArrowDown, WalkThroughArrowUp, WalkThroughPageDown, WalkThroughPageUp };
@@ -0,0 +1,115 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { EditorInput } from 'vscode/vscode/vs/workbench/common/editor/editorInput';
3
+ import { EditorModel } from 'vscode/vscode/vs/workbench/common/editor/editorModel';
4
+ import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
5
+ import marked_1 from 'vscode/external/vscode-marked/lib/marked.esm.js';
6
+ import { isEqual } from 'vscode/vscode/vs/base/common/resources';
7
+ import { requireToContent } from '../common/walkThroughContentProvider.js';
8
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
9
+ import { Schemas } from 'vscode/vscode/vs/base/common/network';
10
+
11
+ var WalkThroughInput_1;
12
+ class WalkThroughModel extends EditorModel {
13
+ constructor(mainRef, snippetRefs) {
14
+ super();
15
+ this.mainRef = mainRef;
16
+ this.snippetRefs = snippetRefs;
17
+ }
18
+ get main() {
19
+ return this.mainRef;
20
+ }
21
+ get snippets() {
22
+ return ( this.snippetRefs.map(snippet => snippet.object));
23
+ }
24
+ dispose() {
25
+ this.snippetRefs.forEach(ref => ref.dispose());
26
+ super.dispose();
27
+ }
28
+ }
29
+ let WalkThroughInput = WalkThroughInput_1 = class WalkThroughInput extends EditorInput {
30
+ get capabilities() {
31
+ return 8 | super.capabilities;
32
+ }
33
+ get resource() { return this.options.resource; }
34
+ constructor(options, instantiationService, textModelResolverService) {
35
+ super();
36
+ this.options = options;
37
+ this.instantiationService = instantiationService;
38
+ this.textModelResolverService = textModelResolverService;
39
+ this.promise = null;
40
+ this.maxTopScroll = 0;
41
+ this.maxBottomScroll = 0;
42
+ }
43
+ get typeId() {
44
+ return this.options.typeId;
45
+ }
46
+ getName() {
47
+ return this.options.name;
48
+ }
49
+ getDescription() {
50
+ return this.options.description || '';
51
+ }
52
+ getTelemetryFrom() {
53
+ return this.options.telemetryFrom;
54
+ }
55
+ getTelemetryDescriptor() {
56
+ const descriptor = super.getTelemetryDescriptor();
57
+ descriptor['target'] = this.getTelemetryFrom();
58
+ return descriptor;
59
+ }
60
+ get onReady() {
61
+ return this.options.onReady;
62
+ }
63
+ get layout() {
64
+ return this.options.layout;
65
+ }
66
+ resolve() {
67
+ if (!this.promise) {
68
+ this.promise = requireToContent(this.instantiationService, this.options.resource)
69
+ .then(content => {
70
+ if (this.resource.path.endsWith('.html')) {
71
+ return ( new WalkThroughModel(content, []));
72
+ }
73
+ const snippets = [];
74
+ let i = 0;
75
+ const renderer = new marked_1.Renderer();
76
+ renderer.code = (code, lang) => {
77
+ i++;
78
+ const resource = this.options.resource.with({ scheme: Schemas.walkThroughSnippet, fragment: `${i}.${lang}` });
79
+ snippets.push(this.textModelResolverService.createModelReference(resource));
80
+ return `<div id="snippet-${resource.fragment}" class="walkThroughEditorContainer" ></div>`;
81
+ };
82
+ content = marked_1(content, { renderer });
83
+ return Promise.all(snippets)
84
+ .then(refs => ( new WalkThroughModel(content, refs)));
85
+ });
86
+ }
87
+ return this.promise;
88
+ }
89
+ matches(otherInput) {
90
+ if (super.matches(otherInput)) {
91
+ return true;
92
+ }
93
+ if (otherInput instanceof WalkThroughInput_1) {
94
+ return isEqual(otherInput.options.resource, this.options.resource);
95
+ }
96
+ return false;
97
+ }
98
+ dispose() {
99
+ if (this.promise) {
100
+ this.promise.then(model => model.dispose());
101
+ this.promise = null;
102
+ }
103
+ super.dispose();
104
+ }
105
+ relativeScrollPosition(topScroll, bottomScroll) {
106
+ this.maxTopScroll = Math.max(this.maxTopScroll, topScroll);
107
+ this.maxBottomScroll = Math.max(this.maxBottomScroll, bottomScroll);
108
+ }
109
+ };
110
+ WalkThroughInput = WalkThroughInput_1 = ( __decorate([
111
+ ( __param(1, IInstantiationService)),
112
+ ( __param(2, ITextModelService))
113
+ ], WalkThroughInput));
114
+
115
+ export { WalkThroughInput };
@@ -0,0 +1,431 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import '../common/walkThroughUtils.js';
3
+ import './media/walkThroughPart.css.js';
4
+ import { DomScrollableElement } from 'vscode/vscode/vs/base/browser/ui/scrollbar/scrollableElement';
5
+ import { Gesture, EventType } from 'vscode/vscode/vs/base/browser/touch';
6
+ import { escape } from 'vscode/vscode/vs/base/common/strings';
7
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
8
+ import { DisposableStore, toDisposable, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
9
+ import { EditorPane } from 'vscode/vscode/vs/workbench/browser/parts/editor/editorPane';
10
+ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
11
+ import { WalkThroughInput } from './walkThroughInput.js';
12
+ import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
13
+ import { ITextResourceConfigurationService } from 'vscode/vscode/vs/editor/common/services/textResourceConfiguration';
14
+ import { CodeEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/codeEditor/codeEditorWidget';
15
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
16
+ import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
17
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
18
+ import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
19
+ import { RawContextKey, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
20
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
21
+ import { isObject } from 'vscode/vscode/vs/base/common/types';
22
+ import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
23
+ import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
24
+ import { UILabelProvider } from 'vscode/vscode/vs/base/common/keybindingLabels';
25
+ import { OS } from 'vscode/vscode/vs/base/common/platform';
26
+ import { deepClone } from 'vscode/vscode/vs/base/common/objects';
27
+ import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
28
+ import { size, safeInnerHtml, addDisposableListener } from 'vscode/vscode/vs/base/browser/dom';
29
+ import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
30
+ import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
31
+
32
+ var WalkThroughPart_1;
33
+ const WALK_THROUGH_FOCUS = ( new RawContextKey('interactivePlaygroundFocus', false));
34
+ const UNBOUND_COMMAND = ( localizeWithPath(
35
+ 'vs/workbench/contrib/welcomeWalkthrough/browser/walkThroughPart',
36
+ 'walkThrough.unboundCommand',
37
+ "unbound"
38
+ ));
39
+ const WALK_THROUGH_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'walkThroughEditorViewState';
40
+ let WalkThroughPart = class WalkThroughPart extends EditorPane {
41
+ static { WalkThroughPart_1 = this; }
42
+ static { this.ID = 'workbench.editor.walkThroughPart'; }
43
+ constructor(group, telemetryService, themeService, textResourceConfigurationService, instantiationService, openerService, keybindingService, storageService, contextKeyService, configurationService, notificationService, extensionService, editorGroupService) {
44
+ super(WalkThroughPart_1.ID, group, telemetryService, themeService, storageService);
45
+ this.instantiationService = instantiationService;
46
+ this.openerService = openerService;
47
+ this.keybindingService = keybindingService;
48
+ this.contextKeyService = contextKeyService;
49
+ this.configurationService = configurationService;
50
+ this.notificationService = notificationService;
51
+ this.extensionService = extensionService;
52
+ this.disposables = ( new DisposableStore());
53
+ this.contentDisposables = [];
54
+ this.editorFocus = WALK_THROUGH_FOCUS.bindTo(this.contextKeyService);
55
+ this.editorMemento = this.getEditorMemento(editorGroupService, textResourceConfigurationService, WALK_THROUGH_EDITOR_VIEW_STATE_PREFERENCE_KEY);
56
+ }
57
+ createEditor(container) {
58
+ this.content = document.createElement('div');
59
+ this.content.classList.add('welcomePageFocusElement');
60
+ this.content.tabIndex = 0;
61
+ this.content.style.outlineStyle = 'none';
62
+ this.scrollbar = ( new DomScrollableElement(this.content, {
63
+ horizontal: 1 ,
64
+ vertical: 1
65
+ }));
66
+ this.disposables.add(this.scrollbar);
67
+ container.appendChild(this.scrollbar.getDomNode());
68
+ this.registerFocusHandlers();
69
+ this.registerClickHandler();
70
+ this.disposables.add(this.scrollbar.onScroll(e => this.updatedScrollPosition()));
71
+ }
72
+ updatedScrollPosition() {
73
+ const scrollDimensions = this.scrollbar.getScrollDimensions();
74
+ const scrollPosition = this.scrollbar.getScrollPosition();
75
+ const scrollHeight = scrollDimensions.scrollHeight;
76
+ if (scrollHeight && this.input instanceof WalkThroughInput) {
77
+ const scrollTop = scrollPosition.scrollTop;
78
+ const height = scrollDimensions.height;
79
+ this.input.relativeScrollPosition(scrollTop / scrollHeight, (scrollTop + height) / scrollHeight);
80
+ }
81
+ }
82
+ onTouchChange(event) {
83
+ event.preventDefault();
84
+ event.stopPropagation();
85
+ const scrollPosition = this.scrollbar.getScrollPosition();
86
+ this.scrollbar.setScrollPosition({ scrollTop: scrollPosition.scrollTop - event.translationY });
87
+ }
88
+ addEventListener(element, type, listener, useCapture) {
89
+ element.addEventListener(type, listener, useCapture);
90
+ return toDisposable(() => { element.removeEventListener(type, listener, useCapture); });
91
+ }
92
+ registerFocusHandlers() {
93
+ this.disposables.add(this.addEventListener(this.content, 'mousedown', e => {
94
+ this.focus();
95
+ }));
96
+ this.disposables.add(this.addEventListener(this.content, 'focus', e => {
97
+ this.editorFocus.set(true);
98
+ }));
99
+ this.disposables.add(this.addEventListener(this.content, 'blur', e => {
100
+ this.editorFocus.reset();
101
+ }));
102
+ this.disposables.add(this.addEventListener(this.content, 'focusin', (e) => {
103
+ if (e.target instanceof HTMLElement && e.target.classList.contains('zone-widget-container')) {
104
+ const scrollPosition = this.scrollbar.getScrollPosition();
105
+ this.content.scrollTop = scrollPosition.scrollTop;
106
+ this.content.scrollLeft = scrollPosition.scrollLeft;
107
+ }
108
+ if (e.target instanceof HTMLElement) {
109
+ this.lastFocus = e.target;
110
+ }
111
+ }));
112
+ }
113
+ registerClickHandler() {
114
+ this.content.addEventListener('click', event => {
115
+ for (let node = event.target; node; node = node.parentNode) {
116
+ if (node instanceof HTMLAnchorElement && node.href) {
117
+ const baseElement = node.ownerDocument.getElementsByTagName('base')[0] || this.window.location;
118
+ if (baseElement && node.href.indexOf(baseElement.href) >= 0 && node.hash) {
119
+ const scrollTarget = this.content.querySelector(node.hash);
120
+ const innerContent = this.content.firstElementChild;
121
+ if (scrollTarget && innerContent) {
122
+ const targetTop = scrollTarget.getBoundingClientRect().top - 20;
123
+ const containerTop = innerContent.getBoundingClientRect().top;
124
+ this.scrollbar.setScrollPosition({ scrollTop: targetTop - containerTop });
125
+ }
126
+ }
127
+ else {
128
+ this.open(( URI.parse(node.href)));
129
+ }
130
+ event.preventDefault();
131
+ break;
132
+ }
133
+ else if (node instanceof HTMLButtonElement) {
134
+ const href = node.getAttribute('data-href');
135
+ if (href) {
136
+ this.open(( URI.parse(href)));
137
+ }
138
+ break;
139
+ }
140
+ else if (node === event.currentTarget) {
141
+ break;
142
+ }
143
+ }
144
+ });
145
+ }
146
+ open(uri) {
147
+ if (uri.scheme === 'command' && uri.path === 'git.clone' && !CommandsRegistry.getCommand('git.clone')) {
148
+ this.notificationService.info(( localizeWithPath(
149
+ 'vs/workbench/contrib/welcomeWalkthrough/browser/walkThroughPart',
150
+ 'walkThrough.gitNotFound',
151
+ "It looks like Git is not installed on your system."
152
+ )));
153
+ return;
154
+ }
155
+ this.openerService.open(this.addFrom(uri), { allowCommands: true });
156
+ }
157
+ addFrom(uri) {
158
+ if (uri.scheme !== 'command' || !(this.input instanceof WalkThroughInput)) {
159
+ return uri;
160
+ }
161
+ const query = uri.query ? JSON.parse(uri.query) : {};
162
+ query.from = this.input.getTelemetryFrom();
163
+ return uri.with({ query: JSON.stringify(query) });
164
+ }
165
+ layout(dimension) {
166
+ this.size = dimension;
167
+ size(this.content, dimension.width, dimension.height);
168
+ this.updateSizeClasses();
169
+ this.contentDisposables.forEach(disposable => {
170
+ if (disposable instanceof CodeEditorWidget) {
171
+ disposable.layout();
172
+ }
173
+ });
174
+ const walkthroughInput = this.input instanceof WalkThroughInput && this.input;
175
+ if (walkthroughInput && walkthroughInput.layout) {
176
+ walkthroughInput.layout(dimension);
177
+ }
178
+ this.scrollbar.scanDomNode();
179
+ }
180
+ updateSizeClasses() {
181
+ const innerContent = this.content.firstElementChild;
182
+ if (this.size && innerContent) {
183
+ innerContent.classList.toggle('max-height-685px', this.size.height <= 685);
184
+ }
185
+ }
186
+ focus() {
187
+ super.focus();
188
+ let active = this.content.ownerDocument.activeElement;
189
+ while (active && active !== this.content) {
190
+ active = active.parentElement;
191
+ }
192
+ if (!active) {
193
+ (this.lastFocus || this.content).focus();
194
+ }
195
+ this.editorFocus.set(true);
196
+ }
197
+ arrowUp() {
198
+ const scrollPosition = this.scrollbar.getScrollPosition();
199
+ this.scrollbar.setScrollPosition({ scrollTop: scrollPosition.scrollTop - this.getArrowScrollHeight() });
200
+ }
201
+ arrowDown() {
202
+ const scrollPosition = this.scrollbar.getScrollPosition();
203
+ this.scrollbar.setScrollPosition({ scrollTop: scrollPosition.scrollTop + this.getArrowScrollHeight() });
204
+ }
205
+ getArrowScrollHeight() {
206
+ let fontSize = this.configurationService.getValue('editor.fontSize');
207
+ if (typeof fontSize !== 'number' || fontSize < 1) {
208
+ fontSize = 12;
209
+ }
210
+ return 3 * fontSize;
211
+ }
212
+ pageUp() {
213
+ const scrollDimensions = this.scrollbar.getScrollDimensions();
214
+ const scrollPosition = this.scrollbar.getScrollPosition();
215
+ this.scrollbar.setScrollPosition({ scrollTop: scrollPosition.scrollTop - scrollDimensions.height });
216
+ }
217
+ pageDown() {
218
+ const scrollDimensions = this.scrollbar.getScrollDimensions();
219
+ const scrollPosition = this.scrollbar.getScrollPosition();
220
+ this.scrollbar.setScrollPosition({ scrollTop: scrollPosition.scrollTop + scrollDimensions.height });
221
+ }
222
+ setInput(input, options, context, token) {
223
+ const store = ( new DisposableStore());
224
+ this.contentDisposables.push(store);
225
+ this.content.innerText = '';
226
+ return super.setInput(input, options, context, token)
227
+ .then(async () => {
228
+ if (input.resource.path.endsWith('.md')) {
229
+ await this.extensionService.whenInstalledExtensionsRegistered();
230
+ }
231
+ return input.resolve();
232
+ })
233
+ .then(model => {
234
+ if (token.isCancellationRequested) {
235
+ return;
236
+ }
237
+ const content = model.main;
238
+ if (!input.resource.path.endsWith('.md')) {
239
+ safeInnerHtml(this.content, content);
240
+ this.updateSizeClasses();
241
+ this.decorateContent();
242
+ this.contentDisposables.push(this.keybindingService.onDidUpdateKeybindings(() => this.decorateContent()));
243
+ input.onReady?.(this.content.firstElementChild, store);
244
+ this.scrollbar.scanDomNode();
245
+ this.loadTextEditorViewState(input);
246
+ this.updatedScrollPosition();
247
+ return;
248
+ }
249
+ const innerContent = document.createElement('div');
250
+ innerContent.classList.add('walkThroughContent');
251
+ const markdown = this.expandMacros(content);
252
+ safeInnerHtml(innerContent, markdown);
253
+ this.content.appendChild(innerContent);
254
+ model.snippets.forEach((snippet, i) => {
255
+ const model = snippet.textEditorModel;
256
+ if (!model) {
257
+ return;
258
+ }
259
+ const id = `snippet-${model.uri.fragment}`;
260
+ const div = innerContent.querySelector(`#${id.replace(/[\\.]/g, '\\$&')}`);
261
+ const options = this.getEditorOptions(model.getLanguageId());
262
+ const telemetryData = {
263
+ target: this.input instanceof WalkThroughInput ? this.input.getTelemetryFrom() : undefined,
264
+ snippet: i
265
+ };
266
+ const editor = this.instantiationService.createInstance(CodeEditorWidget, div, options, {
267
+ telemetryData: telemetryData
268
+ });
269
+ editor.setModel(model);
270
+ this.contentDisposables.push(editor);
271
+ const updateHeight = (initial) => {
272
+ const lineHeight = editor.getOption(67 );
273
+ const height = `${Math.max(model.getLineCount() + 1, 4) * lineHeight}px`;
274
+ if (div.style.height !== height) {
275
+ div.style.height = height;
276
+ editor.layout();
277
+ if (!initial) {
278
+ this.scrollbar.scanDomNode();
279
+ }
280
+ }
281
+ };
282
+ updateHeight(true);
283
+ this.contentDisposables.push(editor.onDidChangeModelContent(() => updateHeight(false)));
284
+ this.contentDisposables.push(editor.onDidChangeCursorPosition(e => {
285
+ const innerContent = this.content.firstElementChild;
286
+ if (innerContent) {
287
+ const targetTop = div.getBoundingClientRect().top;
288
+ const containerTop = innerContent.getBoundingClientRect().top;
289
+ const lineHeight = editor.getOption(67 );
290
+ const lineTop = (targetTop + (e.position.lineNumber - 1) * lineHeight) - containerTop;
291
+ const lineBottom = lineTop + lineHeight;
292
+ const scrollDimensions = this.scrollbar.getScrollDimensions();
293
+ const scrollPosition = this.scrollbar.getScrollPosition();
294
+ const scrollTop = scrollPosition.scrollTop;
295
+ const height = scrollDimensions.height;
296
+ if (scrollTop > lineTop) {
297
+ this.scrollbar.setScrollPosition({ scrollTop: lineTop });
298
+ }
299
+ else if (scrollTop < lineBottom - height) {
300
+ this.scrollbar.setScrollPosition({ scrollTop: lineBottom - height });
301
+ }
302
+ }
303
+ }));
304
+ this.contentDisposables.push(this.configurationService.onDidChangeConfiguration(e => {
305
+ if (e.affectsConfiguration('editor') && snippet.textEditorModel) {
306
+ editor.updateOptions(this.getEditorOptions(snippet.textEditorModel.getLanguageId()));
307
+ }
308
+ }));
309
+ });
310
+ this.updateSizeClasses();
311
+ this.multiCursorModifier();
312
+ this.contentDisposables.push(this.configurationService.onDidChangeConfiguration(e => {
313
+ if (e.affectsConfiguration('editor.multiCursorModifier')) {
314
+ this.multiCursorModifier();
315
+ }
316
+ }));
317
+ input.onReady?.(innerContent, store);
318
+ this.scrollbar.scanDomNode();
319
+ this.loadTextEditorViewState(input);
320
+ this.updatedScrollPosition();
321
+ this.contentDisposables.push(Gesture.addTarget(innerContent));
322
+ this.contentDisposables.push(addDisposableListener(innerContent, EventType.Change, e => this.onTouchChange(e)));
323
+ });
324
+ }
325
+ getEditorOptions(language) {
326
+ const config = deepClone(this.configurationService.getValue('editor', { overrideIdentifier: language }));
327
+ return {
328
+ ...(isObject(config) ? config : Object.create(null)),
329
+ scrollBeyondLastLine: false,
330
+ scrollbar: {
331
+ verticalScrollbarSize: 14,
332
+ horizontal: 'auto',
333
+ useShadows: true,
334
+ verticalHasArrows: false,
335
+ horizontalHasArrows: false,
336
+ alwaysConsumeMouseWheel: false
337
+ },
338
+ overviewRulerLanes: 3,
339
+ fixedOverflowWidgets: false,
340
+ lineNumbersMinChars: 1,
341
+ minimap: { enabled: false },
342
+ };
343
+ }
344
+ expandMacros(input) {
345
+ return input.replace(/kb\(([a-z.\d\-]+)\)/gi, (match, kb) => {
346
+ const keybinding = this.keybindingService.lookupKeybinding(kb);
347
+ const shortcut = keybinding ? keybinding.getLabel() || '' : UNBOUND_COMMAND;
348
+ return `<span class="shortcut">${escape(shortcut)}</span>`;
349
+ });
350
+ }
351
+ decorateContent() {
352
+ const keys = this.content.querySelectorAll('.shortcut[data-command]');
353
+ Array.prototype.forEach.call(keys, (key) => {
354
+ const command = key.getAttribute('data-command');
355
+ const keybinding = command && this.keybindingService.lookupKeybinding(command);
356
+ const label = keybinding ? keybinding.getLabel() || '' : UNBOUND_COMMAND;
357
+ while (key.firstChild) {
358
+ key.removeChild(key.firstChild);
359
+ }
360
+ key.appendChild(document.createTextNode(label));
361
+ });
362
+ const ifkeys = this.content.querySelectorAll('.if_shortcut[data-command]');
363
+ Array.prototype.forEach.call(ifkeys, (key) => {
364
+ const command = key.getAttribute('data-command');
365
+ const keybinding = command && this.keybindingService.lookupKeybinding(command);
366
+ key.style.display = !keybinding ? 'none' : '';
367
+ });
368
+ }
369
+ multiCursorModifier() {
370
+ const labels = UILabelProvider.modifierLabels[OS];
371
+ const value = this.configurationService.getValue('editor.multiCursorModifier');
372
+ const modifier = labels[value === 'ctrlCmd' ? (OS === 2 ? 'metaKey' : 'ctrlKey') : 'altKey'];
373
+ const keys = this.content.querySelectorAll('.multi-cursor-modifier');
374
+ Array.prototype.forEach.call(keys, (key) => {
375
+ while (key.firstChild) {
376
+ key.removeChild(key.firstChild);
377
+ }
378
+ key.appendChild(document.createTextNode(modifier));
379
+ });
380
+ }
381
+ saveTextEditorViewState(input) {
382
+ const scrollPosition = this.scrollbar.getScrollPosition();
383
+ this.editorMemento.saveEditorState(this.group, input, {
384
+ viewState: {
385
+ scrollTop: scrollPosition.scrollTop,
386
+ scrollLeft: scrollPosition.scrollLeft
387
+ }
388
+ });
389
+ }
390
+ loadTextEditorViewState(input) {
391
+ const state = this.editorMemento.loadEditorState(this.group, input);
392
+ if (state) {
393
+ this.scrollbar.setScrollPosition(state.viewState);
394
+ }
395
+ }
396
+ clearInput() {
397
+ if (this.input instanceof WalkThroughInput) {
398
+ this.saveTextEditorViewState(this.input);
399
+ }
400
+ this.contentDisposables = dispose(this.contentDisposables);
401
+ super.clearInput();
402
+ }
403
+ saveState() {
404
+ if (this.input instanceof WalkThroughInput) {
405
+ this.saveTextEditorViewState(this.input);
406
+ }
407
+ super.saveState();
408
+ }
409
+ dispose() {
410
+ this.editorFocus.reset();
411
+ this.contentDisposables = dispose(this.contentDisposables);
412
+ this.disposables.dispose();
413
+ super.dispose();
414
+ }
415
+ };
416
+ WalkThroughPart = WalkThroughPart_1 = ( __decorate([
417
+ ( __param(1, ITelemetryService)),
418
+ ( __param(2, IThemeService)),
419
+ ( __param(3, ITextResourceConfigurationService)),
420
+ ( __param(4, IInstantiationService)),
421
+ ( __param(5, IOpenerService)),
422
+ ( __param(6, IKeybindingService)),
423
+ ( __param(7, IStorageService)),
424
+ ( __param(8, IContextKeyService)),
425
+ ( __param(9, IConfigurationService)),
426
+ ( __param(10, INotificationService)),
427
+ ( __param(11, IExtensionService)),
428
+ ( __param(12, IEditorGroupsService))
429
+ ], WalkThroughPart));
430
+
431
+ export { WALK_THROUGH_FOCUS, WalkThroughPart };