chore(project): 添加项目配置文件和忽略规则
- 添加 Babel 配置文件支持 ES6+ 语法转换 - 添加 ESLint 忽略规则和配置文件 - 添加 Git 忽略规则文件 - 添加 Travis CI 配置文件 - 添加 1.4.2 版本变更日志文件 - 添加 Helm 图表辅助模板文件 - 添加 Helm 忽略规则文件
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import withGGEditorContext from '@common/context/GGEditorContext/withGGEditorContext';
|
||||
|
||||
class Item extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.bindEvent();
|
||||
}
|
||||
|
||||
handleMouseDown = () => {
|
||||
const { type, size, shape, model } = this.props;
|
||||
|
||||
if (this.page) {
|
||||
this.page.beginAdd(type, {
|
||||
type,
|
||||
size,
|
||||
shape,
|
||||
...model,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
bindEvent() {
|
||||
const { onAfterAddPage } = this.props;
|
||||
|
||||
onAfterAddPage(({ page }) => {
|
||||
this.page = page;
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { src, shape, children } = this.props;
|
||||
|
||||
return (
|
||||
<div style={{ cursor: 'pointer' }} onMouseDown={this.handleMouseDown}>
|
||||
{src ? <img src={src} alt={shape} draggable={false} /> : children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withGGEditorContext(Item);
|
||||
@@ -0,0 +1,46 @@
|
||||
import React from 'react';
|
||||
import { pick } from '@utils';
|
||||
import withGGEditorContext from '@common/context/GGEditorContext/withGGEditorContext';
|
||||
import Item from './Item';
|
||||
|
||||
class ItemPanel extends React.Component {
|
||||
page = null;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.bindEvent();
|
||||
}
|
||||
|
||||
handleMouseUp = () => {
|
||||
this.page.cancelAdd();
|
||||
}
|
||||
|
||||
bindEvent() {
|
||||
const { onAfterAddPage } = this.props;
|
||||
|
||||
onAfterAddPage(({ page }) => {
|
||||
this.page = page;
|
||||
|
||||
document.addEventListener('mouseup', this.handleMouseUp);
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
document.removeEventListener('mouseup', this.handleMouseUp);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { children } = this.props;
|
||||
|
||||
return (
|
||||
<div id={this.containerId} {...pick(this.props, ['style', 'className'])}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export { Item };
|
||||
|
||||
export default withGGEditorContext(ItemPanel);
|
||||
Reference in New Issue
Block a user