Code Monkey home page Code Monkey logo

Comments (8)

brijeshb42 avatar brijeshb42 commented on May 27, 2024 2

If you study the code in src/example.js, it is actually using medium-draft as a library and adding some extra functionality to it based on the props that Editor of medium-draft accepts.

So, there are features like -

  • Auto curly quotes while typing,
  • Embed and Break side buttons,
  • File drop (code here),
  • And some keyboard shortcuts

These features are not part of the core medium-draft editor as they are not generic enough.

from medium-draft.

geekpeng avatar geekpeng commented on May 27, 2024

you should use style https://unpkg.com/medium-draft/dist/medium-draft.css
and font-awesome

from medium-draft.

brijeshb42 avatar brijeshb42 commented on May 27, 2024

If you are using webpack, you should import medium-draft/lib/index.css in your final JS file. Or as @geekpeng suggested, you can include the css file from the above link. It applies minimum styling to the editor so that it looks exactly like as it does in the demo.

And if you are using the sideButtons (image, embed etc), then you may have to also include font-awesome. The toolbar itself does not require fontawesome but this may change in future.

from medium-draft.

ammichael avatar ammichael commented on May 27, 2024

I just imported 'medium-draft/lib/index.css' and it worked. Also, I've noticed this is mentioned in usage section of the readme.

My bad.

Thanks guys! (:

from medium-draft.

brijeshb42 avatar brijeshb42 commented on May 27, 2024

Actually I added that section after your issue popped up.

from medium-draft.

ammichael avatar ammichael commented on May 27, 2024

Oh, that makes sense.

Since we are here, I was thinking about opening another issue, but not sure if I should.. The demo has drag and drop for images working perfectly, but I can't replicate this behavior. Am I missing something, again?

from medium-draft.

ammichael avatar ammichael commented on May 27, 2024

Just a last question.. Is there any reason this extra features are not default enabled in medium-draft already?

I mean, it would be nice to have a exposed prop like dropImages={true}. Is it possible?

I've been using React for a couple months, but I'm really, really noob with DraftJS, sorry about that. But if it's possible, I can try and implement this feature and send you a PR maybe..

from medium-draft.

brijeshb42 avatar brijeshb42 commented on May 27, 2024

In the demo, when you drop an image, its added in place using URL.createObjectURL. This does not send the dropped images to any server so as to make it permanent. This is one reason dropping images is not a part of the core editor. (Likewise when image is added using the Image side button.)

There will always be logic specific to developer to deal with persisting the file someplace. You will have to upload it to your CDN, return the image's URL and then use that as the src.

Its not really hard handling files in draft-js or even medium-draft to be specific. There is always the demo code to help you. You can just modify the function here and pass it to medium-draft.

from medium-draft.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.