webview: show find widget with argument
This commit is contained in:
parent
6ab3506e67
commit
818176248e
|
@ -196,6 +196,10 @@ export abstract class SimpleFindWidget extends Widget {
|
|||
return this._findInput.getValue();
|
||||
}
|
||||
|
||||
public setInputValue(value: string) {
|
||||
this._findInput.setValue(value);
|
||||
}
|
||||
|
||||
public get focusTracker(): dom.IFocusTracker {
|
||||
return this._focusTracker;
|
||||
}
|
||||
|
|
|
@ -340,6 +340,13 @@ export class OverlayWebview extends Disposable implements IOverlayWebview {
|
|||
}
|
||||
}
|
||||
|
||||
public showFindWithArg(arg: string) {
|
||||
if (this._webview.value) {
|
||||
this._webview.value.showFindWithArg!(arg);
|
||||
this._findWidgetVisible?.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
hideFind() {
|
||||
this._findWidgetVisible?.reset();
|
||||
this._webview.value?.hideFind();
|
||||
|
|
|
@ -188,6 +188,7 @@ export interface IWebview extends IDisposable {
|
|||
reload(): void;
|
||||
|
||||
showFind(): void;
|
||||
showFindWithArg?(value: string): void;
|
||||
hideFind(): void;
|
||||
runFindAction(previous: boolean): void;
|
||||
|
||||
|
|
|
@ -929,6 +929,11 @@ export class WebviewElement extends Disposable implements IWebview, WebviewFindD
|
|||
this._webviewFindWidget?.reveal();
|
||||
}
|
||||
|
||||
public showFindWithArg(arg: string) {
|
||||
this.showFind();
|
||||
this._webviewFindWidget?.setInputValue(arg);
|
||||
}
|
||||
|
||||
public hideFind() {
|
||||
this._webviewFindWidget?.hide();
|
||||
}
|
||||
|
|
|
@ -39,6 +39,26 @@ export class ShowWebViewEditorFindWidgetAction extends Action2 {
|
|||
}
|
||||
}
|
||||
|
||||
export class ShowWebViewEditorFindWidgetWithArgAction extends Action2 {
|
||||
public static readonly ID = 'editor.action.webvieweditor.showFindWithArg';
|
||||
public static readonly LABEL = nls.localize('editor.action.webvieweditor.showFindWithArg', "Show find with argument");
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
id: ShowWebViewEditorFindWidgetWithArgAction.ID,
|
||||
title: ShowWebViewEditorFindWidgetWithArgAction.LABEL,
|
||||
keybinding: {
|
||||
when: ContextKeyExpr.and(webviewActiveContextKeyExpr, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_ENABLED),
|
||||
weight: KeybindingWeight.EditorContrib
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, ...args: any[]): void {
|
||||
getActiveWebviewEditor(accessor)?.showFindWithArg!(args[0] as string);
|
||||
}
|
||||
}
|
||||
|
||||
export class HideWebViewEditorFindCommand extends Action2 {
|
||||
public static readonly ID = 'editor.action.webvieweditor.hideFind';
|
||||
public static readonly LABEL = nls.localize('editor.action.webvieweditor.hideFind', "Stop find");
|
||||
|
|
|
@ -16,7 +16,7 @@ import { EditorExtensions, IEditorFactoryRegistry } from 'vs/workbench/common/ed
|
|||
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
|
||||
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { HideWebViewEditorFindCommand, ReloadWebviewAction, ShowWebViewEditorFindWidgetAction, WebViewEditorFindNextCommand, WebViewEditorFindPreviousCommand } from './webviewCommands';
|
||||
import { HideWebViewEditorFindCommand, ReloadWebviewAction, ShowWebViewEditorFindWidgetAction, ShowWebViewEditorFindWidgetWithArgAction, WebViewEditorFindNextCommand, WebViewEditorFindPreviousCommand } from './webviewCommands';
|
||||
import { WebviewEditor } from './webviewEditor';
|
||||
import { WebviewInput } from './webviewEditorInput';
|
||||
import { WebviewEditorInputSerializer } from './webviewEditorInputSerializer';
|
||||
|
@ -91,6 +91,7 @@ Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerEdit
|
|||
registerSingleton(IWebviewWorkbenchService, WebviewEditorService, true);
|
||||
|
||||
registerAction2(ShowWebViewEditorFindWidgetAction);
|
||||
registerAction2(ShowWebViewEditorFindWidgetWithArgAction);
|
||||
registerAction2(HideWebViewEditorFindCommand);
|
||||
registerAction2(WebViewEditorFindNextCommand);
|
||||
registerAction2(WebViewEditorFindPreviousCommand);
|
||||
|
|
Loading…
Reference in New Issue