
Copy Rich Text As Markdown In React
An easy React hook that enables you to copy the selected rich text as markdown. Based on the turndown JavaScript library.
How to use it:
1. Install and import the react hook.
# Yarn $ yarn add @cnakazawa/copy-as-markdown # NPM $ npm i @cnakazawa/copy-as-markdown
import useCopyAsMarkdown from '@cnakazawa/copy-as-markdown';
2. Basic usage.
export default function MyComponent() { const setRef = useCopyAsMarkdown(); return ( <div ref={setRef}> <h1>Select To Copy</h1> </div> ); }
3. Customize the list marker and strong delimiter.
const setRef = useCopyAsMarkdown({ bulletListMarker: '-', strongDelimiter: '__', });
Preview:
Download Details:
Author: cpojer
Live Demo: View The Demo
Download Link: Download The Source Code
Official Website: https://github.com/cpojer/copy-as-markdown
License: MIT
Credit: Source link