Skip to content

Commit

Permalink
fix: Fix register command
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoli committed Aug 29, 2018
1 parent 76f1116 commit 3022645
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/Register/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ class Register extends BaseComponent {
const { type } = this;

editor.on(EVENT_BEFORE_ADD_PAGE, ({ className }) => {
let host = Editor[className];
let keys = ['name', 'config', 'extend'];
if (type === 'behaviour') keys = ['name', 'behaviour', 'dependences'];

if (type === 'command') {
host = Editor;
}

if (type === 'behaviour') {
keys = ['name', 'behaviour', 'dependences'];
}

const args = keys.map(key => this.props[key]);

Editor[className][`register${upperFirst(type)}`](...args);
host[`register${upperFirst(type)}`](...args);
});
}
}
Expand Down

0 comments on commit 3022645

Please sign in to comment.