Replies: 2 comments
-
|
Great ! |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
@joffreypersia I created a new repo, I don't know if this exactly what you wanted. Hopefully this can help you in any way. https://github.com/achatzi78/flux-file-manager Let me know if I can help in any way. Regards |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello.
I created a filemanager for one of my projects and I thought I post it here in case it helps someone or maybe the flux team want to use it for a starting point for when they make their own.
It can be used as a standalone filemanager (as gallery) or to select single file and get the url or it can be used with the flux editor as well.
Here is the code (obviously you would need some changes for your case)
The config file (flux-file-manager.php)
the blade view (flux-file-manager.blade.php)
The component (FluxFileManager.php)
Now in order to use it as a standalone (gallery mode), you simple include it in your blade
To use it for a selector for an input or whatever, I put it in a modal and listen to the events.
In my form blade
and in my form component I listen for the event
Now, for the editor, a larger setup is needed.
First install the tiptap Image extension
npm install @tiptap/extension-imageand then register it for the editor. Since we will be modifying various attributes we extend the Image to include these.In your app.js file
Then create a toolbar button for the editor (resources/view/flux/editor/image.blade)
Now use it with your editor like this
Please note that the id attribute in the editor is important because this way the filemanager modal knows with which editor to communicate. You can have multiple editors in the same page, as long as each one has each unique id. When you click the toolbar button, the popup will open and then click on the browse button to open a new modal with the filemanager. When you select an image, the attributes will be populated (src, alt, width, height, border, radius and style). Similarly, when you double click an image in the editor (or single click and then the toolbar button) the attributes will be populated from that.
Obviously a lot of enhancements can be made, a copy and move function, a context menu for various operations and info, etc. But to be honest, for my needs it is enough and since I already spent 3 days for it, I think I will call it a day. I am not very javascript savvy also so the whole alpinejs code took a lot trial and error.
Feel free to use it however you want, no strings attached whatsoever. I just thought I save someone 3 days of pain :)
Cheers
Beta Was this translation helpful? Give feedback.
All reactions