Comments (4)
At the moment there is no way to override the default controller. It would, theoretically, be possible to monkeypatch DinandMentink\Markdown\Http\Controllers\UploadController
.
Is there a specific reason you would want to override the controller? Theoretically I could make this configurable, but it would require some refactoring and maybe there's a better way for your usecase.
from nova-markdown.
@dinandmentink I'm currently using Easy Markdown Editor on it's own and have some custom logic around the uploads. Instead of just dropping the file in a disk and returning a link, I save it to a model using the Laravel Media Library by Spatie and then return a url with a random hash. This decouples the url from the actual location on the disk.
This is what my current controller looks like.
public function upload(Request $request)
{
/** @var User $user */
$user = auth()->user();
$site = $user->activeSite;
$this->authorize('upload', $site);
$name = $request->all()['image']->hashName();
$file = $site->addMedia($request->all()['image']->path())->usingFileName($name)->toMediaCollection('uploads');
$data = ['data' => ['filePath' => Upload::getUrl($user->activeSite, $file->uuid)]];
return response()->json($data);
}
from nova-markdown.
Ok. This makes sense. I think I could make this. I'll make a note to add this in a future release. However, I'm quite swamped at the moment so this may take a while.
There may also be a nicer way than overriding the controller. Some kind of contract which specifies how to handle the upload itself.
Note that some of this behaviour could already be done by overriding the directory
config item with a function (see readme). I use this myself for quite similar behaviour, minus the authorization.
Feel free to submit a PR if you want to have a go at it.
Closing; added to internal list of feature requests.
from nova-markdown.
@dinandmentink The reason I cannot use a function in the config is because my config is cached on deploy, but good thought.
from nova-markdown.
Related Issues (14)
- Differences from the default Markdown field? HOT 3
- Any way to disable options? HOT 2
- Laravel 9 support is available as v3.0.1 HOT 3
- Navbar over fullscreen editor HOT 4
- Nova 4 compatibility HOT 1
- Replacing the link to EasyMDE
- Target class [] does not exist thrown when trying to drag\drop the uploads HOT 9
- Need additional CSS for preview HOT 1
- Laravel v10 support finished. Please respond with any issues. HOT 1
- Follow default behaviour of official markdown field in index and show view HOT 3
- easy-markdown-editor.tk HOT 2
- uploading image causes (blocked:mixed-content) HOT 3
- 🚨 EOL Notice
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nova-markdown.