mirror of
https://github.com/mathuo/dockview
synced 2025-09-04 00:16:36 +00:00
Merge branch 'master' of https://github.com/mathuo/dockview into 79-new-documentation-website
This commit is contained in:
commit
bb13a10d5c
@ -1,4 +1,3 @@
|
|||||||
import { DockviewComponent } from '../..';
|
|
||||||
import {
|
import {
|
||||||
SplitviewApi,
|
SplitviewApi,
|
||||||
PaneviewApi,
|
PaneviewApi,
|
||||||
@ -8,6 +7,7 @@ import {
|
|||||||
import { GridviewComponent } from '../../gridview/gridviewComponent';
|
import { GridviewComponent } from '../../gridview/gridviewComponent';
|
||||||
import { PaneviewComponent } from '../../paneview/paneviewComponent';
|
import { PaneviewComponent } from '../../paneview/paneviewComponent';
|
||||||
import { SplitviewComponent } from '../../splitview/splitviewComponent';
|
import { SplitviewComponent } from '../../splitview/splitviewComponent';
|
||||||
|
import { DockviewComponent } from '../../dockview/dockviewComponent';
|
||||||
|
|
||||||
describe('component.api', () => {
|
describe('component.api', () => {
|
||||||
describe('splitview', () => {
|
describe('splitview', () => {
|
||||||
@ -22,7 +22,7 @@ describe('component.api', () => {
|
|||||||
'onDidLayoutChange',
|
'onDidLayoutChange',
|
||||||
'onDidAddView',
|
'onDidAddView',
|
||||||
'onDidRemoveView',
|
'onDidRemoveView',
|
||||||
'getPanels',
|
'panels',
|
||||||
'focus',
|
'focus',
|
||||||
'resizeToFit',
|
'resizeToFit',
|
||||||
'toJSON',
|
'toJSON',
|
||||||
|
@ -102,7 +102,7 @@ export class SplitviewApi implements CommonApi<SerializedSplitview> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPanels(): ISplitviewPanel[] {
|
getPanels(): ISplitviewPanel[] {
|
||||||
return this.component.getPanels();
|
return this.component.panels;
|
||||||
}
|
}
|
||||||
|
|
||||||
focus(): void {
|
focus(): void {
|
||||||
@ -121,8 +121,8 @@ export class SplitviewApi implements CommonApi<SerializedSplitview> {
|
|||||||
return this.component.layout(width, height);
|
return this.component.layout(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
addPanel(options: AddSplitviewComponentOptions): void {
|
addPanel(options: AddSplitviewComponentOptions): ISplitviewPanel {
|
||||||
this.component.addPanel(options);
|
return this.component.addPanel(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
resizeToFit(): void {
|
resizeToFit(): void {
|
||||||
@ -216,8 +216,8 @@ export class PaneviewApi implements CommonApi<SerializedPaneview> {
|
|||||||
this.component.layout(width, height);
|
this.component.layout(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
addPanel(options: AddPaneviewComponentOptions): void {
|
addPanel(options: AddPaneviewComponentOptions): IPaneviewPanel {
|
||||||
this.component.addPanel(options);
|
return this.component.addPanel(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
resizeToFit(): void {
|
resizeToFit(): void {
|
||||||
@ -300,8 +300,8 @@ export class GridviewApi implements CommonApi<SerializedGridview> {
|
|||||||
this.component.layout(width, height, force);
|
this.component.layout(width, height, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
addPanel(options: AddComponentOptions): void {
|
addPanel(options: AddComponentOptions): IGridviewPanel {
|
||||||
this.component.addPanel(options);
|
return this.component.addPanel(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
removePanel(panel: IGridviewPanel, sizing?: Sizing): void {
|
removePanel(panel: IGridviewPanel, sizing?: Sizing): void {
|
||||||
|
@ -15,26 +15,24 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: var(--dv-drag-over-background-color);
|
background-color: var(--dv-drag-over-background-color);
|
||||||
|
transition: top 70ms ease-out,left 70ms ease-out,width 70ms ease-out,height 70ms ease-out,opacity .15s ease-out;
|
||||||
transition-duration: 0.15s;
|
|
||||||
transition-timing-function: ease-out;
|
|
||||||
will-change: transform;
|
will-change: transform;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
||||||
&.left {
|
&.left {
|
||||||
transform: translateX(-25%) scaleX(50%)
|
transform: translateX(-25%) scaleX(0.5)
|
||||||
}
|
}
|
||||||
|
|
||||||
&.right {
|
&.right {
|
||||||
transform: translateX(25%) scaleX(50%)
|
transform: translateX(25%) scaleX(0.5)
|
||||||
}
|
}
|
||||||
|
|
||||||
&.top {
|
&.top {
|
||||||
transform: translateY(-25%) scaleY(50%);
|
transform: translateY(-25%) scaleY(0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.bottom {
|
&.bottom {
|
||||||
transform: translateY(25%) scaleY(50%);
|
transform: translateY(25%) scaleY(0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.small-top {
|
&.small-top {
|
||||||
|
@ -21,7 +21,7 @@ import { createComponent } from '../panel/componentFactory';
|
|||||||
import {
|
import {
|
||||||
AddGroupOptions,
|
AddGroupOptions,
|
||||||
AddPanelOptions,
|
AddPanelOptions,
|
||||||
DockviewOptions as DockviewComponentOptions,
|
DockviewComponentOptions,
|
||||||
MovementOptions,
|
MovementOptions,
|
||||||
TabContextMenuEvent,
|
TabContextMenuEvent,
|
||||||
} from './options';
|
} from './options';
|
||||||
|
@ -49,12 +49,11 @@ export interface ViewFactoryData {
|
|||||||
tab?: string;
|
tab?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DockviewOptions extends DockviewRenderFunctions {
|
export interface DockviewComponentOptions extends DockviewRenderFunctions {
|
||||||
watermarkComponent?: WatermarkConstructor;
|
watermarkComponent?: WatermarkConstructor;
|
||||||
watermarkFrameworkComponent?: any;
|
watermarkFrameworkComponent?: any;
|
||||||
frameworkComponentFactory?: GroupPanelFrameworkComponentFactory;
|
frameworkComponentFactory?: GroupPanelFrameworkComponentFactory;
|
||||||
tabHeight?: number;
|
tabHeight?: number;
|
||||||
debug?: boolean;
|
|
||||||
orientation?: Orientation;
|
orientation?: Orientation;
|
||||||
styles?: ISplitviewStyles;
|
styles?: ISplitviewStyles;
|
||||||
showDndOverlay?: (event: DragEvent, target: DockviewDropTargets) => boolean;
|
showDndOverlay?: (event: DragEvent, target: DockviewDropTargets) => boolean;
|
||||||
|
@ -44,7 +44,7 @@ export interface AddComponentOptions extends BaseComponentOptions {
|
|||||||
maximumHeight?: number;
|
maximumHeight?: number;
|
||||||
position?: {
|
position?: {
|
||||||
direction: Direction;
|
direction: Direction;
|
||||||
reference: string;
|
referencePanel: string;
|
||||||
};
|
};
|
||||||
location?: number[];
|
location?: number[];
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ export interface IGridviewComponent extends IBaseGrid<GridviewPanel> {
|
|||||||
readonly orientation: Orientation;
|
readonly orientation: Orientation;
|
||||||
readonly onDidLayoutFromJSON: Event<void>;
|
readonly onDidLayoutFromJSON: Event<void>;
|
||||||
updateOptions(options: Partial<GridviewComponentUpdateOptions>): void;
|
updateOptions(options: Partial<GridviewComponentUpdateOptions>): void;
|
||||||
addPanel(options: AddComponentOptions): void;
|
addPanel(options: AddComponentOptions): IGridviewPanel;
|
||||||
removePanel(panel: IGridviewPanel, sizing?: Sizing): void;
|
removePanel(panel: IGridviewPanel, sizing?: Sizing): void;
|
||||||
toggleVisibility(panel: IGridviewPanel): void;
|
toggleVisibility(panel: IGridviewPanel): void;
|
||||||
focus(): void;
|
focus(): void;
|
||||||
@ -273,17 +273,17 @@ export class GridviewComponent
|
|||||||
this.doAddGroup(removedPanel, relativeLocation, options.size);
|
this.doAddGroup(removedPanel, relativeLocation, options.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public addPanel(options: AddComponentOptions): void {
|
public addPanel(options: AddComponentOptions): IGridviewPanel {
|
||||||
let relativeLocation: number[] = options.location || [0];
|
let relativeLocation: number[] = options.location || [0];
|
||||||
|
|
||||||
if (options.position?.reference) {
|
if (options.position?.referencePanel) {
|
||||||
const referenceGroup = this._groups.get(
|
const referenceGroup = this._groups.get(
|
||||||
options.position.reference
|
options.position.referencePanel
|
||||||
)?.value;
|
)?.value;
|
||||||
|
|
||||||
if (!referenceGroup) {
|
if (!referenceGroup) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`reference group ${options.position.reference} does not exist`
|
`reference group ${options.position.referencePanel} does not exist`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,6 +329,8 @@ export class GridviewComponent
|
|||||||
this.registerPanel(view);
|
this.registerPanel(view);
|
||||||
|
|
||||||
this.doAddGroup(view, relativeLocation, options.size);
|
this.doAddGroup(view, relativeLocation, options.size);
|
||||||
|
|
||||||
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private registerPanel(panel: GridviewPanel) {
|
private registerPanel(panel: GridviewPanel) {
|
||||||
|
@ -36,11 +36,10 @@ export interface DockviewReadyEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IDockviewReactProps {
|
export interface IDockviewReactProps {
|
||||||
components?: PanelCollection<IDockviewPanelProps>;
|
components: PanelCollection<IDockviewPanelProps>;
|
||||||
tabComponents?: PanelCollection<IDockviewPanelHeaderProps>;
|
tabComponents?: PanelCollection<IDockviewPanelHeaderProps>;
|
||||||
watermarkComponent?: React.FunctionComponent<IWatermarkPanelProps>;
|
watermarkComponent?: React.FunctionComponent<IWatermarkPanelProps>;
|
||||||
onReady?: (event: DockviewReadyEvent) => void;
|
onReady: (event: DockviewReadyEvent) => void;
|
||||||
debug?: boolean;
|
|
||||||
tabHeight?: number;
|
tabHeight?: number;
|
||||||
onTabContextMenu?: (event: TabContextMenuEvent) => void;
|
onTabContextMenu?: (event: TabContextMenuEvent) => void;
|
||||||
onDidDrop?: (event: DockviewDropEvent) => void;
|
onDidDrop?: (event: DockviewDropEvent) => void;
|
||||||
@ -127,7 +126,6 @@ export const DockviewReact = React.forwardRef(
|
|||||||
frameworkComponents: props.components,
|
frameworkComponents: props.components,
|
||||||
frameworkTabComponents: props.tabComponents,
|
frameworkTabComponents: props.tabComponents,
|
||||||
tabHeight: props.tabHeight,
|
tabHeight: props.tabHeight,
|
||||||
debug: props.debug,
|
|
||||||
watermarkFrameworkComponent: props.watermarkComponent,
|
watermarkFrameworkComponent: props.watermarkComponent,
|
||||||
styles: props.hideBorders
|
styles: props.hideBorders
|
||||||
? { separatorBorder: 'transparent' }
|
? { separatorBorder: 'transparent' }
|
||||||
|
@ -22,8 +22,8 @@ export interface IGridviewPanelProps<T extends { [index: string]: any } = any>
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IGridviewReactProps {
|
export interface IGridviewReactProps {
|
||||||
orientation: Orientation;
|
orientation?: Orientation;
|
||||||
onReady?: (event: GridviewReadyEvent) => void;
|
onReady: (event: GridviewReadyEvent) => void;
|
||||||
components: PanelCollection<IGridviewPanelProps>;
|
components: PanelCollection<IGridviewPanelProps>;
|
||||||
hideBorders?: boolean;
|
hideBorders?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -64,7 +64,7 @@ export const GridviewReact = React.forwardRef(
|
|||||||
typeof props.proportionalLayout === 'boolean'
|
typeof props.proportionalLayout === 'boolean'
|
||||||
? props.proportionalLayout
|
? props.proportionalLayout
|
||||||
: true,
|
: true,
|
||||||
orientation: props.orientation,
|
orientation: props.orientation || Orientation.HORIZONTAL,
|
||||||
frameworkComponents: props.components,
|
frameworkComponents: props.components,
|
||||||
frameworkComponentFactory: {
|
frameworkComponentFactory: {
|
||||||
createComponent: (id: string, componentId, component) => {
|
createComponent: (id: string, componentId, component) => {
|
||||||
|
@ -27,8 +27,8 @@ export interface PaneviewDropEvent extends PaneviewDropEvent2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IPaneviewReactProps {
|
export interface IPaneviewReactProps {
|
||||||
onReady?: (event: PaneviewReadyEvent) => void;
|
onReady: (event: PaneviewReadyEvent) => void;
|
||||||
components?: PanelCollection<IPaneviewPanelProps>;
|
components: PanelCollection<IPaneviewPanelProps>;
|
||||||
headerComponents?: PanelCollection<IPaneviewPanelProps>;
|
headerComponents?: PanelCollection<IPaneviewPanelProps>;
|
||||||
className?: string;
|
className?: string;
|
||||||
disableAutoResizing?: boolean;
|
disableAutoResizing?: boolean;
|
||||||
|
@ -22,8 +22,8 @@ export interface ISplitviewPanelProps<T extends { [index: string]: any } = any>
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ISplitviewReactProps {
|
export interface ISplitviewReactProps {
|
||||||
orientation: Orientation;
|
orientation?: Orientation;
|
||||||
onReady?: (event: SplitviewReadyEvent) => void;
|
onReady: (event: SplitviewReadyEvent) => void;
|
||||||
components: PanelCollection<ISplitviewPanelProps>;
|
components: PanelCollection<ISplitviewPanelProps>;
|
||||||
proportionalLayout?: boolean;
|
proportionalLayout?: boolean;
|
||||||
hideBorders?: boolean;
|
hideBorders?: boolean;
|
||||||
@ -58,7 +58,7 @@ export const SplitviewReact = React.forwardRef(
|
|||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const splitview = new SplitviewComponent(domRef.current!, {
|
const splitview = new SplitviewComponent(domRef.current!, {
|
||||||
orientation: props.orientation,
|
orientation: props.orientation || Orientation.HORIZONTAL,
|
||||||
frameworkComponents: props.components,
|
frameworkComponents: props.components,
|
||||||
frameworkWrapper: {
|
frameworkWrapper: {
|
||||||
createComponent: (
|
createComponent: (
|
||||||
|
@ -61,8 +61,9 @@ export interface ISplitviewComponent extends IDisposable {
|
|||||||
readonly onDidAddView: Event<IView>;
|
readonly onDidAddView: Event<IView>;
|
||||||
readonly onDidRemoveView: Event<IView>;
|
readonly onDidRemoveView: Event<IView>;
|
||||||
readonly onDidLayoutFromJSON: Event<void>;
|
readonly onDidLayoutFromJSON: Event<void>;
|
||||||
|
readonly panels: SplitviewPanel[];
|
||||||
updateOptions(options: Partial<SplitviewComponentUpdateOptions>): void;
|
updateOptions(options: Partial<SplitviewComponentUpdateOptions>): void;
|
||||||
addPanel(options: AddSplitviewComponentOptions): void;
|
addPanel(options: AddSplitviewComponentOptions): ISplitviewPanel;
|
||||||
layout(width: number, height: number): void;
|
layout(width: number, height: number): void;
|
||||||
onDidLayoutChange: Event<void>;
|
onDidLayoutChange: Event<void>;
|
||||||
toJSON(): SerializedSplitview;
|
toJSON(): SerializedSplitview;
|
||||||
@ -72,7 +73,7 @@ export interface ISplitviewComponent extends IDisposable {
|
|||||||
getPanel(id: string): ISplitviewPanel | undefined;
|
getPanel(id: string): ISplitviewPanel | undefined;
|
||||||
setActive(view: ISplitviewPanel, skipFocus?: boolean): void;
|
setActive(view: ISplitviewPanel, skipFocus?: boolean): void;
|
||||||
removePanel(panel: ISplitviewPanel, sizing?: Sizing): void;
|
removePanel(panel: ISplitviewPanel, sizing?: Sizing): void;
|
||||||
getPanels(): SplitviewPanel[];
|
|
||||||
setVisible(panel: ISplitviewPanel, visible: boolean): void;
|
setVisible(panel: ISplitviewPanel, visible: boolean): void;
|
||||||
movePanel(from: number, to: number): void;
|
movePanel(from: number, to: number): void;
|
||||||
}
|
}
|
||||||
@ -87,7 +88,7 @@ export class SplitviewComponent
|
|||||||
private _disposable = new MutableDisposable();
|
private _disposable = new MutableDisposable();
|
||||||
private _splitview!: Splitview;
|
private _splitview!: Splitview;
|
||||||
private _activePanel: SplitviewPanel | undefined;
|
private _activePanel: SplitviewPanel | undefined;
|
||||||
private panels = new Map<string, IValueDisposable<SplitviewPanel>>();
|
private _panels = new Map<string, IValueDisposable<SplitviewPanel>>();
|
||||||
private _options: SplitviewComponentOptions;
|
private _options: SplitviewComponentOptions;
|
||||||
|
|
||||||
private readonly _onDidLayoutfromJSON = new Emitter<void>();
|
private readonly _onDidLayoutfromJSON = new Emitter<void>();
|
||||||
@ -102,15 +103,23 @@ export class SplitviewComponent
|
|||||||
private readonly _onDidLayoutChange = new Emitter<void>();
|
private readonly _onDidLayoutChange = new Emitter<void>();
|
||||||
readonly onDidLayoutChange: Event<void> = this._onDidLayoutChange.event;
|
readonly onDidLayoutChange: Event<void> = this._onDidLayoutChange.event;
|
||||||
|
|
||||||
get options() {
|
get options(): SplitviewComponentOptions {
|
||||||
return this._options;
|
return this._options;
|
||||||
}
|
}
|
||||||
|
|
||||||
get orientation() {
|
get panels(): SplitviewPanel[] {
|
||||||
|
return this.splitview.getViews();
|
||||||
|
}
|
||||||
|
|
||||||
|
get length(): number {
|
||||||
|
return this._panels.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
get orientation(): Orientation {
|
||||||
return this.splitview.orientation;
|
return this.splitview.orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
get splitview() {
|
get splitview(): Splitview {
|
||||||
return this._splitview;
|
return this._splitview;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,30 +137,26 @@ export class SplitviewComponent
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get minimumSize() {
|
get minimumSize(): number {
|
||||||
return this.splitview.minimumSize;
|
return this.splitview.minimumSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
get maximumSize() {
|
get maximumSize(): number {
|
||||||
return this.splitview.maximumSize;
|
return this.splitview.maximumSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
get height() {
|
get height(): number {
|
||||||
return this.splitview.orientation === Orientation.HORIZONTAL
|
return this.splitview.orientation === Orientation.HORIZONTAL
|
||||||
? this.splitview.orthogonalSize
|
? this.splitview.orthogonalSize
|
||||||
: this.splitview.size;
|
: this.splitview.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
get width() {
|
get width(): number {
|
||||||
return this.splitview.orientation === Orientation.HORIZONTAL
|
return this.splitview.orientation === Orientation.HORIZONTAL
|
||||||
? this.splitview.size
|
? this.splitview.size
|
||||||
: this.splitview.orthogonalSize;
|
: this.splitview.orthogonalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
get length() {
|
|
||||||
return this.panels.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly element: HTMLElement,
|
private readonly element: HTMLElement,
|
||||||
options: SplitviewComponentOptions
|
options: SplitviewComponentOptions
|
||||||
@ -195,23 +200,23 @@ export class SplitviewComponent
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
focus() {
|
focus(): void {
|
||||||
this._activePanel?.focus();
|
this._activePanel?.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
movePanel(from: number, to: number) {
|
movePanel(from: number, to: number): void {
|
||||||
this.splitview.moveView(from, to);
|
this.splitview.moveView(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
setVisible(panel: SplitviewPanel, visible: boolean) {
|
setVisible(panel: SplitviewPanel, visible: boolean): void {
|
||||||
const index = this.getPanels().indexOf(panel);
|
const index = this.panels.indexOf(panel);
|
||||||
this.splitview.setViewVisible(index, visible);
|
this.splitview.setViewVisible(index, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
setActive(view: SplitviewPanel, skipFocus?: boolean) {
|
setActive(view: SplitviewPanel, skipFocus?: boolean): void {
|
||||||
this._activePanel = view;
|
this._activePanel = view;
|
||||||
|
|
||||||
this.getPanels()
|
this.panels
|
||||||
.filter((v) => v !== view)
|
.filter((v) => v !== view)
|
||||||
.forEach((v) => {
|
.forEach((v) => {
|
||||||
v.api._onDidActiveChange.fire({ isActive: false });
|
v.api._onDidActiveChange.fire({ isActive: false });
|
||||||
@ -225,12 +230,8 @@ export class SplitviewComponent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getPanels(): SplitviewPanel[] {
|
removePanel(panel: SplitviewPanel, sizing?: Sizing): void {
|
||||||
return this.splitview.getViews();
|
const disposable = this._panels.get(panel.id);
|
||||||
}
|
|
||||||
|
|
||||||
removePanel(panel: SplitviewPanel, sizing?: Sizing) {
|
|
||||||
const disposable = this.panels.get(panel.id);
|
|
||||||
|
|
||||||
if (!disposable) {
|
if (!disposable) {
|
||||||
throw new Error(`unknown splitview panel ${panel.id}`);
|
throw new Error(`unknown splitview panel ${panel.id}`);
|
||||||
@ -239,23 +240,23 @@ export class SplitviewComponent
|
|||||||
disposable.disposable.dispose();
|
disposable.disposable.dispose();
|
||||||
disposable.value.dispose();
|
disposable.value.dispose();
|
||||||
|
|
||||||
this.panels.delete(panel.id);
|
this._panels.delete(panel.id);
|
||||||
|
|
||||||
const index = this.getPanels().findIndex((_) => _ === panel);
|
const index = this.panels.findIndex((_) => _ === panel);
|
||||||
this.splitview.removeView(index, sizing);
|
this.splitview.removeView(index, sizing);
|
||||||
|
|
||||||
const panels = this.getPanels();
|
const panels = this.panels;
|
||||||
if (panels.length > 0) {
|
if (panels.length > 0) {
|
||||||
this.setActive(panels[panels.length - 1]);
|
this.setActive(panels[panels.length - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getPanel(id: string): SplitviewPanel | undefined {
|
getPanel(id: string): SplitviewPanel | undefined {
|
||||||
return this.getPanels().find((view) => view.id === id);
|
return this.panels.find((view) => view.id === id);
|
||||||
}
|
}
|
||||||
|
|
||||||
addPanel(options: AddSplitviewComponentOptions): void {
|
addPanel(options: AddSplitviewComponentOptions): ISplitviewPanel {
|
||||||
if (this.panels.has(options.id)) {
|
if (this._panels.has(options.id)) {
|
||||||
throw new Error(`panel ${options.id} already exists`);
|
throw new Error(`panel ${options.id} already exists`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,6 +293,8 @@ export class SplitviewComponent
|
|||||||
|
|
||||||
this.doAddView(view);
|
this.doAddView(view);
|
||||||
this.setActive(view);
|
this.setActive(view);
|
||||||
|
|
||||||
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -314,7 +317,7 @@ export class SplitviewComponent
|
|||||||
this.splitview.layout(size, orthogonalSize);
|
this.splitview.layout(size, orthogonalSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private doAddView(view: SplitviewPanel) {
|
private doAddView(view: SplitviewPanel): void {
|
||||||
const disposable = view.api.onDidFocusChange((event) => {
|
const disposable = view.api.onDidFocusChange((event) => {
|
||||||
if (!event.isFocused) {
|
if (!event.isFocused) {
|
||||||
return;
|
return;
|
||||||
@ -322,7 +325,7 @@ export class SplitviewComponent
|
|||||||
this.setActive(view, true);
|
this.setActive(view, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.panels.set(view.id, { disposable, value: view });
|
this._panels.set(view.id, { disposable, value: view });
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON(): SerializedSplitview {
|
toJSON(): SerializedSplitview {
|
||||||
@ -349,11 +352,11 @@ export class SplitviewComponent
|
|||||||
fromJSON(serializedSplitview: SerializedSplitview): void {
|
fromJSON(serializedSplitview: SerializedSplitview): void {
|
||||||
const { views, orientation, size, activeView } = serializedSplitview;
|
const { views, orientation, size, activeView } = serializedSplitview;
|
||||||
|
|
||||||
for (const [_, value] of this.panels.entries()) {
|
for (const [_, value] of this._panels.entries()) {
|
||||||
value.disposable.dispose();
|
value.disposable.dispose();
|
||||||
value.value.dispose();
|
value.value.dispose();
|
||||||
}
|
}
|
||||||
this.panels.clear();
|
this._panels.clear();
|
||||||
this.splitview.dispose();
|
this.splitview.dispose();
|
||||||
|
|
||||||
const queue: Function[] = [];
|
const queue: Function[] = [];
|
||||||
@ -366,7 +369,7 @@ export class SplitviewComponent
|
|||||||
views: views.map((view) => {
|
views: views.map((view) => {
|
||||||
const data = view.data;
|
const data = view.data;
|
||||||
|
|
||||||
if (this.panels.has(data.id)) {
|
if (this._panels.has(data.id)) {
|
||||||
throw new Error(`panel ${data.id} already exists`);
|
throw new Error(`panel ${data.id} already exists`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,12 +425,12 @@ export class SplitviewComponent
|
|||||||
this._onDidLayoutfromJSON.fire();
|
this._onDidLayoutfromJSON.fire();
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose(): void {
|
||||||
for (const [_, value] of this.panels.entries()) {
|
for (const [_, value] of this._panels.entries()) {
|
||||||
value.disposable.dispose();
|
value.disposable.dispose();
|
||||||
value.value.dispose();
|
value.value.dispose();
|
||||||
}
|
}
|
||||||
this.panels.clear();
|
this._panels.clear();
|
||||||
|
|
||||||
this.splitview.dispose();
|
this.splitview.dispose();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user