require('./sharePage.less'); const React = require('react'); const createClass = require('create-react-class'); const { Meta } = require('vitreum/headtags'); const Nav = require('naturalcrit/nav/nav.jsx'); const Navbar = require('../../navbar/navbar.jsx'); const PrintLink = require('../../navbar/print.navitem.jsx'); const RecentNavItem = require('../../navbar/recent.navitem.jsx').both; const Account = require('../../navbar/account.navitem.jsx'); const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx'); const SharePage = createClass({ displayName : 'SharePage', getDefaultProps : function() { return { brew : { title : '', text : '', style : '', shareId : null, createdAt : null, updatedAt : null, views : 0, renderer : '' } }; }, componentDidMount : function() { document.addEventListener('keydown', this.handleControlKeys); }, componentWillUnmount : function() { document.removeEventListener('keydown', this.handleControlKeys); }, handleControlKeys : function(e){ if(!(e.ctrlKey || e.metaKey)) return; const P_KEY = 80; if(e.keyCode == P_KEY){ window.open(`/print/${this.processShareId()}?dialog=true`, '_blank').focus(); e.stopPropagation(); e.preventDefault(); } }, processShareId : function() { return this.props.brew.googleId && !this.props.brew.stubbed ? this.props.brew.googleId + this.props.brew.shareId : this.props.brew.shareId; }, render : function(){ return
{this.props.brew.title} {this.props.brew.shareId && <> source view download clone to new }
; } }); module.exports = SharePage;