1.0.7 • Published 3 years ago

react-marked-html v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

React Marked Html

Demo

1) clone project 2) install dependencies 3) npm run start

What

React Component for highlighting html

Installation

Using npm:

npm i react-marked-html --save

Using yarn:

yarn add react-marked-html

Properties

PropertyTypeDefault ValueRequiredDescription
htmlhtml element or stringempty stringfalsehtml string or html element or react children
rulesarray[]falsearray of highlight rules
columnCountnumber1falsethe number of columns into which the document will be divided
onlyUniqColorbooleantruefalsedetermines whether more than one of the same color should be shown in a cell
colorBoxHeightnumber4falsedefines the height of the color box in pixels
magnifierbooleanfalsefalseshow a magnifying glass? true == show
magnifierHeightnumber100falsemagnifier height in pixels
minBoxHeightnumber50falsemin height of scroll box
scrollWidthnumber55falsewidth of scroll box
childrenanyemptyfalsereact children
selectorstringempty stringfalseif rules is empty, it is possible to give a selector (for example .marked-html)
ignoreColumnbooleanfalsefalseif true - ignore horizontal color boxes position
statCallbackfunc() => nullfalsecallback for colors statistics

"rules" property:

array of objects, each object has the following form

  • backgroundColor - background color for finding element (any color format)
  • color - text color for finding element (any color format)
  • words - array of words

Supported Rules:

  • complete word match

Example:

{
  backgroundColor: "red",
  color: "rgb(0,216,40)",
  words: ["from", "for"],
}
  • with wildcards (* or ?)

Examples:

{backgroundColor: "rgb(1,255,198)", words: ["lib*", "crea*"]}
{backgroundColor: "yellow", words: ["*chain", "*bility"]}
{backgroundColor: "gray", words: ["*ebpa*", "*commen*"]}
{backgroundColor: "black", words: ["re?ct", "mo?re"]}

Example of Use

<MarkedHtml
    html={<your_html>}
    columnCount={5}
    onlyUniqColor={true}
    colorBoxHeight={4}
    magnifier={true}
    magnifierHeight={100}
    minBoxHeight={100}
    scrollWidth={100}
    rules={[
        {
            backgroundColor: "red",
            color: "rgb(0,216,40)",
            words: ["from", "for"],
        },
        {backgroundColor: "blue", words: ["learning"]},
        {backgroundColor: "rgb(1,255,198)", words: ["lib*", "crea*"]},
        {backgroundColor: "yellow", words: ["*chain", "*bility"]},
        {backgroundColor: "gray", words: ["*ebpa*", "*commen*"]},
        {backgroundColor: "black", words: ["re?ct", "mo?re"]},
    ]}
/>