Issue #1187Opened June 9, 2018by endersaka0 reactions

[QUESTION]: why dashed lines do not show around components?

Question

After long time I am trying again with GrapesJS.

I am following the Getting Started page and I am stuck to this step https://github.com/artf/grapesjs/wiki#components In fact, I am trying to "highlight" the components with a dashed line, pressing the "eye" button, as explained in the tutorial, but it does not work.

GrapesJS version is 0.14.17. I am using Mac OS X. I tested on both Safari and Chrome. The Web Demo works correctly.

Actually, when I press the "eye" button it changes the CSS of the components (as you can see in the attached image) but the modification is not visible in the canvas.

Here is the code of index.html:

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <meta charset="utf-8">

  <title>My GrapesJS</title>


  <link type="text/css" rel="stylesheet" href="../grapesjs/dist/css/grapes.min.css">
  <script type="text/javascript" src="../grapesjs/dist/grapes.min.js"></script>

  <script type="text/javascript" src="dist/js/bundle.js"></script>

  <link type="text/css" rel="stylesheet" href="css/main.css">
</head>
<body>
  <div id="gjs"></div>

  <script type="text/javascript">
    var editor = grapesjs.init({
      container: '#gjs',
      //components: '<div class="txt-red">Hello world!</div>',
      //style: '.txt-red{color: red}',
      height: '100%',
      storageManager: {
        type: 'none'
      },
      components: '<div style="width:300px; min-height:100px; margin: 0 auto"></div>' +
              '<div style="width:400px; min-height:100px; margin: 0 auto"></div>' +
              '<div style="width:500px; min-height:100px; margin: 0 auto"></div>',
      panels: {
        defaults: [
          {
            id: 'commands',
            buttons: [
              {
                id: 'smile',
                className: 'fa fa-smile-o',
                attributes: {
                  title: 'Smile'
                },
                command: 'helloWorld'
              },
              {
                id        : 'vis',
                className : 'fa fa-eye',
                command   : 'sw-visibility',
                context   : 'some-random-context', // For grouping context of buttons in the same panel
                active    : true,
              }
            ]
          }
        ]
      },
      commands: {
        defaults: [
          {
            id: 'helloWorld',
            run: function(editor, senderBtn){
              alert('Hello world!');

              // Deactivate the button.
              senderBtn.set('active', false);
            },
            stop: function(editor, senderBtn){

            }
          }
        ]
      }
    });
  </script>
</body>
</html>

main.css

body {
  margin: 0;
}

screeshot 2018-06-09 alle 01 19 37

Answers (3)

ssabrewolfJune 10, 20180 reactions

To show the dashed lines you need to run in on editor load event editor.runCommand('sw-visibility');

endersakaJune 11, 20180 reactions

Thanks.

Maybe I don't remember well but I am almost sure that it is not explained in the documentation tutorial.

artfJune 14, 20180 reactions

I think it's just because you need to indicate the height for your document

html,
body {
	height: 100%;
}

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.