GrapesJS / preset-newsletter

GrapesJS preset configuration for the newsletter editor.
https://grapesjs.com/demo-newsletter-editor.html
BSD 3-Clause "New" or "Revised" License
195 stars 143 forks source link

[Bug] device buttons are not active when editor device is changed #82

Closed yuzhva closed 4 years ago

yuzhva commented 4 years ago

The bug present also in the demo: https://grapesjs.com/demo-newsletter-editor.html

Desktop, tablet, mobile buttons are not being active after init, also they are not changing after screen size has been changed.

Screenshot 2020-03-05 at 19 46 07
yuzhva commented 4 years ago

The solution is found.

When adding a command, the stop() {} function is required ❗️

editor.Commands.add('set-device-NAME', {
      run() {
        editor.setDevice(deviceName);
      },
      stop() {
        // NOTE: stop key {stop ()} is required
        // the panel button will have an "-active" class after it is has been pressed
      }
    });