All Projects → prevwong → Craft.js

prevwong / Craft.js

Licence: mit
🚀 A React Framework for building extensible drag and drop page editors

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
shell
77523 projects

Projects that are alternatives of or similar to Craft.js

Brick Design
全场景流式布局,可视化拖拽、随意嵌套组合、实时渲染、实时辅助线展示,实时组件间距展示、实时拖拽排序、状态域管理,可视化属性配置、可视化样式配置、多设备适配展示,支持逻辑渲染、模板字符变量、表达式、自定义方法、自定义状态
Stars: ✭ 4,048 (-10.28%)
Mutual labels:  page-builder, drag-and-drop, html-builder, site-builder, web-builder
Grapesjs
Free and Open source Web Builder Framework. Next generation tool for building templates without coding
Stars: ✭ 14,892 (+230.05%)
Mutual labels:  drag-and-drop, page-builder, site-builder, web-builder
Laravel Pagebuilder
A drag and drop pagebuilder to manage pages in any Laravel project.
Stars: ✭ 189 (-95.81%)
Mutual labels:  page-builder, drag-and-drop, wysiwyg
Megadraft
Megadraft is a Rich Text editor built on top of Facebook's Draft.JS featuring a nice default base of components and extensibility
Stars: ✭ 982 (-78.24%)
Mutual labels:  draft-js, wysiwyg
Braft Editor
美观易用的React富文本编辑器,基于draft-js开发
Stars: ✭ 4,310 (-4.48%)
Mutual labels:  draft-js, wysiwyg
Draftail
📝🍸 A configurable rich text editor built with Draft.js
Stars: ✭ 413 (-90.85%)
Mutual labels:  draft-js, wysiwyg
Elementor
The most advanced frontend drag & drop page builder. Create high-end, pixel perfect websites at record speeds. Any theme, any page, any design.
Stars: ✭ 4,207 (-6.76%)
Mutual labels:  page-builder, wysiwyg
H5 Dooring
H5 Page Maker, H5 Editor, LowCode. Make H5 as easy as building blocks. | 让H5制作像搭积木一样简单, 轻松搭建H5页面, H5网站, PC端网站,LowCode平台.
Stars: ✭ 5,832 (+29.26%)
Mutual labels:  page-builder, drag-and-drop
Builder
Drag and drop page building using your code components
Stars: ✭ 1,281 (-71.61%)
Mutual labels:  page-builder, wysiwyg
draftjs-filters
Filter Draft.js content to preserve only the formatting you allow
Stars: ✭ 53 (-98.83%)
Mutual labels:  wysiwyg, draft-js
smaller-sites
Smaller Sites is a small BUT Powerful, free and easy to use drag and drop builder for blogs, websites or e-commerce stores. Designed for everyone Developers and non Developers. You can use it to design your next website. The goal is to create something like webflow
Stars: ✭ 27 (-99.4%)
Mutual labels:  drag-and-drop, web-builder
react-web-editor
The react-web-editor is a WYSIWYG editor library. you can resize and drag your component. It also has simple rich text editor
Stars: ✭ 191 (-95.77%)
Mutual labels:  drag-and-drop, wysiwyg
Phpagebuilder
A drag and drop page builder to manage pages in any PHP project.
Stars: ✭ 168 (-96.28%)
Mutual labels:  drag-and-drop, wysiwyg
Wyg
A new WYSIWYG editing experience for the modern web
Stars: ✭ 73 (-98.38%)
Mutual labels:  drag-and-drop, wysiwyg
Vvvebjs
Drag and drop website builder javascript library.
Stars: ✭ 4,609 (+2.15%)
Mutual labels:  drag-and-drop, site-builder
plasmic
Visual page builder and web design tool for any website or web app tech stack
Stars: ✭ 1,475 (-67.31%)
Mutual labels:  wysiwyg, page-builder
Piper
A drag-and-drop mobile website builder base on Vue
Stars: ✭ 228 (-94.95%)
Mutual labels:  page-builder, drag-and-drop
analogwp-templates
Style Kits for Elementor adds a number of intuitive styling controls in the Elementor editor that allow you to apply styles globally or per page.
Stars: ✭ 20 (-99.56%)
Mutual labels:  wysiwyg, page-builder
draftjs-conductor
📝✨ Little Draft.js helpers to make rich text editors “just work”
Stars: ✭ 39 (-99.14%)
Mutual labels:  wysiwyg, draft-js
Text
📑 Collaborative document editing using Markdown
Stars: ✭ 282 (-93.75%)
Mutual labels:  wysiwyg

craft.js

Live Demo

Page editors are a great way to provide an excellent user experience. However, to build one is often a pretty dreadful task.

There're existing libraries that come with a fully working page editor out of the box with a user interface and editable components. However, if you wish to make customisations such as modifying the user interface and its behavior, it will most definitely involve modifying the library itself.

Craft.js solves this problem by modularising the building blocks of a page editor. It ships with a drag-n-drop system and handles the way user components should be rendered, updated and moved - among other things. With this, you'll be able to build your own page editor exactly how you want it to look and behave.

Docs

Examples

These examples should give you an idea on the flexibility of Craft.js.

Both these examples look very different from each other, with very different UI. But they are both built with Craft.js! 🤯

Features 🔥

It's just React

