Mayank0255 / Stackoverflow-Clone-Frontend

Clone project of a famous Q/A website for developers built using MySQL, Express, React, Node, Sequelize :globe_with_meridians:
https://stackoverflow-clone-client.vercel.app
MIT License
546 stars 209 forks source link

feat(#22): Setup markdown editor #40

Closed ddsuhaimi closed 3 years ago

Mayank0255 commented 3 years ago

@ddsuhaimi I have requested some small changes on the PR, other than that great work.

ddsuhaimi commented 3 years ago

@Mayank0255 Updated with the requested changes

Mayank0255 commented 3 years ago

@ddsuhaimi

Great job man.

I just checked it out and it works fine for the functionalities given but you have forgotten to add code and hyperlink functionality to it. While adding the code one don't forget to look at the ui of original stackoverflow clone.

And one doubt I had is that what is htmlSubstring used for with injectEllipsis?

Mayank0255 commented 3 years ago

@ddsuhaimi One last thing that don't forget to remove the monospace feature as it's not required

ddsuhaimi commented 3 years ago

@Mayank0255 For htmlSubstring and injectEllipsis, I used it for post item in the homepage. Normally, you substring the body to show only first 200 characters right? Since what we have right now is a string of html, I can't simply do body.substring(200), so htmlSubstring comes to play. What it does is that it will extract the first 200 character without touching the html tag (so we wont lose any formatting). I then created injectEllipsis to inject ellipsis at the end of that substring. If I dont do that, when it happen to cut off in the middle of the word, it looks weird.

For the other 2, the converter library still having an open issues for code block (https://github.com/HubSpot/draft-convert/issues/182) (you can uncomment the code block, it works but having conversion issues) and I'll see how to implement the link since it doesn't come by default in draft.js

Mayank0255 commented 3 years ago

For htmlSubstring and injectEllipsis, I used it for post item in the homepage. Normally, you substring the body to show only first 200 characters right?

Yes, good work 👍🏽

I'll see how to implement the link since it doesn't come by default in draft.js

Sure, do that please and work on the code block thing and removing the monospace too while you are at it.

Mayank0255 commented 3 years ago

@ddsuhaimi

What's the progress on this?

ddsuhaimi commented 3 years ago

@ddsuhaimi

Sorry, it is probably gonna take a while. I've been kinda busy lately. I'll develop this in the weekend.

Mayank0255 commented 3 years ago

@ddsuhaimi Sure

Mayank0255 commented 3 years ago

@ddsuhaimi Are you facing any kind of problem somewhere?

ddsuhaimi commented 3 years ago

@Mayank0255

Hi, sorry it took a while. Turns out, the issue is on 'draft-convert' library itself. It just can't convert code block to its corresponding html (and it is actually an open issue in its repo and still hasn't been resolved). So, there is pretty much no use of having code block in the editor when we can't convert it. This is also the case for link.

Mayank0255 commented 3 years ago

@ddsuhaimi

Okay, I see

Here's an answer for draftjs to html conversion by the author himself - Here

In which the author has recommended to use the libraries listed over there as it's officially built by them and for a running example you can see this and the repository to which is listed here

In the demo shown code block is specifically implemented also. The link to the package repo is here

I hope this solves the issue and if not then let me know.

I know this can be tiring to find out the solution but till know you have done a marvelous job so it won't hurt to finish it off perfectly too. It might seem a big task of replacing the draft-convert with this but it would take hardly and hour after figuring out the approach and for which I am here.

P.S. - I am thinking of integrating docusaurus to the backend in which along with the API, a blog page would also be there in which news would come out referring the contributors and congratulating them and explaining about the contribution to the project. This is just to tell you that the contribution won't be in vain.

ddsuhaimi commented 3 years ago

@Mayank0255

so is it okay if instead of using pure draft-js with draft-convert, we use react-rte? which i think, under the hood, is draft-js?

Mayank0255 commented 3 years ago

@ddsuhaimi Sure, go ahead

As long as it satisfies our needs, its fine

ddsuhaimi commented 3 years ago

@Mayank0255 Sure thing.

image image

Mayank0255 commented 3 years ago

@ddsuhaimi Good job man!!

Thank you for working patiently with me 😄

Looking forward to more of the contributions from your side