oberon / quill-delta
Compose the deltas of a quill editor history ops array. Port of npm library quill-delta
Installs: 75
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/oberon/quill-delta
Requires
- php: >=5.6.0
 
Requires (Dev)
- madewithlove/phpunit-snapshots: ^0.1.2
 - phpunit/phpunit: ^5.7
 
This package is auto-updated.
Last update: 2025-10-22 12:53:45 UTC
README
This is a PHP port of the npm library quill-delta. Right now it only ports the compose function to compose the full history including all the retains and deletes to a final version with only the necessary inserts.
installation
Use composer
composer require oberon/quill-delta
usage
use Oberon\Quill\Delta\Composer;
    
$fullOps = [
    [
        "ops" => [
            ["insert" => "hello"],
        ],
    ],
    [
        "ops" => [
            ["retain" => 5],
            ["insert" => " world"],
        ],
    ],
];
$quilComposer = new Composer();
echo $quilComposer->compose($fullOps);
// {"ops":[{"insert":"hello world"}]}
or
use Oberon\Quill\Delta\Delta;
$fullOps = [
    [
        "ops" => [
            ["insert" => "hello"],
        ],
    ],
    [
        "ops" => [
            ["retain" => 5],
            ["insert" => " world"],
        ],
    ],
];
$output = array_reduce($fullOps, function(Delta $delta, $ops){
    $comp = $delta->compose(new Delta($ops));
    return $comp;
}, new Delta());
echo $output;
// {"ops":[{"insert":"hello world"}]}
notes
* only supports the delta compose method, diff and other utilities are not supported