index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import Editor from '@components/Base/Editor';
  2. import {
  3. MIND_CONTAINER,
  4. MIND_CLASS_NAME,
  5. EVENT_BEFORE_ADD_PAGE,
  6. EVENT_AFTER_ADD_PAGE,
  7. } from '@common/constants';
  8. import Page from '@components/Page';
  9. import withGGEditorContext from '@common/context/GGEditorContext/withGGEditorContext';
  10. class Mind extends Page {
  11. get pageId() {
  12. const { editor } = this.props;
  13. return `${MIND_CONTAINER}_${editor.id}`;
  14. }
  15. initPage() {
  16. const { editor } = this.props;
  17. editor.emit(EVENT_BEFORE_ADD_PAGE, { className: MIND_CLASS_NAME });
  18. this.page = new Editor.Mind(this.config);
  19. editor.add(this.page);
  20. editor.emit(EVENT_AFTER_ADD_PAGE, { page: this.page });
  21. }
  22. bindEvent() {
  23. super.bindEvent();
  24. this.bindKeyUpEditLabel();
  25. }
  26. bindKeyUpEditLabel() {
  27. const editLabel = this.page.get('labelTextArea');
  28. editLabel.on('keyup', (e) => {
  29. e.stopPropagation();
  30. const item = editLabel.focusItem;
  31. const text = editLabel.textContent;
  32. this.page.emit('keyUpEditLabel', {
  33. item,
  34. text,
  35. });
  36. });
  37. }
  38. }
  39. export default withGGEditorContext(Mind);