JSPM

  • Created
  • Published
  • Downloads 8356
  • Score
    100M100P100Q132666F

A simple ReactJS wrapper-component to mark (text)content. This one is inspired by mark.js - https://markjs.io

Package Exports

  • react-mark.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-mark.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React Mark JS (Inspired by mark.js)

CodeSandbox DEMO

Marking a String

import { Marker } from 'react-mark.js'
// OR
import Marker from 'react-mark.js/dist/components/Marker'

const MyComponent = () => <Marker mark="o">Hello World</Mark>

// OR (with array)

const MyComponent = () => <Marker mark={['o', 'W']}>Hello World</Mark>

Marking a Regular Expression (RegEx)

import { RegExpMarker } from 'react-mark.js'
// OR
import RegExpMarker from 'react-mark.js/dist/components/RegExpMarker'

const MyComponent = () => (
  <RegExpMarker
    mark={/l/}
    options={
      {
        /*optional*/
      }
    }
    unmarkOptions={
      {
        /*optional*/
      }
    }
  >
    Hello World
  </Mark>
)

Marking a Range

import { RangesMarker } from 'react-mark.js'
// OR
import RangesMarker from 'react-mark.js/dist/components/RangesMarker'

const MyComponent = () => (
  <RangesMarker
    mark={[
      {
        length: 4,
        start: 3,
      },
    ]}
  >
    <h1>0123456789</h1>
  </RangesMarker>
)