There may be better ways to do it, but this is working for me:
First, I created a custom component to house all the mce logic, and call that from my livewire component like so. Note that it's in this custom component that I'm attaching the livewire variable I want it responsible for
<x-input.tinymce
wire:model.lazy="your_livewire_variable"
class="h-screen"
/>
That component looks like this:
<div
wire:ignore
x-data
{{ $attributes }}
>
<script src='https://cdn.tiny.cloud/1/d2eyrcjk5emsow4ou6uvrn3bwn2y91axba4csr8wlm940lzj/tinymce/5/tinymce.min.js'
referrerpolicy="origin">
</script>
<script>
tinymce.init({
// All your init stuff here, then the super important part at the bottom
setup: function (editor) {
editor.on('init change', function () {
editor.save();
});
// This section says that when you leave the text edit area, it will set whatever livewire variable you like to the currnt contents
editor.on('blur', function (e) {
@this.set('your_livewire_variable', editor.getContent());
});
},
});
</script>
<textarea class="h-screen p-2"
id="mytextarea"
name="mytextarea"
> </textarea>
</div>
This is working like a charm for me - hope it helps (either you, or whoever googles this next! :D )