定制 storyblok/richtext-resolver 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

storyblok/richtext-resolver

最新稳定版本:2.2.1

Composer 安装命令:

composer require storyblok/richtext-resolver

包简介

A package allowing you to get an HTML string from the richtext field of Storyblok.

README 文档

README

Warning

This package is discontinued and will only receive critical security updates.
Please use the new official Tiptap Extension.

Storyblok PHP Richtext Renderer - Deprecated

This package allows you to get an HTML string from the richtext field of Storyblok.

Installing the Storyblok PHP Richtext Renderer

You can install the Storyblok PHP Richtext Renderer via composer. Storyblok PHP Richtext Renderer requires PHP version 7.3 to 8.2. The suggestion is to use an actively supported version of PHP (8.1 and 8.2).

If you want to install the stable release of Storyblok PHP Richtext Renderer you can launch:

composer require storyblok/richtext-resolver

If you want to install the current development release, you can add the version dev-master:

composer require storyblok/richtext-resolver dev-master

For executing the command above, you need to have composer installed on your development environment. If you need to install Composer, you can follow the official Composer documentation:

We suggest using the latest version of PHP.

composer require storyblok/richtext-resolver dev-master

Usage:

Instantiate the Resolver class:

use Storyblok\RichtextRender\Resolver;

$resolver = new Resolver();

Use the function render() to get the html string from your richtext field.

// previous code...

// Note that in php our objects use multidimensional array notation
$data = [
  "type" => "doc",
  "content" => [
    [
      "type" => "horizontal_rule"
    ]
  ]
];

$resolver->render($data) # renders a html string: '<hr />'

How to define a custom schema for resolver?

Make a copy of the default schema storyblok-php-richtext-renderer/src/Schema.php and add your own schema as parameter to the Richtext class.

$resolver = new Resolver($my_custom_schema);

Testing

We use PHPUnit for tests. You can execute the following composer task to run the tests:

composer run test

If you want to generate the coverage report you can launch:

composer run test-coverage

You will find the HTML reports in the coverage/ directory.

Code Style guide

For consistency, we are using PHP Coding Standards Fixer tool, for checking and fixing the code to follow standards.

For checking the code you can execute:

composer run codestyle-check

If you want to automatically fix the code to follow standards:

composer run codestyle-fix

If you want to execute fix and test coverage:

composer run all-check

Contribution

Fork me on Github

统计信息

  • 总下载量: 538.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 1
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 17
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-25