Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update the Guides in Chinese #525

Merged
merged 32 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8be213e
docs: update the introduction
wewoor Nov 4, 2021
73ef058
docs: update the Introduction of zhCN version
wewoor Nov 4, 2021
4a39d19
docs: tutorials for keybinding, quickAccess and Icon
wewoor Nov 29, 2021
226b575
feat: improve homepage (#527)
mortalYoung Dec 1, 2021
b8d9e9a
build: update the limitation of node version (#515)
mortalYoung Nov 22, 2021
0915a69
fix: fix can't clear the notifications (#518)
mortalYoung Nov 23, 2021
a0d939c
fix: fix create file node incorrect on contextMenu (#522)
mortalYoung Nov 29, 2021
1ecae54
refactor: optimize the MoleculeProvider (#517)
wewoor Nov 30, 2021
e8e614e
fix: show the SubMenu in right place when the Menu is horizontal mode…
wewoor Nov 30, 2021
53b079e
feat: support sort in folderTree (#524)
mortalYoung Nov 30, 2021
623b29e
docs: update Guides
wewoor Dec 1, 2021
198de2e
docs: unify the files name
wewoor Dec 1, 2021
76e47cc
docs: update Guides, Overview
wewoor Dec 1, 2021
d5d6dc6
docs: update the QuickStart
wewoor Dec 2, 2021
472c16d
docs: update the first extension
wewoor Dec 2, 2021
a9bdc8e
docs: update the extension guides
wewoor Dec 2, 2021
c9f557c
docs: update Workbench UI
wewoor Dec 2, 2021
62d5499
fix: improve the circular dep error when execute yarn link (#528)
mortalYoung Dec 1, 2021
e9fb20c
fix: remove the warning in console (#529)
mortalYoung Dec 2, 2021
2be7e29
docs: update ColorTheme, readme, keybinding, i18n
wewoor Dec 2, 2021
6b8803f
docs: update Keybinding
wewoor Dec 2, 2021
3526881
docs: update quickAccess, add demo tips
wewoor Dec 2, 2021
56fb067
docs: update i18n
wewoor Dec 2, 2021
52f6219
docs: update Settings guide
wewoor Dec 2, 2021
7ac3d8d
docs: update Icon guide
wewoor Dec 2, 2021
0d9b64a
docs: update customize the Workbench guide
wewoor Dec 2, 2021
53c6355
docs: update images
wewoor Dec 3, 2021
5bb4430
docs: update Contributing
wewoor Dec 3, 2021
a8c8af8
docs: update English version
wewoor Dec 3, 2021
577fc46
fix: remove the 140 width limit for buttons
wewoor Dec 3, 2021
c354dce
docs: default locale is zh-CN
wewoor Dec 3, 2021
4652331
docs: improve the links (#533)
mortalYoung Dec 6, 2021
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: 5 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ node_modules
yarn.lock
coverage
storybook-static
docs/api
docs/api
website/build
website/docs/api
website/.docusaurus
website/node_modules
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@

The **Molecule** is a lightweight **Web IDE UI** Framework built with React.js,and inspired by the VSCode. We also provide the Extension APIs the seem like VSCode, to help developers extend the Workbench easily. The Molecule integrates with React.js applications is simple. It has applied to many [DTStack](https://www.dtstack.com/) inner projects.

<<<<<<< HEAD
wewoor marked this conversation as resolved.
Show resolved Hide resolved
[Online Preview](https://github.com/DTStack/molecule-examples)
=======
[Online Preview]((https://github.com/DTStack/molecule-examples)

> > > > > > > docs: update the introduction

## Features

Expand Down
7 changes: 2 additions & 5 deletions build/preinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ let err = false;

const majorNodeVersion = parseInt(/^(\d+)\./.exec(process.versions.node)[1]);

if (majorNodeVersion < 10 || majorNodeVersion > 14) {
console.error('\033[1;31m*** Please use node >=10 and <=14.\033[0;0m');
if (majorNodeVersion < 10) {
wewoor marked this conversation as resolved.
Show resolved Hide resolved
console.error('\033[1;31m*** Please use node >=10.\033[0;0m\n');
err = true;
}

const cp = require('child_process');

if (err) {
console.error('');
process.exit(1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exports[`Test the Menu Component Match the List snapshot 1`] = `
>
<li
className="mo-menu__item"
data-mode="vertical"
data-submenu={true}
id="File"
>
Expand Down Expand Up @@ -76,6 +77,7 @@ exports[`Test the Menu Component Match the List snapshot 1`] = `
</li>
<li
className="mo-menu__item"
data-mode="vertical"
data-submenu={true}
id="Edit"
>
Expand Down Expand Up @@ -137,6 +139,7 @@ exports[`Test the Menu Component Match the List snapshot 1`] = `
</li>
<li
className="mo-menu__item"
data-mode="vertical"
data-submenu={true}
id="Selection"
>
Expand Down Expand Up @@ -198,6 +201,7 @@ exports[`Test the Menu Component Match the List snapshot 1`] = `
</li>
<li
className="mo-menu__item"
data-mode="vertical"
data-submenu={true}
id="View"
>
Expand Down Expand Up @@ -257,6 +261,7 @@ exports[`Test the Menu Component Match the List snapshot 1`] = `
</li>
<li
className="mo-menu__item"
data-mode="vertical"
data-submenu={true}
id="Appearance"
>
Expand Down Expand Up @@ -364,6 +369,7 @@ exports[`Test the Menu Component Match the List snapshot 1`] = `
</li>
<li
className="mo-menu__item"
data-mode="vertical"
data-submenu={true}
id="Run"
>
Expand Down Expand Up @@ -409,6 +415,7 @@ exports[`Test the Menu Component Match the List snapshot 1`] = `
</li>
<li
className="mo-menu__item"
data-mode="vertical"
data-submenu={true}
id="Help"
>
Expand Down
28 changes: 18 additions & 10 deletions src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import React, { useEffect, useCallback, useRef } from 'react';
import { classNames } from 'mo/common/className';
import { MenuItem } from './menuItem';
import { isHorizontal, ISubMenuProps, MenuMode, SubMenu } from './subMenu';
import { debounce } from 'lodash';
import { mergeFunctions } from 'mo/common/utils';
import { cloneReactChildren } from 'mo/react';
import { em2Px } from 'mo/common/css';
import { getRelativePosition, triggerEvent } from 'mo/common/dom';

import {
activeClassName,
defaultMenuClassName,
defaultSubMenuClassName,
horizontalMenuClassName,
verticalMenuClassName,
} from './base';
import { mergeFunctions } from 'mo/common/utils';
import { cloneReactChildren } from 'mo/react';
import { em2Px } from 'mo/common/css';
import { getRelativePosition, triggerEvent } from 'mo/common/dom';
import { Divider } from './divider';
import { MenuItem } from './menuItem';
import { isHorizontal, ISubMenuProps, MenuMode, SubMenu } from './subMenu';

export type IMenuProps = ISubMenuProps;

Expand Down Expand Up @@ -64,13 +65,14 @@ export function Menu(props: React.PropsWithChildren<IMenuProps>) {
onClick,
trigger = 'hover',
title,
...custom
...restProps
} = props;
const menuRef = useRef<HTMLUListElement>(null);
const isMouseInMenu = useRef(false);
let content = cloneReactChildren(children, { onClick });
// Only when the trigger is hover need to set the delay
const delay = trigger === 'hover' ? 200 : 0;

const modeClassName =
mode === MenuMode.Horizontal
? horizontalMenuClassName
Expand All @@ -81,12 +83,13 @@ export function Menu(props: React.PropsWithChildren<IMenuProps>) {
const renderMenusByData = (menus: IMenuProps[]) => {
return menus.map((item: IMenuProps) => {
if (item.type === 'divider') return <Divider />;

const handleClick = mergeFunctions(onClick, item.onClick);
if (item.data && item.data.length > 0) {
return (
<SubMenu
key={item.id}
mode={mode}
mode={item.mode || mode}
{...item}
onClick={handleClick}
>
Expand Down Expand Up @@ -140,7 +143,12 @@ export function Menu(props: React.PropsWithChildren<IMenuProps>) {
}
visibleMenuItem(liDom);
const subMenu = liDom?.querySelector('ul') || undefined;
setPositionForSubMenu(liDom, subMenu, isHorizontal(mode));
const subMenuMode = liDom?.dataset.mode || mode;
setPositionForSubMenu(
liDom,
subMenu,
isHorizontal(subMenuMode as MenuMode)
);
}
}, delay);

Expand Down Expand Up @@ -199,7 +207,7 @@ export function Menu(props: React.PropsWithChildren<IMenuProps>) {
// prevent JSX render in HTMLElement
{...(typeof title === 'string' ? { title } : {})}
{...getEventListener()}
{...custom}
{...restProps}
>
{content}
</ul>
Expand Down
11 changes: 7 additions & 4 deletions src/components/menu/menuItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { classNames } from 'mo/common/className';
import { Icon } from '../icon';
import type { HTMLElementProps, UniqueId } from 'mo/common/types';

import {
checkClassName,
disabledClassName,
Expand All @@ -9,7 +10,7 @@ import {
labelClassName,
menuContentClassName,
} from './base';
import type { HTMLElementProps, UniqueId } from 'mo/common/types';
import { Icon } from '../icon';

export interface IMenuItemProps extends HTMLElementProps {
id: UniqueId;
Expand Down Expand Up @@ -52,7 +53,8 @@ export function MenuItem(
name,
title,
id,
...custom
sortIndex,
...restProps
} = props;

const events = {
Expand All @@ -69,10 +71,11 @@ export function MenuItem(
disabled ? disabledClassName : null
)}
id={id?.toString()}
data-sort={sortIndex}
// prevent render JSX title in HTMLElement
{...(typeof title === 'string' ? { title } : {})}
{...events}
{...custom}
{...restProps}
>
<div className={menuContentClassName}>
<Icon type={icon} className={checkClassName} />
Expand Down
9 changes: 6 additions & 3 deletions src/components/menu/subMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export function SubMenu(props: React.PropsWithChildren<ISubMenuProps>) {
children,
onClick,
title,
...custom
sortIndex,
...restProps
} = props;
const cNames = classNames(defaultSubMenuClassName, className);
const isAlignHorizontal = isHorizontal(mode);
Expand All @@ -63,7 +64,7 @@ export function SubMenu(props: React.PropsWithChildren<ISubMenuProps>) {
style={{ opacity: '0', pointerEvents: 'none' }}
data={data}
onClick={onClick}
{...custom}
{...restProps}
/>
) : (
<Menu
Expand All @@ -82,9 +83,11 @@ export function SubMenu(props: React.PropsWithChildren<ISubMenuProps>) {
disabled ? disabledClassName : null
)}
data-submenu
data-mode={mode}
data-sort={sortIndex}
// prevent render JSX title in HTMLElement
{...(typeof title === 'string' ? { title } : {})}
{...custom}
{...restProps}
>
<div className={menuContentClassName}>
{typeof icon === 'string' ? (
Expand Down
29 changes: 6 additions & 23 deletions src/controller/__tests__/notification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ const notificationService = container.resolve(NotificationService);
const statusBarService = container.resolve(StatusBarService);
const builtinService = container.resolve(BuiltinService);

jest.mock('react-dom', () => {
return {
render: jest.fn(),
};
});

describe('The notification controller', () => {
test('Should support initialize the service', () => {
notificationController.initView();
Expand Down Expand Up @@ -94,34 +88,23 @@ describe('The notification controller', () => {
expect(notificationService.getState().data).toHaveLength(0);
});

test('Should support to toggleNotifications', () => {
expect(
(notificationController as any)._notificationPane
).toBeUndefined();
expect(notificationService.getState().showNotifications).toBeFalsy();
notificationController.toggleNotifications();

expect(
(notificationController as any)._notificationPane
).not.toBeUndefined();
expect(notificationService.getState().showNotifications).toBeTruthy();
});

test('Should support to execute onClick', () => {
expect(notificationService.getState().showNotifications).toBeTruthy();
expect(notificationService.getState().showNotifications).toBeFalsy();

notificationController.onClick({} as any, { id: 'test' });

expect(notificationService.getState().showNotifications).toBeFalsy();
expect(notificationService.getState().showNotifications).toBeTruthy();
});

test('Should support to execute onActionBarClick', () => {
expect(notificationService.getState().showNotifications).toBeFalsy();
notificationService.add([{ id: 1, value: 'test' }]);
expect(notificationService.getState().data).toHaveLength(1);
notificationController.onActionBarClick({} as any, {
id: constants.NOTIFICATION_CLEAR_ALL_ID,
});
expect(notificationService.getState().showNotifications).toBeTruthy();
expect(notificationService.getState().data).toHaveLength(0);

expect(notificationService.getState().showNotifications).toBeTruthy();
notificationController.onActionBarClick({} as any, {
id: constants.NOTIFICATION_HIDE_ID,
});
Expand Down
29 changes: 18 additions & 11 deletions src/controller/explorer/folderTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import type { UniqueId } from 'mo/common/types';

export interface IFolderTreeController extends Partial<Controller> {
readonly createTreeNode?: (type: FileType) => void;
readonly createTreeNode?: (type: FileType, id?: UniqueId) => void;
readonly onClickContextMenu?: (
contextMenu: IMenuItemProps,
treeNode?: IFolderTreeNodeProps
Expand Down Expand Up @@ -102,14 +102,19 @@ export class FolderTreeController
});
}

public createTreeNode = (type: FileType) => {
const folderTreeState = this.folderTreeService.getState();
const { data, current } = folderTreeState?.folderTree || {};
// The current selected node id or the first root node
const nodeId =
typeof current?.id === 'undefined' ? data?.[0]?.id : current?.id;

this.emit(FolderTreeEvent.onCreate, type, nodeId);
public createTreeNode = (type: FileType, id?: UniqueId) => {
if (typeof id === 'undefined') {
const folderTreeState = this.folderTreeService.getState();
const { data, current } = folderTreeState?.folderTree || {};
// The current selected node id or the first root node
const nodeId =
typeof current?.id === 'undefined'
? data?.[0]?.id
: current?.id;
this.emit(FolderTreeEvent.onCreate, type, nodeId);
} else {
this.emit(FolderTreeEvent.onCreate, type, id);
}
};

public readonly onClickContextMenu = (
Expand All @@ -136,11 +141,13 @@ export class FolderTreeController
break;
}
case NEW_FILE_COMMAND_ID: {
this.createTreeNode(FileTypes.File);
const { id } = treeNode!;
this.createTreeNode(FileTypes.File, id);
break;
}
case NEW_FOLDER_COMMAND_ID: {
this.createTreeNode(FileTypes.Folder);
const { id } = treeNode!;
this.createTreeNode(FileTypes.Folder, id);
break;
}
case OPEN_TO_SIDE_COMMAND_ID: {
Expand Down
Loading