read container width and height at copy time (#1041)

main
Michael Fix 4 years ago committed by GitHub
parent ad523b1cc5
commit e765b54baa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,10 +8,12 @@ import Button from './Button'
import Popout, { managePopout } from './Popout' import Popout, { managePopout } from './Popout'
import CopySVG from './svg/Copy' import CopySVG from './svg/Copy'
const toIFrame = url => const toIFrame = (url, width, height) =>
`<iframe `<iframe
src="${location.origin}/embed${url.replace(/^\/\?/, '?')}" src="${location.origin}/embed${url.replace(/^\/\?/, '?')}"
style="transform:scale(0.7); width:1024px; height:473px; border:0; overflow:hidden;" style="width: ${width || 1024}px; height: ${
height || 473
}px; border:0; transform: scale(1); overflow:hidden;"
sandbox="allow-scripts allow-same-origin"> sandbox="allow-scripts allow-same-origin">
</iframe> </iframe>
` `
@ -52,7 +54,7 @@ function useClipboardSupport() {
return isClipboardSupports return isClipboardSupports
} }
function CopyMenu({ isVisible, toggleVisibility, copyImage }) { function CopyMenu({ isVisible, toggleVisibility, copyImage, carbonRef }) {
const clipboardSupported = useClipboardSupport() const clipboardSupported = useClipboardSupport()
const [showCopied, { loading: copied }] = useAsyncCallback( const [showCopied, { loading: copied }] = useAsyncCallback(
@ -93,7 +95,10 @@ function CopyMenu({ isVisible, toggleVisibility, copyImage }) {
</CopyButton> </CopyButton>
)} )}
<CopyEmbed title="Medium.com" mapper={toEncodedURL} /> <CopyEmbed title="Medium.com" mapper={toEncodedURL} />
<CopyEmbed title="IFrame" mapper={toIFrame} /> <CopyEmbed
title="IFrame"
mapper={url => toIFrame(url, carbonRef.clientWidth, carbonRef.clientHeight)}
/>
<CopyEmbed title="Plain URL" mapper={toURL} /> <CopyEmbed title="Plain URL" mapper={toURL} />
</div> </div>
</Popout> </Popout>

@ -415,7 +415,7 @@ class Editor extends React.Component {
/> />
<div id="style-editor-button" /> <div id="style-editor-button" />
<div className="buttons"> <div className="buttons">
<CopyMenu copyImage={this.copyImage} /> <CopyMenu copyImage={this.copyImage} carbonRef={this.carbonNode.current} />
<TweetButton onClick={this.tweet} /> <TweetButton onClick={this.tweet} />
<ExportMenu <ExportMenu
onChange={this.updateSetting} onChange={this.updateSetting}

Loading…
Cancel
Save