mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
parent
8f25356ff1
commit
9cf2fabdd6
|
@ -29,7 +29,7 @@
|
|||
"configuration.markdown.links.openLocation.currentGroup": "Open links in the active editor group.",
|
||||
"configuration.markdown.links.openLocation.beside": "Open links beside the active editor.",
|
||||
"configuration.markdown.suggest.paths.enabled.description": "Enable/disable path suggestions for markdown links",
|
||||
"configuration.markdown.editor.drop.enabled": "Enable/disable dropping into the markdown editor to insert shift. Requires enabling `#workbench.editor.dropIntoEditor.enabled#`.",
|
||||
"configuration.markdown.editor.drop.enabled": "Enable/disable dropping into the markdown editor to insert shift. Requires enabling `#editor.dropIntoEditor.enabled#`.",
|
||||
"configuration.markdown.editor.pasteLinks.enabled": "Enable/disable pasting files into a Markdown editor inserts Markdown links. Requires enabling `#editor.experimental.pasteActions.enabled#`.",
|
||||
"configuration.markdown.experimental.validate.enabled.description": "Enable/disable all error reporting in Markdown files.",
|
||||
"configuration.markdown.experimental.validate.referenceLinks.enabled.description": "Validate reference links in Markdown files, e.g. `[link][ref]`. Requires enabling `#markdown.experimental.validate.enabled#`.",
|
||||
|
|
|
@ -371,7 +371,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
|||
this._register(new dom.DragAndDropObserver(this._domElement, {
|
||||
onDragEnter: () => undefined,
|
||||
onDragOver: e => {
|
||||
if (!this._configuration.options.get(EditorOption.enableDropIntoEditor)) {
|
||||
if (!this._configuration.options.get(EditorOption.dropIntoEditor).enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
|||
}
|
||||
},
|
||||
onDrop: async e => {
|
||||
if (!this._configuration.options.get(EditorOption.enableDropIntoEditor)) {
|
||||
if (!this._configuration.options.get(EditorOption.dropIntoEditor).enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1189,7 +1189,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
|||
result.ariaLabel = options.originalAriaLabel;
|
||||
}
|
||||
result.readOnly = !this._options.originalEditable;
|
||||
result.enableDropIntoEditor = !result.readOnly;
|
||||
result.dropIntoEditor = { enabled: !result.readOnly };
|
||||
result.extraEditorClassName = 'original-in-monaco-diff-editor';
|
||||
return {
|
||||
...result,
|
||||
|
|
|
@ -665,11 +665,11 @@ export interface IEditorOptions {
|
|||
bracketPairColorization?: IBracketPairColorizationOptions;
|
||||
|
||||
/**
|
||||
* Enables dropping into the editor from an external source.
|
||||
* Controls dropping into the editor from an external source.
|
||||
*
|
||||
* This shows a preview of the drop location and triggers an `onDropIntoEditor` event.
|
||||
* When enabled, this shows a preview of the drop location and triggers an `onDropIntoEditor` event.
|
||||
*/
|
||||
enableDropIntoEditor?: boolean;
|
||||
dropIntoEditor?: IDropIntoEditorOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4439,6 +4439,53 @@ class EditorWrappingInfoComputer extends ComputedEditorOption<EditorOption.wrapp
|
|||
|
||||
//#endregion
|
||||
|
||||
//#region dropIntoEditor
|
||||
|
||||
/**
|
||||
* Configuration options for editor drop into behavior
|
||||
*/
|
||||
export interface IDropIntoEditorOptions {
|
||||
/**
|
||||
* Enable the dropping into editor.
|
||||
* Defaults to true.
|
||||
*/
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type EditorDropIntoEditorOptions = Readonly<Required<IDropIntoEditorOptions>>;
|
||||
|
||||
class EditorDropIntoEditor extends BaseEditorOption<EditorOption.dropIntoEditor, IDropIntoEditorOptions, EditorDropIntoEditorOptions> {
|
||||
|
||||
constructor() {
|
||||
const defaults: EditorDropIntoEditorOptions = { enabled: true };
|
||||
super(
|
||||
EditorOption.dropIntoEditor, 'dropIntoEditor', defaults,
|
||||
{
|
||||
'editor.dropIntoEditor.enabled': {
|
||||
type: 'boolean',
|
||||
default: defaults.enabled,
|
||||
markdownDescription: nls.localize('dropIntoEditor.enabled', "Controls whether you can drag and drop a file into a text editor by holding down `shift` (instead of opening the file in an editor)."),
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public validate(_input: any): EditorDropIntoEditorOptions {
|
||||
if (!_input || typeof _input !== 'object') {
|
||||
return this.defaultValue;
|
||||
}
|
||||
const input = _input as IDropIntoEditorOptions;
|
||||
return {
|
||||
enabled: boolean(input.enabled, this.defaultValue.enabled)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace';
|
||||
const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace';
|
||||
const DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', \'monospace\', monospace';
|
||||
|
@ -4501,7 +4548,7 @@ export const enum EditorOption {
|
|||
disableMonospaceOptimizations,
|
||||
domReadOnly,
|
||||
dragAndDrop,
|
||||
enableDropIntoEditor,
|
||||
dropIntoEditor,
|
||||
emptySelectionClipboard,
|
||||
extraEditorClassName,
|
||||
fastScrollSensitivity,
|
||||
|
@ -4811,9 +4858,7 @@ 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
|
||||
)),
|
||||
dropIntoEditor: register(new EditorDropIntoEditor()),
|
||||
extraEditorClassName: register(new EditorStringOption(
|
||||
EditorOption.extraEditorClassName, 'extraEditorClassName', '',
|
||||
)),
|
||||
|
|
|
@ -204,7 +204,7 @@ export enum EditorOption {
|
|||
disableMonospaceOptimizations = 29,
|
||||
domReadOnly = 30,
|
||||
dragAndDrop = 31,
|
||||
enableDropIntoEditor = 32,
|
||||
dropIntoEditor = 32,
|
||||
emptySelectionClipboard = 33,
|
||||
extraEditorClassName = 34,
|
||||
fastScrollSensitivity = 35,
|
||||
|
|
|
@ -25,7 +25,6 @@ import { CodeEditorStateFlag, EditorStateCancellationTokenSource } from 'vs/edit
|
|||
import { performSnippetEdit } from 'vs/editor/contrib/snippet/browser/snippetController2';
|
||||
import { SnippetParser } from 'vs/editor/contrib/snippet/browser/snippetParser';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
|
@ -37,7 +36,6 @@ export class DropIntoEditorController extends Disposable implements IEditorContr
|
|||
constructor(
|
||||
editor: ICodeEditor,
|
||||
@IBulkEditService private readonly _bulkEditService: IBulkEditService,
|
||||
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||
@ILanguageFeaturesService private readonly _languageFeaturesService: ILanguageFeaturesService,
|
||||
@IProgressService private readonly _progressService: IProgressService,
|
||||
@IWorkspaceContextService workspaceContextService: IWorkspaceContextService,
|
||||
|
@ -46,22 +44,7 @@ export class DropIntoEditorController extends Disposable implements IEditorContr
|
|||
|
||||
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.editor.dropIntoEditor.enabled')) {
|
||||
this.updateEditorOptions(editor);
|
||||
}
|
||||
}));
|
||||
|
||||
this.updateEditorOptions(editor);
|
||||
}
|
||||
|
||||
private updateEditorOptions(editor: ICodeEditor) {
|
||||
editor.updateOptions({
|
||||
enableDropIntoEditor: this._configurationService.getValue('workbench.editor.dropIntoEditor.enabled')
|
||||
});
|
||||
}
|
||||
|
||||
private async onDropIntoEditor(editor: ICodeEditor, position: IPosition, dragEvent: DragEvent) {
|
||||
|
|
21
src/vs/monaco.d.ts
vendored
21
src/vs/monaco.d.ts
vendored
|
@ -3439,11 +3439,11 @@ declare namespace monaco.editor {
|
|||
*/
|
||||
bracketPairColorization?: IBracketPairColorizationOptions;
|
||||
/**
|
||||
* Enables dropping into the editor from an external source.
|
||||
* Controls dropping into the editor from an external source.
|
||||
*
|
||||
* This shows a preview of the drop location and triggers an `onDropIntoEditor` event.
|
||||
* When enabled, this shows a preview of the drop location and triggers an `onDropIntoEditor` event.
|
||||
*/
|
||||
enableDropIntoEditor?: boolean;
|
||||
dropIntoEditor?: IDropIntoEditorOptions;
|
||||
}
|
||||
|
||||
export interface IDiffEditorBaseOptions {
|
||||
|
@ -4330,6 +4330,17 @@ declare namespace monaco.editor {
|
|||
readonly wrappingColumn: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration options for editor drop into behavior
|
||||
*/
|
||||
export interface IDropIntoEditorOptions {
|
||||
/**
|
||||
* Enable the dropping into editor.
|
||||
* Defaults to true.
|
||||
*/
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
export enum EditorOption {
|
||||
acceptSuggestionOnCommitCharacter = 0,
|
||||
acceptSuggestionOnEnter = 1,
|
||||
|
@ -4363,7 +4374,7 @@ declare namespace monaco.editor {
|
|||
disableMonospaceOptimizations = 29,
|
||||
domReadOnly = 30,
|
||||
dragAndDrop = 31,
|
||||
enableDropIntoEditor = 32,
|
||||
dropIntoEditor = 32,
|
||||
emptySelectionClipboard = 33,
|
||||
extraEditorClassName = 34,
|
||||
fastScrollSensitivity = 35,
|
||||
|
@ -4503,7 +4514,7 @@ declare namespace monaco.editor {
|
|||
domReadOnly: IEditorOption<EditorOption.domReadOnly, boolean>;
|
||||
dragAndDrop: IEditorOption<EditorOption.dragAndDrop, boolean>;
|
||||
emptySelectionClipboard: IEditorOption<EditorOption.emptySelectionClipboard, boolean>;
|
||||
enableDropIntoEditor: IEditorOption<EditorOption.enableDropIntoEditor, boolean>;
|
||||
dropIntoEditor: IEditorOption<EditorOption.dropIntoEditor, Readonly<Required<IDropIntoEditorOptions>>>;
|
||||
extraEditorClassName: IEditorOption<EditorOption.extraEditorClassName, string>;
|
||||
fastScrollSensitivity: IEditorOption<EditorOption.fastScrollSensitivity, number>;
|
||||
find: IEditorOption<EditorOption.find, Readonly<Required<IEditorFindOptions>>>;
|
||||
|
|
|
@ -32,7 +32,7 @@ interface IDropOperation {
|
|||
}
|
||||
|
||||
function isDropIntoEditorEnabledGlobally(configurationService: IConfigurationService) {
|
||||
return configurationService.getValue<boolean>('workbench.editor.dropIntoEditor.enabled');
|
||||
return configurationService.getValue<boolean>('editor.dropIntoEditor.enabled');
|
||||
}
|
||||
|
||||
function isDragIntoEditorEvent(e: DragEvent): boolean {
|
||||
|
|
|
@ -240,7 +240,7 @@ export class TextDiffEditor extends AbstractTextEditor<IDiffEditorViewState> imp
|
|||
return {
|
||||
...super.getConfigurationOverrides(),
|
||||
readOnly,
|
||||
enableDropIntoEditor: !readOnly,
|
||||
dropIntoEditor: { enabled: !readOnly },
|
||||
originalEditable: this.input instanceof DiffEditorInput && !this.input.original.hasCapability(EditorInputCapabilities.Readonly),
|
||||
lineDecorationsWidth: '2ch'
|
||||
};
|
||||
|
@ -251,7 +251,7 @@ export class TextDiffEditor extends AbstractTextEditor<IDiffEditorViewState> imp
|
|||
this.diffEditorControl?.updateOptions({
|
||||
readOnly: input.hasCapability(EditorInputCapabilities.Readonly),
|
||||
originalEditable: !input.original.hasCapability(EditorInputCapabilities.Readonly),
|
||||
enableDropIntoEditor: !input.hasCapability(EditorInputCapabilities.Readonly)
|
||||
dropIntoEditor: { enabled: !input.hasCapability(EditorInputCapabilities.Readonly) }
|
||||
});
|
||||
} else {
|
||||
super.updateReadonly(input);
|
||||
|
|
|
@ -138,7 +138,7 @@ export abstract class AbstractTextEditor<T extends IEditorViewState> extends Abs
|
|||
|
||||
this.updateEditorControlOptions({
|
||||
readOnly,
|
||||
enableDropIntoEditor: !readOnly
|
||||
dropIntoEditor: { enabled: !readOnly },
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ export abstract class AbstractTextEditor<T extends IEditorViewState> extends Abs
|
|||
lineNumbersMinChars: 3,
|
||||
fixedOverflowWidgets: true,
|
||||
readOnly,
|
||||
enableDropIntoEditor: !readOnly,
|
||||
dropIntoEditor: { enabled: !readOnly },
|
||||
renderValidationDecorations: 'on' // render problems even in readonly editors (https://github.com/microsoft/vscode/issues/89057)
|
||||
};
|
||||
}
|
||||
|
|
|
@ -466,11 +466,6 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
|
|||
'default': 'both',
|
||||
'description': localize('layoutControlType', "Controls whether the layout control in the custom title bar is displayed as a single menu button or with multiple UI toggles."),
|
||||
},
|
||||
'workbench.editor.dropIntoEditor.enabled': {
|
||||
'type': 'boolean',
|
||||
'default': true,
|
||||
'markdownDescription': localize('dropIntoEditor', "Controls whether you can drag and drop a file into a text editor by holding down `shift` (instead of opening the file in an editor)."),
|
||||
},
|
||||
'workbench.experimental.layoutControl.enabled': {
|
||||
'type': 'boolean',
|
||||
'tags': ['experimental'],
|
||||
|
|
|
@ -329,7 +329,7 @@ export class StatefulMarkdownCell extends Disposable {
|
|||
width: width,
|
||||
height: editorHeight
|
||||
},
|
||||
enableDropIntoEditor: true,
|
||||
dropIntoEditor: { enabled: true },
|
||||
// overflowWidgetsDomNode: this.notebookEditor.getOverflowContainerDomNode()
|
||||
}, {
|
||||
contributions: this.notebookEditor.creationOptions.cellEditorContributions
|
||||
|
|
|
@ -275,7 +275,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
|
|||
width: 0,
|
||||
height: 0
|
||||
},
|
||||
enableDropIntoEditor: true,
|
||||
dropIntoEditor: { enabled: true },
|
||||
}, {
|
||||
contributions: this.notebookEditor.creationOptions.cellEditorContributions
|
||||
});
|
||||
|
|
|
@ -1963,7 +1963,7 @@ class SCMInputWidget {
|
|||
scrollbar: { alwaysConsumeMouseWheel: false },
|
||||
overflowWidgetsDomNode,
|
||||
renderWhitespace: 'none',
|
||||
enableDropIntoEditor: true,
|
||||
dropIntoEditor: { enabled: true },
|
||||
accessibilitySupport
|
||||
};
|
||||
|
||||
|
|
2
src/vscode-dts/vscode.d.ts
vendored
2
src/vscode-dts/vscode.d.ts
vendored
|
@ -5430,7 +5430,7 @@ declare module 'vscode' {
|
|||
/**
|
||||
* Provider which handles dropping of resources into a text editor.
|
||||
*
|
||||
* The user can drop into a text editor by holding down `shift` while dragging. Requires `workbench.editor.dropIntoEditor.enabled` to be on.
|
||||
* The user can drop into a text editor by holding down `shift` while dragging. Requires `editor.dropIntoEditor.enabled` to be on.
|
||||
*/
|
||||
export interface DocumentDropEditProvider {
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue