grch/editor-plugin
Composer 安装命令:
composer require grch/editor-plugin
包简介
Most powerful, next generation block styled editor with multilingual support.
README 文档
README
Meet the new Editor. The most advanced "WYSWYG" (if you can say so) editor ever.
Key features
- It is a block-styled editor
- It returns clean data output in JSON
- Designed to be extendable and pluggable with a simple API
- Native OctoberCMS events support for convenient extending of custom blocks
Integrations ready:
- RainLab.Blog
- RainLab.StaticPages
- Lovata.GoodNews
- Indikator.News
Blocks supported:
- Paragraph
- Header
- List (ul, ol)
- CheckList
- Link (Opengraph)
- Table
- Code
- Raw
- Embed
- Delimiter
- Image (paste url, drag'n'drop, upload)
What does it mean «block-styled editor»
Workspace in classic editors is made of a single contenteditable element, used to create different HTML markups. Editor workspace consists of separate Blocks: paragraphs, headings, images, lists, quotes, etc. Each of them is an independent contenteditable element (or more complex structure) provided by Plugin and united by Editor's Core.
There are dozens of ready-to-use Blocks and the simple API for creation any Block you need. For example, you can implement Blocks for Tweets, Instagram posts, surveys and polls, CTA-buttons and even games.
What does it mean clean data output
Classic WYSIWYG-editors produce raw HTML-markup with both content data and content appearance. On the contrary, Editor.js outputs JSON object with data of each Block.
Given data can be used as you want: render with HTML for Web clients, render natively for mobile apps, create markup for Facebook Instant Articles or Google AMP, generate an audio version and so on.
How to install
Install plugin by OctoberCMS plugin updater.
Go to Settings –> Updates&Plugins find EditorJS in plugin search. Click on icon and install it.
Usage
After installing plugin, you are now able to set in fields.yaml type:editorjs to any desirable field. That's all.
You are not limited of how many editors can be rendered at one page.
How to enable integrations
- Make sure that the desirable plugin for integration is installed in system (list of supported plugins listed in Key Features section)
- Go to Settings
- In the sidebar find
Editor Settingsbutton insideEditor tab - Enable desirable integrations
- Done.
How to render HTML from Editor JSON
To implement Editor to your Model, you must prepare a column in a database that is set to text.
- Create a column with type
textat your Model table, or use an already existing one. - Add
'grch.Editor.Behaviors.ConvertToHtml'to $implement attribute of your model. - Add getHtmlAttribute() method and paste line of code as in the example below:
return $this->convertJsonToHtml($this->YourColumnName);
- Render your field
{{ model.YourColumnName_html|raw }} - Add editor styles to your page by
<link href="/plugins/grch/editor/assets/css/editorjs.css" rel="stylesheet">
Example of model:
// ...
class Post extends Model
{
// ...
public $implement = [
'Grch.Editor.Behaviors.ConvertToHtml'
];
// ...
public function getContentHtmlAttribute()
{
return $this->convertJsonToHtml($this->content);
}
}
Example of rendering:
{{ post.content_html|raw }}
Extending
You can create any new block as you like by reading official documentation that you can find here Editor.Js docs
After creating new JS scripts with new block type Class, you can go through steps below to extend EditorJS formwidget:
- Create new method in your Plugin.php file named
registerEditorBlocks(), and by example below add blocks array and scripts for them./** * Registers additional blocks for EditorJS * @return array */ public function registerEditorBlocks() { return [ 'raw' => [ 'settings' => [ 'class' => 'RawTool' ], 'validation' => [ 'html' => [ 'type' => 'string', 'allowedTags' => '*', ] ], 'scripts' => [ '/plugins/grch/editor/formwidgets/editorjs/assets/js/tools/raw.js', ], 'view' => 'grch.editor::blocks.raw' ], ]; } - Done.
Now you can even publish your editorjs extender plugin to marketplace, so everyone can use your block!
Editor.js developed by CodeX Club of web-development. Adapted for OctoberCMS by Nick Khaetsky. reazzon.ru
grch/editor-plugin 适用场景与选型建议
grch/editor-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 05 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 grch/editor-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 grch/editor-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 45
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-13