<div wire:ignore class="form-group row">
<x-label class="col-md-3 col-form-label" for="message" :value="__('Compose message')" />
<div class="col-md-9">
<textarea wire:model="message" class="form-control required" name="message"
id="message"></textarea>
<x-error-message :value="__('message')" />
</div>
</div>
<script src="https://cdn.ckeditor.com/4.16.1/full/ckeditor.js"></script>
<script>
const editor = CKEDITOR.replace('message');
# OR 1
editor.on('change', function (event) {
// console.log(event.editor.getData())
@this.set('message', event.editor.getData());
})
# OR 2
CKEDITOR.instances.message.on('change', function() {
@this.set('message', this.getData());
});
# OR 3 now I don't want to render data in each request
document.querySelector("#submit").addEventListener("click", () => {
// console.log(editor.getData())
@this.set('message', editor.getData());
});
</script>
<script src="https://cdn.ckeditor.com/ckeditor5/27.1.0/classic/ckeditor.js"></script>
<script>
ClassicEditor
.create(document.querySelector('#message'))
.then(editor => {
editor.model.document.on('change:data', () => {
@this.set('message', editor.getData());
})
})
.catch(error => {
console.error(error);
});
</script>
# optional if you want fire the event when submit button is clicked
<script>
ClassicEditor
.create(document.querySelector('#message'))
.then(editor => {
document.querySelector("#submit").addEventListener("click", () => {
const textareaValue = $("#message").data("message");
eval(textareaValue).set("message", editor.getData());
// @this.set('message', editor.getData());
});
})
.catch(error => {
console.error(error);
});
</script>
how upload image whit ckeditor and livewire?