Skip to content

Commit

Permalink
evolution on proposed API dropMetadata with vs code 1.82
Browse files Browse the repository at this point in the history
note the API can't be fully implemented until next monaco upgrade
Fixes #12986

contributed on behalf of STMicroelectronics
  • Loading branch information
rschnekenbu committed Oct 19, 2023
1 parent 30d166e commit 5f16e3a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
1 change: 1 addition & 0 deletions packages/plugin-ext/src/common/plugin-api-rpc-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ export interface DocumentDropEdit {
}

export interface DocumentDropEditProviderMetadata {
readonly id: string;
readonly dropMimeTypes: readonly string[];
}

Expand Down
12 changes: 7 additions & 5 deletions packages/plugin-ext/src/main/browser/languages-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,8 @@ export class LanguagesMainImpl implements LanguagesMain, Disposable {

createDocumentDropEditProvider(handle: number, _metadata?: DocumentDropEditProviderMetadata): DocumentOnDropEditProvider {
return {
// @monaco-uplift dropMimeTypes should be supported by the monaco drop editor provider after 1.79.0
// @monaco-uplift id and dropMimeTypes should be supported by the monaco drop editor provider after 1.82.0
// id?: string;
// dropMimeTypes: metadata?.dropMimeTypes ?? ['*/*'],
provideDocumentOnDropEdits: async (model, position, dataTransfer, token) => this.provideDocumentDropEdits(handle, model, position, dataTransfer, token)
};
Expand All @@ -752,10 +753,11 @@ export class LanguagesMainImpl implements LanguagesMain, Disposable {
const edit = await this.proxy.$provideDocumentDropEdits(handle, model.uri, position, await DataTransfer.toDataTransferDTO(dataTransfer), token);
if (edit) {
return {
// @monaco-uplift id, priority and label should be supported by monaco after 1.79.0. The implementation relies on a copy of the plugin data
// id: edit.id ? plugin.identifier.value + '.' + edit.id : plugin.identifier.value,
// label: edit.label ?? nls.localizeByDefault("Drop using '{0}' extension", plugin.displayName || plugin.name),
// priority: edit.priority ?? 0,
// @monaco-uplift label and yieldTo should be supported by monaco after 1.82.0. The implementation relies on a copy of the plugin data
// label: label: edit.label ?? localize('defaultDropLabel', "Drop using '{0}' extension", this._extension.displayName || this._extension.name),,
// yieldTo: edit.yieldTo?.map(yTo => {
// return 'mimeType' in yTo ? yTo : { providerId: DocumentOnDropEditAdapter.toInternalProviderId(yTo.extensionId, yTo.providerId) };
// }),
insertText: edit.insertText instanceof SnippetString ? { snippet: edit.insertText.value } : edit.insertText,
additionalEdit: toMonacoWorkspaceEdit(edit?.additionalEdit)
};
Expand Down
29 changes: 19 additions & 10 deletions packages/plugin/src/theia.proposed.dropMetadata.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,36 @@ export module '@theia/plugin' {
// https://github.com/microsoft/vscode/issues/179430

export interface DocumentDropEdit {

/**
* Identifies the type of edit.
*
* This id should be unique within the extension but does not need to be unique across extensions.
* Human readable label that describes the edit.
*/
id?: string;
label?: string;

/**
* The relative priority of this edit. Higher priority items are shown first in the UI.
*
* Defaults to `0`.
* The mime type from the {@link DataTransfer} that this edit applies.
*/
priority?: number;
handledMimeType?: string;

/**
* Human readable label that describes the edit.
* Controls the ordering or multiple paste edits. If this provider yield to edits, it will be shown lower in the list.
*/
label?: string;
yieldTo?: ReadonlyArray<
| { readonly extensionId: string; readonly providerId: string }
| { readonly mimeType: string }
>;
}

export interface DocumentDropEditProviderMetadata {
/**
* Identifies the provider.
*
* This id is used when users configure the default provider for drop.
*
* This id should be unique within the extension but does not need to be unique across extensions.
*/
readonly id: string;

/**
* List of data transfer types that the provider supports.
*
Expand Down

0 comments on commit 5f16e3a

Please sign in to comment.