Skip to content

This is the updated copy button #2460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions client/modules/IDE/pages/IDEView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next';
import { Helmet } from 'react-helmet';
import SplitPane from 'react-split-pane';
import MediaQuery from 'react-responsive';
import { BiCopy } from 'react-icons/bi';
import IDEKeyHandlers from '../components/IDEKeyHandlers';
import Sidebar from '../components/Sidebar';
import PreviewFrame from '../components/PreviewFrame';
Expand Down Expand Up @@ -127,7 +128,15 @@ const IDEView = () => {
}
};
}, [shouldAutosave, dispatch]);

const handleCopy = async () => {
const editor = cmRef.current;
try {
const content = editor;
await navigator.clipboard.writeText(content.getContent().content);
} catch (error) {
console.error('Failed to copy text to clipboard:', error);
}
};
return (
<RootPage>
<Helmet>
Expand All @@ -142,7 +151,12 @@ const IDEView = () => {
<MediaQuery minWidth={770}>
{(matches) =>
matches ? (
<main className="editor-preview-container">
<main
className="editor-preview-container"
style={{
color: 'red'
}}
>
<SplitPane
split="vertical"
size={ide.sidebarIsExpanded ? sidebarSize : 20}
Expand Down Expand Up @@ -188,8 +202,27 @@ const IDEView = () => {
</SplitPane>
<section className="preview-frame-holder">
<header className="preview-frame__header">
<h2 className="preview-frame__title">
<h2
className="preview-frame__title"
style={{ position: 'absolute', display: 'block' }}
>
{t('Toolbar.Preview')}
<button
style={{
outline: '0',
padding: '0',
margin: '0',
border: '0',
position: 'relative',
top: '130%',
left: '-130%',
fontSize: '17.5px',
cursor: 'pointer'
}}
onClick={handleCopy}
>
<BiCopy />
</button>
</h2>
</header>
<div className="preview-frame__content">
Expand Down
64 changes: 64 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@
"react-ga": "^3.3.0",
"react-helmet": "^5.1.3",
"react-i18next": "^11.11.3",
"react-icon": "^1.0.0",
"react-icons": "^4.11.0",
"react-markdown": "^6.0.3",
"react-redux": "^7.2.4",
"react-refresh": "^0.14.0",
Expand Down