creagia / filament-code-field
一个 Filamentphp 输入字段,用于编辑或查看代码数据。
3.0.1
2024-03-21 13:14 UTC
Requires
- php: ^8.2
- filament/filament: ^3.2
- illuminate/contracts: ^9.0||^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.0.1
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0||^7.0
- orchestra/testbench: ^7.0||^8.0
- pestphp/pest: ^2.34.4
- pestphp/pest-plugin-laravel: ^2.3.0
- pestphp/pest-plugin-livewire: ^2.1.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5||^10.0||^11.0
- spatie/laravel-ray: ^1.26
- dev-main
- 3.0.1
- 3.0.0
- v2.x-dev
- 2.0.0
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/github_actions/dependabot/fetch-metadata-2.1.0
- dev-dependabot/github_actions/aglipanci/laravel-pint-action-2.3.1
- dev-dependabot/github_actions/ramsey/composer-install-3
- dev-patch-1
This package is auto-updated.
Last update: 2024-08-29 14:39:47 UTC
README
为 Filamentphp 管理面板和表单构建器提供动力的 CodeMirror 代码字段。
具有代码自动完成、浅色/深色模式、多种语言、只读模式等。
查看截图并了解更多关于此包的信息,请参阅我们的 博客文章。
安装
此包的最新版本需要 Filament 3 和 Laravel 11。
您可以通过 composer 安装此包
composer require creagia/filament-code-field
⚠️ 使用版本 2.x.x
以支持 Filament 3 和 Laravel 10 ⚠️
composer require "creagia/filament-code-field:^2.0.0"
⚠️ 使用版本 1.x.x
以支持 Filament 2 ⚠️
composer require "creagia/filament-code-field:^1.0.0"
用法
创建代码字段很简单,只需为所需的属性实例化 CodeField
类。
use Creagia\FilamentCodeField\CodeField; return $form ->schema([ CodeField::make('my_json'), // other fields ]);
选择其他语言
默认情况下,将创建一个 JSON 字段。
如果您想为其他支持的语言创建字段,可以使用 setLanguage()
和辅助方法。
支持的语言:JSON、PHP、HTML、XML 和 JavaScript (JS)。
use Creagia\FilamentCodeField\CodeField; return $form ->schema([ CodeField::make('js_code') ->setLanguage(CodeField::JS), // or ->jsField() ]);
禁用代码自动完成
默认情况下,字段带有启用的代码自动完成/建议。
要禁用此功能,请使用 disableAutocompletion()
。
use Creagia\FilamentCodeField\CodeField; return $form ->schema([ CodeField::make('js_code') ->htmlField() ->disableAutocompletion(), ]);
行号
可以使用 withLineNumbers()
方法启用行号。
use Creagia\FilamentCodeField\CodeField; return $form ->schema([ CodeField::make('json') ->withLineNumbers(), ]);
只读模式
添加 Filamentphp 的 disabled()
方法将使代码字段为只读。
use Creagia\FilamentCodeField\CodeField; return $form ->schema([ CodeField::make('json') ->disabled(), ]);
Filamentphp 方法
当然,代码字段扩展了 Filamentphp
字段类,您可以使用所有常规方法,如 label()
。
use Creagia\FilamentCodeField\CodeField; return $form ->schema([ CodeField::make('json') ->label('Your JSON data') ->hint('Top right corner info') ->helper('More info after the text field') // more methods , ]);