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

Extending react-markdown for example to have underline and text-highlighting #144

Open
ortonomy opened this issue Aug 29, 2018 · 3 comments

Comments

@ortonomy
Copy link

ortonomy commented Aug 29, 2018

We'd like to use react-markdown in a project, but we'd like to extend it to support markdown-it plugins and a couple more decorators.

We're targeting supporting centering text, highlighting, and underline.

Do you have a guide on adding buttons and decorators or a couple pointers where to start?

I noticed https://opuscapita.github.io/react-markdown//branches/master/index.html?currentComponentName=MarkdownInput

which allows me to define extensions as buttons, and even a renderer. Is this all I need to do?

@ortonomy ortonomy changed the title Support for markdown-it plugins and modifying react-markdown Extending react-markdown for example to have underline and text-highlighting Aug 29, 2018
@kvolkovich-sc
Copy link
Contributor

kvolkovich-sc commented Aug 29, 2018

Hi, @ortonomy.

We currently don't have guide on adding buttons and decorators.

You can achieve what you want by diving into slatejs documentation

"slate": "0.24.0",

and react-markdown source code.

I'm not sure if this is a very simple task.

Also I'm not sure that you need text centering and underline into markdown editor.

Of course you can do it by using html tags into markdown. But you must understand that this editor is raw markdown text editor (at the current time).

@ortonomy
Copy link
Author

@kvolkovich-sc -- thanks for answering so fast.

Perhaps I can let you know about our requirements:

  1. We will have editors who will be creating content such that they require to be able to mark pieces of text as formatted (an exhaustive list): bold, italic, underline, highlighted, centered
  2. We don't want to store HTML output in our DB, we want to store it in markdown (it's more like meta data that way, not the resulting presentation)
  3. We then want to show a preview to the user after, or during
  4. We will want to extend the metadata with our domain markdown later (for more complicated formats: e.g mathjax, custom formats).

react-markdown uses markdown-it to parse the markdown -- which supports plugins for mathjax, but also custom markdown decorators, react-markdown seems like an ideal candidate for creating our own custom decorators and making them parse

But you must understand that this editor is raw markdown text editor (at the current time)

I get this, but ...

React-markdown seems to format the markdown to show the resulting format e.g., bold, italic, strikethrough e.g.:

image

So basically, we'd like to be able to add decorators, (e.g. $$ 1^2 $$ for mathjax) and add them as a button too, and then see the result of the markdown, either in separate preview, or partially formatted inside the editor.

Does that make sense?

@kvolkovich-sc
Copy link
Contributor

kvolkovich-sc commented Aug 29, 2018

Yes, it make sense.

You can add additional buttons which can insert custom text right now. Its not complex.

But I'm not sure about visual decorators by adding CSS class or something like that.

Sure, it should be possible by making a little code changes for regex mathing.

Right now we have no resources ⏳ to support react-markdown out of business cases bounds.

If you want, you can dive into codebase and make a Pull Request.

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

No branches or pull requests

2 participants