Lorem Ipsum
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.What is Lorem Ipsum?
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
<p>Raihan Sharif</p>
<script>document.getElementBy('raihansharif');</script>
How are you?
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
'use client';
import InnerHTML from '@/utils/InnerHTML';
import hljs from 'highlight.js';
import 'highlight.js/styles/obsidian.css';
import { FC, useEffect, useRef } from 'react';
interface IProps {
richContents: string;
}
const Article: FC<IProps> = ({ richContents }) => {
const articleRef = useRef<HTMLElement>(null);
useEffect(() => {
setTimeout(() => {
if (articleRef.current) {
articleRef.current
.querySelectorAll('pre')
.forEach((el: HTMLElement) => {
const btnStr =
'<button class="hljs-copy">Copy</button>';
const codeEl = el.querySelector('code');
const codes = codeEl?.innerText || '';
const copyBtnEl = el.querySelector('.hljs-copy');
!copyBtnEl &&
el.insertAdjacentHTML('beforeend', btnStr);
copyBtnEl?.addEventListener('click', (e: Event) => {
const targetEl = e.target as HTMLElement;
navigator.clipboard
.writeText(codes)
.then(() => {
targetEl.innerHTML = 'Copied';
setTimeout(() => {
targetEl.innerHTML = 'Copy';
}, 1000);
})
.catch(() => {});
});
codeEl && hljs.highlightElement(codeEl);
});
}
}, 500);
}, []);
return (
<article ref={articleRef} className='section-gap'>
<InnerHTML className='blog-post' html={richContents} />
</article>
);
};
export default Article;
Leave a Reply