import { decode } from "he" ; param html export default function getHTMLPlainText ( html ) { const htmlWithNewLine = html . replace ( /((<\/(ul|li|blockquote)>)|(<\/(div|p)>\s*(<[^/]))|(<br>(?!\s*<\/(div|p|li|blockquote))))/g , "\n$1" ) ; let textContent ; if ( process . env . WEBPACK !== "true" ) { textContent = decode ( require ( "striptags" ) ( htmlWithNewLine ) ) ; } else { const divElement = document . createElement ( "div" ) ; divElement . innerHTML = htmlWithNewLine ; textContent = divElement . textContent || "" ; } return textContent . trim ( ) ; }