Issue #1014Opened April 7, 2018by tommedema1 reactions

[Question] making preview mode remember if visibility mode should be restored or not

Question

Currently when you enable preview mode and then disable it again, it always turns on visibility mode, even if visibility mode was turned off. This can be rather annoying.

I would like to create a PR to fix this, but could use your advice because I'm not completely following how you would do this properly in the way you use backbone.

At commands/view/Preview.js you have the following logic in the stop function:

<img width="385" alt="screen shot 2018-04-06 at 4 24 34 pm" src="https://user-images.githubusercontent.com/331833/38448138-05a23d7c-39b7-11e8-8ef2-418b429960b5.png">

Now, line 54 should become conditional. Something like:

    if (editor.visibilityMode()) {
        editor.runCommand('sw-visibility');
    }

How would you implement this visibilityMode boolean? Would this be part of the components model?

Answers (3)

artfApril 9, 20181 reactions

I really like the idea, what about keeping track of all commands status at Commands level?!? Like for example, on any runCommand(CMD_ID) we gonna store it inside Commands.active object (eg. active[CMD_ID] = 1) and clear on stopCommand. Then we'll need Commands.isActive(CMD_ID) method for the check and probably also Editor.isCommandActive(CMD_ID) (just as a proxy method). I'd like also to move the runCommand/stopCommand logic from Editor and put it inside new Commands.run/stop methods (just to make it a more organized). What do you think? Would you able to create such a PR? :)

tommedemaApril 9, 20180 reactions

@artf I can probably do it if I can ask some questions here along the way. I'm still getting used to Backbone. Where would you put that Commands object?

Could you elaborate more on this?

I'd like also to move the runCommand/stopCommand logic from Editor and put it inside new Commands.run/stop methods (just to make it a more organized).

artfApril 14, 20180 reactions

For Commands I mean the Commands module

Could you elaborate more on this?

I'd like, for example, moving this Editor. runCommand logic inside the Commands module, so in the Editor we will get:

    runCommand(id, options = {}) {
      return em.get('Commands').run(id, options);
    },

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.