feat: integrate Spatie Media Library (#4)
- Added Spatie Media Library - Added media library configuration file - Updated Entry model to support media handling - Added featured image upload with gallery selection and preview - Added login tests with Dusk for user authentication - Added Dusk test for featured image selection Co-authored-by: jon brookes <marshyon@gmail.com> Reviewed-on: https://codeberg.org/headshed/share-lt/pulls/4
This commit is contained in:
parent
6cf8d5dfd4
commit
56607285bd
38 changed files with 2200 additions and 16 deletions
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
document.addEventListener('livewire:init', () => {
|
||||
Livewire.on('insert-editor-content', (data) => {
|
||||
// console.log('Received insert-editor-content data:', data);
|
||||
// Handle if data is an array
|
||||
const payload = Array.isArray(data) ? data[0] : data;
|
||||
const statePath = payload.statePath;
|
||||
const html = payload.html;
|
||||
// console.log('Extracted statePath:', statePath, 'html:', html);
|
||||
// 1. Find the editor by its statePath
|
||||
const container = document.querySelector(`[wire\\:model="${statePath}"]`) || document.querySelector(`[statepath="${statePath}"]`);
|
||||
// console.log('Container found:', container);
|
||||
const editorElement = container ? container.querySelector('.tiptap') : null;
|
||||
// console.log('Editor element found:', editorElement);
|
||||
|
||||
if (editorElement && editorElement.editor) {
|
||||
// console.log('Inserting content:', html);
|
||||
// 2. Insert the HTML (the <img> tag) into the editor
|
||||
setTimeout(() => {
|
||||
editorElement.editor.chain().focus().insertContent(html).run();
|
||||
}, 500);
|
||||
} else {
|
||||
// console.log('Editor not found or not initialized');
|
||||
// Fallback: try to find any .tiptap on the page
|
||||
const anyTiptap = document.querySelector('.tiptap');
|
||||
// console.log('Any tiptap found:', anyTiptap);
|
||||
if (anyTiptap && anyTiptap.editor) {
|
||||
// console.log('Inserting to any tiptap');
|
||||
setTimeout(() => {
|
||||
anyTiptap.editor.chain().focus().insertContent(html).run();
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Livewire.on('featured-image-added', (data) => {
|
||||
// console.log('Received featured-image-added event:', data);
|
||||
const payload = Array.isArray(data) ? data[0] : data;
|
||||
|
||||
// Reload the page to show the updated featured image
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue