mirror of
https://github.com/mathuo/dockview
synced 2025-02-02 22:45:48 +00:00
refactor: move and delete code
This commit is contained in:
parent
09a6f265d5
commit
3a458461a1
@ -8,7 +8,7 @@ import {
|
||||
IGroupPanelInitParameters,
|
||||
} from '../../dockview/types';
|
||||
import { PanelUpdateEvent } from '../../panel/types';
|
||||
import { Orientation } from '../../splitview/core/splitview';
|
||||
import { Orientation } from '../../splitview/splitview';
|
||||
import { CompositeDisposable } from '../../lifecycle';
|
||||
import { Emitter } from '../../events';
|
||||
import { IDockviewPanel } from '../../dockview/dockviewPanel';
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
PanelUpdateEvent,
|
||||
Parameters,
|
||||
} from '../../panel/types';
|
||||
import { LayoutPriority, Orientation } from '../../splitview/core/splitview';
|
||||
import { LayoutPriority, Orientation } from '../../splitview/splitview';
|
||||
|
||||
class TestPanel implements IGridPanelView {
|
||||
_onDidChange = new Emitter<IViewSize | undefined>();
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Gridview } from '../../gridview/gridview';
|
||||
import { Orientation } from '../../splitview/core/splitview';
|
||||
import { Orientation } from '../../splitview/splitview';
|
||||
|
||||
describe('gridview', () => {
|
||||
let container: HTMLElement;
|
||||
|
@ -2,7 +2,7 @@ import { GridviewComponent } from '../../gridview/gridviewComponent';
|
||||
import { GridviewPanel } from '../../gridview/gridviewPanel';
|
||||
import { CompositeDisposable } from '../../lifecycle';
|
||||
import { IFrameworkPart } from '../../panel/types';
|
||||
import { Orientation } from '../../splitview/core/splitview';
|
||||
import { Orientation } from '../../splitview/splitview';
|
||||
|
||||
class TestGridview extends GridviewPanel {
|
||||
constructor(id: string, componentName: string) {
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
IPaneHeaderPart,
|
||||
PaneviewPanel,
|
||||
} from '../../paneview/paneviewPanel';
|
||||
import { Orientation } from '../../splitview/core/splitview';
|
||||
import { Orientation } from '../../splitview/splitview';
|
||||
|
||||
class TestPanel extends PaneviewPanel {
|
||||
protected getBodyComponent(): IPaneBodyPart {
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
IPaneHeaderPart,
|
||||
PanePanelComponentInitParameter,
|
||||
} from '../../paneview/paneviewPanel';
|
||||
import { Orientation } from '../../splitview/core/splitview';
|
||||
import { Orientation } from '../../splitview/splitview';
|
||||
|
||||
class TestPanel extends PaneviewPanel {
|
||||
constructor(id: string, component: string) {
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Emitter } from '../../../events';
|
||||
import { CompositeDisposable } from '../../../lifecycle';
|
||||
import { Emitter } from '../../events';
|
||||
import { CompositeDisposable } from '../../lifecycle';
|
||||
import {
|
||||
IView,
|
||||
LayoutPriority,
|
||||
Orientation,
|
||||
Sizing,
|
||||
Splitview,
|
||||
} from '../../../splitview/core/splitview';
|
||||
} from '../../splitview/splitview';
|
||||
|
||||
class Testview implements IView {
|
||||
private _element: HTMLElement = document.createElement('div');
|
@ -1,6 +1,6 @@
|
||||
import { PanelDimensionChangeEvent } from '../../api/panelApi';
|
||||
import { CompositeDisposable } from '../../lifecycle';
|
||||
import { Orientation } from '../../splitview/core/splitview';
|
||||
import { Orientation } from '../../splitview/splitview';
|
||||
import { SplitviewComponent } from '../../splitview/splitviewComponent';
|
||||
import { SplitviewPanel } from '../../splitview/splitviewPanel';
|
||||
|
||||
|
@ -1,29 +0,0 @@
|
||||
.actions-bar {
|
||||
text-align: right;
|
||||
width: 28px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
|
||||
.actions-container {
|
||||
display: flex;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
justify-content: flex-end;
|
||||
|
||||
.close-action {
|
||||
padding: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
color: var(--dv-activegroup-hiddenpanel-tab-color);
|
||||
|
||||
&:hover {
|
||||
border-radius: 2px;
|
||||
background-color: var(--dv-icon-hover-background-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
export class ActionContainer {
|
||||
private _element: HTMLElement;
|
||||
private _list: HTMLElement;
|
||||
|
||||
get element(): HTMLElement {
|
||||
return this._element;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this._element = document.createElement('div');
|
||||
this._element.className = 'actions-bar';
|
||||
|
||||
this._list = document.createElement('ul');
|
||||
this._list.className = 'actions-container';
|
||||
|
||||
this._element.appendChild(this._list);
|
||||
}
|
||||
|
||||
public add(element: HTMLElement): void {
|
||||
const listItem = document.createElement('li');
|
||||
listItem.className = 'action-item';
|
||||
this._list.appendChild(element);
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ import {
|
||||
SerializedSplitview,
|
||||
SplitviewComponentUpdateOptions,
|
||||
} from '../splitview/splitviewComponent';
|
||||
import { IView, Orientation, Sizing } from '../splitview/core/splitview';
|
||||
import { IView, Orientation, Sizing } from '../splitview/splitview';
|
||||
import { ISplitviewPanel } from '../splitview/splitviewPanel';
|
||||
import {
|
||||
DockviewGroupPanel,
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
&.has-actions {
|
||||
.watermark-title {
|
||||
.actions-bar {
|
||||
.actions-container {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@ -18,4 +18,28 @@
|
||||
.watermark-content {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.actions-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0px 8px;
|
||||
// padding: 0px;
|
||||
// margin: 0px;
|
||||
// justify-content: flex-end;
|
||||
|
||||
.close-action {
|
||||
padding: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
color: var(--dv-activegroup-hiddenpanel-tab-color);
|
||||
|
||||
&:hover {
|
||||
border-radius: 2px;
|
||||
background-color: var(--dv-icon-hover-background-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { GroupPanelPartInitParameters, IWatermarkRenderer } from '../../types';
|
||||
import { ActionContainer } from '../../../actionbar/actionsContainer';
|
||||
import { addDisposableListener } from '../../../events';
|
||||
import { toggleClass } from '../../../dom';
|
||||
import { CompositeDisposable } from '../../../lifecycle';
|
||||
@ -36,15 +35,17 @@ export class Watermark
|
||||
this._element.appendChild(title);
|
||||
this._element.appendChild(content);
|
||||
|
||||
const actions = new ActionContainer();
|
||||
title.appendChild(emptySpace);
|
||||
title.appendChild(actions.element);
|
||||
const actionsContainer = document.createElement('div');
|
||||
actionsContainer.className = 'actions-container';
|
||||
|
||||
const closeAnchor = document.createElement('div');
|
||||
closeAnchor.className = 'close-action';
|
||||
closeAnchor.appendChild(createCloseButton());
|
||||
|
||||
actions.add(closeAnchor);
|
||||
actionsContainer.appendChild(closeAnchor);
|
||||
|
||||
title.appendChild(emptySpace);
|
||||
title.appendChild(actionsContainer);
|
||||
|
||||
this.addDisposables(
|
||||
addDisposableListener(closeAnchor, 'click', (ev) => {
|
||||
|
@ -35,7 +35,7 @@ import {
|
||||
toTarget,
|
||||
} from '../gridview/baseComponentGridview';
|
||||
import { DockviewApi } from '../api/component.api';
|
||||
import { Orientation, Sizing } from '../splitview/core/splitview';
|
||||
import { Orientation, Sizing } from '../splitview/splitview';
|
||||
import {
|
||||
GroupOptions,
|
||||
GroupPanelViewState,
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
DockviewGroupPanel,
|
||||
DockviewGroupPanelApi,
|
||||
} from './dockviewGroupPanel';
|
||||
import { ISplitviewStyles, Orientation } from '../splitview/core/splitview';
|
||||
import { ISplitviewStyles, Orientation } from '../splitview/splitview';
|
||||
import { FrameworkFactory } from '../types';
|
||||
import { PanelTransfer } from '../dnd/dataTransfer';
|
||||
import { IDisposable } from '../lifecycle';
|
||||
|
@ -3,11 +3,7 @@ import { getGridLocation, Gridview, IGridView } from './gridview';
|
||||
import { Position } from '../dnd/droptarget';
|
||||
import { CompositeDisposable, IValueDisposable } from '../lifecycle';
|
||||
import { sequentialNumberGenerator } from '../math';
|
||||
import {
|
||||
ISplitviewStyles,
|
||||
Orientation,
|
||||
Sizing,
|
||||
} from '../splitview/core/splitview';
|
||||
import { ISplitviewStyles, Orientation, Sizing } from '../splitview/splitview';
|
||||
import { IPanel } from '../panel/types';
|
||||
import { MovementOptions2 } from '../dockview/options';
|
||||
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
Sizing,
|
||||
LayoutPriority,
|
||||
ISplitviewStyles,
|
||||
} from '../splitview/core/splitview';
|
||||
} from '../splitview/splitview';
|
||||
import { Emitter, Event } from '../events';
|
||||
import { INodeDescriptor } from './gridview';
|
||||
import { LeafNode } from './leafNode';
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
LayoutPriority,
|
||||
Orientation,
|
||||
Sizing,
|
||||
} from '../splitview/core/splitview';
|
||||
} from '../splitview/splitview';
|
||||
import { tail } from '../array';
|
||||
import { LeafNode } from './leafNode';
|
||||
import { BranchNode } from './branchNode';
|
||||
|
@ -22,7 +22,7 @@ import {
|
||||
IGridviewPanel,
|
||||
} from './gridviewPanel';
|
||||
import { BaseComponentOptions } from '../panel/types';
|
||||
import { Orientation, Sizing } from '../splitview/core/splitview';
|
||||
import { Orientation, Sizing } from '../splitview/splitview';
|
||||
import { createComponent } from '../panel/componentFactory';
|
||||
import { Emitter, Event } from '../events';
|
||||
import { Position } from '../dnd/droptarget';
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
GridviewPanelApi,
|
||||
GridviewPanelApiImpl,
|
||||
} from '../api/gridviewPanelApi';
|
||||
import { LayoutPriority } from '../splitview/core/splitview';
|
||||
import { LayoutPriority } from '../splitview/splitview';
|
||||
import { Emitter, Event } from '../events';
|
||||
import { IViewSize } from './gridview';
|
||||
|
||||
|
@ -3,11 +3,7 @@
|
||||
* https://github.com/microsoft/vscode/tree/main/src/vs/base/browser/ui/grid
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import {
|
||||
IView,
|
||||
LayoutPriority,
|
||||
Orientation,
|
||||
} from '../splitview/core/splitview';
|
||||
import { IView, LayoutPriority, Orientation } from '../splitview/splitview';
|
||||
import { Emitter, Event } from '../events';
|
||||
import { IGridView } from './gridview';
|
||||
import { IDisposable } from '../lifecycle';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { GridviewPanel } from './gridviewPanel';
|
||||
import { ISplitviewStyles, Orientation } from '../splitview/core/splitview';
|
||||
import { ISplitviewStyles, Orientation } from '../splitview/splitview';
|
||||
import { FrameworkFactory } from '../types';
|
||||
|
||||
export interface GridviewComponentOptions {
|
||||
|
@ -18,8 +18,8 @@ export {
|
||||
export * from './panel/types';
|
||||
export * from './panel/componentFactory';
|
||||
|
||||
export * from './splitview/core/splitview';
|
||||
export * from './splitview/core/options';
|
||||
export * from './splitview/splitview';
|
||||
export * from './splitview/options';
|
||||
|
||||
export * from './paneview/paneview';
|
||||
export * from './gridview/gridview';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IDisposable } from '../lifecycle';
|
||||
import { LayoutPriority } from '../splitview/core/splitview';
|
||||
import { LayoutPriority } from '../splitview/splitview';
|
||||
|
||||
/**
|
||||
* A key-value object of anything that is a valid JavaScript Object.
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
import { Droptarget, DroptargetEvent } from '../dnd/droptarget';
|
||||
import { Emitter } from '../events';
|
||||
import { IDisposable } from '../lifecycle';
|
||||
import { Orientation } from '../splitview/core/splitview';
|
||||
import { Orientation } from '../splitview/splitview';
|
||||
import { IPaneviewComponent } from './paneviewComponent';
|
||||
import {
|
||||
IPaneviewPanel,
|
||||
|
@ -3,7 +3,7 @@ import {
|
||||
Orientation,
|
||||
ISplitViewDescriptor,
|
||||
Sizing,
|
||||
} from '../splitview/core/splitview';
|
||||
} from '../splitview/splitview';
|
||||
import { CompositeDisposable, IDisposable } from '../lifecycle';
|
||||
import { Emitter, Event } from '../events';
|
||||
import { addClasses, removeClasses } from '../dom';
|
||||
|
@ -6,11 +6,7 @@ import {
|
||||
IDisposable,
|
||||
MutableDisposable,
|
||||
} from '../lifecycle';
|
||||
import {
|
||||
LayoutPriority,
|
||||
Orientation,
|
||||
Sizing,
|
||||
} from '../splitview/core/splitview';
|
||||
import { LayoutPriority, Orientation, Sizing } from '../splitview/splitview';
|
||||
import { PaneviewComponentOptions } from './options';
|
||||
import { Paneview } from './paneview';
|
||||
import {
|
||||
|
@ -14,7 +14,7 @@ import {
|
||||
PanelUpdateEvent,
|
||||
Parameters,
|
||||
} from '../panel/types';
|
||||
import { IView, Orientation } from '../splitview/core/splitview';
|
||||
import { IView, Orientation } from '../splitview/splitview';
|
||||
|
||||
export interface PanePanelViewState extends BasePanelViewState {
|
||||
headerComponent?: string;
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { IPanel, PanelInitParameters } from '../../panel/types';
|
||||
import { IPanel, PanelInitParameters } from '../panel/types';
|
||||
import { IView, SplitViewOptions, LayoutPriority } from './splitview';
|
||||
import { FrameworkFactory } from '../../types';
|
||||
import { SplitviewPanel } from '../splitviewPanel';
|
||||
import { SplitviewComponent } from '../splitviewComponent';
|
||||
import { FrameworkFactory } from '../types';
|
||||
import { SplitviewPanel } from './splitviewPanel';
|
||||
import { SplitviewComponent } from './splitviewComponent';
|
||||
|
||||
export interface PanelViewInitParameters extends PanelInitParameters {
|
||||
minimumSize?: number;
|
@ -8,10 +8,10 @@ import {
|
||||
addClasses,
|
||||
toggleClass,
|
||||
getElementsByTagName,
|
||||
} from '../../dom';
|
||||
import { clamp } from '../../math';
|
||||
import { Event, Emitter } from '../../events';
|
||||
import { pushToStart, pushToEnd, range, firstIndex } from '../../array';
|
||||
} from '../dom';
|
||||
import { clamp } from '../math';
|
||||
import { Event, Emitter } from '../events';
|
||||
import { pushToStart, pushToEnd, range, firstIndex } from '../array';
|
||||
import { ViewItem } from './viewItem';
|
||||
|
||||
export enum Orientation {
|
@ -10,8 +10,8 @@ import {
|
||||
Orientation,
|
||||
Sizing,
|
||||
Splitview,
|
||||
} from './core/splitview';
|
||||
import { SplitviewComponentOptions } from './core/options';
|
||||
} from './splitview';
|
||||
import { SplitviewComponentOptions } from './options';
|
||||
import { BaseComponentOptions } from '../panel/types';
|
||||
import { Emitter, Event } from '../events';
|
||||
import { SplitviewPanel, ISplitviewPanel } from './splitviewPanel';
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { ISerializableView, PanelViewInitParameters } from './core/options';
|
||||
import { ISerializableView, PanelViewInitParameters } from './options';
|
||||
import {
|
||||
BasePanelView,
|
||||
BasePanelViewExported,
|
||||
} from '../gridview/basePanelView';
|
||||
import { SplitviewPanelApiImpl } from '../api/splitviewPanelApi';
|
||||
import { LayoutPriority, Orientation } from './core/splitview';
|
||||
import { LayoutPriority, Orientation } from './splitview';
|
||||
import { FunctionOrValue } from '../types';
|
||||
import { Emitter, Event } from '../events';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IDisposable } from '../../lifecycle';
|
||||
import { clamp } from '../../math';
|
||||
import { IDisposable } from '../lifecycle';
|
||||
import { clamp } from '../math';
|
||||
import { IView, LayoutPriority } from './splitview';
|
||||
|
||||
export class ViewItem {
|
@ -4,7 +4,6 @@ import { IDockviewPanelProps } from '../dockview/dockview';
|
||||
import {
|
||||
DockviewEmitter,
|
||||
DockviewEvent,
|
||||
DockviewGroupPanel,
|
||||
PanelUpdateEvent,
|
||||
IContentRenderer,
|
||||
GroupPanelContentPartInitParameters,
|
||||
|
@ -3,7 +3,6 @@ import { ReactPart, ReactPortalStore } from '../react';
|
||||
import { IGroupPanelBaseProps } from './dockview';
|
||||
import {
|
||||
PanelUpdateEvent,
|
||||
DockviewGroupPanel,
|
||||
ITabRenderer,
|
||||
GroupPanelPartInitParameters,
|
||||
} from 'dockview-core';
|
||||
|
@ -1,90 +0,0 @@
|
||||
import {
|
||||
GroupPanelPartInitParameters,
|
||||
IContentRenderer,
|
||||
DockviewGroupPanel,
|
||||
HostedContainer,
|
||||
PanelUpdateEvent,
|
||||
DockviewEvent,
|
||||
} from 'dockview-core';
|
||||
import { ReactPart, ReactPortalStore } from '../../react';
|
||||
import { IDockviewPanelProps } from '../dockview';
|
||||
|
||||
export class ReactContentRenderer implements IContentRenderer {
|
||||
private _hostedContainer: HostedContainer;
|
||||
private _element: HTMLElement;
|
||||
private part?: ReactPart<IDockviewPanelProps>;
|
||||
private parameters: GroupPanelPartInitParameters | undefined;
|
||||
|
||||
get element(): HTMLElement {
|
||||
return this._element;
|
||||
}
|
||||
|
||||
get onDidBlur(): DockviewEvent<void> {
|
||||
return this._hostedContainer.onDidBlur;
|
||||
}
|
||||
|
||||
get onDidFocus(): DockviewEvent<void> {
|
||||
return this._hostedContainer.onDidFocus;
|
||||
}
|
||||
|
||||
constructor(
|
||||
public readonly id: string,
|
||||
private readonly component: React.FunctionComponent<IDockviewPanelProps>,
|
||||
private readonly reactPortalStore: ReactPortalStore
|
||||
) {
|
||||
this._hostedContainer = new HostedContainer({
|
||||
id,
|
||||
parent: document
|
||||
.getElementsByClassName('dockview')
|
||||
.item(0) as HTMLElement,
|
||||
});
|
||||
|
||||
this._element = document.createElement('div');
|
||||
this._element.style.height = '100%';
|
||||
this._element.style.width = '100%';
|
||||
}
|
||||
|
||||
focus(): void {
|
||||
// noop
|
||||
}
|
||||
|
||||
public init(parameters: GroupPanelPartInitParameters): void {
|
||||
this.parameters = parameters;
|
||||
|
||||
parameters.api.onDidVisibilityChange((event) => {
|
||||
if (event.isVisible) {
|
||||
this._hostedContainer.show();
|
||||
this._hostedContainer.layout(this.element);
|
||||
} else {
|
||||
this._hostedContainer.hide();
|
||||
}
|
||||
});
|
||||
|
||||
this.part = new ReactPart(
|
||||
this._hostedContainer.element,
|
||||
this.reactPortalStore,
|
||||
this.component,
|
||||
{
|
||||
params: parameters.params,
|
||||
api: parameters.api,
|
||||
containerApi: parameters.containerApi,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public update(params: PanelUpdateEvent): void {
|
||||
if (this.parameters) {
|
||||
this.parameters.params = params.params;
|
||||
}
|
||||
|
||||
this.part?.update(params.params);
|
||||
}
|
||||
|
||||
public layout(_width: number, _height: number): void {
|
||||
this._hostedContainer.layout(this.element);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this.part?.dispose();
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
import {
|
||||
GroupPanelPartInitParameters,
|
||||
IContentRenderer,
|
||||
DockviewGroupPanel,
|
||||
HostedContainer,
|
||||
PanelUpdateEvent,
|
||||
} from 'dockview-core';
|
||||
|
||||
export class WebviewContentRenderer implements IContentRenderer {
|
||||
private _hostedContainer: HostedContainer;
|
||||
private _element: HTMLElement;
|
||||
private parameters: GroupPanelPartInitParameters | undefined;
|
||||
|
||||
get element(): HTMLElement {
|
||||
return this._element;
|
||||
}
|
||||
|
||||
constructor(public readonly id: string) {
|
||||
this._hostedContainer = new HostedContainer({ id });
|
||||
|
||||
this._element = document.createElement('div');
|
||||
this._element.style.height = '100%';
|
||||
this._element.style.width = '100%';
|
||||
}
|
||||
|
||||
focus(): void {
|
||||
// noop
|
||||
}
|
||||
|
||||
public init(parameters: GroupPanelPartInitParameters): void {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public update(params: PanelUpdateEvent): void {
|
||||
if (this.parameters) {
|
||||
this.parameters.params = params.params;
|
||||
}
|
||||
}
|
||||
|
||||
public layout(_width: number, _height: number): void {
|
||||
this._hostedContainer.layout(this._element);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
//
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user