Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropzone implementation docs? #303

Open
royduin opened this issue Aug 17, 2017 · 1 comment
Open

Dropzone implementation docs? #303

royduin opened this issue Aug 17, 2017 · 1 comment

Comments

@royduin
Copy link
Contributor

royduin commented Aug 17, 2017

Maybe add some information about how to implement Dropzone in the Bootstrap Markdown editor?

How I've implemented it in my Laravel 5.4 project;

package.json:

"bootstrap-markdown": "toopay/bootstrap-markdown",
"dropzone": "^5.1.1",
"markdown": "^0.5.0",

I'm using toopay/bootstrap-markdown there so NPM will get it from Github instead of fetching the latest version which doesn't include Dropzone support, see: #301

bootstrap.js

window.dropzone = require('dropzone');
window.markdown = require('markdown').markdown;
require('bootstrap-markdown/js/bootstrap-markdown.js');

app.scss

@import "node_modules/dropzone/dist/basic";

markdown.js

window.dropzone.autoDiscover = false;
(function(){
    $('textarea.markdown').markdown({
        dropZoneOptions: {
            url: '/media/upload,
            headers: {
                'X-CSRF-Token': document.head.querySelector('meta[name="csrf-token"]').content
            }
        }
    });
})();

MediaController.php

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
    $validator = Validator::make($request->all(), ['file' => 'required|image']);

    if ($validator->fails()) {
        return response($validator->errors()->first(), 422);
    }

    return response(env('APP_URL').'/uploads/'.$request->file->store(date('Y'), 'uploads'));
}

To use it, create a textarea with the markdown class in one of your Blade/HTML templates.

This is working nicely, but this fix is needed else the styling isn't correct: #302

@toopay
Copy link
Member

toopay commented Aug 21, 2017

I'm not sure how to add this onto the doc - since this most likely is edge case for common user. Maybe in the future i'll collect this kind of "Nice to know" stuff into wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants