propsAPI.js 464 B

123456789101112131415161718192021
  1. class PropsAPI {
  2. editor = null;
  3. constructor(editor) {
  4. this.editor = editor;
  5. ['executeCommand'].forEach((key) => {
  6. this[key] = (...params) => this.editor[key](...params);
  7. });
  8. ['read', 'save', 'add', 'find', 'update', 'remove', 'getSelected'].forEach((key) => {
  9. this[key] = (...params) => this.currentPage[key](...params);
  10. });
  11. }
  12. get currentPage() {
  13. return this.editor.getCurrentPage();
  14. }
  15. }
  16. export default PropsAPI;