diff --git a/src/App.js b/src/App.js index 149b7a3..d8e504b 100644 --- a/src/App.js +++ b/src/App.js @@ -50,6 +50,20 @@ const tabletIcon = ( ); +const clipboardIcon = ( + + + + +); + const viewList = [ { icon: desktopIcon, @@ -87,6 +101,7 @@ class App extends Component { this.changeView = this.changeView.bind(this); this.toggleSidebar = this.toggleSidebar.bind(this); this.toggleView = this.toggleView.bind(this); + this.copyToClipboard = this.copyToClipboard.bind(this); this.markupRef = React.createRef(); this.textareaRef = React.createRef(); } @@ -188,6 +203,16 @@ class App extends Component { this.setState({ sidebar: !this.state.sidebar }); } + copyToClipboard() { + const code = this.beautifyHTML(this.state.markup); + var input = document.createElement('textarea'); + input.innerHTML = code; + document.body.appendChild(input); + input.select(); + document.execCommand('copy'); + document.body.removeChild(input); +} + render() { const { darkMode, theme, blockName, blockType, sidebar, view } = this.state; return ( @@ -198,6 +223,12 @@ class App extends Component {
+ {this.state.codeView ? ( + ) : '' + }