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 Distribution

draftjs_exporter-7.1.0.tar.gz (45.3 kB view details)

Uploaded Source

Built Distribution

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

draftjs_exporter-7.1.0-py3-none-any.whl (62.6 kB view details)

Uploaded Python 3

File details

Details for the file draftjs_exporter-7.1.0.tar.gz.

File metadata

  • Download URL: draftjs_exporter-7.1.0.tar.gz
  • Upload date:
  • Size: 45.3 kB
  • Tags: Source
  • 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.1.0.tar.gz
Algorithm Hash digest
SHA256 ad27634d514f8bcfb828b19cfc84a8fee7cb1f0fd706d249f70633436272d687
MD5 f353760c12c65bcad604db21d079e4d1
BLAKE2b-256 9eac18fe333830cfaab6fceb760fcfd0db9f5c08a8ae53605f7c5b3e194d4f0c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: draftjs_exporter-7.1.0-py3-none-any.whl
  • Upload date:
  • Size: 62.6 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a9397751aae7e66b25cba538a4a0421801c5dcfee2e75e9f664bd9cb37e90fd
MD5 6e65a782f502813b2f5a3fa2c86f7f21
BLAKE2b-256 05837bb024971238052574eb6e4479f2c80339784be533268a60559fa544bca9

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 Sentry Error logging StatusPage Status page