• Stars
    star
    112
  • Rank 303,498 (Top 7 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created about 7 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Markdown editor (input) based on React

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

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.

More Repositories

1

filemanager

React based FileManager for browser ( + FS REST API for Node.js and Express)
JavaScript
554
star
2

react-showroom-client

Catalog of React based components with versioning and realtime props editing support
JavaScript
244
star
3

weceem-plugin

Grails Weceem CMS Plugin
Groovy
58
star
4

weceem-app

Weceem CMS Standalone Application
Groovy
53
star
5

react-dates

React date(range) inputs/pickers
JavaScript
47
star
6

fsm-workflow

FSM workflow (for Node.js)
JavaScript
28
star
7

react-grid

React grid component
JavaScript
25
star
8

react-crudeditor

OpusCapita React CRUD Editor
JavaScript
20
star
9

react-signalr

Higher-Order Component that provides a connection to a SignalR hub. This component adds a hub proxy, that may be used to register and unregister event listeners, and also to invoke a hub controller and send data to it.
JavaScript
19
star
10

react-dashboard

Dashboard component with draggable resizable grid layout. Demo:
JavaScript
18
star
11

grailsflow-core-plugin

Open source Workflow and Process Engine written in Grails
Groovy
16
star
12

grailsflow-app

Application that demonstrates usage of grailsflow-core plugin
Groovy
8
star
13

i18n

Provides simple i18n mechanism for JS applications/modules.
JavaScript
7
star
14

react-loaders

Loading and rendering React components from remote JS bundles on the fly!
JavaScript
7
star
15

eslint-config

Company wide specific rules for (es)linting
JavaScript
6
star
16

react-async-select

Async dropdown component with advanced search modal
JavaScript
6
star
17

svg-icons

SVG (Scalable Vector Graphics) icons library
JavaScript
5
star
18

properties

Command line utility to work with '*.properties' file
Go
5
star
19

react-hierarchy-selector

React component for selecting items from hierarchies
JavaScript
5
star
20

weceem-spring-security

Grails Plugin for Weceem Spring Security integration
Groovy
4
star
21

oc-common-ui

OpusCapita common styles and React components for user interfaces
CSS
4
star
22

react-navigation

Navigation menu
JavaScript
4
star
23

react-reference-select

Base React components for creating reference search components
JavaScript
4
star
24

raml-to-markdown

Create Markdown documentaion out of RAML files.
JavaScript
3
star
25

react-hierarchy-tree

Hierarchy tree component that uses @opuscapita/react-grid and @opuscapita/react-treeview components
JavaScript
3
star
26

styles

Node.js based service that serves shared styles/images/fonts via HTTP
HTML
3
star
27

react-component-template

JavaScript
3
star
28

npm-scripts

NPM scripts: used for publishing packages, etc.
JavaScript
3
star
29

react-wizard

Wizard component that can contain any number of wizard pages and provides navigation between pages
CSS
3
star
30

react-buttons

JavaScript
3
star
31

react-rich-editors

JS React based rich editors based on Draft.js
JavaScript
3
star
32

node-tutorial

Simple tutorial for anyone who never worked with node
JavaScript
2
star
33

react-alerts

React alerts component to show global notifications
JavaScript
2
star
34

react-overlays

Modals, tooltips, etc.
JavaScript
2
star
35

react-select

Wrapper around "react-select" with OpusCapita styles.
JavaScript
2
star
36

react-tree-component

Simple React Tree Component using rc-tree as a base component.
CSS
2
star
37

react-svg

React components for easilly using SVG
JavaScript
2
star
38

react-layouts

JavaScript
1
star
39

embedded-tomcat-ci

Provides possibility to build executable JAR from WAR
Groovy
1
star
40

fsm4j

JavaScript
1
star
41

node-base

Docker node base image based on node:8-alpine with rsync, curl and npm@latest (5.0.1)
1
star
42

babel-plugin-transform-import-styles

Pack CSS/LESS into JS without Webpack (library building)
JavaScript
1
star
43

react-list

React list component
JavaScript
1
star
44

react-cards

React cards component
CSS
1
star
45

sequelize-to-markdown

DEPRECATED Create Markdown documentations out of sequelize models.
JavaScript
1
star
46

test-github-flow

Test repository used to demonstrate github power to team (will be removed soon)
JavaScript
1
star
47

minsk-core-presentations

Slides for presentation
JavaScript
1
star
48

react-splitpane

React draggable split pane component
CSS
1
star
49

react-autocompletes

JavaScript
1
star
50

pim-integrations-expression-unit-test

A tool from OpusCapita, to make it possible to write unit tests for expressions in PIM
JavaScript
1
star
51

pim-integrations-expression-unit-test-examples

A collection of examples how to use the unitTestLibrary
JavaScript
1
star