20minutes/php-draftjs-html

Export Draft.js ContentState to HTML

Installs: 28 680

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 0

Forks: 9

pkg:composer/20minutes/php-draftjs-html

v1.0.3 2021-09-15 09:45 UTC

This package is not auto-updated.

Last update: 2025-10-10 03:55:36 UTC


README

Export DraftJS ContentState to HTML from PHP

Installation

$ docker-compose build
$ docker-compose composer

Usage

<?php

namespace Tests;

use Willtj\PhpDraftjsHtml\Converter;
use Prezly\DraftPhp\Converter as DraftConverter;

// From a JSON string
$contentState = DraftConverter::convertFromJson($input);
$converter = new Converter;
$result = $converter
    ->setState($contentState)
    ->toHtml();

Basic customisation can be carried out by overriding the default style map, eg

$converter->updateStyleMap(['BOLD' => ['element' => 'b']]);

The class can be extended for more advanced custom rendering.

Tests

$ docker-compose phpunit