mirror of
https://github.com/mathuo/dockview
synced 2025-03-10 07:52:07 +00:00
Merge branch 'master' of https://github.com/mathuo/dockview into 100-docs
This commit is contained in:
commit
b486e3ae58
@ -14,7 +14,7 @@ const config = {
|
|||||||
title: 'Dockview',
|
title: 'Dockview',
|
||||||
tagline: 'Zero dependency layout manager for React',
|
tagline: 'Zero dependency layout manager for React',
|
||||||
url: 'https://your-docusaurus-test-site.com',
|
url: 'https://your-docusaurus-test-site.com',
|
||||||
baseUrl: process.env.CI ? `/dockview/${DEPLOY_PATH}/` : '/',
|
baseUrl: process.env.CI ? `/${DEPLOY_PATH}/` : '/',
|
||||||
onBrokenLinks: 'throw',
|
onBrokenLinks: 'throw',
|
||||||
onBrokenMarkdownLinks: 'warn',
|
onBrokenMarkdownLinks: 'warn',
|
||||||
favicon: 'img/favicon.ico',
|
favicon: 'img/favicon.ico',
|
||||||
@ -37,15 +37,6 @@ const config = {
|
|||||||
return {
|
return {
|
||||||
name: 'webpack',
|
name: 'webpack',
|
||||||
configureWebpack: (config, isServer, utils) => {
|
configureWebpack: (config, isServer, utils) => {
|
||||||
if (isServer) {
|
|
||||||
return {
|
|
||||||
externals: [
|
|
||||||
'react',
|
|
||||||
'react-dom',
|
|
||||||
...(config.externals || []),
|
|
||||||
],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
// externals: ['react', 'react-dom'],
|
// externals: ['react', 'react-dom'],
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
|
22774
docs/package-lock.json
generated
22774
docs/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -20,7 +20,7 @@
|
|||||||
"@docusaurus/preset-classic": "2.0.0-beta.20",
|
"@docusaurus/preset-classic": "2.0.0-beta.20",
|
||||||
"@mdx-js/react": "^1.6.22",
|
"@mdx-js/react": "^1.6.22",
|
||||||
"clsx": "^1.1.1",
|
"clsx": "^1.1.1",
|
||||||
"dockview": "file:../packages/dockview",
|
"dockview": "^1.4.2",
|
||||||
"prism-react-renderer": "^1.3.1",
|
"prism-react-renderer": "^1.3.1",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
|
10801
docs/yarn.lock
10801
docs/yarn.lock
File diff suppressed because it is too large
Load Diff
@ -100,6 +100,10 @@ class ClassUnderTest extends BaseGrid<TestPanel> {
|
|||||||
public toJSON(): object {
|
public toJSON(): object {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public clear(): void {
|
||||||
|
//
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('baseComponentGridview', () => {
|
describe('baseComponentGridview', () => {
|
||||||
|
@ -43,6 +43,7 @@ export interface CommonApi<T = any> {
|
|||||||
layout(width: number, height: number): void;
|
layout(width: number, height: number): void;
|
||||||
fromJSON(data: T): void;
|
fromJSON(data: T): void;
|
||||||
toJSON(): T;
|
toJSON(): T;
|
||||||
|
clear(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SplitviewApi implements CommonApi<SerializedSplitview> {
|
export class SplitviewApi implements CommonApi<SerializedSplitview> {
|
||||||
@ -127,6 +128,10 @@ export class SplitviewApi implements CommonApi<SerializedSplitview> {
|
|||||||
toJSON(): SerializedSplitview {
|
toJSON(): SerializedSplitview {
|
||||||
return this.component.toJSON();
|
return this.component.toJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear(): void {
|
||||||
|
this.component.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PaneviewApi implements CommonApi<SerializedPaneview> {
|
export class PaneviewApi implements CommonApi<SerializedPaneview> {
|
||||||
@ -214,6 +219,10 @@ export class PaneviewApi implements CommonApi<SerializedPaneview> {
|
|||||||
toJSON(): SerializedPaneview {
|
toJSON(): SerializedPaneview {
|
||||||
return this.component.toJSON();
|
return this.component.toJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear(): void {
|
||||||
|
this.component.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GridviewApi implements CommonApi<SerializedGridview> {
|
export class GridviewApi implements CommonApi<SerializedGridview> {
|
||||||
@ -309,6 +318,10 @@ export class GridviewApi implements CommonApi<SerializedGridview> {
|
|||||||
toJSON(): SerializedGridview {
|
toJSON(): SerializedGridview {
|
||||||
return this.component.toJSON();
|
return this.component.toJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear(): void {
|
||||||
|
this.component.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DockviewApi implements CommonApi<SerializedDockview> {
|
export class DockviewApi implements CommonApi<SerializedDockview> {
|
||||||
@ -453,4 +466,8 @@ export class DockviewApi implements CommonApi<SerializedDockview> {
|
|||||||
toJSON(): SerializedDockview {
|
toJSON(): SerializedDockview {
|
||||||
return this.component.toJSON();
|
return this.component.toJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear(): void {
|
||||||
|
this.component.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ export class DockviewComponent
|
|||||||
{
|
{
|
||||||
private _deserializer: IPanelDeserializer | undefined;
|
private _deserializer: IPanelDeserializer | undefined;
|
||||||
private _api: DockviewApi;
|
private _api: DockviewApi;
|
||||||
private _options: DockviewComponentOptions;
|
private _options: Exclude<DockviewComponentOptions, 'orientation'>;
|
||||||
|
|
||||||
private readonly _onTabContextMenu = new Emitter<TabContextMenuEvent>();
|
private readonly _onTabContextMenu = new Emitter<TabContextMenuEvent>();
|
||||||
readonly onTabContextMenu: Event<TabContextMenuEvent> =
|
readonly onTabContextMenu: Event<TabContextMenuEvent> =
|
||||||
@ -237,7 +237,7 @@ export class DockviewComponent
|
|||||||
updateOptions(options: DockviewComponentUpdateOptions): void {
|
updateOptions(options: DockviewComponentUpdateOptions): void {
|
||||||
const hasOrientationChanged =
|
const hasOrientationChanged =
|
||||||
typeof options.orientation === 'string' &&
|
typeof options.orientation === 'string' &&
|
||||||
this.options.orientation !== options.orientation;
|
this.gridview.orientation !== options.orientation;
|
||||||
|
|
||||||
this._options = { ...this.options, ...options };
|
this._options = { ...this.options, ...options };
|
||||||
|
|
||||||
@ -333,25 +333,7 @@ export class DockviewComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
fromJSON(data: SerializedDockview): void {
|
fromJSON(data: SerializedDockview): void {
|
||||||
const groups = Array.from(this._groups.values()).map((_) => _.value);
|
this.clear()
|
||||||
|
|
||||||
const hasActiveGroup = !!this.activeGroup;
|
|
||||||
const hasActivePanel = !!this.activePanel
|
|
||||||
|
|
||||||
for (const group of groups) {
|
|
||||||
// remove the group will automatically remove the panels
|
|
||||||
this.removeGroup(group, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasActiveGroup) {
|
|
||||||
this.doSetGroupActive(undefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( hasActivePanel) {
|
|
||||||
this._onDidActivePanelChange.fire(undefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.gridview.clear();
|
|
||||||
|
|
||||||
if (!this.deserializer) {
|
if (!this.deserializer) {
|
||||||
throw new Error('invalid deserializer');
|
throw new Error('invalid deserializer');
|
||||||
@ -414,6 +396,28 @@ export class DockviewComponent
|
|||||||
this._onDidLayoutFromJSON.fire();
|
this._onDidLayoutFromJSON.fire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear():void {
|
||||||
|
const groups = Array.from(this._groups.values()).map((_) => _.value);
|
||||||
|
|
||||||
|
const hasActiveGroup = !!this.activeGroup;
|
||||||
|
const hasActivePanel = !!this.activePanel
|
||||||
|
|
||||||
|
for (const group of groups) {
|
||||||
|
// remove the group will automatically remove the panels
|
||||||
|
this.removeGroup(group, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasActiveGroup) {
|
||||||
|
this.doSetGroupActive(undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( hasActivePanel) {
|
||||||
|
this._onDidActivePanelChange.fire(undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.gridview.clear();
|
||||||
|
}
|
||||||
|
|
||||||
closeAllGroups(): void {
|
closeAllGroups(): void {
|
||||||
for (const entry of this._groups.entries()) {
|
for (const entry of this._groups.entries()) {
|
||||||
const [_, group] = entry;
|
const [_, group] = entry;
|
||||||
|
@ -61,6 +61,7 @@ export interface IBaseGrid<T extends IGridPanelView> {
|
|||||||
getPanel(id: string): T | undefined;
|
getPanel(id: string): T | undefined;
|
||||||
toJSON(): object;
|
toJSON(): object;
|
||||||
fromJSON(data: any): void;
|
fromJSON(data: any): void;
|
||||||
|
clear(): void;
|
||||||
layout(width: number, height: number, force?: boolean): void;
|
layout(width: number, height: number, force?: boolean): void;
|
||||||
setVisible(panel: T, visible: boolean): void;
|
setVisible(panel: T, visible: boolean): void;
|
||||||
isVisible(panel: T): boolean;
|
isVisible(panel: T): boolean;
|
||||||
@ -173,6 +174,8 @@ export abstract class BaseGrid<T extends IGridPanelView>
|
|||||||
|
|
||||||
public abstract fromJSON(data: any): void;
|
public abstract fromJSON(data: any): void;
|
||||||
|
|
||||||
|
public abstract clear(): void;
|
||||||
|
|
||||||
public setVisible(panel: T, visible: boolean) {
|
public setVisible(panel: T, visible: boolean) {
|
||||||
this.gridview.setViewVisible(getGridLocation(panel.element), visible);
|
this.gridview.setViewVisible(getGridLocation(panel.element), visible);
|
||||||
this._onDidLayoutChange.fire();
|
this._onDidLayoutChange.fire();
|
||||||
|
@ -78,7 +78,7 @@ export class GridviewComponent
|
|||||||
extends BaseGrid<GridviewPanel>
|
extends BaseGrid<GridviewPanel>
|
||||||
implements IGridviewComponent
|
implements IGridviewComponent
|
||||||
{
|
{
|
||||||
private _options: GridviewComponentOptions;
|
private _options: Exclude<GridviewComponentOptions, 'orientation'>;
|
||||||
private _deserializer: IPanelDeserializer | undefined;
|
private _deserializer: IPanelDeserializer | undefined;
|
||||||
|
|
||||||
private readonly _onDidLayoutfromJSON = new Emitter<void>();
|
private readonly _onDidLayoutfromJSON = new Emitter<void>();
|
||||||
@ -124,7 +124,7 @@ export class GridviewComponent
|
|||||||
updateOptions(options: Partial<GridviewComponentUpdateOptions>): void {
|
updateOptions(options: Partial<GridviewComponentUpdateOptions>): void {
|
||||||
const hasOrientationChanged =
|
const hasOrientationChanged =
|
||||||
typeof options.orientation === 'string' &&
|
typeof options.orientation === 'string' &&
|
||||||
this.options.orientation !== options.orientation;
|
this.gridview.orientation !== options.orientation;
|
||||||
|
|
||||||
this._options = { ...this.options, ...options };
|
this._options = { ...this.options, ...options };
|
||||||
|
|
||||||
@ -173,22 +173,10 @@ export class GridviewComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
public fromJSON(serializedGridview: SerializedGridview) {
|
public fromJSON(serializedGridview: SerializedGridview) {
|
||||||
|
this.clear();
|
||||||
|
|
||||||
const { grid, activePanel } = serializedGridview;
|
const { grid, activePanel } = serializedGridview;
|
||||||
|
|
||||||
const hasActiveGroup = this.activeGroup;
|
|
||||||
|
|
||||||
const groups = Array.from(this._groups.values()); // reassign since group panels will mutate
|
|
||||||
for (const group of groups) {
|
|
||||||
group.disposable.dispose();
|
|
||||||
this.doRemoveGroup(group.value, { skipActive: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasActiveGroup) {
|
|
||||||
this.doSetGroupActive(undefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.gridview.clear();
|
|
||||||
|
|
||||||
const queue: Function[] = [];
|
const queue: Function[] = [];
|
||||||
|
|
||||||
this.gridview.deserialize(grid, {
|
this.gridview.deserialize(grid, {
|
||||||
@ -244,6 +232,22 @@ export class GridviewComponent
|
|||||||
this._onDidLayoutfromJSON.fire();
|
this._onDidLayoutfromJSON.fire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear(): void {
|
||||||
|
const hasActiveGroup = this.activeGroup;
|
||||||
|
|
||||||
|
const groups = Array.from(this._groups.values()); // reassign since group panels will mutate
|
||||||
|
for (const group of groups) {
|
||||||
|
group.disposable.dispose();
|
||||||
|
this.doRemoveGroup(group.value, { skipActive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasActiveGroup) {
|
||||||
|
this.doSetGroupActive(undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.gridview.clear();
|
||||||
|
}
|
||||||
|
|
||||||
movePanel(
|
movePanel(
|
||||||
panel: GridviewPanel,
|
panel: GridviewPanel,
|
||||||
options: { direction: Direction; reference: string; size?: number }
|
options: { direction: Direction; reference: string; size?: number }
|
||||||
|
@ -3,6 +3,7 @@ import { PaneviewPanelApiImpl } from '../api/paneviewPanelApi';
|
|||||||
import { CompositeDisposable, MutableDisposable } from '../lifecycle';
|
import { CompositeDisposable, MutableDisposable } from '../lifecycle';
|
||||||
import { PanelUpdateEvent } from '../panel/types';
|
import { PanelUpdateEvent } from '../panel/types';
|
||||||
import { IPaneHeaderPart, PanePanelInitParameter } from './paneviewPanel';
|
import { IPaneHeaderPart, PanePanelInitParameter } from './paneviewPanel';
|
||||||
|
import { toggleClass } from '../dom';
|
||||||
|
|
||||||
export class DefaultHeader
|
export class DefaultHeader
|
||||||
extends CompositeDisposable
|
extends CompositeDisposable
|
||||||
@ -40,10 +41,12 @@ export class DefaultHeader
|
|||||||
this.apiRef.api = params.api;
|
this.apiRef.api = params.api;
|
||||||
|
|
||||||
this._content.textContent = params.title;
|
this._content.textContent = params.title;
|
||||||
this._expander.textContent = params.api.isExpanded ? '▼' : '▶';
|
this._expander.textContent = '▼';
|
||||||
|
|
||||||
|
toggleClass(this._expander, 'collapsed', !params.api.isExpanded);
|
||||||
|
|
||||||
this.disposable.value = params.api.onDidExpansionChange((e) => {
|
this.disposable.value = params.api.onDidExpansionChange((e) => {
|
||||||
this._expander.textContent = e.isExpanded ? '▼' : '▶';
|
toggleClass(this._expander, 'collapsed', !e.isExpanded);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +31,12 @@
|
|||||||
padding: 0px 8px;
|
padding: 0px 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
a {
|
.collapsed {
|
||||||
padding-right: 8px;
|
transform: rotate(-90deg);
|
||||||
width: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
> span {
|
> span {
|
||||||
|
padding-left: 8px;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,7 @@ export interface IPaneviewComponent extends IDisposable {
|
|||||||
getPanel(id: string): IPaneviewPanel | undefined;
|
getPanel(id: string): IPaneviewPanel | undefined;
|
||||||
movePanel(from: number, to: number): void;
|
movePanel(from: number, to: number): void;
|
||||||
updateOptions(options: Partial<PaneviewComponentOptions>): void;
|
updateOptions(options: Partial<PaneviewComponentOptions>): void;
|
||||||
|
clear(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PaneviewComponent
|
export class PaneviewComponent
|
||||||
@ -343,17 +344,12 @@ export class PaneviewComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
fromJSON(serializedPaneview: SerializedPaneview): void {
|
fromJSON(serializedPaneview: SerializedPaneview): void {
|
||||||
|
this.clear();
|
||||||
|
|
||||||
const { views, size } = serializedPaneview;
|
const { views, size } = serializedPaneview;
|
||||||
|
|
||||||
const queue: Function[] = [];
|
const queue: Function[] = [];
|
||||||
|
|
||||||
for (const [_, value] of this._viewDisposables.entries()) {
|
|
||||||
value.dispose();
|
|
||||||
}
|
|
||||||
this._viewDisposables.clear();
|
|
||||||
|
|
||||||
this.paneview.dispose();
|
|
||||||
|
|
||||||
this.paneview = new Paneview(this.element, {
|
this.paneview = new Paneview(this.element, {
|
||||||
orientation: Orientation.VERTICAL,
|
orientation: Orientation.VERTICAL,
|
||||||
descriptor: {
|
descriptor: {
|
||||||
@ -437,6 +433,15 @@ export class PaneviewComponent
|
|||||||
this._onDidLayoutfromJSON.fire();
|
this._onDidLayoutfromJSON.fire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear(): void {
|
||||||
|
for (const [_, value] of this._viewDisposables.entries()) {
|
||||||
|
value.dispose();
|
||||||
|
}
|
||||||
|
this._viewDisposables.clear();
|
||||||
|
|
||||||
|
this.paneview.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
private doAddPanel(panel: PaneFramework) {
|
private doAddPanel(panel: PaneFramework) {
|
||||||
const disposable = panel.onDidDrop((event) => {
|
const disposable = panel.onDidDrop((event) => {
|
||||||
this._onDidDrop.fire(event);
|
this._onDidDrop.fire(event);
|
||||||
|
@ -72,6 +72,7 @@ export interface ISplitviewComponent extends IDisposable {
|
|||||||
removePanel(panel: ISplitviewPanel, sizing?: Sizing): void;
|
removePanel(panel: ISplitviewPanel, sizing?: Sizing): void;
|
||||||
setVisible(panel: ISplitviewPanel, visible: boolean): void;
|
setVisible(panel: ISplitviewPanel, visible: boolean): void;
|
||||||
movePanel(from: number, to: number): void;
|
movePanel(from: number, to: number): void;
|
||||||
|
clear(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -334,14 +335,9 @@ export class SplitviewComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
fromJSON(serializedSplitview: SerializedSplitview): void {
|
fromJSON(serializedSplitview: SerializedSplitview): void {
|
||||||
const { views, orientation, size, activeView } = serializedSplitview;
|
this.clear();
|
||||||
|
|
||||||
for (const [_, value] of this._panels.entries()) {
|
const { views, orientation, size, activeView } = serializedSplitview;
|
||||||
value.disposable.dispose();
|
|
||||||
value.value.dispose();
|
|
||||||
}
|
|
||||||
this._panels.clear();
|
|
||||||
this.splitview.dispose();
|
|
||||||
|
|
||||||
const queue: Function[] = [];
|
const queue: Function[] = [];
|
||||||
|
|
||||||
@ -409,6 +405,15 @@ export class SplitviewComponent
|
|||||||
this._onDidLayoutfromJSON.fire();
|
this._onDidLayoutfromJSON.fire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear(): void {
|
||||||
|
for (const [_, value] of this._panels.entries()) {
|
||||||
|
value.disposable.dispose();
|
||||||
|
value.value.dispose();
|
||||||
|
}
|
||||||
|
this._panels.clear();
|
||||||
|
this.splitview.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
dispose(): void {
|
dispose(): void {
|
||||||
for (const [_, value] of this._panels.entries()) {
|
for (const [_, value] of this._panels.entries()) {
|
||||||
value.disposable.dispose();
|
value.disposable.dispose();
|
||||||
|
Loading…
Reference in New Issue
Block a user