advoor/nova-editor-js 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

advoor/nova-editor-js

Composer 安装命令:

composer require advoor/nova-editor-js

包简介

A Laravel Nova field bringing EditorJs magic to Nova.

README 文档

README

Latest Version on Github Total Downloads

A Laravel Nova implementation of Editor.js by @advoor.

Installation

Install via composer:

composer require advoor/nova-editor-js

Publish the config file

php artisan vendor:publish --provider="Advoor\NovaEditorJs\FieldServiceProvider"

Version Compatibility

Laravel Nova 4.x isn't backwards compatible with 3.x, so we had to make a version split. Please use the below table to find which versions are suitable for your installation.

Package version Nova Version Laravel Version PHP version
4.x 4.x - 5.x 10.x - 13.x 8.2+
3.x 4.x 8.x - 10.x 8.1+
2.x 2.x - 3.x 5.x - 8.x 5.6 - 7.4

Note that we really pushed the PHP version up. If you're staying on new versions of Laravel and Nova, we're expecting your PHP version to match that behaviour.

Upgrade

See the upgrade guide.

Usage

To add EditorJS to your application, you'll need to modify your Nova resource. For ease-of-use we also recommend to update your models, but that's optional.

Updating your Nova resource

This package exposes a NovaEditorJsField that takes care of displaying the HTML contents and providing the user with the EditorJS field.

To use it, simply import the field,

use Advoor\NovaEditorJs\NovaEditorJsField;

use it in your fields array,

return [
    // …
    NovaEditorJsField::make('about'),
];

And boom, you've got yourself a fancy editor.

Updating your models (optional)

For ease-of-use, we recommend you add the NovaEditorJsCast to the $casts on your models. This will map the value to a NovaEditorJsData model, which can be returned in Blade (rendering HTML), or sent via API calls (rendering JSON, unless you call toHtml on it or cast it to a string).

use Advoor\NovaEditorJs\NovaEditorJsCast;

class User extends Model {
    protected $casts = [
        'about' => NovaEditorJsCast::class,
    ];
}

Since the NovaEditorJsData model is an Htmlable, Blade will recognize it as safe HTML. This means you don't have to use Blade "unescaped statements".

<article>
    <h1>About {{ $user->name }}</h1>
    {{ $user->about }}
</article>

Rendering HTML without model changes

You can also use the NovaEditorJs facade to render HTML from stored data.

NovaEditorJs::generateHtmlOutput($user->about);

The return value of generateHtmlOutput is an HtmlString, which is treated as safe by Blade. This means you don't have to use Blade "unescaped statements".

<article>
    <h1>About {{ $user->name }}</h1>
    {{ NovaEditorJs::generateHtmlOutput($user->about) }}
</article>

Customizing

You can configure the editor settings and what tools the Editor should use, by updating the editorSettings and toolSettings property in the config file respectively.

From the config, you can define the following editor settings:

  • placeholder (docs) - The placeholder to show in an empty editor
  • defaultBlock (docs) - The block that's used by default
  • autofocus (docs) - If the editor should auto-focus, only use if you never have multiple editors on a page and after considering the accessibility implications
  • rtl (docs) - Set to true to enable right-to-left mode, for languages like Arabic and Hebrew

Furthermore, you can customize the tools the editor should use. The following tools are enabled by default:

You can customize the views for each component, by changing the view in resources/views/vendor/nova-editor-js/.

The Embeds tool is triggered by pasting URLs to embeddable content. It does not have an entry in the "Add" menu.

Registering custom components

Please refer to the extending Nova EditorJS guide on instructions on how to register custom components.

advoor/nova-editor-js 适用场景与选型建议

advoor/nova-editor-js 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 219.32k 次下载、GitHub Stars 达 91, 最近一次更新时间为 2019 年 04 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「wysiwyg」 「editor」 「nova」 「laravel」 「editorjs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 advoor/nova-editor-js 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 advoor/nova-editor-js 我们能提供哪些服务?
定制开发 / 二次开发

基于 advoor/nova-editor-js 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 219.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 92
  • 点击次数: 26
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 91
  • Watchers: 5
  • Forks: 65
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-02