- 添加 Babel 配置文件支持 ES6+ 语法转换 - 添加 ESLint 忽略规则和配置文件 - 添加 Git 忽略规则文件 - 添加 Travis CI 配置文件 - 添加 1.4.2 版本变更日志文件 - 添加 Helm 图表辅助模板文件 - 添加 Helm 忽略规则文件
42 lines
903 B
JavaScript
42 lines
903 B
JavaScript
import React from 'react';
|
|
import Editor from '@components/Base/Editor';
|
|
import { pick } from '@utils';
|
|
import { TOOLBAR_CONTAINER } from '@common/constants';
|
|
import withGGEditorContext from '@common/context/GGEditorContext/withGGEditorContext';
|
|
|
|
class Toolbar extends React.Component {
|
|
toolbar = null;
|
|
|
|
get containerId() {
|
|
const { editor } = this.props;
|
|
|
|
return `${TOOLBAR_CONTAINER}_${editor.id}`;
|
|
}
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
const { editor, onAfterAddPage } = props;
|
|
|
|
onAfterAddPage(() => {
|
|
this.toolbar = new Editor.Toolbar({
|
|
container: this.containerId,
|
|
});
|
|
|
|
editor.add(this.toolbar);
|
|
});
|
|
}
|
|
|
|
render() {
|
|
const { children } = this.props;
|
|
|
|
return (
|
|
<div id={this.containerId} {...pick(this.props, ['style', 'className'])}>
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default withGGEditorContext(Toolbar);
|