mirror of
https://github.com/mathuo/dockview
synced 2025-09-02 15:36:42 +00:00
feat: reintroduce panel.update(..) to public api
This commit is contained in:
parent
ff88de0395
commit
26f2908b39
@ -157,10 +157,6 @@ const components: PanelCollection<IDockviewPanelProps> = {
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onClick = () => {
|
|
||||||
props.api.setState('test_key', 'hello');
|
|
||||||
};
|
|
||||||
|
|
||||||
const backgroundColor = React.useMemo(
|
const backgroundColor = React.useMemo(
|
||||||
() =>
|
() =>
|
||||||
// "#1e1e1e",
|
// "#1e1e1e",
|
||||||
@ -241,7 +237,6 @@ const components: PanelCollection<IDockviewPanelProps> = {
|
|||||||
{`${panelState.isPanelVisible}`}
|
{`${panelState.isPanelVisible}`}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button onClick={onClick}>set state</button>
|
|
||||||
<button onClick={onRename}>rename</button>
|
<button onClick={onRename}>rename</button>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
|
@ -56,8 +56,6 @@ const components = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const SPLIT_PANEL_STATE_KEY = 'splitview_panel_state';
|
|
||||||
|
|
||||||
export const SplitPanel = (props: IDockviewPanelProps) => {
|
export const SplitPanel = (props: IDockviewPanelProps) => {
|
||||||
const api = React.useRef<SplitviewApi>();
|
const api = React.useRef<SplitviewApi>();
|
||||||
const registry = useLayoutRegistry();
|
const registry = useLayoutRegistry();
|
||||||
@ -67,9 +65,6 @@ export const SplitPanel = (props: IDockviewPanelProps) => {
|
|||||||
props.api.onDidDimensionsChange((event) => {
|
props.api.onDidDimensionsChange((event) => {
|
||||||
api.current?.layout(event.width, event.height - 25);
|
api.current?.layout(event.width, event.height - 25);
|
||||||
}),
|
}),
|
||||||
api.current.onDidLayoutChange(() => {
|
|
||||||
props.api.setState(SPLIT_PANEL_STATE_KEY, api.current.toJSON());
|
|
||||||
}),
|
|
||||||
props.api.onFocusEvent(() => {
|
props.api.onFocusEvent(() => {
|
||||||
api.current.focus();
|
api.current.focus();
|
||||||
})
|
})
|
||||||
@ -98,11 +93,6 @@ export const SplitPanel = (props: IDockviewPanelProps) => {
|
|||||||
event.api.addPanel({ id: '2', component: 'default1' });
|
event.api.addPanel({ id: '2', component: 'default1' });
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSave = () => {
|
|
||||||
props.api.setState(SPLIT_PANEL_STATE_KEY, api.current.toJSON());
|
|
||||||
console.log(JSON.stringify(api.current.toJSON(), null, 4));
|
|
||||||
};
|
|
||||||
|
|
||||||
const onUpdateProps = () => {
|
const onUpdateProps = () => {
|
||||||
const panel = api.current.getPanel('1');
|
const panel = api.current.getPanel('1');
|
||||||
panel.update({ params: { text: Date.now().toString() } });
|
panel.update({ params: { text: Date.now().toString() } });
|
||||||
|
@ -22,6 +22,7 @@ export interface BasePanelViewExported<T extends PanelApiImpl> {
|
|||||||
readonly params: Record<string, any> | undefined;
|
readonly params: Record<string, any> | undefined;
|
||||||
focus(): void;
|
focus(): void;
|
||||||
toJSON(): object;
|
toJSON(): object;
|
||||||
|
update(event: PanelUpdateEvent): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class BasePanelView<T extends PanelApiImpl>
|
export abstract class BasePanelView<T extends PanelApiImpl>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user