Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Jodit Laravel Package

nasirkhan/laravel-jodit

Laravel package that integrates the Jodit WYSIWYG editor via a reusable Blade component. Works in Blade, view components, and Livewire with wire-model syncing. Includes a configurable server-side file browser/uploader connector and loads assets via CDN (no build step).

View on GitHub
Deep Wiki
Context7
## Getting Started

### Minimal Setup
1. **Install the package**:
   ```bash
   composer require nasirkhan/laravel-jodit

The service provider is auto-discovered.

  1. Ensure asset stacks exist in your layout:

    @stack('after-styles')
    @stack('after-scripts')
    
  2. Use the component in a form:

    <x-jodit::editor name="content" :value="old('content', $post->content ?? '')" />
    

First Use Case: Basic Livewire Integration

For a Livewire component, sync the editor with a property:

<x-jodit::editor name="description" wire-model="description" />

The component automatically handles wire:ignore and debounced sync.


Implementation Patterns

Blade Integration

  • Plain Blade Forms:
    <x-jodit::editor
        name="article_body"
        :value="$article->body"
        placeholder="Write your article here..."
        :required="true"
    />
    
  • Custom Toolbar:
    <x-jodit::editor
        name="editor_content"
        :buttons="['bold', 'italic', '|', 'link', 'image']"
    />
    

Livewire Integration

  • Debounced Sync: The wire-model prop automatically debounces changes (default: 300ms). Override with :debounce="500" if needed.
  • Dynamic Updates:
    // Livewire component
    public $content = '';
    
    // Automatically updates via JS API
    

File Browser Customization

  • Disable File Browser:
    <x-jodit::editor name="excerpt" :file-browser="false" />
    
  • Custom Connector Route:
    <x-jodit::editor
        name="content"
        connector-url="{{ route('admin.jodit.connector') }}"
    />
    

Configuration Overrides

Publish the config and customize:

php artisan vendor:publish --tag=jodit-config

Modify config/jodit.php to:

  • Change CDN URLs for offline builds.
  • Adjust default toolbar buttons.
  • Set custom storage paths or middleware.

Gotchas and Tips

Common Pitfalls

  1. Missing Asset Stacks: Forgetting @stack('after-styles') or @stack('after-scripts') in your layout will break the editor. Verify these exist in <head> and before </body>.

  2. Livewire Model Binding: Ensure the wire-model prop matches the Livewire property name exactly (case-sensitive). Example:

    <!-- Correct -->
    <x-jodit::editor name="bio" wire-model="bio" />
    
    <!-- Incorrect (case mismatch) -->
    <x-jodit::editor name="Bio" wire-model="bio" />
    
  3. File Upload Permissions: If using the built-in file browser, ensure the storage/app/public/jodit directory is writable:

    mkdir -p storage/app/public/jodit && chmod -R 755 storage/app/public/jodit
    
  4. Toolbar Button Names: Use the exact button names from the Buttons Reference. For example, align (dropdown) vs. left, center, etc. (individual buttons).

Debugging Tips

  • Console Errors: Check the browser console for missing assets or JS errors. Common issues:

    • CDN blocked by firewall (test with https://unpkg.com/jodit@4.1.16/es2021/jodit.min.js directly).
    • Conflicting jQuery versions (Jodit requires jQuery 3.x).
  • Livewire Sync Issues: If changes aren’t syncing, verify:

    • The wire-model prop is correctly bound.
    • No JavaScript errors in the console.
    • The debounce delay isn’t too long (reduce :debounce temporarily for testing).

Extension Points

  1. Custom File Browser Backend: Disable the built-in connector ('route' => ['enabled' => false]) and point the editor to a custom endpoint:

    <x-jodit::editor
        name="content"
        connector-url="{{ route('spatie.dropzone.connector') }}"
    />
    
  2. Predefined Toolbar Profiles: Extend the config to add reusable button sets:

    // config/jodit.php
    'profiles' => [
        'minimal' => ['bold', 'italic', 'link', 'image'],
        'rich'    => ['bold', 'italic', '|', 'align', '|', 'ul', 'ol', '|', 'link', 'image', 'video'],
    ],
    

    Use in Blade:

    <x-jodit::editor name="content" profile="minimal" />
    
  3. Middleware for Connector: Restrict access to the connector route by adding middleware to config/jodit.php:

    'route' => [
        'middleware' => ['web', 'auth', 'verified'],
    ],
    

Performance Notes

  • Lazy-Loading: For large applications, consider lazy-loading the editor’s JS/CSS only on pages where it’s needed.
  • Image Optimization: If using intervention/image-laravel, ensure the resize and crop features are configured in config/jodit.php for optimal uploads.

---
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests