Skip to content

Commit

Permalink
refactor: Move to files
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to committed May 16, 2024
1 parent 144add8 commit d27106f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 34 deletions.
5 changes: 5 additions & 0 deletions public/css/quill.snow.css
Original file line number Diff line number Diff line change
Expand Up @@ -943,3 +943,8 @@
.ql-container.ql-snow {
border: 1px solid #ccc;
}

.ql-container, .ql-toolbar {
background-color: white!important;
color: black!important;
}
24 changes: 24 additions & 0 deletions public/js/quill-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
document.addEventListener('alpine:init', () => {
Alpine.data('quill', () => ({
textarea: null,
editor: null,

init() {
this.textarea = this.$root.querySelector('.ql-textarea')
this.editor = this.$root.querySelector('.ql-editor')

const t = this

this.$nextTick(function() {
let quill = new Quill(`#${t.editor.id}`, {
theme: 'snow'
});

quill.on('text-change', () => {
t.textarea.value = t.editor.innerHTML || '';
t.textarea.dispatchEvent(new Event('change'));
});
})
},
}))
})
34 changes: 0 additions & 34 deletions resources/views/fields/quill.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,3 @@
])->except('x-bind:id')"
>{!! $value ?? '' !!}</x-moonshine::form.textarea>
</div>

<script>
document.addEventListener('alpine:init', () => {
Alpine.data('quill', () => ({
textarea: null,
editor: null,
init() {
this.textarea = this.$root.querySelector('.ql-textarea')
this.editor = this.$root.querySelector('.ql-editor')
const t = this
this.$nextTick(function() {
let quill = new Quill(`#${t.editor.id}`, {
theme: 'snow'
});
quill.on('text-change', () => {
t.textarea.value = t.editor.innerHTML || '';
t.textarea.dispatchEvent(new Event('change'));
});
})
},
}))
})
</script>

<style>
.ql-container, .ql-toolbar {
background-color: white!important;
color: black!important;
}
</style>
1 change: 1 addition & 0 deletions src/Fields/Quill.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ final class Quill extends Textarea
protected array $assets = [
'vendor/moonshine-quill/css/quill.snow.css',
'vendor/moonshine-quill/js/quill.js',
'vendor/moonshine-quill/js/quill-init.js',
];
}

0 comments on commit d27106f

Please sign in to comment.