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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

draftjs_exporter-7.0.0-py3-none-any.whl (62.1 kB view details)

Uploaded Python 3

File details

Details for the file draftjs_exporter-7.0.0-py3-none-any.whl.

File metadata

  • Download URL: draftjs_exporter-7.0.0-py3-none-any.whl
  • Upload date:
  • Size: 62.1 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for draftjs_exporter-7.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a19e28a18c758284a26ad36210fb43f4992a12ffbd7aeed8be89b92cfedf581c
MD5 7c0c790219d50e7df69a4aa51c746e16
BLAKE2b-256 da3e7e2944b99b0246cf66e3750f58e041b59341469892b1ecb0e46eee3a4abc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page