I have installed it via npm and also have been given some code snippets.
Assistant
Great! Since you installed CKEditor 5 via npm and have some code snippets ready, I can help you integrate it properly into your Laravel app.
To ensure a smooth integration, could you share the code snippets you have? That way I can review and guide you on how to use them effectively in your Laravel project.
Meanwhile, here’s an overview of what the setup usually looks like:
Typical process after installing CKEditor 5 via npm:
Import CKEditor in your JavaScript
In resources/js/app.js (or wherever you handle your JS):
Make sure your Blade layout or view includes the compiled JS file (usually public/js/app.js), like:
blade
<script src="{{ mix('js/app.js') }}"></script>
If you send me your snippets, I can tailor the instructions to your code and help troubleshoot any issues.
It sounds like you're running into a CSRF (Cross-Site Request Forgery) token mismatch issue in your Laravel form submission. This is a very common issue and easy to fix.
What is the problem?
Laravel includes CSRF protection on all POST, PUT, PATCH, and DELETE routes by default. This means every form submitting data to your Laravel backend must include a CSRF token, or Laravel will reject the request with a 419 (Page Expired) error.
How to fix CSRF issues in your form?
1. Add @csrf directive in your Blade form
Make sure your form includes the Blade directive @csrf inside the form, like this:
import axios from 'axios';
axios.defaults.headers.common['X-CSRF-TOKEN'] = token;
// then make your post call:
axios.post('/your-post-route', { content: editorData })
.then(response => { /* ... */ })
.catch(error => { /* ... */ });
3. Verify your route and method
Check that the form's action URL is correct and that your route uses the right HTTP method (POST) that the form uses. Example in your routes file (routes/web.php):