Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions resources/views/livewire/quill-text-editor.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,27 @@
quill.root.innerHTML = $wire.get('value');
quill.on('text-change', function () {
let value = quill.root.innerHTML;
@this.set('value', value);
let timeout = null;
function handleTextChange() {
if (timeout !== null) {
clearTimeout(timeout);
}
timeout = setTimeout(function() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is the best way to handle this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why??

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you are using a timeout.

Copy link

@ghabriel25 ghabriel25 Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dasundev Just use lodash debounce

quill.on('text-change', _.debounce( () => {
    let value = quill.root.innerHTML;
    @this.set('value', value);
}, 1000));

lodash comes along with quill

let value = quill.root.innerHTML;
@this.set('value', value);
}, 1000);
}
quill.on('text-change', function() {
handleTextChange();
});
quill.on('selection-change', function() {
if (quill.hasFocus()) {
handleTextChange();
}
});
</script>
@endscript