diff --git a/src/tsconfig.monaco.json b/src/tsconfig.monaco.json index f9f0c874eb6..7d18928f6b4 100644 --- a/src/tsconfig.monaco.json +++ b/src/tsconfig.monaco.json @@ -2,7 +2,10 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "noEmit": true, - "types": ["trusted-types"], + "types": [ + "trusted-types", + "wicg-file-system-access" + ], "paths": {}, "module": "amd", "moduleResolution": "classic", diff --git a/src/vs/editor/common/dnd.ts b/src/vs/base/common/dataTransfer.ts similarity index 100% rename from src/vs/editor/common/dnd.ts rename to src/vs/base/common/dataTransfer.ts diff --git a/src/vs/editor/browser/config/editorConfiguration.ts b/src/vs/editor/browser/config/editorConfiguration.ts index 58474ac9363..e3f41e0d416 100644 --- a/src/vs/editor/browser/config/editorConfiguration.ts +++ b/src/vs/editor/browser/config/editorConfiguration.ts @@ -30,12 +30,6 @@ export interface IEditorConstructionOptions extends IEditorOptions { * Defaults to an internal DOM node. */ overflowWidgetsDomNode?: HTMLElement; - /** - * Enables dropping into the editor. - * - * This shows a preview of the drop location and triggers an `onDropIntoEditor` event. - */ - enableDropIntoEditor?: boolean; } export class EditorConfiguration extends Disposable implements IEditorConfiguration { diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index 801501376ce..25890eb2332 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -368,35 +368,42 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE this._actions[internalAction.id] = internalAction; }); - if (_options.enableDropIntoEditor) { - this._register(new dom.DragAndDropObserver(this._domElement, { - onDragEnter: () => undefined, - onDragOver: e => { - const target = this.getTargetAtClientPoint(e.clientX, e.clientY); - if (target?.position) { - this.showDropIndicatorAt(target.position); - } - }, - onDrop: async e => { - this.removeDropIndicator(); + this._register(new dom.DragAndDropObserver(this._domElement, { + onDragEnter: () => undefined, + onDragOver: e => { + if (!this._configuration.options.get(EditorOption.enableDropIntoEditor)) { + return; + } - if (!e.dataTransfer) { - return; - } + const target = this.getTargetAtClientPoint(e.clientX, e.clientY); + if (target?.position) { + this.showDropIndicatorAt(target.position); + } + }, + onDrop: async e => { + if (!this._configuration.options.get(EditorOption.enableDropIntoEditor)) { + return; + } + + this.removeDropIndicator(); + + if (!e.dataTransfer) { + return; + } + + const target = this.getTargetAtClientPoint(e.clientX, e.clientY); + if (target?.position) { + this._onDropIntoEditor.fire({ position: target.position, event: e }); + } + }, + onDragLeave: () => { + this.removeDropIndicator(); + }, + onDragEnd: () => { + this.removeDropIndicator(); + }, + })); - const target = this.getTargetAtClientPoint(e.clientX, e.clientY); - if (target?.position) { - this._onDropIntoEditor.fire({ position: target.position, event: e }); - } - }, - onDragLeave: () => { - this.removeDropIndicator(); - }, - onDragEnd: () => { - this.removeDropIndicator(); - }, - })); - } this._codeEditorService.addCodeEditor(this); } diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index feb0bd01946..022895e3e55 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -659,6 +659,13 @@ export interface IEditorOptions { * Configures bracket pair colorization (disabled by default). */ bracketPairColorization?: IBracketPairColorizationOptions; + + /** + * Enables dropping into the editor from an external source. + * + * This shows a preview of the drop location and triggers an `onDropIntoEditor` event. + */ + enableDropIntoEditor?: boolean; } /** @@ -4431,6 +4438,7 @@ export const enum EditorOption { disableMonospaceOptimizations, domReadOnly, dragAndDrop, + enableDropIntoEditor, emptySelectionClipboard, extraEditorClassName, fastScrollSensitivity, @@ -4739,6 +4747,9 @@ export const EditorOptions = { { description: nls.localize('dragAndDrop', "Controls whether the editor should allow moving selections via drag and drop.") } )), emptySelectionClipboard: register(new EditorEmptySelectionClipboard()), + enableDropIntoEditor: register(new EditorBooleanOption( + EditorOption.enableDropIntoEditor, 'enableDropIntoEditor', true + )), extraEditorClassName: register(new EditorStringOption( EditorOption.extraEditorClassName, 'extraEditorClassName', '', )), diff --git a/src/vs/editor/common/languages.ts b/src/vs/editor/common/languages.ts index 74306ee05d9..b5c7361ce88 100644 --- a/src/vs/editor/common/languages.ts +++ b/src/vs/editor/common/languages.ts @@ -4,11 +4,14 @@ *--------------------------------------------------------------------------------------------*/ import { CancellationToken } from 'vs/base/common/cancellation'; +import { Codicon, CSSIcon } from 'vs/base/common/codicons'; import { Color } from 'vs/base/common/color'; +import { IDataTransfer } from 'vs/base/common/dataTransfer'; import { Event } from 'vs/base/common/event'; import { IMarkdownString } from 'vs/base/common/htmlContent'; import { IDisposable } from 'vs/base/common/lifecycle'; import { URI, UriComponents } from 'vs/base/common/uri'; +import { ISingleEditOperation } from 'vs/editor/common/core/editOperation'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import { Selection } from 'vs/editor/common/core/selection'; @@ -16,10 +19,7 @@ import * as model from 'vs/editor/common/model'; import { TokenizationRegistry as TokenizationRegistryImpl } from 'vs/editor/common/tokenizationRegistry'; import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions'; import { IMarkerData } from 'vs/platform/markers/common/markers'; -import { Codicon, CSSIcon } from 'vs/base/common/codicons'; import { ThemeIcon } from 'vs/platform/theme/common/themeService'; -import { ISingleEditOperation } from 'vs/editor/common/core/editOperation'; -import { IDataTransfer } from 'vs/editor/common/dnd'; /** * Open ended enum at runtime diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index 265cb543054..8d709286d5c 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -199,107 +199,108 @@ export enum EditorOption { disableMonospaceOptimizations = 29, domReadOnly = 30, dragAndDrop = 31, - emptySelectionClipboard = 32, - extraEditorClassName = 33, - fastScrollSensitivity = 34, - find = 35, - fixedOverflowWidgets = 36, - folding = 37, - foldingStrategy = 38, - foldingHighlight = 39, - foldingImportsByDefault = 40, - foldingMaximumRegions = 41, - unfoldOnClickAfterEndOfLine = 42, - fontFamily = 43, - fontInfo = 44, - fontLigatures = 45, - fontSize = 46, - fontWeight = 47, - formatOnPaste = 48, - formatOnType = 49, - glyphMargin = 50, - gotoLocation = 51, - hideCursorInOverviewRuler = 52, - hover = 53, - inDiffEditor = 54, - inlineSuggest = 55, - letterSpacing = 56, - lightbulb = 57, - lineDecorationsWidth = 58, - lineHeight = 59, - lineNumbers = 60, - lineNumbersMinChars = 61, - linkedEditing = 62, - links = 63, - matchBrackets = 64, - minimap = 65, - mouseStyle = 66, - mouseWheelScrollSensitivity = 67, - mouseWheelZoom = 68, - multiCursorMergeOverlapping = 69, - multiCursorModifier = 70, - multiCursorPaste = 71, - occurrencesHighlight = 72, - overviewRulerBorder = 73, - overviewRulerLanes = 74, - padding = 75, - parameterHints = 76, - peekWidgetDefaultFocus = 77, - definitionLinkOpensInPeek = 78, - quickSuggestions = 79, - quickSuggestionsDelay = 80, - readOnly = 81, - renameOnType = 82, - renderControlCharacters = 83, - renderFinalNewline = 84, - renderLineHighlight = 85, - renderLineHighlightOnlyWhenFocus = 86, - renderValidationDecorations = 87, - renderWhitespace = 88, - revealHorizontalRightPadding = 89, - roundedSelection = 90, - rulers = 91, - scrollbar = 92, - scrollBeyondLastColumn = 93, - scrollBeyondLastLine = 94, - scrollPredominantAxis = 95, - selectionClipboard = 96, - selectionHighlight = 97, - selectOnLineNumbers = 98, - showFoldingControls = 99, - showUnused = 100, - snippetSuggestions = 101, - smartSelect = 102, - smoothScrolling = 103, - stickyTabStops = 104, - stopRenderingLineAfter = 105, - suggest = 106, - suggestFontSize = 107, - suggestLineHeight = 108, - suggestOnTriggerCharacters = 109, - suggestSelection = 110, - tabCompletion = 111, - tabIndex = 112, - unicodeHighlighting = 113, - unusualLineTerminators = 114, - useShadowDOM = 115, - useTabStops = 116, - wordSeparators = 117, - wordWrap = 118, - wordWrapBreakAfterCharacters = 119, - wordWrapBreakBeforeCharacters = 120, - wordWrapColumn = 121, - wordWrapOverride1 = 122, - wordWrapOverride2 = 123, - wrappingIndent = 124, - wrappingStrategy = 125, - showDeprecated = 126, - inlayHints = 127, - editorClassName = 128, - pixelRatio = 129, - tabFocusMode = 130, - layoutInfo = 131, - wrappingInfo = 132 + enableDropIntoEditor = 32, + emptySelectionClipboard = 33, + extraEditorClassName = 34, + fastScrollSensitivity = 35, + find = 36, + fixedOverflowWidgets = 37, + folding = 38, + foldingStrategy = 39, + foldingHighlight = 40, + foldingImportsByDefault = 41, + foldingMaximumRegions = 42, + unfoldOnClickAfterEndOfLine = 43, + fontFamily = 44, + fontInfo = 45, + fontLigatures = 46, + fontSize = 47, + fontWeight = 48, + formatOnPaste = 49, + formatOnType = 50, + glyphMargin = 51, + gotoLocation = 52, + hideCursorInOverviewRuler = 53, + hover = 54, + inDiffEditor = 55, + inlineSuggest = 56, + letterSpacing = 57, + lightbulb = 58, + lineDecorationsWidth = 59, + lineHeight = 60, + lineNumbers = 61, + lineNumbersMinChars = 62, + linkedEditing = 63, + links = 64, + matchBrackets = 65, + minimap = 66, + mouseStyle = 67, + mouseWheelScrollSensitivity = 68, + mouseWheelZoom = 69, + multiCursorMergeOverlapping = 70, + multiCursorModifier = 71, + multiCursorPaste = 72, + occurrencesHighlight = 73, + overviewRulerBorder = 74, + overviewRulerLanes = 75, + padding = 76, + parameterHints = 77, + peekWidgetDefaultFocus = 78, + definitionLinkOpensInPeek = 79, + quickSuggestions = 80, + quickSuggestionsDelay = 81, + readOnly = 82, + renameOnType = 83, + renderControlCharacters = 84, + renderFinalNewline = 85, + renderLineHighlight = 86, + renderLineHighlightOnlyWhenFocus = 87, + renderValidationDecorations = 88, + renderWhitespace = 89, + revealHorizontalRightPadding = 90, + roundedSelection = 91, + rulers = 92, + scrollbar = 93, + scrollBeyondLastColumn = 94, + scrollBeyondLastLine = 95, + scrollPredominantAxis = 96, + selectionClipboard = 97, + selectionHighlight = 98, + selectOnLineNumbers = 99, + showFoldingControls = 100, + showUnused = 101, + snippetSuggestions = 102, + smartSelect = 103, + smoothScrolling = 104, + stickyTabStops = 105, + stopRenderingLineAfter = 106, + suggest = 107, + suggestFontSize = 108, + suggestLineHeight = 109, + suggestOnTriggerCharacters = 110, + suggestSelection = 111, + tabCompletion = 112, + tabIndex = 113, + unicodeHighlighting = 114, + unusualLineTerminators = 115, + useShadowDOM = 116, + useTabStops = 117, + wordSeparators = 118, + wordWrap = 119, + wordWrapBreakAfterCharacters = 120, + wordWrapBreakBeforeCharacters = 121, + wordWrapColumn = 122, + wordWrapOverride1 = 123, + wordWrapOverride2 = 124, + wrappingIndent = 125, + wrappingStrategy = 126, + showDeprecated = 127, + inlayHints = 128, + editorClassName = 129, + pixelRatio = 130, + tabFocusMode = 131, + layoutInfo = 132, + wrappingInfo = 133 } /** diff --git a/src/vs/workbench/contrib/dropIntoEditor/browser/dropIntoEditor.contibution.ts b/src/vs/editor/contrib/dropIntoEditor/browser/dropIntoEditorContribution.ts similarity index 62% rename from src/vs/workbench/contrib/dropIntoEditor/browser/dropIntoEditor.contibution.ts rename to src/vs/editor/contrib/dropIntoEditor/browser/dropIntoEditorContribution.ts index def227ff8b3..d113f9e513c 100644 --- a/src/vs/workbench/contrib/dropIntoEditor/browser/dropIntoEditor.contibution.ts +++ b/src/vs/editor/contrib/dropIntoEditor/browser/dropIntoEditorContribution.ts @@ -5,6 +5,7 @@ import { distinct } from 'vs/base/common/arrays'; import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation'; +import { IDataTransfer, IDataTransferItem } from 'vs/base/common/dataTransfer'; import { Disposable } from 'vs/base/common/lifecycle'; import { Mimes } from 'vs/base/common/mime'; import { relativePath } from 'vs/base/common/resources'; @@ -13,13 +14,15 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { registerEditorContribution } from 'vs/editor/browser/editorExtensions'; import { IPosition } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; -import { IDataTransfer, IDataTransferItem } from 'vs/editor/common/dnd'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; +import { DocumentOnDropEditProvider, SnippetTextEdit } from 'vs/editor/common/languages'; +import { ITextModel } from 'vs/editor/common/model'; import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures'; import { performSnippetEdit } from 'vs/editor/contrib/snippet/browser/snippetController2'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { extractEditorsDropData, FileAdditionalNativeProperties } from 'vs/platform/dnd/browser/dnd'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; -import { extractEditorsDropData } from 'vs/workbench/browser/dnd'; export class DropIntoEditorController extends Disposable implements IEditorContribution { @@ -28,13 +31,31 @@ export class DropIntoEditorController extends Disposable implements IEditorContr constructor( editor: ICodeEditor, + @IWorkspaceContextService workspaceContextService: IWorkspaceContextService, @IInstantiationService private readonly _instantiationService: IInstantiationService, @ILanguageFeaturesService private readonly _languageFeaturesService: ILanguageFeaturesService, - @IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService, + @IConfigurationService private readonly _configurationService: IConfigurationService, ) { super(); - editor.onDropIntoEditor(e => this.onDropIntoEditor(editor, e.position, e.event)); + this._register(editor.onDropIntoEditor(e => this.onDropIntoEditor(editor, e.position, e.event))); + + + this._languageFeaturesService.documentOnDropEditProvider.register('*', new DefaultOnDropProvider(workspaceContextService)); + + this._register(this._configurationService.onDidChangeConfiguration(e => { + if (e.affectsConfiguration('workbench.experimental.editor.dropIntoEditor.enabled')) { + this.updateEditorOptions(editor); + } + })); + + this.updateEditorOptions(editor); + } + + private updateEditorOptions(editor: ICodeEditor) { + editor.updateOptions({ + enableDropIntoEditor: this._configurationService.getValue('workbench.experimental.editor.dropIntoEditor.enabled') + }); } private async onDropIntoEditor(editor: ICodeEditor, position: IPosition, dragEvent: DragEvent) { @@ -45,7 +66,39 @@ export class DropIntoEditorController extends Disposable implements IEditorContr const model = editor.getModel(); const modelVersionNow = model.getVersionId(); + const ourDataTransfer = await this.extractDataTransferData(dragEvent); + if (ourDataTransfer.size === 0) { + return; + } + + if (editor.getModel().getVersionId() !== modelVersionNow) { + return; + } + + const cts = new CancellationTokenSource(); + editor.onDidDispose(() => cts.cancel()); + model.onDidChangeContent(() => cts.cancel()); + + const providers = this._languageFeaturesService.documentOnDropEditProvider.ordered(model); + for (const provider of providers) { + const edit = await provider.provideDocumentOnDropEdits(model, position, ourDataTransfer, cts.token); + if (cts.token.isCancellationRequested || editor.getModel().getVersionId() !== modelVersionNow) { + return; + } + + if (edit) { + performSnippetEdit(editor, edit); + return; + } + } + } + + public async extractDataTransferData(dragEvent: DragEvent): Promise { const textEditorDataTransfer: IDataTransfer = new Map(); + if (!dragEvent.dataTransfer) { + return textEditorDataTransfer; + } + for (const item of dragEvent.dataTransfer.items) { const type = item.type; if (item.kind === 'string') { @@ -61,7 +114,7 @@ export class DropIntoEditorController extends Disposable implements IEditorContr textEditorDataTransfer.set(type, { asString: () => Promise.resolve(''), asFile: () => { - const uri = file.path ? URI.parse(file.path) : undefined; + const uri = (file as FileAdditionalNativeProperties).path ? URI.parse((file as FileAdditionalNativeProperties).path!) : undefined; return { name: file.name, uri: uri, @@ -76,66 +129,52 @@ export class DropIntoEditorController extends Disposable implements IEditorContr } } - if (!textEditorDataTransfer.has(Mimes.uriList.toLowerCase())) { + if (!textEditorDataTransfer.has(Mimes.uriList)) { const editorData = (await this._instantiationService.invokeFunction(extractEditorsDropData, dragEvent)) .filter(input => input.resource) .map(input => input.resource!.toString()); if (editorData.length) { + const added: IDataTransfer = new Map(); + const str = distinct(editorData).join('\n'); - textEditorDataTransfer.set(Mimes.uriList.toLowerCase(), { - asString: () => Promise.resolve(str), + added.set(Mimes.uriList.toLowerCase(), { asFile: () => undefined, - value: undefined + asString: async () => str, + value: str, }); + return added; } } - if (textEditorDataTransfer.size === 0) { - return; - } - - if (editor.getModel().getVersionId() !== modelVersionNow) { - return; - } - - const cts = new CancellationTokenSource(); - editor.onDidDispose(() => cts.cancel()); - model.onDidChangeContent(() => cts.cancel()); - - const ordered = this._languageFeaturesService.documentOnDropEditProvider.ordered(model); - for (const provider of ordered) { - const edit = await provider.provideDocumentOnDropEdits(model, position, textEditorDataTransfer, cts.token); - if (cts.token.isCancellationRequested || editor.getModel().getVersionId() !== modelVersionNow) { - return; - } - - if (edit) { - performSnippetEdit(editor, edit); - return; - } - } - - return this.doDefaultDrop(editor, position, textEditorDataTransfer, cts.token); + return textEditorDataTransfer; } +} - private async doDefaultDrop(editor: ICodeEditor, position: IPosition, textEditorDataTransfer: IDataTransfer, token: CancellationToken): Promise { +class DefaultOnDropProvider implements DocumentOnDropEditProvider { + + constructor( + @IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService, + ) { } + + async provideDocumentOnDropEdits(model: ITextModel, position: IPosition, dataTransfer: IDataTransfer, _token: CancellationToken): Promise { const range = new Range(position.lineNumber, position.column, position.lineNumber, position.column); - const urlListEntry = textEditorDataTransfer.get('text/uri-list'); + const urlListEntry = dataTransfer.get('text/uri-list'); if (urlListEntry) { const urlList = await urlListEntry.asString(); - return this.doUriListDrop(editor, range, urlList, token); + return this.doUriListDrop(range, urlList); } - const textEntry = textEditorDataTransfer.get('text') ?? textEditorDataTransfer.get(Mimes.text); + const textEntry = dataTransfer.get('text') ?? dataTransfer.get(Mimes.text); if (textEntry) { const text = await textEntry.asString(); - performSnippetEdit(editor, { range, snippet: text }); + return { range, snippet: text }; } + return undefined; } - private async doUriListDrop(editor: ICodeEditor, range: Range, urlList: string, token: CancellationToken): Promise { + private doUriListDrop(range: Range, urlList: string): SnippetTextEdit | undefined { const uris: URI[] = []; for (const resource of urlList.split('\n')) { try { @@ -162,7 +201,7 @@ export class DropIntoEditorController extends Disposable implements IEditorContr }) .join(' '); - performSnippetEdit(editor, { range, snippet }); + return { range, snippet }; } } diff --git a/src/vs/editor/editor.all.ts b/src/vs/editor/editor.all.ts index fdd3f3f8d7f..aba1e89aa1d 100644 --- a/src/vs/editor/editor.all.ts +++ b/src/vs/editor/editor.all.ts @@ -19,6 +19,7 @@ import 'vs/editor/contrib/comment/browser/comment'; import 'vs/editor/contrib/contextmenu/browser/contextmenu'; import 'vs/editor/contrib/cursorUndo/browser/cursorUndo'; import 'vs/editor/contrib/dnd/browser/dnd'; +import 'vs/editor/contrib/dropIntoEditor/browser/dropIntoEditorContribution'; import 'vs/editor/contrib/find/browser/findController'; import 'vs/editor/contrib/folding/browser/folding'; import 'vs/editor/contrib/fontZoom/browser/fontZoom'; diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 8390e8adca5..cba1ad5adc5 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -3413,6 +3413,12 @@ declare namespace monaco.editor { * Configures bracket pair colorization (disabled by default). */ bracketPairColorization?: IBracketPairColorizationOptions; + /** + * Enables dropping into the editor from an external source. + * + * This shows a preview of the drop location and triggers an `onDropIntoEditor` event. + */ + enableDropIntoEditor?: boolean; } export interface IDiffEditorBaseOptions { @@ -4314,107 +4320,108 @@ declare namespace monaco.editor { disableMonospaceOptimizations = 29, domReadOnly = 30, dragAndDrop = 31, - emptySelectionClipboard = 32, - extraEditorClassName = 33, - fastScrollSensitivity = 34, - find = 35, - fixedOverflowWidgets = 36, - folding = 37, - foldingStrategy = 38, - foldingHighlight = 39, - foldingImportsByDefault = 40, - foldingMaximumRegions = 41, - unfoldOnClickAfterEndOfLine = 42, - fontFamily = 43, - fontInfo = 44, - fontLigatures = 45, - fontSize = 46, - fontWeight = 47, - formatOnPaste = 48, - formatOnType = 49, - glyphMargin = 50, - gotoLocation = 51, - hideCursorInOverviewRuler = 52, - hover = 53, - inDiffEditor = 54, - inlineSuggest = 55, - letterSpacing = 56, - lightbulb = 57, - lineDecorationsWidth = 58, - lineHeight = 59, - lineNumbers = 60, - lineNumbersMinChars = 61, - linkedEditing = 62, - links = 63, - matchBrackets = 64, - minimap = 65, - mouseStyle = 66, - mouseWheelScrollSensitivity = 67, - mouseWheelZoom = 68, - multiCursorMergeOverlapping = 69, - multiCursorModifier = 70, - multiCursorPaste = 71, - occurrencesHighlight = 72, - overviewRulerBorder = 73, - overviewRulerLanes = 74, - padding = 75, - parameterHints = 76, - peekWidgetDefaultFocus = 77, - definitionLinkOpensInPeek = 78, - quickSuggestions = 79, - quickSuggestionsDelay = 80, - readOnly = 81, - renameOnType = 82, - renderControlCharacters = 83, - renderFinalNewline = 84, - renderLineHighlight = 85, - renderLineHighlightOnlyWhenFocus = 86, - renderValidationDecorations = 87, - renderWhitespace = 88, - revealHorizontalRightPadding = 89, - roundedSelection = 90, - rulers = 91, - scrollbar = 92, - scrollBeyondLastColumn = 93, - scrollBeyondLastLine = 94, - scrollPredominantAxis = 95, - selectionClipboard = 96, - selectionHighlight = 97, - selectOnLineNumbers = 98, - showFoldingControls = 99, - showUnused = 100, - snippetSuggestions = 101, - smartSelect = 102, - smoothScrolling = 103, - stickyTabStops = 104, - stopRenderingLineAfter = 105, - suggest = 106, - suggestFontSize = 107, - suggestLineHeight = 108, - suggestOnTriggerCharacters = 109, - suggestSelection = 110, - tabCompletion = 111, - tabIndex = 112, - unicodeHighlighting = 113, - unusualLineTerminators = 114, - useShadowDOM = 115, - useTabStops = 116, - wordSeparators = 117, - wordWrap = 118, - wordWrapBreakAfterCharacters = 119, - wordWrapBreakBeforeCharacters = 120, - wordWrapColumn = 121, - wordWrapOverride1 = 122, - wordWrapOverride2 = 123, - wrappingIndent = 124, - wrappingStrategy = 125, - showDeprecated = 126, - inlayHints = 127, - editorClassName = 128, - pixelRatio = 129, - tabFocusMode = 130, - layoutInfo = 131, - wrappingInfo = 132 + enableDropIntoEditor = 32, + emptySelectionClipboard = 33, + extraEditorClassName = 34, + fastScrollSensitivity = 35, + find = 36, + fixedOverflowWidgets = 37, + folding = 38, + foldingStrategy = 39, + foldingHighlight = 40, + foldingImportsByDefault = 41, + foldingMaximumRegions = 42, + unfoldOnClickAfterEndOfLine = 43, + fontFamily = 44, + fontInfo = 45, + fontLigatures = 46, + fontSize = 47, + fontWeight = 48, + formatOnPaste = 49, + formatOnType = 50, + glyphMargin = 51, + gotoLocation = 52, + hideCursorInOverviewRuler = 53, + hover = 54, + inDiffEditor = 55, + inlineSuggest = 56, + letterSpacing = 57, + lightbulb = 58, + lineDecorationsWidth = 59, + lineHeight = 60, + lineNumbers = 61, + lineNumbersMinChars = 62, + linkedEditing = 63, + links = 64, + matchBrackets = 65, + minimap = 66, + mouseStyle = 67, + mouseWheelScrollSensitivity = 68, + mouseWheelZoom = 69, + multiCursorMergeOverlapping = 70, + multiCursorModifier = 71, + multiCursorPaste = 72, + occurrencesHighlight = 73, + overviewRulerBorder = 74, + overviewRulerLanes = 75, + padding = 76, + parameterHints = 77, + peekWidgetDefaultFocus = 78, + definitionLinkOpensInPeek = 79, + quickSuggestions = 80, + quickSuggestionsDelay = 81, + readOnly = 82, + renameOnType = 83, + renderControlCharacters = 84, + renderFinalNewline = 85, + renderLineHighlight = 86, + renderLineHighlightOnlyWhenFocus = 87, + renderValidationDecorations = 88, + renderWhitespace = 89, + revealHorizontalRightPadding = 90, + roundedSelection = 91, + rulers = 92, + scrollbar = 93, + scrollBeyondLastColumn = 94, + scrollBeyondLastLine = 95, + scrollPredominantAxis = 96, + selectionClipboard = 97, + selectionHighlight = 98, + selectOnLineNumbers = 99, + showFoldingControls = 100, + showUnused = 101, + snippetSuggestions = 102, + smartSelect = 103, + smoothScrolling = 104, + stickyTabStops = 105, + stopRenderingLineAfter = 106, + suggest = 107, + suggestFontSize = 108, + suggestLineHeight = 109, + suggestOnTriggerCharacters = 110, + suggestSelection = 111, + tabCompletion = 112, + tabIndex = 113, + unicodeHighlighting = 114, + unusualLineTerminators = 115, + useShadowDOM = 116, + useTabStops = 117, + wordSeparators = 118, + wordWrap = 119, + wordWrapBreakAfterCharacters = 120, + wordWrapBreakBeforeCharacters = 121, + wordWrapColumn = 122, + wordWrapOverride1 = 123, + wordWrapOverride2 = 124, + wrappingIndent = 125, + wrappingStrategy = 126, + showDeprecated = 127, + inlayHints = 128, + editorClassName = 129, + pixelRatio = 130, + tabFocusMode = 131, + layoutInfo = 132, + wrappingInfo = 133 } export const EditorOptions: { @@ -4452,6 +4459,7 @@ declare namespace monaco.editor { domReadOnly: IEditorOption; dragAndDrop: IEditorOption; emptySelectionClipboard: IEditorOption; + enableDropIntoEditor: IEditorOption; extraEditorClassName: IEditorOption; fastScrollSensitivity: IEditorOption; find: IEditorOption>>; @@ -4573,12 +4581,6 @@ declare namespace monaco.editor { * Defaults to an internal DOM node. */ overflowWidgetsDomNode?: HTMLElement; - /** - * Enables dropping into the editor. - * - * This shows a preview of the drop location and triggers an `onDropIntoEditor` event. - */ - enableDropIntoEditor?: boolean; } /** diff --git a/src/vs/platform/dnd/browser/dnd.ts b/src/vs/platform/dnd/browser/dnd.ts new file mode 100644 index 00000000000..14c6c8d11d3 --- /dev/null +++ b/src/vs/platform/dnd/browser/dnd.ts @@ -0,0 +1,339 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { DataTransfers } from 'vs/base/browser/dnd'; +import { DragMouseEvent } from 'vs/base/browser/mouseEvent'; +import { coalesce } from 'vs/base/common/arrays'; +import { DeferredPromise } from 'vs/base/common/async'; +import { VSBuffer } from 'vs/base/common/buffer'; +import { parse } from 'vs/base/common/marshalling'; +import { Schemas } from 'vs/base/common/network'; +import { isWeb } from 'vs/base/common/platform'; +import Severity from 'vs/base/common/severity'; +import { withNullAsUndefined } from 'vs/base/common/types'; +import { URI } from 'vs/base/common/uri'; +import { localize } from 'vs/nls'; +import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; +import { IBaseTextResourceEditorInput } from 'vs/platform/editor/common/editor'; +import { HTMLFileSystemProvider } from 'vs/platform/files/browser/htmlFileSystemProvider'; +import { WebFileSystemAccess } from 'vs/platform/files/browser/webFileSystemAccess'; +import { ByteSize, IFileService } from 'vs/platform/files/common/files'; +import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; +import { extractSelection } from 'vs/platform/opener/common/opener'; +import { Registry } from 'vs/platform/registry/common/platform'; + +export interface FileAdditionalNativeProperties { + /** + * The real path to the file on the users filesystem. Only available on electron. + */ + readonly path?: string; +} + + +//#region Editor / Resources DND + +export const CodeDataTransfers = { + EDITORS: 'CodeEditors', + FILES: 'CodeFiles' +}; + +export interface IDraggedResourceEditorInput extends IBaseTextResourceEditorInput { + resource: URI | undefined; + + /** + * A hint that the source of the dragged editor input + * might not be the application but some external tool. + */ + isExternal?: boolean; + + /** + * Whether we probe for the dropped editor to be a workspace + * (i.e. code-workspace file or even a folder), allowing to + * open it as workspace instead of opening as editor. + */ + allowWorkspaceOpen?: boolean; +} + +export async function extractEditorsDropData(accessor: ServicesAccessor, e: DragEvent): Promise> { + const editors: IDraggedResourceEditorInput[] = []; + if (e.dataTransfer && e.dataTransfer.types.length > 0) { + + // Data Transfer: Code Editors + const rawEditorsData = e.dataTransfer.getData(CodeDataTransfers.EDITORS); + if (rawEditorsData) { + try { + editors.push(...parse(rawEditorsData)); + } catch (error) { + // Invalid transfer + } + } + + // Data Transfer: Resources + else { + try { + const rawResourcesData = e.dataTransfer.getData(DataTransfers.RESOURCES); + editors.push(...createDraggedEditorInputFromRawResourcesData(rawResourcesData)); + } catch (error) { + // Invalid transfer + } + } + + // Check for native file transfer + if (e.dataTransfer?.files) { + for (let i = 0; i < e.dataTransfer.files.length; i++) { + const file = e.dataTransfer.files[i]; + if (file && (file as FileAdditionalNativeProperties).path /* Electron only */) { + try { + editors.push({ resource: URI.file((file as FileAdditionalNativeProperties).path!), isExternal: true, allowWorkspaceOpen: true }); + } catch (error) { + // Invalid URI + } + } + } + } + + // Check for CodeFiles transfer + const rawCodeFiles = e.dataTransfer.getData(CodeDataTransfers.FILES); + if (rawCodeFiles) { + try { + const codeFiles: string[] = JSON.parse(rawCodeFiles); + for (const codeFile of codeFiles) { + editors.push({ resource: URI.file(codeFile), isExternal: true, allowWorkspaceOpen: true }); + } + } catch (error) { + // Invalid transfer + } + } + + // Web: Check for file transfer + if (isWeb && containsDragType(e, DataTransfers.FILES)) { + const files = e.dataTransfer.items; + if (files) { + const instantiationService = accessor.get(IInstantiationService); + const filesData = await instantiationService.invokeFunction(accessor => extractFilesDropData(accessor, e)); + for (const fileData of filesData) { + editors.push({ resource: fileData.resource, contents: fileData.contents?.toString(), isExternal: true, allowWorkspaceOpen: fileData.isDirectory }); + } + } + } + + // Workbench contributions + const contributions = Registry.as(Extensions.DragAndDropContribution).getAll(); + for (const contribution of contributions) { + const data = e.dataTransfer.getData(contribution.dataFormatKey); + if (data) { + try { + editors.push(...contribution.getEditorInputs(data)); + } catch (error) { + // Invalid transfer + } + } + } + } + + return editors; +} + +export function createDraggedEditorInputFromRawResourcesData(rawResourcesData: string | undefined): IDraggedResourceEditorInput[] { + const editors: IDraggedResourceEditorInput[] = []; + + if (rawResourcesData) { + const resourcesRaw: string[] = JSON.parse(rawResourcesData); + for (const resourceRaw of resourcesRaw) { + if (resourceRaw.indexOf(':') > 0) { // mitigate https://github.com/microsoft/vscode/issues/124946 + const { selection, uri } = extractSelection(URI.parse(resourceRaw)); + editors.push({ resource: uri, options: { selection } }); + } + } + } + + return editors; +} + + +interface IFileTransferData { + resource: URI; + isDirectory?: boolean; + contents?: VSBuffer; +} + +async function extractFilesDropData(accessor: ServicesAccessor, event: DragEvent): Promise { + + // Try to extract via `FileSystemHandle` + if (WebFileSystemAccess.supported(window)) { + const items = event.dataTransfer?.items; + if (items) { + return extractFileTransferData(accessor, items); + } + } + + // Try to extract via `FileList` + const files = event.dataTransfer?.files; + if (!files) { + return []; + } + + return extractFileListData(accessor, files); +} + +async function extractFileTransferData(accessor: ServicesAccessor, items: DataTransferItemList): Promise { + const fileSystemProvider = accessor.get(IFileService).getProvider(Schemas.file); + if (!(fileSystemProvider instanceof HTMLFileSystemProvider)) { + return []; // only supported when running in web + } + + const results: DeferredPromise[] = []; + + for (let i = 0; i < items.length; i++) { + const file = items[i]; + if (file) { + const result = new DeferredPromise(); + results.push(result); + + (async () => { + try { + const handle = await file.getAsFileSystemHandle(); + if (!handle) { + result.complete(undefined); + return; + } + + if (WebFileSystemAccess.isFileSystemFileHandle(handle)) { + result.complete({ + resource: await fileSystemProvider.registerFileHandle(handle), + isDirectory: false + }); + } else if (WebFileSystemAccess.isFileSystemDirectoryHandle(handle)) { + result.complete({ + resource: await fileSystemProvider.registerDirectoryHandle(handle), + isDirectory: true + }); + } else { + result.complete(undefined); + } + } catch (error) { + result.complete(undefined); + } + })(); + } + } + + return coalesce(await Promise.all(results.map(result => result.p))); +} + +export async function extractFileListData(accessor: ServicesAccessor, files: FileList): Promise { + const dialogService = accessor.get(IDialogService); + + const results: DeferredPromise[] = []; + + for (let i = 0; i < files.length; i++) { + const file = files.item(i); + if (file) { + + // Skip for very large files because this operation is unbuffered + if (file.size > 100 * ByteSize.MB) { + dialogService.show(Severity.Warning, localize('fileTooLarge', "File is too large to open as untitled editor. Please upload it first into the file explorer and then try again.")); + continue; + } + + const result = new DeferredPromise(); + results.push(result); + + const reader = new FileReader(); + + reader.onerror = () => result.complete(undefined); + reader.onabort = () => result.complete(undefined); + + reader.onload = async event => { + const name = file.name; + const loadResult = withNullAsUndefined(event.target?.result); + if (typeof name !== 'string' || typeof loadResult === 'undefined') { + result.complete(undefined); + return; + } + + result.complete({ + resource: URI.from({ scheme: Schemas.untitled, path: name }), + contents: typeof loadResult === 'string' ? VSBuffer.fromString(loadResult) : VSBuffer.wrap(new Uint8Array(loadResult)) + }); + }; + + // Start reading + reader.readAsArrayBuffer(file); + } + } + + return coalesce(await Promise.all(results.map(result => result.p))); +} + +//#endregion + +export function containsDragType(event: DragEvent, ...dragTypesToFind: string[]): boolean { + if (!event.dataTransfer) { + return false; + } + + const dragTypes = event.dataTransfer.types; + const lowercaseDragTypes: string[] = []; + for (let i = 0; i < dragTypes.length; i++) { + lowercaseDragTypes.push(dragTypes[i].toLowerCase()); // somehow the types are lowercase + } + + for (const dragType of dragTypesToFind) { + if (lowercaseDragTypes.indexOf(dragType.toLowerCase()) >= 0) { + return true; + } + } + + return false; +} + +//#region DND contributions + +export interface IResourceStat { + resource: URI; + isDirectory?: boolean; +} + +export interface IDragAndDropContributionRegistry { + /** + * Registers a drag and drop contribution. + */ + register(contribution: IDragAndDropContribution): void; + + /** + * Returns all registered drag and drop contributions. + */ + getAll(): IterableIterator; +} + +export interface IDragAndDropContribution { + readonly dataFormatKey: string; + getEditorInputs(data: string): IDraggedResourceEditorInput[]; + setData(resources: IResourceStat[], event: DragMouseEvent | DragEvent): void; +} + +class DragAndDropContributionRegistry implements IDragAndDropContributionRegistry { + private readonly _contributions = new Map(); + + register(contribution: IDragAndDropContribution): void { + if (this._contributions.has(contribution.dataFormatKey)) { + throw new Error(`A drag and drop contributiont with key '${contribution.dataFormatKey}' was already registered.`); + } + this._contributions.set(contribution.dataFormatKey, contribution); + } + + getAll(): IterableIterator { + return this._contributions.values(); + } +} + +export const Extensions = { + DragAndDropContribution: 'workbench.contributions.dragAndDrop' +}; + +Registry.add(Extensions.DragAndDropContribution, new DragAndDropContributionRegistry()); + +//#endregion diff --git a/src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts b/src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts index 07d04a05c60..16fada27b5b 100644 --- a/src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts +++ b/src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts @@ -30,7 +30,7 @@ import * as search from 'vs/workbench/contrib/search/common/search'; import * as typeh from 'vs/workbench/contrib/typeHierarchy/common/typeHierarchy'; import { extHostNamedCustomer, IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers'; import { ExtHostContext, ExtHostLanguageFeaturesShape, ICallHierarchyItemDto, ICodeActionDto, ICodeActionProviderMetadataDto, IdentifiableInlineCompletion, IdentifiableInlineCompletions, IDocumentFilterDto, IIndentationRuleDto, IInlayHintDto, ILanguageConfigurationDto, ILanguageWordDefinitionDto, ILinkDto, ILocationDto, ILocationLinkDto, IOnEnterRuleDto, IRegExpDto, ISignatureHelpProviderMetadataDto, ISuggestDataDto, ISuggestDataDtoField, ISuggestResultDtoField, ITypeHierarchyItemDto, IWorkspaceSymbolDto, MainContext, MainThreadLanguageFeaturesShape, reviveWorkspaceEditDto } from '../common/extHost.protocol'; -import { IDataTransfer } from 'vs/editor/common/dnd'; +import { IDataTransfer } from 'vs/base/common/dataTransfer'; @extHostNamedCustomer(MainContext.MainThreadLanguageFeatures) export class MainThreadLanguageFeatures extends Disposable implements MainThreadLanguageFeaturesShape { diff --git a/src/vs/workbench/api/browser/mainThreadTreeViews.ts b/src/vs/workbench/api/browser/mainThreadTreeViews.ts index 54e79e9918c..6e96ff8161f 100644 --- a/src/vs/workbench/api/browser/mainThreadTreeViews.ts +++ b/src/vs/workbench/api/browser/mainThreadTreeViews.ts @@ -15,7 +15,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten import { ILogService } from 'vs/platform/log/common/log'; import { DataTransferConverter } from 'vs/workbench/api/common/shared/dataTransfer'; import { CancellationToken } from 'vs/base/common/cancellation'; -import { IDataTransfer } from 'vs/editor/common/dnd'; +import { IDataTransfer } from 'vs/base/common/dataTransfer'; import { VSBuffer } from 'vs/base/common/buffer'; import { DataTransferCache } from 'vs/workbench/api/common/shared/dataTransferCache'; diff --git a/src/vs/workbench/api/common/extHostTreeViews.ts b/src/vs/workbench/api/common/extHostTreeViews.ts index 960b8d39a9e..b984ae6569e 100644 --- a/src/vs/workbench/api/common/extHostTreeViews.ts +++ b/src/vs/workbench/api/common/extHostTreeViews.ts @@ -25,7 +25,7 @@ import { Command } from 'vs/editor/common/languages'; import { DataTransferConverter, DataTransferDTO } from 'vs/workbench/api/common/shared/dataTransfer'; import { ITreeViewsService, TreeviewsService } from 'vs/workbench/services/views/common/treeViewsService'; import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions'; -import { IDataTransfer } from 'vs/editor/common/dnd'; +import { IDataTransfer } from 'vs/base/common/dataTransfer'; type TreeItemHandle = string; diff --git a/src/vs/workbench/api/common/shared/dataTransfer.ts b/src/vs/workbench/api/common/shared/dataTransfer.ts index dd4749b607b..a16dfe65f96 100644 --- a/src/vs/workbench/api/common/shared/dataTransfer.ts +++ b/src/vs/workbench/api/common/shared/dataTransfer.ts @@ -5,7 +5,7 @@ import { once } from 'vs/base/common/functional'; import { URI, UriComponents } from 'vs/base/common/uri'; -import { IDataTransfer, IDataTransferItem } from 'vs/editor/common/dnd'; +import { IDataTransfer, IDataTransferItem } from 'vs/base/common/dataTransfer'; export interface IDataTransferFileDTO { readonly name: string; diff --git a/src/vs/workbench/api/common/shared/dataTransferCache.ts b/src/vs/workbench/api/common/shared/dataTransferCache.ts index c3e845c61d4..02184d68d18 100644 --- a/src/vs/workbench/api/common/shared/dataTransferCache.ts +++ b/src/vs/workbench/api/common/shared/dataTransferCache.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { VSBuffer } from 'vs/base/common/buffer'; -import { IDataTransfer, IDataTransferItem } from 'vs/editor/common/dnd'; +import { IDataTransfer, IDataTransferItem } from 'vs/base/common/dataTransfer'; export class DataTransferCache { diff --git a/src/vs/workbench/browser/dnd.ts b/src/vs/workbench/browser/dnd.ts index b1f9001e03c..63cfe74d6de 100644 --- a/src/vs/workbench/browser/dnd.ts +++ b/src/vs/workbench/browser/dnd.ts @@ -3,45 +3,37 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { localize } from 'vs/nls'; -import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; -import { VSBuffer } from 'vs/base/common/buffer'; -import Severity from 'vs/base/common/severity'; -import { IWorkspaceFolderCreationData, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces'; -import { basename, isEqual } from 'vs/base/common/resources'; -import { ByteSize, IFileService } from 'vs/platform/files/common/files'; -import { IWindowOpenable } from 'vs/platform/window/common/window'; -import { URI } from 'vs/base/common/uri'; -import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; -import { FileAccess, Schemas } from 'vs/base/common/network'; -import { IBaseTextResourceEditorInput } from 'vs/platform/editor/common/editor'; import { DataTransfers, IDragAndDropData } from 'vs/base/browser/dnd'; -import { DragMouseEvent } from 'vs/base/browser/mouseEvent'; -import { Mimes } from 'vs/base/common/mime'; -import { isWeb, isWindows } from 'vs/base/common/platform'; -import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; -import { IEditorIdentifier, GroupIdentifier, isEditorIdentifier, EditorResourceAccessor } from 'vs/workbench/common/editor'; -import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; -import { Disposable, IDisposable, DisposableStore } from 'vs/base/common/lifecycle'; import { addDisposableListener, DragAndDropObserver, EventType } from 'vs/base/browser/dom'; -import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService'; -import { IWorkspaceEditingService } from 'vs/workbench/services/workspaces/common/workspaceEditing'; -import { IHostService } from 'vs/workbench/services/host/browser/host'; -import { Emitter } from 'vs/base/common/event'; -import { coalesce } from 'vs/base/common/arrays'; -import { parse, stringify } from 'vs/base/common/marshalling'; -import { ILabelService } from 'vs/platform/label/common/label'; -import { hasWorkspaceFileExtension, isTemporaryWorkspace, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; -import { withNullAsUndefined } from 'vs/base/common/types'; -import { IDataTransfer } from 'vs/editor/common/dnd'; -import { extractSelection } from 'vs/platform/opener/common/opener'; +import { DragMouseEvent } from 'vs/base/browser/mouseEvent'; import { IListDragAndDrop } from 'vs/base/browser/ui/list/list'; import { ElementsDragAndDropData } from 'vs/base/browser/ui/list/listView'; import { ITreeDragOverReaction } from 'vs/base/browser/ui/tree/tree'; -import { WebFileSystemAccess } from 'vs/platform/files/browser/webFileSystemAccess'; -import { HTMLFileSystemProvider } from 'vs/platform/files/browser/htmlFileSystemProvider'; -import { DeferredPromise } from 'vs/base/common/async'; +import { coalesce } from 'vs/base/common/arrays'; +import { IDataTransfer } from 'vs/base/common/dataTransfer'; +import { Emitter } from 'vs/base/common/event'; +import { Disposable, DisposableStore, IDisposable } from 'vs/base/common/lifecycle'; +import { stringify } from 'vs/base/common/marshalling'; +import { Mimes } from 'vs/base/common/mime'; +import { FileAccess, Schemas } from 'vs/base/common/network'; +import { isWindows } from 'vs/base/common/platform'; +import { basename, isEqual } from 'vs/base/common/resources'; +import { URI } from 'vs/base/common/uri'; +import { CodeDataTransfers, createDraggedEditorInputFromRawResourcesData, Extensions, extractEditorsDropData, IDragAndDropContributionRegistry, IDraggedResourceEditorInput, IResourceStat } from 'vs/platform/dnd/browser/dnd'; +import { IFileService } from 'vs/platform/files/common/files'; +import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; +import { ILabelService } from 'vs/platform/label/common/label'; +import { extractSelection } from 'vs/platform/opener/common/opener'; import { Registry } from 'vs/platform/registry/common/platform'; +import { IWindowOpenable } from 'vs/platform/window/common/window'; +import { hasWorkspaceFileExtension, isTemporaryWorkspace, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; +import { IWorkspaceFolderCreationData, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces'; +import { EditorResourceAccessor, GroupIdentifier, IEditorIdentifier, isEditorIdentifier } from 'vs/workbench/common/editor'; +import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService'; +import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; +import { IHostService } from 'vs/workbench/services/host/browser/host'; +import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; +import { IWorkspaceEditingService } from 'vs/workbench/services/workspaces/common/workspaceEditing'; //#region Editor / Resources DND @@ -60,124 +52,6 @@ export class DraggedTreeItemsIdentifier { constructor(readonly identifier: string) { } } -export const CodeDataTransfers = { - EDITORS: 'CodeEditors', - FILES: 'CodeFiles' -}; - -export interface IDraggedResourceEditorInput extends IBaseTextResourceEditorInput { - resource: URI | undefined; - - /** - * A hint that the source of the dragged editor input - * might not be the application but some external tool. - */ - isExternal?: boolean; - - /** - * Whether we probe for the dropped editor to be a workspace - * (i.e. code-workspace file or even a folder), allowing to - * open it as workspace instead of opening as editor. - */ - allowWorkspaceOpen?: boolean; -} - -export async function extractEditorsDropData(accessor: ServicesAccessor, e: DragEvent): Promise> { - const editors: IDraggedResourceEditorInput[] = []; - if (e.dataTransfer && e.dataTransfer.types.length > 0) { - - // Data Transfer: Code Editors - const rawEditorsData = e.dataTransfer.getData(CodeDataTransfers.EDITORS); - if (rawEditorsData) { - try { - editors.push(...parse(rawEditorsData)); - } catch (error) { - // Invalid transfer - } - } - - // Data Transfer: Resources - else { - try { - const rawResourcesData = e.dataTransfer.getData(DataTransfers.RESOURCES); - editors.push(...createDraggedEditorInputFromRawResourcesData(rawResourcesData)); - } catch (error) { - // Invalid transfer - } - } - - // Check for native file transfer - if (e.dataTransfer?.files) { - for (let i = 0; i < e.dataTransfer.files.length; i++) { - const file = e.dataTransfer.files[i]; - if (file?.path /* Electron only */) { - try { - editors.push({ resource: URI.file(file.path), isExternal: true, allowWorkspaceOpen: true }); - } catch (error) { - // Invalid URI - } - } - } - } - - // Check for CodeFiles transfer - const rawCodeFiles = e.dataTransfer.getData(CodeDataTransfers.FILES); - if (rawCodeFiles) { - try { - const codeFiles: string[] = JSON.parse(rawCodeFiles); - for (const codeFile of codeFiles) { - editors.push({ resource: URI.file(codeFile), isExternal: true, allowWorkspaceOpen: true }); - } - } catch (error) { - // Invalid transfer - } - } - - // Web: Check for file transfer - if (isWeb && containsDragType(e, DataTransfers.FILES)) { - const files = e.dataTransfer.items; - if (files) { - const instantiationService = accessor.get(IInstantiationService); - const filesData = await instantiationService.invokeFunction(accessor => extractFilesDropData(accessor, e)); - for (const fileData of filesData) { - editors.push({ resource: fileData.resource, contents: fileData.contents?.toString(), isExternal: true, allowWorkspaceOpen: fileData.isDirectory }); - } - } - } - - // Workbench contributions - const contributions = Registry.as(Extensions.DragAndDropContribution).getAll(); - for (const contribution of contributions) { - const data = e.dataTransfer.getData(contribution.dataFormatKey); - if (data) { - try { - editors.push(...contribution.getEditorInputs(data)); - } catch (error) { - // Invalid transfer - } - } - } - } - - return editors; -} - -function createDraggedEditorInputFromRawResourcesData(rawResourcesData: string | undefined): IDraggedResourceEditorInput[] { - const editors: IDraggedResourceEditorInput[] = []; - - if (rawResourcesData) { - const resourcesRaw: string[] = JSON.parse(rawResourcesData); - for (const resourceRaw of resourcesRaw) { - if (resourceRaw.indexOf(':') > 0) { // mitigate https://github.com/microsoft/vscode/issues/124946 - const { selection, uri } = extractSelection(URI.parse(resourceRaw)); - editors.push({ resource: uri, options: { selection } }); - } - } - } - - return editors; -} - export async function extractTreeDropData(dataTransfer: IDataTransfer): Promise> { const editors: IDraggedResourceEditorInput[] = []; const resourcesKey = Mimes.uriList.toLowerCase(); @@ -201,121 +75,6 @@ export function convertResourceUrlsToUriList(resourceUrls: string): string { return asJson.map(uri => uri.toString()).join('\n'); } -interface IFileTransferData { - resource: URI; - isDirectory?: boolean; - contents?: VSBuffer; -} - -async function extractFilesDropData(accessor: ServicesAccessor, event: DragEvent): Promise { - - // Try to extract via `FileSystemHandle` - if (WebFileSystemAccess.supported(window)) { - const items = event.dataTransfer?.items; - if (items) { - return extractFileTransferData(accessor, items); - } - } - - // Try to extract via `FileList` - const files = event.dataTransfer?.files; - if (!files) { - return []; - } - - return extractFileListData(accessor, files); -} - -async function extractFileTransferData(accessor: ServicesAccessor, items: DataTransferItemList): Promise { - const fileSystemProvider = accessor.get(IFileService).getProvider(Schemas.file); - if (!(fileSystemProvider instanceof HTMLFileSystemProvider)) { - return []; // only supported when running in web - } - - const results: DeferredPromise[] = []; - - for (let i = 0; i < items.length; i++) { - const file = items[i]; - if (file) { - const result = new DeferredPromise(); - results.push(result); - - (async () => { - try { - const handle = await file.getAsFileSystemHandle(); - if (!handle) { - result.complete(undefined); - return; - } - - if (WebFileSystemAccess.isFileSystemFileHandle(handle)) { - result.complete({ - resource: await fileSystemProvider.registerFileHandle(handle), - isDirectory: false - }); - } else if (WebFileSystemAccess.isFileSystemDirectoryHandle(handle)) { - result.complete({ - resource: await fileSystemProvider.registerDirectoryHandle(handle), - isDirectory: true - }); - } else { - result.complete(undefined); - } - } catch (error) { - result.complete(undefined); - } - })(); - } - } - - return coalesce(await Promise.all(results.map(result => result.p))); -} - -export async function extractFileListData(accessor: ServicesAccessor, files: FileList): Promise { - const dialogService = accessor.get(IDialogService); - - const results: DeferredPromise[] = []; - - for (let i = 0; i < files.length; i++) { - const file = files.item(i); - if (file) { - - // Skip for very large files because this operation is unbuffered - if (file.size > 100 * ByteSize.MB) { - dialogService.show(Severity.Warning, localize('fileTooLarge', "File is too large to open as untitled editor. Please upload it first into the file explorer and then try again.")); - continue; - } - - const result = new DeferredPromise(); - results.push(result); - - const reader = new FileReader(); - - reader.onerror = () => result.complete(undefined); - reader.onabort = () => result.complete(undefined); - - reader.onload = async event => { - const name = file.name; - const loadResult = withNullAsUndefined(event.target?.result); - if (typeof name !== 'string' || typeof loadResult === 'undefined') { - result.complete(undefined); - return; - } - - result.complete({ - resource: URI.from({ scheme: Schemas.untitled, path: name }), - contents: typeof loadResult === 'string' ? VSBuffer.fromString(loadResult) : VSBuffer.wrap(new Uint8Array(loadResult)) - }); - }; - - // Start reading - reader.readAsArrayBuffer(file); - } - } - - return coalesce(await Promise.all(results.map(result => result.p))); -} - export interface IResourcesDropHandlerOptions { /** @@ -443,11 +202,6 @@ export class ResourcesDropHandler { } } -interface IResourceStat { - resource: URI; - isDirectory?: boolean; -} - export function fillEditorsDragData(accessor: ServicesAccessor, resources: URI[], event: DragMouseEvent | DragEvent): void; export function fillEditorsDragData(accessor: ServicesAccessor, resources: IResourceStat[], event: DragMouseEvent | DragEvent): void; export function fillEditorsDragData(accessor: ServicesAccessor, editors: IEditorIdentifier[], event: DragMouseEvent | DragEvent): void; @@ -591,48 +345,6 @@ export function fillEditorsDragData(accessor: ServicesAccessor, resourcesOrEdito //#endregion -//#region DND contributions - -export interface IDragAndDropContributionRegistry { - /** - * Registers a drag and drop contribution. - */ - register(contribution: IDragAndDropContribution): void; - - /** - * Returns all registered drag and drop contributions. - */ - getAll(): IterableIterator; -} - -export interface IDragAndDropContribution { - readonly dataFormatKey: string; - getEditorInputs(data: string): IDraggedResourceEditorInput[]; - setData(resources: IResourceStat[], event: DragMouseEvent | DragEvent): void; -} - -class DragAndDropContributionRegistry implements IDragAndDropContributionRegistry { - private readonly _contributions = new Map(); - - register(contribution: IDragAndDropContribution): void { - if (this._contributions.has(contribution.dataFormatKey)) { - throw new Error(`A drag and drop contributiont with key '${contribution.dataFormatKey}' was already registered.`); - } - this._contributions.set(contribution.dataFormatKey, contribution); - } - - getAll(): IterableIterator { - return this._contributions.values(); - } -} - -export const Extensions = { - DragAndDropContribution: 'workbench.contributions.dragAndDrop' -}; - -Registry.add(Extensions.DragAndDropContribution, new DragAndDropContributionRegistry()); - -//#endregion //#region DND Utilities @@ -681,26 +393,6 @@ export class LocalSelectionTransfer { } } -export function containsDragType(event: DragEvent, ...dragTypesToFind: string[]): boolean { - if (!event.dataTransfer) { - return false; - } - - const dragTypes = event.dataTransfer.types; - const lowercaseDragTypes: string[] = []; - for (let i = 0; i < dragTypes.length; i++) { - lowercaseDragTypes.push(dragTypes[i].toLowerCase()); // somehow the types are lowercase - } - - for (const dragType of dragTypesToFind) { - if (lowercaseDragTypes.indexOf(dragType.toLowerCase()) >= 0) { - return true; - } - } - - return false; -} - //#endregion //#region Composites DND diff --git a/src/vs/workbench/browser/parts/editor/editorDropTarget.ts b/src/vs/workbench/browser/parts/editor/editorDropTarget.ts index f81d3790b5d..ad6a0289f12 100644 --- a/src/vs/workbench/browser/parts/editor/editorDropTarget.ts +++ b/src/vs/workbench/browser/parts/editor/editorDropTarget.ts @@ -18,7 +18,8 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { activeContrastBorder } from 'vs/platform/theme/common/colorRegistry'; import { IThemeService, Themable } from 'vs/platform/theme/common/themeService'; import { isTemporaryWorkspace, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; -import { CodeDataTransfers, containsDragType, DraggedEditorGroupIdentifier, DraggedEditorIdentifier, DraggedTreeItemsIdentifier, Extensions as DragAndDropExtensions, extractTreeDropData, IDragAndDropContributionRegistry, LocalSelectionTransfer, ResourcesDropHandler } from 'vs/workbench/browser/dnd'; +import { CodeDataTransfers, containsDragType, Extensions as DragAndDropExtensions, IDragAndDropContributionRegistry } from 'vs/platform/dnd/browser/dnd'; +import { DraggedEditorGroupIdentifier, DraggedEditorIdentifier, DraggedTreeItemsIdentifier, extractTreeDropData, LocalSelectionTransfer, ResourcesDropHandler } from 'vs/workbench/browser/dnd'; import { fillActiveEditorViewState, IEditorGroupsAccessor, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor'; import { EditorInputCapabilities, IEditorIdentifier, IUntypedEditorInput } from 'vs/workbench/common/editor'; import { EDITOR_DRAG_AND_DROP_BACKGROUND, EDITOR_DROP_INTO_PROMPT_BACKGROUND, EDITOR_DROP_INTO_PROMPT_BORDER, EDITOR_DROP_INTO_PROMPT_FOREGROUND } from 'vs/workbench/common/theme'; diff --git a/src/vs/workbench/browser/parts/views/treeView.ts b/src/vs/workbench/browser/parts/views/treeView.ts index 9b06e86ae1f..9d2c5d0dab0 100644 --- a/src/vs/workbench/browser/parts/views/treeView.ts +++ b/src/vs/workbench/browser/parts/views/treeView.ts @@ -31,7 +31,7 @@ import { isString } from 'vs/base/common/types'; import { URI } from 'vs/base/common/uri'; import { generateUuid } from 'vs/base/common/uuid'; import 'vs/css!./media/views'; -import { IDataTransfer } from 'vs/editor/common/dnd'; +import { IDataTransfer } from 'vs/base/common/dataTransfer'; import { Command } from 'vs/editor/common/languages'; import { localize } from 'vs/nls'; import { createActionViewItem, createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem'; @@ -54,7 +54,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { focusBorder, listFilterMatchHighlight, listFilterMatchHighlightBorder, textCodeBlockBackground, textLinkForeground } from 'vs/platform/theme/common/colorRegistry'; import { ColorScheme } from 'vs/platform/theme/common/theme'; import { FileThemeIcon, FolderThemeIcon, IThemeService, registerThemingParticipant, ThemeIcon } from 'vs/platform/theme/common/themeService'; -import { CodeDataTransfers, convertResourceUrlsToUriList, DraggedTreeItemsIdentifier, fillEditorsDragData, LocalSelectionTransfer } from 'vs/workbench/browser/dnd'; +import { convertResourceUrlsToUriList, DraggedTreeItemsIdentifier, fillEditorsDragData, LocalSelectionTransfer } from 'vs/workbench/browser/dnd'; import { IResourceLabel, ResourceLabels } from 'vs/workbench/browser/labels'; import { API_OPEN_DIFF_EDITOR_COMMAND_ID, API_OPEN_EDITOR_COMMAND_ID } from 'vs/workbench/browser/parts/editor/editorCommands'; import { IViewPaneOptions, ViewPane } from 'vs/workbench/browser/parts/views/viewPane'; @@ -66,6 +66,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten import { IHoverService } from 'vs/workbench/services/hover/browser/hover'; import { ThemeSettings } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { ITreeViewsService } from 'vs/workbench/services/views/browser/treeViewsService'; +import { CodeDataTransfers } from 'vs/platform/dnd/browser/dnd'; export class TreeViewPane extends ViewPane { diff --git a/src/vs/workbench/common/views.ts b/src/vs/workbench/common/views.ts index 7bd541c1248..5c9c7d93a9d 100644 --- a/src/vs/workbench/common/views.ts +++ b/src/vs/workbench/common/views.ts @@ -27,7 +27,7 @@ import { mixin } from 'vs/base/common/objects'; import { Codicon } from 'vs/base/common/codicons'; import { registerIcon } from 'vs/platform/theme/common/iconRegistry'; import { CancellationToken } from 'vs/base/common/cancellation'; -import { IDataTransfer } from 'vs/editor/common/dnd'; +import { IDataTransfer } from 'vs/base/common/dataTransfer'; export const defaultViewIcon = registerIcon('default-view-icon', Codicon.window, localize('defaultViewIcon', 'Default view icon.')); diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts b/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts index 99b7c3eb1f1..0d895be2eae 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts @@ -58,7 +58,7 @@ import { registerAction2, Action2, MenuId } from 'vs/platform/actions/common/act import { IPaneComposite } from 'vs/workbench/common/panecomposite'; import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite'; import { coalesce } from 'vs/base/common/arrays'; -import { extractEditorsDropData } from 'vs/workbench/browser/dnd'; +import { extractEditorsDropData } from 'vs/platform/dnd/browser/dnd'; import { extname } from 'vs/base/common/resources'; const SearchMarketplaceExtensionsContext = new RawContextKey('searchMarketplaceExtensions', false); diff --git a/src/vs/workbench/contrib/files/browser/fileImportExport.ts b/src/vs/workbench/contrib/files/browser/fileImportExport.ts index 71eda39201c..2215ecd93ad 100644 --- a/src/vs/workbench/contrib/files/browser/fileImportExport.ts +++ b/src/vs/workbench/contrib/files/browser/fileImportExport.ts @@ -20,7 +20,7 @@ import { ExplorerItem } from 'vs/workbench/contrib/files/common/explorerModel'; import { URI } from 'vs/base/common/uri'; import { IHostService } from 'vs/workbench/services/host/browser/host'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; -import { extractEditorsDropData } from 'vs/workbench/browser/dnd'; +import { extractEditorsDropData } from 'vs/platform/dnd/browser/dnd'; import { IWorkspaceEditingService } from 'vs/workbench/services/workspaces/common/workspaceEditing'; import { isWeb } from 'vs/base/common/platform'; import { triggerDownload } from 'vs/base/browser/dom'; diff --git a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts index 1181f9867c4..a24f390cf51 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts @@ -30,7 +30,8 @@ import { equals, deepClone } from 'vs/base/common/objects'; import * as path from 'vs/base/common/path'; import { ExplorerItem, NewExplorerItem } from 'vs/workbench/contrib/files/common/explorerModel'; import { compareFileExtensionsDefault, compareFileNamesDefault, compareFileNamesUpper, compareFileExtensionsUpper, compareFileNamesLower, compareFileExtensionsLower, compareFileNamesUnicode, compareFileExtensionsUnicode } from 'vs/base/common/comparers'; -import { fillEditorsDragData, CodeDataTransfers, containsDragType } from 'vs/workbench/browser/dnd'; +import { CodeDataTransfers, containsDragType } from 'vs/platform/dnd/browser/dnd'; +import { fillEditorsDragData } from 'vs/workbench/browser/dnd'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IDragAndDropData, DataTransfers } from 'vs/base/browser/dnd'; import { Schemas } from 'vs/base/common/network'; diff --git a/src/vs/workbench/contrib/files/browser/views/openEditorsView.ts b/src/vs/workbench/contrib/files/browser/views/openEditorsView.ts index 06ba5acdbde..fdfcc0a46a0 100644 --- a/src/vs/workbench/contrib/files/browser/views/openEditorsView.ts +++ b/src/vs/workbench/contrib/files/browser/views/openEditorsView.ts @@ -32,7 +32,8 @@ import { createAndFillInContextMenuActions } from 'vs/platform/actions/browser/m import { IMenuService, MenuId, IMenu, Action2, registerAction2, MenuRegistry } from 'vs/platform/actions/common/actions'; import { OpenEditorsDirtyEditorContext, OpenEditorsGroupContext, OpenEditorsReadonlyEditorContext, SAVE_ALL_LABEL, SAVE_ALL_COMMAND_ID, NEW_UNTITLED_FILE_COMMAND_ID } from 'vs/workbench/contrib/files/browser/fileConstants'; import { ResourceContextKey } from 'vs/workbench/common/contextkeys'; -import { ResourcesDropHandler, fillEditorsDragData, CodeDataTransfers, containsDragType } from 'vs/workbench/browser/dnd'; +import { CodeDataTransfers, containsDragType } from 'vs/platform/dnd/browser/dnd'; +import { ResourcesDropHandler, fillEditorsDragData } from 'vs/workbench/browser/dnd'; import { ViewPane } from 'vs/workbench/browser/parts/views/viewPane'; import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet'; import { IDragAndDropData, DataTransfers } from 'vs/base/browser/dnd'; diff --git a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts index e7d863ed61c..a3059234eb1 100644 --- a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts +++ b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts @@ -85,6 +85,7 @@ import { MarkdownRenderer } from 'vs/editor/contrib/markdownRenderer/browser/mar import { Button, ButtonWithDescription } from 'vs/base/browser/ui/button/button'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { RepositoryContextKeys } from 'vs/workbench/contrib/scm/browser/scmViewService'; +import { DropIntoEditorController } from 'vs/editor/contrib/dropIntoEditor/browser/dropIntoEditorContribution'; type TreeElement = ISCMRepository | ISCMInput | ISCMActionButton | ISCMResourceGroup | IResourceNode | ISCMResource; @@ -1935,7 +1936,8 @@ class SCMInputWidget extends Disposable { quickSuggestions: false, scrollbar: { alwaysConsumeMouseWheel: false }, overflowWidgetsDomNode, - renderWhitespace: 'none' + renderWhitespace: 'none', + enableDropIntoEditor: true, }; const codeEditorWidgetOptions: ICodeEditorWidgetOptions = { @@ -1948,7 +1950,8 @@ class SCMInputWidget extends Disposable { ContextMenuController.ID, ColorDetector.ID, ModesHoverController.ID, - LinkDetector.ID + LinkDetector.ID, + DropIntoEditorController.ID ]) }; diff --git a/src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts b/src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts index f8aae95de73..104e9f455e1 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts @@ -16,7 +16,7 @@ import { KeybindingWeight, KeybindingsRegistry, IKeybindings } from 'vs/platform import { Registry } from 'vs/platform/registry/common/platform'; import { getQuickNavigateHandler } from 'vs/workbench/browser/quickaccess'; import { Extensions as ViewContainerExtensions, IViewContainersRegistry, ViewContainerLocation, IViewsRegistry } from 'vs/workbench/common/views'; -import { Extensions as DragAndDropExtensions, IDragAndDropContributionRegistry, IDraggedResourceEditorInput } from 'vs/workbench/browser/dnd'; +import { Extensions as DragAndDropExtensions, IDragAndDropContributionRegistry, IDraggedResourceEditorInput } from 'vs/platform/dnd/browser/dnd'; import { registerTerminalActions, terminalSendSequenceCommand } from 'vs/workbench/contrib/terminal/browser/terminalActions'; import { TerminalViewPane } from 'vs/workbench/contrib/terminal/browser/terminalView'; import { TERMINAL_VIEW_ID, TerminalCommandId, ITerminalProfileService } from 'vs/workbench/contrib/terminal/common/terminal'; diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index f845f8ddc33..61c2efbb885 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -48,7 +48,7 @@ import { activeContrastBorder, scrollbarSliderActiveBackground, scrollbarSliderB import { IColorTheme, ICssStyleCollector, IThemeService, registerThemingParticipant, ThemeIcon } from 'vs/platform/theme/common/themeService'; import { IWorkspaceContextService, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; import { IWorkspaceTrustRequestService } from 'vs/platform/workspace/common/workspaceTrust'; -import { CodeDataTransfers, containsDragType } from 'vs/workbench/browser/dnd'; +import { CodeDataTransfers, containsDragType } from 'vs/platform/dnd/browser/dnd'; import { IViewDescriptorService, IViewsService, ViewContainerLocation } from 'vs/workbench/common/views'; import { IDetectedLinks, TerminalLinkManager } from 'vs/workbench/contrib/terminal/browser/links/terminalLinkManager'; import { TerminalLinkQuickpick } from 'vs/workbench/contrib/terminal/browser/links/terminalLinkQuickpick'; diff --git a/src/vs/workbench/contrib/terminal/browser/terminalTabsList.ts b/src/vs/workbench/contrib/terminal/browser/terminalTabsList.ts index 868644fc918..0a39093d05e 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalTabsList.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalTabsList.ts @@ -40,7 +40,7 @@ import { once } from 'vs/base/common/functional'; import { attachInputBoxStyler } from 'vs/platform/theme/common/styler'; import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { KeyCode } from 'vs/base/common/keyCodes'; -import { CodeDataTransfers, containsDragType } from 'vs/workbench/browser/dnd'; +import { CodeDataTransfers, containsDragType } from 'vs/platform/dnd/browser/dnd'; import { terminalStrings } from 'vs/workbench/contrib/terminal/common/terminalStrings'; import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { IProcessDetails } from 'vs/platform/terminal/common/terminalProcess'; diff --git a/src/vs/workbench/services/dialogs/browser/fileDialogService.ts b/src/vs/workbench/services/dialogs/browser/fileDialogService.ts index 1fc0ccc3570..87f6e2ca052 100644 --- a/src/vs/workbench/services/dialogs/browser/fileDialogService.ts +++ b/src/vs/workbench/services/dialogs/browser/fileDialogService.ts @@ -16,7 +16,7 @@ import { basename } from 'vs/base/common/resources'; import { triggerDownload, triggerUpload } from 'vs/base/browser/dom'; import Severity from 'vs/base/common/severity'; import { VSBuffer } from 'vs/base/common/buffer'; -import { extractFileListData } from 'vs/workbench/browser/dnd'; +import { extractFileListData } from 'vs/platform/dnd/browser/dnd'; import { Iterable } from 'vs/base/common/iterator'; import { WebFileSystemAccess } from 'vs/platform/files/browser/webFileSystemAccess'; diff --git a/src/vs/workbench/services/views/browser/treeViewsService.ts b/src/vs/workbench/services/views/browser/treeViewsService.ts index 988300aadee..93d426deed5 100644 --- a/src/vs/workbench/services/views/browser/treeViewsService.ts +++ b/src/vs/workbench/services/views/browser/treeViewsService.ts @@ -5,7 +5,7 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; -import { IDataTransfer } from 'vs/editor/common/dnd'; +import { IDataTransfer } from 'vs/base/common/dataTransfer'; import { ITreeItem } from 'vs/workbench/common/views'; import { ITreeViewsService as ITreeViewsServiceCommon, TreeviewsService } from 'vs/workbench/services/views/common/treeViewsService'; diff --git a/src/vs/workbench/workbench.common.main.ts b/src/vs/workbench/workbench.common.main.ts index bf87db19d53..992aec9c53f 100644 --- a/src/vs/workbench/workbench.common.main.ts +++ b/src/vs/workbench/workbench.common.main.ts @@ -343,7 +343,4 @@ import 'vs/workbench/contrib/list/browser/list.contribution'; // Audio Cues import 'vs/workbench/contrib/audioCues/browser/audioCues.contribution'; -// Drop into editor -import 'vs/workbench/contrib/dropIntoEditor/browser/dropIntoEditor.contibution'; - //#endregion