diff --git a/src/extensions/editor/statusBarView/index.tsx b/src/extensions/editor/statusBarView/index.tsx deleted file mode 100644 index 38775d2e5..000000000 --- a/src/extensions/editor/statusBarView/index.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import * as React from 'react'; - -export function EditorStatusBarView(props: any) { - const { data = { ln: 0, col: 0 } } = props; - return {`Ln ${data.ln}, Col ${data.col}`}; -} diff --git a/src/model/workbench/editor.ts b/src/model/workbench/editor.ts index 5e2a9b625..c44505ed1 100644 --- a/src/model/workbench/editor.ts +++ b/src/model/workbench/editor.ts @@ -46,6 +46,7 @@ export interface IEditor { */ current?: IEditorGroup | null; groups?: IEditorGroup[]; + entry?: React.ReactNode; } export const EDITOR_MENU_CLOSE_TO_RIGHT = 'editor.closeToRight'; @@ -125,12 +126,15 @@ export class EditorGroupModel implements IEditorGroup { 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; } } diff --git a/src/services/workbench/editorService.ts b/src/services/workbench/editorService.ts index c444f2aec..a7f2e3cb3 100644 --- a/src/services/workbench/editorService.ts +++ b/src/services/workbench/editorService.ts @@ -24,6 +24,10 @@ export interface IEditorService extends Component { group: IEditorGroup ): IEditorTab | 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; @@ -68,6 +72,12 @@ export class EditorService this.state = container.resolve(EditorModel); } + public setEntry(component: React.ReactNode) { + this.setState({ + entry: component, + }); + } + public getTabById( tabId: string, group: IEditorGroup diff --git a/src/workbench/editor/editor.tsx b/src/workbench/editor/editor.tsx index 2a0e3e423..99ca9932d 100644 --- a/src/workbench/editor/editor.tsx +++ b/src/workbench/editor/editor.tsx @@ -13,6 +13,7 @@ export function Editor(props: IEditor & IEditorController) { const { groups = [], current, + entry = , onClickContextMenu, onCloseTab, onMoveTab, @@ -73,7 +74,7 @@ export function Editor(props: IEditor & IEditorController) { return (
- {current ? renderGroups() : } + {current ? renderGroups() : entry}
); } diff --git a/stories/extensions/test/entry.scss b/stories/extensions/test/entry.scss new file mode 100644 index 000000000..e2086b17e --- /dev/null +++ b/stories/extensions/test/entry.scss @@ -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; + } + } +} diff --git a/stories/extensions/test/entry.tsx b/stories/extensions/test/entry.tsx new file mode 100644 index 000000000..85bacea08 --- /dev/null +++ b/stories/extensions/test/entry.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import './entry.scss'; + +export const Entry = () => { + return ( +
+

molecule

+
+
显示所有命令
+
command + b
+
+
+
打开文件或文件夹
+
command + b
+
+
+
打开最近文件
+
command + b
+
+
+
新的无标题文件
+
command + b
+
+
+ ); +}; diff --git a/stories/extensions/test/index.tsx b/stories/extensions/test/index.tsx index dd9fd2d93..01f32f0a2 100644 --- a/stories/extensions/test/index.tsx +++ b/stories/extensions/test/index.tsx @@ -9,6 +9,7 @@ import { import { IExtension } from 'mo/model'; import TestPane from './testPane'; +import { Entry } from './entry'; export const ExtendTestPane: IExtension = { activate() { @@ -30,6 +31,8 @@ export const ExtendTestPane: IExtension = { molecule.activityBar.addBar(newItem); molecule.sidebar.addPane(testSidePane); + molecule.editor.setEntry(); + molecule.settings.onChangeConfiguration(async (value) => { console.log('onChangeConfiguration:', value); molecule.settings.update(value);