New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-medium-highlighter

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-medium-highlighter

Simple Medium-like highlighter

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
0
Created
Source

React Medium Highlighter

React Highlighter Demo

A lightweight, Medium-like text highlighter for React. Highlight text, add comments, and rehydrate saved annotations.

Features

  • Highlight text with custom colors.
  • Add comments or annotations.
  • Save and rehydrate highlights.
  • Easily copy selected text.

Installation

Install the library using npm or yarn:

npm install react-highlighter

Usage

import React, { useState } from "react";
import { Highlighter } from "react-highlighter";

const App = () => {
const [annotations, setAnnotations] = useState([]);

const handleCreate = (annotation) => setAnnotations([...annotations, annotation]);
const handleRemove = (annotation) => setAnnotations(annotations.filter(a => a.text !== annotation.text));

return (
<Highlighter
      createAnnotation={handleCreate}
      removeAnnotation={handleRemove}
      annotations={annotations}
    />
);
};

export default App;

Props

NameTypeDescription
createAnnotationFunctionTriggered when a highlight is created.
removeAnnotationFunctionTriggered when a highlight is removed.
annotationsArrayPre-existing highlights.

License

This project is licensed under the MIT License.

Keywords

highlighter

FAQs

Package last updated on 24 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts