Merge pull request #25 from mathuo/20-enhance-public-api

feat: reintroduce panel.update(..) to public api
This commit is contained in:
mathuo 2022-03-10 22:15:31 +00:00 committed by GitHub
commit 181c5f0a2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 15 deletions

View File

@ -157,10 +157,6 @@ const components: PanelCollection<IDockviewPanelProps> = {
};
}, []);
const onClick = () => {
props.api.setState('test_key', 'hello');
};
const backgroundColor = React.useMemo(
() =>
// "#1e1e1e",
@ -241,7 +237,6 @@ const components: PanelCollection<IDockviewPanelProps> = {
{`${panelState.isPanelVisible}`}
</span>
</div>
<button onClick={onClick}>set state</button>
<button onClick={onRename}>rename</button>
<input

View File

@ -56,8 +56,6 @@ const components = {
},
};
const SPLIT_PANEL_STATE_KEY = 'splitview_panel_state';
export const SplitPanel = (props: IDockviewPanelProps) => {
const api = React.useRef<SplitviewApi>();
const registry = useLayoutRegistry();
@ -67,9 +65,6 @@ export const SplitPanel = (props: IDockviewPanelProps) => {
props.api.onDidDimensionsChange((event) => {
api.current?.layout(event.width, event.height - 25);
}),
api.current.onDidLayoutChange(() => {
props.api.setState(SPLIT_PANEL_STATE_KEY, api.current.toJSON());
}),
props.api.onFocusEvent(() => {
api.current.focus();
})
@ -98,11 +93,6 @@ export const SplitPanel = (props: IDockviewPanelProps) => {
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 panel = api.current.getPanel('1');
panel.update({ params: { text: Date.now().toString() } });

View File

@ -22,6 +22,7 @@ export interface BasePanelViewExported<T extends PanelApiImpl> {
readonly params: Record<string, any> | undefined;
focus(): void;
toJSON(): object;
update(event: PanelUpdateEvent): void;
}
export abstract class BasePanelView<T extends PanelApiImpl>