Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/extensions/editor/statusBarView/index.tsx

This file was deleted.

6 changes: 5 additions & 1 deletion src/model/workbench/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface IEditor {
*/
current?: IEditorGroup | null;
groups?: IEditorGroup[];
entry?: React.ReactNode;
}

export const EDITOR_MENU_CLOSE_TO_RIGHT = 'editor.closeToRight';
Expand Down Expand Up @@ -125,12 +126,15 @@ export class EditorGroupModel<E = any, T = any> implements IEditorGroup<E, T> {
export class EditorModel implements IEditor {
public current: IEditorGroup | null;
public groups: IEditorGroup[];
public entry: React.ReactNode;

constructor(
current: IEditorGroup | null = null,
groups: IEditorGroup[] = []
groups: IEditorGroup[] = [],
entry: React.ReactNode
) {
this.current = current;
this.groups = groups;
this.entry = entry;
}
}
10 changes: 10 additions & 0 deletions src/services/workbench/editorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export interface IEditorService extends Component<IEditor> {
group: IEditorGroup
): IEditorTab<T> | undefined;
updateTab(tab: IEditorTab, groupId: number): IEditorTab;
/**
* Specify a entry page for editor
*/
setEntry(component: React.ReactNode): void;
closeTab(tabId: string, groupId: number): void;
closeOthers(tab: IEditorTab, groupId: number): void;
closeToRight(tab: IEditorTab, groupId: number): void;
Expand Down Expand Up @@ -68,6 +72,12 @@ export class EditorService
this.state = container.resolve(EditorModel);
}

public setEntry(component: React.ReactNode) {
this.setState({
entry: component,
});
}

public getTabById<T>(
tabId: string,
group: IEditorGroup
Expand Down
3 changes: 2 additions & 1 deletion src/workbench/editor/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function Editor(props: IEditor & IEditorController) {
const {
groups = [],
current,
entry = <Welcome />,
onClickContextMenu,
onCloseTab,
onMoveTab,
Expand Down Expand Up @@ -73,7 +74,7 @@ export function Editor(props: IEditor & IEditorController) {

return (
<div className={defaultEditorClassName}>
{current ? renderGroups() : <Welcome />}
{current ? renderGroups() : entry}
</div>
);
}
Expand Down
35 changes: 35 additions & 0 deletions stories/extensions/test/entry.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.entry {
align-items: center;
background-color: var(--panel-background);
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
width: 100%;

* {
font-family: monospace;
}

dl {
border-collapse: separate;
border-spacing: 13px 17px;
color: hsla(0, 0%, 100%, 0.6);
cursor: default;
display: table-row;
font-size: 13px;
margin: 0;

dt {
display: table-cell;
letter-spacing: 0.04em;
text-align: right;
}

dd {
display: table-cell;
margin-left: 12px;
text-align: left;
}
}
}
26 changes: 26 additions & 0 deletions stories/extensions/test/entry.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import './entry.scss';

export const Entry = () => {
return (
<div className="entry">
<h1>molecule</h1>
<dl>
<dt>显示所有命令</dt>
<dd> command + b</dd>
</dl>
<dl>
<dt>打开文件或文件夹</dt>
<dd> command + b</dd>
</dl>
<dl>
<dt>打开最近文件</dt>
<dd> command + b</dd>
</dl>
<dl>
<dt>新的无标题文件</dt>
<dd> command + b</dd>
</dl>
</div>
);
};
3 changes: 3 additions & 0 deletions stories/extensions/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { IExtension } from 'mo/model';

import TestPane from './testPane';
import { Entry } from './entry';

export const ExtendTestPane: IExtension = {
activate() {
Expand All @@ -30,6 +31,8 @@ export const ExtendTestPane: IExtension = {
molecule.activityBar.addBar(newItem);
molecule.sidebar.addPane(testSidePane);

molecule.editor.setEntry(<Entry />);

molecule.settings.onChangeConfiguration(async (value) => {
console.log('onChangeConfiguration:', value);
molecule.settings.update(value);
Expand Down