chore(project): 添加项目配置文件和忽略规则
- 添加 Babel 配置文件支持 ES6+ 语法转换 - 添加 ESLint 忽略规则和配置文件 - 添加 Git 忽略规则文件 - 添加 Travis CI 配置文件 - 添加 1.4.2 版本变更日志文件 - 添加 Helm 图表辅助模板文件 - 添加 Helm 忽略规则文件
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import React from 'react';
|
||||
|
||||
class Menu extends React.Component {
|
||||
static create = function (type) {
|
||||
return class TypedMenu extends Menu {
|
||||
constructor(props) {
|
||||
super(props, type);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props, type) {
|
||||
super(props);
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
render() {
|
||||
const { children } = this.props;
|
||||
const { type } = this;
|
||||
|
||||
return (
|
||||
<div className="menu" data-status={`${type}-selected`}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Menu;
|
||||
@@ -0,0 +1,44 @@
|
||||
import React from 'react';
|
||||
import { pick } from '@utils';
|
||||
import Editor from '@components/Base/Editor';
|
||||
import { CONTEXT_MENU_CONTAINER } from '@common/constants';
|
||||
import withGGEditorContext from '@common/context/GGEditorContext/withGGEditorContext';
|
||||
import Menu from './Menu';
|
||||
|
||||
class ContextMenu extends React.Component {
|
||||
contextMenu = null;
|
||||
|
||||
get containerId() {
|
||||
const { editor } = this.props;
|
||||
|
||||
return `${CONTEXT_MENU_CONTAINER}_${editor.id}`;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { editor } = this.props;
|
||||
|
||||
this.contextMenu = new Editor.Contextmenu({
|
||||
container: this.containerId,
|
||||
});
|
||||
|
||||
editor.add(this.contextMenu);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { children } = this.props;
|
||||
|
||||
return (
|
||||
<div id={this.containerId} {...pick(this.props, ['style', 'className'])}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const NodeMenu = Menu.create('node');
|
||||
export const EdgeMenu = Menu.create('edge');
|
||||
export const GroupMenu = Menu.create('group');
|
||||
export const MultiMenu = Menu.create('multi');
|
||||
export const CanvasMenu = Menu.create('canvas');
|
||||
|
||||
export default withGGEditorContext(ContextMenu);
|
||||
Reference in New Issue
Block a user