JSPM

  • Created
  • Published
  • Downloads 8356
  • Score
    100M100P100Q132474F

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 { Mark } from 'react-mark.js'
// OR
import Mark from 'react-mark.js/dist/components/Mark'

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

Marking a Regular Expression (RegEx)

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

const MyComponent = () => (
  <Mark mark={/l/} type="markRegExp">
    Hello World
  </Mark>
)

Marking a Range

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

const MyComponent = () => (
  <Mark
    mark={[
      {
        length: 3,
        start: 1,
      },
      {
        length: 4,
        start: 6,
      },
    ]}
    type="markRanges"
  >
    0123456789
  </Mark>
)