feat: align event names

This commit is contained in:
mathuo 2024-01-28 13:43:09 +00:00
parent a8472e8b71
commit 6274708acb
No known key found for this signature in database
GPG Key ID: C6EEDEFD6CA07281
4 changed files with 19 additions and 20 deletions

View File

@ -830,8 +830,8 @@ export class DockviewApi implements CommonApi<SerializedDockview> {
options?: { options?: {
position?: Box; position?: Box;
popoutUrl?: string; popoutUrl?: string;
onOpened?: (id: string, window: Window) => void; onDidOpen?: (event: { id: string; window: Window }) => void;
onClosing?: (id: string, window: Window) => void; onWillClose?: (event: { id: string; window: Window }) => void;
} }
): void { ): void {
this.component.addPopoutGroup(item, options); this.component.addPopoutGroup(item, options);

View File

@ -287,8 +287,8 @@ export interface IDockviewComponent extends IBaseGrid<DockviewGroupPanel> {
options?: { options?: {
position?: Box; position?: Box;
popoutUrl?: string; popoutUrl?: string;
onOpened?: (id: string, window: Window) => void; onDidOpen?: (event: { id: string; window: Window }) => void;
onClosing?: (id: string, window: Window) => void; onWillClose?: (event: { id: string; window: Window }) => void;
} }
): void; ): void;
} }
@ -516,8 +516,8 @@ export class DockviewComponent
skipRemoveGroup?: boolean; skipRemoveGroup?: boolean;
position?: Box; position?: Box;
popoutUrl?: string; popoutUrl?: string;
onOpened?: (id: string, window: Window) => void; onDidOpen?: (event: { id: string; window: Window }) => void;
onClosing?: (id: string, window: Window) => void; onWillClose?: (event: { id: string; window: Window }) => void;
} }
): void { ): void {
let group: DockviewGroupPanel; let group: DockviewGroupPanel;
@ -566,8 +566,8 @@ export class DockviewComponent
width: box.width, width: box.width,
height: box.height, height: box.height,
}, },
onOpened: options?.onOpened, onDidOpen: options?.onDidOpen,
onClosing: options?.onClosing onWillClose: options?.onWillClose,
} }
); );

View File

@ -13,8 +13,8 @@ export class DockviewPopoutGroupPanel extends CompositeDisposable {
className: string; className: string;
popoutUrl: string; popoutUrl: string;
box: Box; box: Box;
onOpened?: (id: string, window: Window) => void; onDidOpen?: (event: { id: string; window: Window }) => void;
onClosing?: (id: string, window: Window) => void; onWillClose?: (event: { id: string; window: Window }) => void;
} }
) { ) {
super(); super();
@ -25,8 +25,8 @@ export class DockviewPopoutGroupPanel extends CompositeDisposable {
top: this.options.box.top, top: this.options.box.top,
width: this.options.box.width, width: this.options.box.width,
height: this.options.box.height, height: this.options.box.height,
onOpened: this.options.onOpened, onDidOpen: this.options.onDidOpen,
onClosing: this.options.onClosing, onWillClose: this.options.onWillClose,
}); });
group.model.location = { group.model.location = {

View File

@ -5,8 +5,8 @@ import { Box } from './types';
export type PopoutWindowOptions = { export type PopoutWindowOptions = {
url: string; url: string;
onOpened?: (id: string, window: Window) => void; onDidOpen?: (event: { id: string; window: Window }) => void;
onClosing?: (id: string, window: Window) => void; onWillClose?: (event: { id: string; window: Window }) => void;
} & Box; } & Box;
export class PopoutWindow extends CompositeDisposable { export class PopoutWindow extends CompositeDisposable {
@ -53,9 +53,10 @@ export class PopoutWindow extends CompositeDisposable {
if (this._window) { if (this._window) {
this._onWillClose.fire(); this._onWillClose.fire();
if (this.options.onClosing) { this.options.onWillClose?.({
this.options.onClosing(this.target, this._window.value); id: this.target,
} window: this._window.value,
});
this._window.disposable.dispose(); this._window.disposable.dispose();
this._window.value.close(); this._window.value.close();
@ -132,9 +133,7 @@ export class PopoutWindow extends CompositeDisposable {
}); });
}); });
if (this.options.onOpened) { this.options.onDidOpen?.({ id: this.target, window: externalWindow });
this.options.onOpened(this.target, externalWindow);
}
} }
private createPopoutWindowContainer(): HTMLElement { private createPopoutWindowContainer(): HTMLElement {