Skip to content

Commit

Permalink
remove trailing new line
Browse files Browse the repository at this point in the history
  • Loading branch information
adred committed May 20, 2024
1 parent 12e7a9d commit a331b01
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/app/common/elements/markdown2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ function CodeBlock(props: any): JSX.Element {
};

const handleCopy = async (e: any) => {
const textToCopy = getTextContent(props.children);
let textToCopy = getTextContent(props.children);
textToCopy = textToCopy.replace(/\n$/, ""); // remove trailing newline
await navigator.clipboard.writeText(textToCopy);
setCopied(true);
setTimeout(() => setCopied(false), 2000); // Reset copied state after 2 seconds
Expand All @@ -61,15 +62,6 @@ function CodeBlock(props: any): JSX.Element {

@mobxReact.observer
class Markdown2 extends React.Component<{ text: string; style?: any; className?: string }, {}> {
@boundMethod
handleClick(e: React.MouseEvent<HTMLElement>) {
let blockText = (e.target as HTMLElement).innerText;
if (blockText) {
blockText = blockText.replace(/\n$/, ""); // remove trailing newline
navigator.clipboard.writeText(blockText);
}
}

render() {
let { text, className } = this.props;
let markdownComponents = {
Expand Down

0 comments on commit a331b01

Please sign in to comment.