Git Product home page Git Product logo

grapesjs-code-editor's Introduction

grapesjs-code-editor

GrapesJS plugin Code Editor using Monaco Editor
Edit HTML and CSS

Demo

Must be configured in grapesjs selectorManager: { componentFirst: true }

Settings

{
  panelId: 'views-container', //Panel to append the code editor
  appendTo: '', //Append to element instead of views-container
  openState: { //State when open
     cv: '65%',
     pn: '35%'
  },
  closedState: { //State when closed
     cv: '85%',
     pn: '15%'
  },
  classOpenCode: { // Use class on open
     cv: "code-editor-aberto",
     pn: "code-editor-aberto"
  }, 
  preserveWidth: false, //Stop resizing openState and closedState
  editJs: false, //Allow editing of javascript, set allowScripts to true for this to work
  htmlBtnText: 'Aplicar', //Save HTML button text
  cssBtnText: 'Aplicar', //Save CSS button text
  blockPage: block, // Object loading
  acceptJS: false, // Accept JS in html code
  configEditor: { // Config Monaco Editor
     wordWrap: "on",
     minimap: { enabled: false },
     scrollBeyondLastLine: false,
     contextmenu: false,
     fixedOverflowWidgets: true, // Render widgets outside of the container
     showFoldingControls: 'always',
     suggestOnTriggerCharacters: true,
     lineDecorationsWidth: 0,
     //renderLineHighlight: 'none',
     tabSize: 3,
     formatOnType: true,
     formatOnPaste: true,
     autoIndent: true,
     autoClosingBrackets: true,
     autoClosingPairs: true,
     fontSize: "12px",
     scrollbar: {
        verticalScrollbarSize: 8,
        horizontal: 'hidden',
     },
   }
}

For wrapper listing all styles.

grapesjs-code-editor's People

Contributors

andcmatias avatar pety-dc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

pety-dc

grapesjs-code-editor's Issues

plugin forgets CSS content when HTML content is applied

I tried this plugin as a replacement for grapesjs-component-code-editor.

Unfortunately I bumped into a bug:
When I click on the apply button in the HTML section every CSS content that was previously in the CSS section gets dismissed.

It can be tried in the Demo: https://codepen.io/Anderson-Caldeireiro-Matias/pen/jOXrvgJ
Add a Text component which naturally has a 10px padding and try to edit the HTML content with the side panel. After applying, the padding gets dismissed.

CSS definitions of nested components are not handled properly

With grapesjs-component-code-editor when I select a component that has a child component, the CSS editor field lists the CSS definiton of both components

this plugin however only lists the CSS of the currently selected component. This may be an intentional design choice.
But unfortunately when the parent component is selected and HTML content gets applied, the CSS definitions of the child element get dismissed.

Again I can see that this plugin has similarities with grapesjs-component-code-editor which updates the CSS editor field with this code part:

this.cssCodeEditor.setContent(this.editor.CodeManager.getCode(this.component, 'css', {
                cssc: this.editor.Css
            }));

You use the same solution only for the wrapper (root) component. I don't know for that reason, but maybe instead of using the

if (component.attributes.type === 'wrapper') 

the

if (component.components().length) 

as condition that handles CSS of nested components would be more approprate.

Unfortunately this is not enough as the CSS of the child component appears in the css editor field, but still doesn't get saved this way.

styles.scss is not properly working

Hey @andcmatias

thanks for accepting my PRs

However when I updated the package I noticed that there is no new built version in the dist folder yet.
I tried to import the index.js from the src folder instead. But then I got an error in styles.scss

It seems to me that styles.scss is not a real scss file. I have sass interpreter in my project and it seems to me that you don't. Therefore I guess webpack doesn't try to interpret it as a real scss file.
If I remove the 'export default' line from the beginning and ticks, then another error occurs that it misses the $prefix variable.
If I rename it locally to styles.js it works as expected.

I'm not quite into scss but grapesjs-component-code-editor does this differently (it also has sass as dependency)

If you do not wish to bother to research and apply the scss handling, would you care to either rename the file to styles.js (and import it by that name in the index.js)
Or build and upload a new dist version?

Thx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.