webstronauts / draft-php
This package is abandoned and no longer maintained.
No replacement package was suggested.
A php implementation of Facebook's Draft.js library
dev-master / 1.0.x-dev
2017-01-11 08:33 UTC
Requires
- php: ^5.6|^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: 2.0.0-alpha
- phpspec/phpspec: ^2.0
- sllh/php-cs-fixer-styleci-bridge: ^2.1
This package is not auto-updated.
Last update: 2020-01-24 16:43:56 UTC
README
A simple library to handle the content state of Draft.js in the backend.
Usage
use Draft\Encoding; use Draft\Model\Immutable\ContentState; $rawState = json_decode('{"entityMap":{"0":{"type":"LINK","mutability":"MUTABLE","data":{"url":"/","rel":null,"title":"hi","extra":"foo"}}},"blocks":[{"key":"8r91j","text":"a","type":"unstyled","depth":0,"inlineStyleRanges":[{"offset":0,"length":1,"style":"ITALIC"}],"entityRanges":[{"offset":0,"length":1,"key":0}]}]}', true); $contentBlocks = Encoding::convertFromRaw($rawState); $contentState = ContentState::createFromBlockArray($contentBlocks); var_dump($contentState);
Under Development
This bundle is currently under heavy development and some aspects are likely to change until considered stable.
Tests
To run the test suite, you need install the dependencies via composer, then run PHPUnit.
$ composer install
$ composer test
Inspiration
Many thanks to the Draft.js team for the initial inspiration that became the groundworks for the library.
License
MIT, see LICENSE