dubizzlelabs/nova-tiptap 问题修复 & 功能扩展

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

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

dubizzlelabs/nova-tiptap

Composer 安装命令:

composer require dubizzlelabs/nova-tiptap

包简介

A Laravel Nova tiptap editor field.

README 文档

README

GitHub GitHub release (latest by date)

Laravel Nova Tiptap Editor Field

A Laravel Nova implementation of the tiptap editor for Vue.js by @ueberdosis.

Installation

Install via composer:

composer require dubizzleLabs/nova-tiptap

Usage with default settings:

Tiptap::make('FieldName')

This will give you just the bold and italic buttons.

You will also have to add this use statement to the top of the file:

use DubizzleLabs\Tiptap\Tiptap;

Usage with your selection of buttons:

Tiptap::make('FieldName')
  ->buttons([
        'heading',
        '|',
        'italic',
        'bold',
        '|',
        'link',
        'code',
        'strike',
        'underline',
        'highlight',
        '|',
        'bulletList',
        'orderedList',
        'br',
        'codeBlock',
        'blockquote',
        '|',
        'horizontalRule',
        'hardBreak',
        '|',
        'table',
        '|',
        'image',
        '|',
        'textAlign',
        '|',
        'rtl',
        '|',
        'history',
        '|',
        'editHtml',
    ])
    ->headingLevels([2, 3, 4]),

| and br

You can use | to define a vertical line between two buttons, and you can use br to define a hard break after a button.

Headings and headingLevels

When just passing the string 'heading' you will have H1, H2 and H3 to choose from. You can set the level of headings by using for example headingLevels([2, 3, 4]) which will give you H2 through H4.

Links and linkSettings and fileSettings

When just passing the string 'link' you will be able to link text with an URL and define if the link should open in a new window. You will also be able to link text with a file you uploaded to the server. You can optionally use linkSettings to define if this file upload should be possible/visible like so:

Tiptap::make('FieldName')
  ->buttons([
      'italic',
      'bold',
      'link',
  ])
  ->linkSettings([
      'withFileUpload' => false,
  ]),

And you can optionally use fileSettings to define the disk and the path:

Tiptap::make('FieldName')
  ->buttons([
      'italic',
      'bold',
      'link',
  ])
  ->fileSettings([
      'disk' => 'your_custom_disk',
      'path' => 'your/custom/path',
  ]),

If no disk is defined here, it assumes public if a public disk is defined in your config/filesystems.php, otherwise it assumes config('filesystems.default').

And if no path is defined here, it assumes the root folder of that disk.

Images and imageSettings

With the button 'image' you can let the user add images either from a file upload or from adding a URL. And you can optionally use imageSettings to define the disk and the path:

Tiptap::make('FieldName')
  ->buttons([
      'italic',
      'bold',
      'image',
  ])
  ->imageSettings([
      'disk' => 'your_custom_disk',
      'path' => 'your/custom/path',
  ]),

If no disk is defined here, it assumes public if a public disk is defined in your config/filesystems.php, otherwise it assumes config('filesystems.default').

And if no path is defined here, it assumes the root folder of that disk.

Disallowing file upload for images

For images you can also disallow the file upload completely with the withFileUpload attribute:

Tiptap::make('FieldName')
  ->buttons([
      'italic',
      'bold',
      'image',
  ])
  ->imageSettings([
      'withFileUpload' => false,
  ]),

Text alignment with textAlign

When adding textAlign you get four buttons for aligning text left, right, center and justify. The default alignment will be left.

Tiptap::make('FieldName')
  ->buttons([
      'italic',
      'bold',
      'textAlign',
  ]),

If you want to change some of this, you can use the methods alignments and defaultAlignment:

Tiptap::make('FieldName')
  ->buttons([
      'italic',
      'bold',
      'textAlign',
  ])
  ->alignments(['right', 'left'])
  ->defaultAlignment('right'),

RTL support with rtl

When adding rtl you get a button for toggling RTL mode for all selected block elements (dir="rtl").

Tiptap::make('FieldName')
  ->buttons([
      'italic',
      'bold',
      'rtl',
  ]),

The two different "code" buttons

'code' is inline code (like <code></code>) while 'codeBlock' will give you <pre><code></code></pre>.

Syntax Highlighting when using codeBlock

Tiptap::make('FieldName')
  ->buttons([
      'italic',
      'bold',
      'code',
      'codeBlock'
  ])
  ->syntaxHighlighting(),

When using 'codeBlock' you can turn on syntax highlighting by using syntaxHighlighting().

Edit HTML

the 'editHtml' option will enable the ability to toggle to the tiptap editor to a textarea and manually edit the HTML

HTML theme when using editHtml

Tiptap::make('FieldName')
  ->buttons([
      'italic',
      'bold',
      'code',
      'editHtml'
  ])
  ->htmlTheme('night'),

When using 'editHtml' you can set the theme by using using htmlTheme(). The default theme used is "material". You can find all the codemirror themes used here .

Save JSON

You can optionally use saveAsJson to enable the ability to save the tiptap editor content as JSON in the field

Tiptap::make('FieldName')
  ->buttons([
      'italic',
      'bold',
      'code'
  ])
  ->saveAsJson(),

Visibility in index view

Like Textarea and Trix fields this field is hidden from index views. You can make the content visible by using a computed field.

Screenshots

The tiptap editor with all the buttons:

the tiptap editor with all the buttons

The idea is that the editor can be themed together with the rest of Nova - here it is looking differently just by using the Laravel Nova Stripe Theme:

the tiptap editor with all the buttons

Licence

The MIT License (MIT). Please see License File for more information.

dubizzlelabs/nova-tiptap 适用场景与选型建议

dubizzlelabs/nova-tiptap 是一款 基于 CSS 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: CSS

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-16