New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grapesjs-code-editor

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grapesjs-code-editor

Enable users to edit html/css for the currently selected component

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Grapesjs Code Editor

When a component is selected, this plugin allows you to edit the HTML code and CSS code, and save them.

alt text

Usage

HTML

[demo](https://codesandbox.io/p/sandbox/nyccjr)
<html>
  <head>
    <link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
    <script src="https://unpkg.com/grapesjs"></script>
    <script src="https://unpkg.com/grapesjs-parser-postcss"></script>
    <script src="https://unpkg.com/grapesjs-code-editor"></script>
    <link href="https://unpkg.com/grapesjs-code-editor/dist/style.css" rel="stylesheet">
    <style>
      body, html { height: 100%; }
    </style>
  </head>
  <body>
    <div id="gjs">
      <h1 class="title">Hello, GrapesJs code editor</h1>
      <style>.title {color: red}</style>
    </div>
    <script>
      const editor = grapesjs.init({
        height: '100%',
        container: '#gjs',
        fromElement: true,
        storageManager: false,
        plugins: ['grapesjs-code-editor', 'grapesjs-parser-postss'],
      });

      const pn = window.editor.Panels;
      const panelViews = pn.addPanel({id: 'views'});
      panelViews.get('buttons').add([{
        attributes: { title: 'Open Code' },
        className: 'fa fa-file-code-o',
        command: 'open-code',
        togglable: false, //do not close when button is clicked again
        id: 'open-code'
      }]);
    </script>
  </body>
</html>

JS

demo

import grapesjs from 'grapesjs';
import grapesjsParserPostcss from 'grapesjs-parser-postcss';
import 'grapesjs/dist/css/grapes.min.css';
import grapesjsCodeEditor from 'grapesjs-code-editor';
import 'grapesjs-code-editor/dist/style.css';

window.editor = grapesjs.init({
  height: '100%',
  container: '#gjs',
  fromElement: true,
  storageManager: false,
  plugins: [grapesjsCodeEditor, grapesjsParserPostcss],
});

const pn = window.editor.Panels;
const panelViews = pn.addPanel({id: 'views'});
panelViews.get('buttons').add([{
  attributes: { title: 'Open Code' },
  className: 'fa fa-file-code-o',
  command: 'open-code',
  togglable: false, //do not close when button is clicked again
  id: 'open-code'
}]);

Development

$ git clone https://github.com/allenhwkim/grapesjs-code-editor.git
$ cd grapesjs-code-editor
$ npm i
$ npm start

License

MIT

Keywords

FAQs

Package last updated on 30 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc