[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:
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)
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? :)
@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).
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.
Issue #1540
[Question] Is it possible to add event for preview?
I'd like to convert some texts when a user clicks the preview button. for instance, ((name)) (in the editor) should be 'David' (in preview...
Issue #927
[QUESTION] How to disable image resize?
I was looking for it in wiki but I didn't found anything about it. I would like to disable resize for all current and future images for def...
Issue #1043
[Question] Should I always save the CSS? (and other questions)
First, thanks a lot for this! It's an amazing piece of software. I've been playing around with grapesjs, and few questions popped up, would...
Issue #1322
Disable editing in Preview Mode.
@artf How can we disable editing in the preview mode and re-enable it when preview mode off. I want to remove editor and hide toolbar in th...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.