giantpeach/acf-editorjs
Composer 安装命令:
composer require giantpeach/acf-editorjs
包简介
ACF field for EditorJS rich text editor
README 文档
README
A WordPress plugin that adds Editor.js as a field type for Advanced Custom Fields.
Features
- Rich text editing with Editor.js
- Multiple block types: Header, Paragraph, List, Quote, Code, Table, Warning, Image, Embed
- Configurable tools per field
- JSON data storage
- Composer installation support
Requirements
- PHP >= 7.4
- WordPress >= 5.0
- Advanced Custom Fields >= 5.8
Installation
Via Composer
- Add the plugin to your project:
composer require giantpeach/acf-editorjs
- The plugin will be installed to your
mu-pluginsorpluginsdirectory (depending on your composer configuration).
Manual Installation
- Download the plugin
- Upload to your
/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
Usage
Once activated, you'll have a new "EditorJS" field type available in ACF field groups.
Field Settings
- Default Value: Set the default content for new posts
- Placeholder Text: Placeholder shown in empty editor
- Available Tools: Choose which Editor.js tools to enable
- Minimum Height: Set the minimum height of the editor
Retrieving Data
The field returns Editor.js data as an array:
$content = get_field('editorjs_field'); // Returns array like: // [ // 'time' => 1234567890, // 'blocks' => [ // [ // 'type' => 'paragraph', // 'data' => [ // 'text' => 'Hello world!' // ] // ] // ], // 'version' => '2.22.0' // ]
Rendering Content
You'll need to create your own renderer for the Editor.js data. Example:
function render_editorjs_content($data) { if (empty($data['blocks'])) { return ''; } $html = ''; foreach ($data['blocks'] as $block) { switch ($block['type']) { case 'paragraph': $html .= '<p>' . esc_html($block['data']['text']) . '</p>'; break; case 'header': $level = $block['data']['level']; $html .= '<h' . $level . '>' . esc_html($block['data']['text']) . '</h' . $level . '>'; break; // Add more block types as needed } } return $html; }
Development
Building Assets
The plugin includes EditorJS and its tools locally for better control and performance:
- Install dependencies:
npm install - Build all assets:
npm run build - For development with watch mode:
npm run dev
Build Process
npm run build- Builds the complete bundlenpm run dev- Builds and watches for changesnpm run clean- Removes the dist directory
The build process creates:
dist/acf-editorjs.iife.js- Complete bundle with EditorJS core, tools, and field initialization (~357KB)
License
MIT
giantpeach/acf-editorjs 适用场景与选型建议
giantpeach/acf-editorjs 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 26 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 07 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 giantpeach/acf-editorjs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 giantpeach/acf-editorjs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-22