No need for complicated plugin systems. Design your editor from top to bottom the same way as you would design any other frontend application in React.

A simple user component can easily be defined as such:

import {useNode} from "@craftjs/core";

const TextComponent = ({text}) => {
  const { connectors: {drag} } = useNode();

  return (
    <div ref={drag}>
      <h2>{text}</h2>
    </div>
  )
}

Heck, the entire UI of your page editor is built using just React.

import React from "react";
import {Editor, Frame, Canvas, Selector} from "@craftjs/core";
const App = () => {
  return (
    <div>
      <header>Some fancy header or whatever</header>
      <Editor>
        // Editable area starts here
        <Frame resolver={TextComponent, Container}>
          <Canvas>
            <TextComponent text="I'm already rendered here" />
          </Canvas>
        </Frame>
      </Editor>
    </div>
  )
}

Control how your components are edited

An obvious requirement for page editors is that they need to allow users to edit components. With Craft.js, you control the process of which these components should be edited.

In the following example, when the user clicks on a component, we'll display a modal that requires the user to input a value for the text prop. As the input value changes, the component will be re-rendered with updated prop.

import {useNode} from "@craftjs/core";

const TextComponent = ({text}) => {
  const { connectors: { connect, drag }, isClicked, actions: {setProp} } = useNode(
    (state) => ({
      isClicked: state.event.selected,
    })
  );

  return (
    <div ref={dom => connect(drag(dom))}>
      <h2>{text}</h2>
      {
        isClicked ? (
          <Modal>
            <input
              type="text"
              value={text}
              onChange={e => setProp(e.target.value)}
            />
          </Modal>
        )
      }
    </div>
  )
}

With this, you could easily implement content editable text or drag-to-resize components, just as any modern page editor would have.

User components with droppable regions

Let's say we need a "Container" component which users can drop into the editor. Additionally, we would also like them to be able to drag and drop other components into the Container.

In Craft.js, it's as simple as calling the <Canvas />

import {useNode} from "@craftjs/core";
const Container = () => {
  const { connectors: {drag} } = useNode();

  return (
    <div ref={drag}>
      <Canvas id="drop_section">
         // Now users will be able to drag/drop components into this section
        <TextComponent />
      </Canvas>
    </div>
  )
}

Extensible

Craft.js provides an expressive API which allows you to easily read and manipulate the editor state. Let's say you would like to implement a copy function for a component:

import {useEditor, useNode} from "@craftjs/core";
const Container = () => {
  const { actions: {add}, query: { createNode, node } } = useEditor();
  const { id, connectors: {drag, connect} } = useNode();
  return (
    <div ref={dom => connect(drag(dom))}>
      ...
      <a onClick={() => {
        const { data: {type, props}} = node(id).get();
        add(
          createNode(React.createElement(type, props));
        );
      }}>
        Make a copy of me
      </a>
    </div>
  )
}

Serializable state

The editor's state can be serialized into JSON which you can then apply a compression technique of your choice for storage.

const SaveButton = () => {
  const { query } = useEditor();
  return <a onClick={() => console.log(query.serialize()) }>Get JSON</a>
}

Of course, Craft.js will also able to recreate the entire state from the JSON string.

const App = () => {
  const jsonString = /* retrieve JSON from server */
  return (
    <Editor>
      <Frame json={jsonString}>
        ...
      </Frame>
    </Editor>
  )
}

Who is this for? 🤔

You should use this if:

  • You want to design your page editor according to your own UI specifications. With Craft.js, you control almost every aspect of the look and feel of your page editor.
  • You like the React ecosystem. Being a React framework, not only do you get to build your user interface declaratively, but you will also be able to extend upon thousands of existing React components for your page editor.
  • You're the coolest kid in class 😎

You should not use this if:

  • You need a page editor that works out of the box. Craft.js is an abstraction where you implement your own page editor upon. For example, it does not come with a ready-made user interface.
    • However, you could still consider using the examples as a starting point.

Additional Packages 🎉

Acknowledgements 🙌

  • react-dnd The React drag-n-drop library. Although it is not actually used here, many aspects of Craft.js are written with react-dnd as a reference along with some utilities and functions being borrowed.
  • Grape.js The HTML web builder framework. This has served as an inspiration for Craft.js. The element positioning logic used in Craft.js is borrowed from Grape.js
  • use-methods A super handy hook when dealing with reducers. Craft.js uses a slightly modified version of use-methods to better fit our API.

Getting Help 👋

If you have questions or there's something you'd like to discuss (eg: contributing), please head over to our Discord server.

Contributors

Craft.js is made with ❤️ by these wonderful people (emoji key):


Prev Wong

💻 🎨 📖 🤔 💡

azreenashah

📖

MO

📖

Andy Krings-Stern

💻 📖 🤔

Shingo Yamazaki

📖

Joel Schneider

🐛 📖

Evan Rusmisel

📖

Michele Riccardo Esposito

💻 🤔

Mateusz Drulis

💻 🤔

Sigit Prabowo

🐛

Srinath Janakiraman

📖

Kim

🐛

This project follows the all-contributors specification. Contributions of any kind are welcome!

Support 💟

Craft.js is released under the MIT license and is built with 100% love. If you found it useful and would like to ensure its continued development, please consider becoming a backer/sponsor or making a one-time donation via Open Collective or Paypal.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].