🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

reactjs-editor

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reactjs-editor

A simple react library that lets you highlight text, make text bold, and add comment on any text as a sticky notes

5.5.5
Source
npm
Version published
Weekly downloads
27
-63.01%
Maintainers
1
Weekly downloads
 
Created
Source


ReactjsEditor
ReactJSEditor

React package to highlight text,make text bold,add comment to text.View Demo.

screenshot

Get Started 👨🏻‍✈️

🛠️🛠️ Installation and Setup 🌱🌱


$ npm i reactjs-editor

🦄✨🧙🏼‍♀️ USAGE 🦄✨🧙🏼‍♀️

Import Package in your project

$ import { Editor } from 'reactjs-editor';

Use Editor component and insert any html content

   <Editor
        htmlContent={`<main> 
          <h1>Welcome to My Website</h1>
          <p>This is a paragraph of text in HTML. It's simple and easy to create.</p>
          <p>HTML stands for HyperText Markup Language. It's the standard markup language for  creating web pages.</p>
          <p>In HTML, you can create different types of elements such as headings, paragraphs, links, lists, and more to structure and format your content.</p>
         </main>`}
      />

🎉🎉🎉 Easy Peasy 🎉🎉🎉 Check it out



🚨🚨🚨 Note: ⚠️⚠️ Its important:

🚨🚨🚨 Make sure your htmlContent is wrapped inside main tag

✅✅✅

htmlContent={
<main>
{ *** all your html content here *** }
</main>
}

✅✅✅


🎉🎉🎉 That's it. 🎉🎉🎉



Additional Props for Customizations

Add your own colors

<Editor
      colors={["black","gold","red"]}
      ....
      />

Make sure to add your class in your css file

/* In your css file */

.black{
    background-color:#000,
    color:#fff,
},
.red{
    background-color:red,
    color:#fff,
}
.gold{
    background-color:gold,
    color:#fff,
}

//add as much as you like



Get Access to Changed HTML Element.

💾 Save user html changes and show them their changes on subsequent visit


import { Editor, useDomValue } from 'reactjs-editor';

...

 const { dom, setDom } = useDomValue();

  // eslint-disable-next-line react-hooks/exhaustive-deps
  const updatedDomValue  = {
    key: dom?.key,
    props: dom?.props,
    ref: dom?.ref,
    type: dom?.type,
  }


  console.log("%j", updatedDomValue );  
  
  // get your changed dom  like this and save it if you like to in your database or some place

Update dom using that " updatedDomValue " values you saved from above


useEffect(()=>{
  function updateDom(updatedDomValue:any){
   setDom(updatedDomValue); //set your dom like this
 
  }
  updateDom(updatedDomValue) // call this function where ever you like

},[])



If you want to customize designs of all other components such as floating button and modals

1. Inspect html element
2. Find className of specific elements
3. Override css present there from your own css files 

 In future update, I will create option to pass all components in a props

Support

Buy Me A Coffee

License

MIT

vivekneupane11@gmail.com  ·  GitHub @vivekneupane11  · 

Keywords

react-editor

FAQs

Package last updated on 05 Feb 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