Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor cannot be used outside of a Livewire component #802

Open
andyunleashed opened this issue Dec 3, 2024 · 3 comments
Open

Editor cannot be used outside of a Livewire component #802

andyunleashed opened this issue Dec 3, 2024 · 3 comments

Comments

@andyunleashed
Copy link

Using the boilerplate component, customized with a model or not - e.g <flux:editor wire:model="content" label="…" description="…" /> throws this error: Using $this when not in object context

Image

I tried publishing the component and then looking at the code inside and if I comment out the assets method - e.g:

{{-- @assets --}}
<flux:editor.scripts />
<flux:editor.styles />
{{-- @endassets --}}

It does load without an issue:
Image

@mauritskorse
Copy link

mauritskorse commented Dec 3, 2024

Looks like the error when using livewire blade directives outside of a livewire component.
I can reproduce this after running flux:publish editor.

For me replacing the @assets for @push('scripts') works. I guess this would require some documentation or improvement of the flux:publish script.

@joshhanley
Copy link
Member

@mauritskorse at this stage, using Flux components outside of a Livewire component isn't officially supported (although most components will work). @assets is a Livewire directive, hence why you would be getting that error.

@calebporzio I wonder whether we could have something users can add to a service provider (or a config option - although I prefer adding to a service provider) to disable including the assets in editor/index.blade.php and they can manually add them to their layout file (or just the pages they want to include the editor on)?

Something like

class AppServiceProvider
{
    public function boot()
    {
        FluxPro::injectEditorAssets(false);
    }
}

@mauritskorse
Copy link

@mauritskorse at this stage, using Flux components outside of a Livewire component isn't officially supported (although most components will work). @assets is a Livewire directive, hence why you would be getting that error.

Ah, yes, that sounds fair :)
And indeed, when I use a published flux:editor from within a livewire component the issue doesn't occur.

@joshhanley joshhanley changed the title flux:editor error - "Using $this when not in object context" Editor component cannot be used outside of a Livewire component Dec 19, 2024
@joshhanley joshhanley changed the title Editor component cannot be used outside of a Livewire component Editor cannot be used outside of a Livewire component Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants