Skip to content

willtj/php-draftjs-html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-draftjs-html

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

About

Export DraftJS ContentState to HTML

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published