npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@opuscapita/react-markdown

v2.3.13

Published

React markdown editor component

Downloads

96

Readme

React Markdown

CircleCI Status badge-npm-version badge-license NPM Downloads

demo

Built using slate-js

Usage

Install npm package:

npm install -E @opuscapita/react-markdown

Import it to your application

import MarkdownInput from '@opuscapita/react-markdown

See interactive example for more details: https://opuscapita.github.io/react-markdown

Demo powered by React Showroom

If you want to use together with Bootstrap Modal, you need to add styles:

.markdown-input_fullscreen { // pass this class to Modal component
  overflow: hidden;
}
.markdown-input_fullscreen.modal.in .modal-dialog {
  transform: none;
}

How it works

MarkdownEditor supports the following decorators:

  • bold
  • italic
  • strikethrough
  • heading-1
  • heading-2
  • heading-3
  • heading-4
  • heading-5
  • heading-6
  • list
  • ordered-list

Buttons (their groups, sequence)

[B, I, S] [A] [H1, H2, H3, H4, H5, H6], [UL, OL]

  • inline text actions
    • [B] - bold mark
    • [I] - italic mark
    • [S] - strikethrough mark
  • link
    • [A] - anchor insert
  • text block actions
    • [H1] - header 1 block
    • [H2] - header 2 block
    • [H3] - header 3 block
    • [H4] - header 4 block
    • [H5] - header 5 block
    • [H6] - header 6 block
  • lists
    • [UL] - list block
    • [OL] - ordered list block

Note for multi-line selection: only list and ordered list are available for multi-line selection, other buttons in a toolbar are disabled, because otherwise markdown highlighting becomes inconsistent.

Behaviour

Block elements

List [UL] button

Here is specification by video example for this button

list-button-optimized

  • Insert marker '* ' at the beginning of the line if line does not start with ['{number}. ', '# ', '## ', '### ', '#### ', '##### ', '###### ']
  • Replace with marker '* ' if line starts with ['{number}. ', '# ', '## ', '### ', '#### ', '##### ', '###### ']
  • Insert marker '* ' at the beginning of the next line if enter is pressed at the end of the line that is marked as list item if item contain any text
  • Clear line from '* ' and put cursor to a new line if user pressed enter at the end of the line that marked as list item but does not contain any text
Ordered list [OL] button

Here is specification by video example for this button

ordered-list-button-optimized

  • Insert marker '1. ' at start of the line if it does not start with ['* ', '# ', '## ', '### ', '#### ', '##### ', '###### ']
  • Replace with marker '1. ' if line starts with ['* ', '# ', '## ', '### ', '#### ', '##### ', '###### ']
  • Insert marker '{number+1} ' at the beginning of in the next line if enter is pressed at the end of the line that is marked as list item if item contains any text
  • Clear line from '{number} ' and put cursor to a new line if user pressed enter at the end of the line that is marked as ordered list item but does not contain any text
Header item [h1-h6] buttons

Here is specification by video example for [H2] button (other header buttons work correspondingly)

h2-button-optimized

  • Insert marker '# ' - '###### ' (in depends on button) at start of the line if it does not start with ['* ', '{number}. ']
  • Replace with marker '# ' - '###### ' (in depends on button) if line stars with ['* ', '{number}. ']
  • Remove existing header marker if corresponding header button is clicked
  • Update existing header marker to another header marker one if current header marker does not correspond to pressed header button

Marked elements

Here is specification by video example for these buttons

bold-italic-strikethrough-optimized

Bold [B] button
  • Selected text is wrapped with '**', e.g. {selected_text} -> **{selected_text}**
  • If selected text contains bold text then it is unwrapped, for example **{selected_text}** -> {selected_text}
  • Inserts '**{cursor}**' into cursor position if text is not selected, and cursor is placed inside
Italic [I] button
  • Selected text is wrapped with '_', e.g. {selected_text} -> _{selected_text}_
  • If selected text is marked as italic then it is unwrapped, for example _{selected_text}_ -> {selected_text}
  • Inserts '_{cursor}_' into cursor position if text is not selected, and cursor is placed inside
Strikethrough [S] button
  • Selected text is wrapped with '~~', e.g. {selected_text} -> ~~{selected_text}~~
  • If selected text is marked as strikethrough then it is unwrapped, for example ~~{selected_text}~~ -> {selected_text}
  • Inserts '~~{cursor}~~' into cursor position if text is not selected, and cursor is placed inside

Inline elements

External anchor [A] button

Here is specification by video example for this button

link-button-optimized

  • Wraps selected text with '[' and '](http://example.com)', for example {selected_text} -> [{selected_text}](http://example.com)
  • Inserts text [link text](http://example.com) into cursor position if text is not selected.

Known issues

  • In case of multi line selection toolbar all buttons except list and ordered list are not available (no action is supported)
  • Code blocks are not supported

Contributors

| | Alexey Sergeev | | :---: | :---: | | Dmitry Divin | | Dmitry Sanko | | Aleksandr Baliunov | | | Kirill Volkovich |

License

Licensed under the Apache License, Version 2.0. See LICENSE for the full license text.