n-ramos/celebrimbor-filament-plugin
Composer 安装命令:
composer require n-ramos/celebrimbor-filament-plugin
包简介
Filament 5 plugin connecting an Eloquent resource to the Celebrimbor visual page builder, with interface contracts enforcing what the model/resource must expose.
README 文档
README
n-ramos/celebrimbor-filament-plugin
A Filament 5
plugin that plugs the @n-ramos/celebrimbor visual page
builder into any Eloquent resource.
It follows the page builder's integration philosophy to the letter:
- blocks stay TypeScript-only — PHP never redefines them;
- Laravel only stores and transports JSON;
- the editor is the web component, two-way bound to Livewire.
What this package adds on top is enforcement: interface contracts that make the compiler/runtime refuse to mount the field unless the model exposes exactly what the editor needs.
Requirements
- PHP 8.2+
- Filament 5
No front-end build step. The plugin ships a self-contained editor bundle
(vendored from @n-ramos/celebrimbor-embed)
that defines the <my-page-builder> web component with the basic block library.
Installation
composer require n-ramos/celebrimbor-filament-plugin php artisan filament:assets
That's it — the editor works out of the box. filament:assets publishes the
bundled JS/CSS (versioned with the package) into public/.
Publish the config (optional):
php artisan vendor:publish --tag="celebrimbor-config"
Register the plugin on your panel
use NRamos\CelebrimborFilament\PageBuilderPlugin; public function panel(Panel $panel): Panel { return $panel ->plugin( PageBuilderPlugin::make() ->defaultPreset('marketing') ->assetEndpoint('/admin/page-builder/assets/pick'), ); }
(Advanced) Bring your own bundle
The default bundle ships the basic block library. To register custom blocks
or fields, set celebrimbor.serve_bundle to false and provide your own bundle
that defines <my-page-builder> — exactly as in the Celebrimbor docs:
import "@n-ramos/celebrimbor-editor-element/styles.css"; import { createBlockRegistry } from "@n-ramos/celebrimbor-core"; import { registerBasicBlocks } from "@n-ramos/celebrimbor-blocks-basic"; import { definePageBuilderElement } from "@n-ramos/celebrimbor-editor-element"; const registry = registerBasicBlocks(createBlockRegistry()); definePageBuilderElement({ registry }); // defines <my-page-builder>
The plugin's Livewire glue binds to whatever <my-page-builder> you register.
The contracts (what gets enforced)
1. The model must implement HasPageBuilderContent
This is the hard requirement. The field throws
MissingPageBuilderContract at mount time if the bound model does not implement
it. The InteractsWithPageBuilderContent trait gives you a zero-boilerplate
implementation (and auto-casts the column to array).
use NRamos\CelebrimborFilament\Concerns\InteractsWithPageBuilderContent; use NRamos\CelebrimborFilament\Contracts\HasPageBuilderContent; use NRamos\CelebrimborFilament\Enums\PageBuilderFormat; use Illuminate\Database\Eloquent\Model; class Page extends Model implements HasPageBuilderContent { use InteractsWithPageBuilderContent; protected $fillable = ['title', 'slug', 'status', 'document']; // Optional overrides (these are the defaults): protected string $pageBuilderColumn = 'document'; protected string $pageBuilderFormat = PageBuilderFormat::Portable->value; }
Migration:
Schema::create('pages', function (Blueprint $table) { $table->id(); $table->string('title'); $table->string('slug')->unique(); $table->string('status')->default('draft'); $table->json('document'); $table->timestamps(); });
2. (Optional) declare your blocks with ProvidesPageBuilderBlocks
Implement it on the model or the resource to bind the editor to a specific preset/element without configuring the field every time:
use NRamos\CelebrimborFilament\Contracts\ProvidesPageBuilderBlocks; class Page extends Model implements HasPageBuilderContent, ProvidesPageBuilderBlocks { use InteractsWithPageBuilderContent; public function pageBuilderPreset(): string { return 'marketing'; } public function pageBuilderEditorElement(): string { return 'my-page-builder'; } }
Usage in a resource form
use NRamos\CelebrimborFilament\Forms\Components\PageBuilderField; use Filament\Forms; public static function form(Schema $schema): Schema { return $schema->components([ Forms\Components\TextInput::make('title')->required(), Forms\Components\TextInput::make('slug')->required(), PageBuilderField::make('document') ->columnSpanFull(), ]); }
Per-field overrides are available when you need them:
PageBuilderField::make('document') ->format(PageBuilderFormat::Document) ->blocksPreset('landing') ->editorElement('my-page-builder') ->assetEndpoint('/admin/page-builder/assets/pick') ->assetHeaders(['X-CSRF-TOKEN' => csrf_token()]) ->minHeight('800px') ->columnSpanFull();
Resolution order for every option: explicit field setter → model/resource contract → panel plugin default → config file.
How it fits together
Filament form
└─ PageBuilderField (celebrimbor::field)
└─ <div x-data="celebrimborField({ state: $entangle(...) })">
└─ <my-page-builder> ← provided by the bundled editor (or your own)
├─ emits my-page-builder:change → updates Livewire state
└─ value property ← seeded from Livewire state
- The field validates the model contract before rendering.
format/preset/editorElementare resolved from the contracts/config.- The JSON is persisted by Filament like any other
array-cast column. - Rendering the final page is the host front-end's job (Celebrimbor stays the single source of truth for blocks).
Asset picker
Point assetEndpoint at a route returning a Celebrimbor-compatible payload:
{ "id": "1", "url": "https://cdn/img.jpg", "alt": "…", "width": 1200, "height": 800 }
Documentation
- Installation
- Contracts
- Configuration
- Front-end & rendering
- Testing
- Rendering (preview & public, host-owned)
- Declaring a new block (end to end)
- Releasing (maintainers — the npm → Composer bridge)
- Local Laravel test (copy-paste scaffolding)
Testing
composer install
composer test
A Pest + Testbench suite covers the enum, the trait, the exception, the plugin config, and the field's contract enforcement and option-resolution priority. See docs/05-testing.md.
License
MIT — see LICENSE.md.
n-ramos/celebrimbor-filament-plugin 适用场景与选型建议
n-ramos/celebrimbor-filament-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「page-builder」 「filament」 「filament-plugin」 「celebrimbor」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 n-ramos/celebrimbor-filament-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 n-ramos/celebrimbor-filament-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 n-ramos/celebrimbor-filament-plugin 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Comprehensive PHPStan stubs for Elementor and Elementor Pro WordPress page builder - auto-generated, self-contained, plug & play
A visual drag-and-drop page builder for Filament admin panels, powered by GrapeJS v3. Build landing pages, marketing sites, and custom content pages without writing code.
A section-based page builder for Laravel using JSON layouts, sections, blocks, and themes.
SilverStripe module to allow for modular, block based content in SilverStripe
Dynamic page customization system for Bagisto - Create and manage page sections, fields, and content from the backend with API support
Predefined section-based page builder for Laravel + Inertia + React.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 38
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-09