Skip to main content

Draft.js exporter

Library to convert rich text from Draft.js raw ContentState to HTML.

Features

This project adheres to Semantic Versioning, and measures performance and code coverage. Code is checked with mypy.

  • Extensive configuration of the generated HTML.
  • Default, extensible block & inline style maps for common HTML elements.
  • Convert line breaks to <br> elements with decorators.
  • Define any attribute in the block map – custom class names for elements.
  • React-like API to create custom components.
  • Automatic conversion of entity data to HTML attributes (int & boolean to string, style object to style string).
  • Nested lists (<li> elements go inside <ul> or <ol>, with multiple levels).
  • Output inline styles as inline elements (<em>, <strong>, pick and choose, with any attribute).
  • Overlapping inline style and entity ranges.
  • Static type annotations.

It is developed alongside the Draftail rich text editor, for Wagtail. Check out the online demo, and our introductory blog post.

When to use the exporter

Draft.js is a rich text editor framework for React. Its approach is different from most rich text editors because it does not store data as HTML, but rather in its own representation called ContentState. This exporter is useful when the ContentState to HTML conversion has to be done in a Python ecosystem.

The initial use case was to gain more control over the content managed by rich text editors in a Wagtail/Django site. If you want to read the full story, have a look at our blog post: Rethinking rich text pipelines with Draft.js.

Documentation

The full documentation is available at on the docs website. For LLM-assisted tooling, there is also a concise llms.txt and a complete llms-full.txt.

Contributing

See anything you like in here? Anything missing? We welcome all support, whether on bug reports, feature requests, code, design, reviews, tests, documentation, and more. Please have a look at our contribution guidelines.

Credits

Draftail was created by Springload, and is now maintained by Wagtail contributors. View the full list of contributors. MIT licensed.

Release files for draftjs_exporter 7.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for draftjs_exporter 7.1.0
File Size Uploaded
draftjs_exporter-7.1.0.tar.gz 45.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for draftjs_exporter 7.1.0
File Interpreter ABI Platform
draftjs_exporter-7.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 107.9 kB

Release files / draftjs_exporter-7.1.0.tar.gz

Download URL draftjs_exporter-7.1.0.tar.gz
Size 45.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ad27634d514f8bcfb828b19cfc84a8fee7cb1f0fd706d249f70633436272d687
BLAKE2b-256 checksum
How to use checksums
9eac18fe333830cfaab6fceb760fcfd0db9f5c08a8ae53605f7c5b3e194d4f0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / draftjs_exporter-7.1.0-py3-none-any.whl

Download URL draftjs_exporter-7.1.0-py3-none-any.whl
Size 62.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a9397751aae7e66b25cba538a4a0421801c5dcfee2e75e9f664bd9cb37e90fd
BLAKE2b-256 checksum
How to use checksums
05837bb024971238052574eb6e4479f2c80339784be533268a60559fa544bca9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

7.1.0 This release

2 release files

7.0.0

1 release file

6.0.0

2 release files

5.2.0

2 release files

5.1.0

2 release files

5.0.0

2 release files

4.1.2

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.0

1 release file

3.0.1

1 release file

3.0.0

1 release file

2.1.7

2 release files

2.1.6

2 release files

2.1.5

2 release files

2.1.4

1 release file

2.1.3

1 release file

2.1.2

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.0

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.9.0

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.7.0

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page