Serve content-addressed editing assets to Laravel Filament hosts
Verify WYSIWYG package / Full verification (pull_request) Successful in 50s
Verify WYSIWYG package / Full verification (pull_request) Successful in 50s
This commit is contained in:
@@ -15,4 +15,9 @@ jobs:
|
||||
cache: npm
|
||||
- run: npm ci --ignore-scripts
|
||||
- run: npm run verify
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.3'
|
||||
tools: composer
|
||||
- run: composer validate --strict && php -l src/WysiwygServiceProvider.php
|
||||
- run: git diff --check
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# TROPIKAL Filament WYSIWYG
|
||||
|
||||
A small, dependency-free browser editing engine for real website previews.
|
||||
Works with Filament 3 and 5 host adapters; it has no PHP or framework dependency.
|
||||
Works with Filament 3 and 5 host adapters. The browser engine has no framework
|
||||
dependency; an optional Laravel 12 service provider serves the same engine to
|
||||
the Filament parent without copying assets between repositories.
|
||||
It is not a CMS, rich-document editor or generic HTML page builder.
|
||||
|
||||
```js
|
||||
@@ -37,3 +39,10 @@ durable)` reports storage denial so the UI can ask the user to keep a copy.
|
||||
Only call the host's authorized editing command from `deliver`; do not accept
|
||||
operations or arbitrary executable payloads from browser storage. Publication
|
||||
should wait while `hasPending()` is true. This is not a synchronization service.
|
||||
|
||||
Laravel hosts can install the Composer package `tropikal-ai/filament-wysiwyg`
|
||||
from this public VCS repository at an immutable released tag, then import
|
||||
`WysiwygServiceProvider::assetUrl()` in their existing Filament view. The route
|
||||
serves only the package's static module and validates its content hash. It has
|
||||
no content API, database or configurable file path. The npm and Composer
|
||||
lockfiles should resolve to the same release commit.
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "tropikal-ai/filament-wysiwyg",
|
||||
"description": "Immutable browser editing assets for Laravel 12 Filament website previews",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"require": { "php": "^8.2", "illuminate/support": "^12.0" },
|
||||
"autoload": { "psr-4": { "Tropikal\\FilamentWysiwyg\\": "src/" } },
|
||||
"extra": { "laravel": { "providers": ["Tropikal\\FilamentWysiwyg\\WysiwygServiceProvider"] } }
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Tropikal\FilamentWysiwyg;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
final class WysiwygServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot(): void
|
||||
{
|
||||
Route::get('/tropikal-wysiwyg/{hash}/editor.js', function (string $hash) {
|
||||
abort_unless(hash_equals(self::hash(), $hash), 404);
|
||||
|
||||
return response()->file(__DIR__.'/index.js', [
|
||||
'Content-Type' => 'application/javascript; charset=UTF-8',
|
||||
'Cache-Control' => 'public, max-age=31536000, immutable',
|
||||
]);
|
||||
})->name('tropikal-wysiwyg.asset');
|
||||
}
|
||||
|
||||
public static function assetUrl(): string
|
||||
{
|
||||
return route('tropikal-wysiwyg.asset', ['hash' => self::hash()]);
|
||||
}
|
||||
|
||||
private static function hash(): string
|
||||
{
|
||||
return hash_file('sha256', __DIR__.'/index.js');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user