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

react-movable-block-editor

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-movable-block-editor

React component for creating layouts and content via drag-and-drop blocks.


Version published
Weekly downloads
6
increased by50%
Maintainers
1
Weekly downloads
 
Created

React Movable Block Editor

React component for creating layouts and content via drag-and-drop blocks.

The output is an object that can be serialized to json, React, html.

Installation:

npm install react-movable-block-editor react-color react-resizable react-markdown lodash-es --save

Demos:

Remix on Glitch:

Usage:


import {
  BlockEditor,
  Preview,
  BlockEditorControl,
  BlockEditorValue,
} from 'react-movable-block-editor';
import 'react-movable-block-editor/css/drag.css';
import 'react-resizable/css/styles.css';

const App: React.FC = () => {
  const [editorState, setEditorState] = useState<BlockEditorValue>({
    copiedNode: null,
    focusedNodeId: null,
    undoStack: [],
    redoStack: [],
    byId: {
      container1: {
        id: 'container1',
        type: 'layer',
        name: 'container1',
        parentId: null, // root
        width: 500,
        height: 300,
        childrenIds: [],
      },
    },
    rootNodeId: 'container1',
  });

  return (
    <div>
      <BlockEditorControl
        value={editorState}
        onChange={v => (console.log('VAL', v) as any) || setEditorState(v)}
      />
      <div>
        <BlockEditor value={editorState} onChange={setEditorState} />
      </div>
      <div style={{ borderWidth: 1, borderStyle: 'dashed' }}>
        <Preview
          byId={editorState.byId}
          node={editorState.byId[editorState.rootNodeId]}
        />
      </div>
    </div>
  );
};

Examples

Running an example

cd example/editor-example

npm install

npm start

grid-blocks

Bootstrapped with TSDX

FAQs

Package last updated on 31 Mar 2020

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