Skip to content

Commit

Permalink
follow Filament plugin pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
tanthammar committed Sep 14, 2024
1 parent 995d172 commit dbc3e77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
5 changes: 3 additions & 2 deletions resources/views/json-editor.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
:state-path="$getStatePath()"
>
<div class="w-full"
x-load-css="['{{ asset('css/awcodes/headings/invaders-filament-jsoneditor.css') }}']"
x-load-css="[@js(\Filament\Support\Facades\FilamentAsset::getStyleHref('invaders-filament-jsoneditor', package: 'invaders/jsoneditor'))]"
data-js-before="app.js"
x-load-js="['{{ asset('js/awcodes/headings/invaders-filament-jsoneditor.js') }}']"
x-load-js="[@js(\Filament\Support\Facades\FilamentAsset::getScriptSrc('invaders-filament-jsoneditor', package: 'invaders/jsoneditor'))]"
data-dispatch="jsoneditor-loaded"
x-on:jsoneditor-loaded-js.window="start"
x-data="{
state: $wire.entangle('{{ $getStatePath() }}'),
editor: null,
destroy() {
this.editor = null;
console.info('destroy');
},
start() {
$nextTick(() => {
Expand Down
20 changes: 7 additions & 13 deletions src/FilamentJsoneditorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,18 @@ public function configurePackage(Package $package): void
{
$package
->name(static::$name)
->hasConfigFile()
->hasAssets()
->hasViews();

$this->publishes([
__DIR__ . '/../dist/jsoneditor/img/jsoneditor-icons.svg' => public_path('css/awcodes/headings/img/jsoneditor-icons.svg'),
__DIR__ . '/../dist/jsoneditor/jsoneditor.min.css' => public_path('css/awcodes/headings/jsoneditor.min.css'),
__DIR__ . '/../dist/jsoneditor/jsoneditor.min.js' => public_path('js/awcodes/headings/jsoneditor.min.js'),
], 'filament-jsoneditor');
__DIR__ . '/../dist/jsoneditor/img/jsoneditor-icons.svg' => public_path('css/invaders/jsoneditor/img/jsoneditor-icons.svg'),
], 'filament-jsoneditor-img');
}

public function packageRegistered(): void
public function packageBooted(): void
{
if ($this->app->runningInConsole()) {
FilamentAsset::register([
Css::make('invaders-filament-jsoneditor', __DIR__ . '/../dist/jsoneditor/jsoneditor.min.css'),
Js::make('invaders-filament-jsoneditor', __DIR__ . '/../dist/jsoneditor/jsoneditor.min.js'),
], 'awcodes/headings');
}
FilamentAsset::register([
Css::make('invaders-filament-jsoneditor', __DIR__ . '/../dist/jsoneditor/jsoneditor.min.css')->loadedOnRequest(),
Js::make('invaders-filament-jsoneditor', __DIR__ . '/../dist/jsoneditor/jsoneditor.min.js')->loadedOnRequest(),
], 'invaders/jsoneditor');
}
}

0 comments on commit dbc3e77

Please sign in to comment.