index.js 839 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // panel/index.js, this filename needs to match the one registered in package.json
  2. Editor.Panel.extend({
  3. // css style for panel
  4. style: `
  5. :host { margin: 5px; }
  6. h2 { color: #f90; }
  7. `,
  8. // html template for panel
  9. template: `
  10. <h2>compressImages</h2>
  11. <hr />
  12. <div>State: <span id="label">--</span></div>
  13. <hr />
  14. <ui-button id="btn">Send To Main</ui-button>
  15. `,
  16. // element and variable binding
  17. $: {
  18. btn: '#btn',
  19. label: '#label',
  20. },
  21. // method executed when template and styles are successfully loaded and initialized
  22. ready () {
  23. this.$btn.addEventListener('confirm', () => {
  24. Editor.Ipc.sendToMain('compressImages:clicked');
  25. });
  26. },
  27. // register your ipc messages here
  28. messages: {
  29. 'compressImages:hello' (event) {
  30. this.$label.innerText = 'Hello!';
  31. }
  32. }
  33. });