All Projects → ejilay → draftjs

ejilay / draftjs

Licence: MIT license
Draft.js exporter for Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to draftjs

draftjs exporter
Library to convert Draft.js ContentState to HTML
Stars: ✭ 77 (+250%)
Mutual labels:  draft-js, draftjs-exporter
draftjs-filters
Filter Draft.js content to preserve only the formatting you allow
Stars: ✭ 53 (+140.91%)
Mutual labels:  draft-js, draftjs-utils
draftjs-conductor
📝✨ Little Draft.js helpers to make rich text editors “just work”
Stars: ✭ 39 (+77.27%)
Mutual labels:  draft-js, draftjs-utils
Draftail
📝🍸 A configurable rich text editor built with Draft.js
Stars: ✭ 413 (+1777.27%)
Mutual labels:  draft-js
React Draft Wysiwyg
A Wysiwyg editor build on top of ReactJS and DraftJS. https://jpuri.github.io/react-draft-wysiwyg
Stars: ✭ 5,434 (+24600%)
Mutual labels:  draft-js
Medium Draft
📝 A medium like Rich Text Editor built on draft-js with a focus on keyboard shortcuts.
Stars: ✭ 1,705 (+7650%)
Mutual labels:  draft-js
wagtaildraftail
🐦📝🍸 Draft.js editor for Wagtail, built upon Draftail and draftjs_exporter
Stars: ✭ 23 (+4.55%)
Mutual labels:  draft-js
Draft Js Plugins
React Plugin Architecture for Draft.js including Slack-Like Emojis, FB-Like Mentions and Stickers
Stars: ✭ 3,918 (+17709.09%)
Mutual labels:  draft-js
Mui Rte
Material-UI Rich Text Editor and Viewer
Stars: ✭ 233 (+959.09%)
Mutual labels:  draft-js
Draft Extend
Build extensible Draft.js editors with configurable plugins and integrated serialization.
Stars: ✭ 109 (+395.45%)
Mutual labels:  draft-js
Z Editor
Online Z-notations Editor with Draft.js and React.js
Stars: ✭ 99 (+350%)
Mutual labels:  draft-js
Dante2
A complete rewrite of dante editor in draft-js
Stars: ✭ 890 (+3945.45%)
Mutual labels:  draft-js
React Tapable Editor
A pluginable, intuitive medium/notion like rich text editor(currently in wip)
Stars: ✭ 170 (+672.73%)
Mutual labels:  draft-js
Draft Convert
Extensibly serialize & deserialize Draft.js ContentState with HTML.
Stars: ✭ 416 (+1790.91%)
Mutual labels:  draft-js
React Text Selection Popover
Selection based Text UI made easy
Stars: ✭ 245 (+1013.64%)
Mutual labels:  draft-js
Braft Editor
美观易用的React富文本编辑器,基于draft-js开发
Stars: ✭ 4,310 (+19490.91%)
Mutual labels:  draft-js
Yoyo
A dead simple comment engine built on top of AWS lambda and React, alternative comment service to Disqus.
Stars: ✭ 210 (+854.55%)
Mutual labels:  draft-js
Gatsby Starter Procyon
An opinionated Gatsby starter designed for trash-eating pandas.
Stars: ✭ 88 (+300%)
Mutual labels:  draft-js
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 (+4363.64%)
Mutual labels:  draft-js
Repost
An open source software to communicate with your team members through posting daily reports.
Stars: ✭ 121 (+450%)
Mutual labels:  draft-js

Draft.js Exporter

Go Report Card

Draft.js is a framework for building rich text editors. However, it does not support exporting documents at HTML. This package is designed to take the raw ContentState (output of convertToRaw) from Draft.js and convert it to HTML using Go. Mostly it useful for server-side rendering. I should note this package does not provide any input validation and assumes correct and safe input data.

Usage

func main() {

	// get your contentState JSON-string
	draftState := exampleDraftStateSource

	// make auxiliary variable
	contentState := draftjs.ContentState{}
	json.Unmarshal([]byte(draftState), &contentState) // don't forget error handling

	// prepare some config (HTML here)
	config := draftjs.DefaultConfig()

	// and just render content state to HTML-string
	s := draftjs.Render(&contentState, config)

	// that's it
	fmt.Println(s)
}

For RawContentState like this

{
  "entityMap": {
    "0": {
      "type": "LINK",
      "data": {
        "url": "https://medium.com/@rajaraodv/how-draft-js-represents-rich-text-data-eeabb5f25cf2#.ce9y2wyux"
      }
    }
  },
  "blocks": [
    {
      "text": "Rich text with link",
      "type": "unstyled",
      "depth": 0,
      "inlineStyleRanges": [
        {
          "offset": 0,
          "length": 4,
          "style": "BOLD"
        }, {
          "offset": 2,
          "length": 10,
          "style": "UNDERLINE"
        }, {
          "offset": 5,
          "length": 4,
          "style": "ITALIC"
        }, {
          "offset": 10,
          "length": 4,
          "style": "CODE"
        }
      ],
      "entityRanges": [{
          "offset": 15,
          "length": 4,
          "key": 0
       }]
}]}

It will give something like this but without indention:

<p>
	<strong>Ri</strong>
	<strong>
		<ins>ch</ins>
	</strong>
	<ins>
		<em>text</em>
	</ins>
	<ins>
		<code>wi</code>
	</ins>
	<code>th</code>
	<a href="https://medium.com/@rajaraodv/how-draft-js-represents-rich-text-data-eeabb5f25cf2#.ce9y2wyux" target="_blank">link</a>
</p>

That look like

Ri ch text wi th link

Setup

You'll need Golang installed first :o)

go get github.com/ejilay/draftjs

Testing

To test run the following command in project's root directory:

go test ./...
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].