tbmatuka / editorjs-bundle
Editor.js 的 Symfony 扩展包
v0.1.5
2021-03-14 14:56 UTC
Requires
- php: >=7.2
- ext-json: *
- symfony/config: ^4.0|^5.0
- symfony/dependency-injection: ^4.0|^5.0
- symfony/form: ^4.0|^5.0
- symfony/framework-bundle: ^4.0|^5.0
- symfony/http-foundation: ^4.0|^5.0
- symfony/http-kernel: ^4.0|^5.0
- symfony/options-resolver: ^4.0|^5.0
- symfony/property-access: ^4.0|^5.0
- symfony/routing: ^4.0|^5.0
- symfony/twig-bundle: ^4.0|^5.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14
- symfony/framework-bundle: ^4.0
- symfony/phpunit-bridge: ^4.1
This package is auto-updated.
Last update: 2024-09-30 01:52:09 UTC
README
一个主要与 Symfony Forms 集成的 Editor.js 扩展包。
安装
Symfony
- 使用 composer 下载包:
$ composer require tbmatuka/editorjs-bundle
- 如果未自动添加,请将扩展包添加到
bundles.php
文件中:Tbmatuka\EditorjsBundle\TbmatukaEditorjsBundle::class => ['all' => true],
- 复制示例配置文件(
examples/ediotrjs.yaml
)或根据它创建自己的配置。 - 将表单主题添加到您的 twig 配置中
twig:
form_themes:
- '@TbmatukaEditorjs/Form/editorjs_widget.html.twig'
JavaScript
JS 实现的示例在 examples/editorjs-init.js
中。
Encore/webpack
如果您使用 Encore,您需要安装 Editor.js 的 npm 包(@editorjs/editorjs
)和您想要使用的任何插件。将示例复制到您的资产目录中,将插件类添加到数组中,并从您的主 JS 文件中导入该文件。
内联
将需要为其他加载方法(如从 CDN 加载 JS 或在组件中内联加载本地路径)添加配置选项和示例,但现在还没有。
使用
Symfony Forms
您可以在表单中使用 EditorjsType
以在前端获取 Editor.js。数据(解码 json)以数组的形式返回。
Twig
您可以直接从 Twig 扩展获取 Editor.js 配置。在 src/Resources/views/Form/editorjs_widget.html.twig
中检查表单组件,以了解如何使用它。editorjs()
Twig 函数接受配置对象或您想要使用的配置名称。
贡献
欢迎任何形式的帮助,特别是关于包含的 JS 在特定浏览器中不工作的信息。在提交 pull request 之前,请先打开一个 issue 来讨论您想要工作的内容,并避免在 issue 讨论中达成一致之前进行任何 BC 破坏性更改。