Description:
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: '__',
});





