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 MetadataNav = require('../../navbar/metadata.navitem.jsx'); const PrintNavItem = 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 { DEFAULT_BREW_LOAD } = require('../../../../server/brewDefaults.js'); const { printCurrentBrew, fetchThemeBundle } = require('../../../../shared/helpers.js'); const SharePage = createClass({ displayName : 'SharePage', getDefaultProps : function() { return { brew : DEFAULT_BREW_LOAD, disableMeta : false }; }, getInitialState : function() { return { themeBundle : {} }; }, componentDidMount : function() { document.addEventListener('keydown', this.handleControlKeys); fetchThemeBundle(this, this.props.brew.renderer, this.props.brew.theme); }, 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){ if(e.keyCode == P_KEY) printCurrentBrew(); 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; }, renderEditLink : function(){ if(!this.props.brew.editId) return; let editLink = this.props.brew.editId; if(this.props.brew.googleId && !this.props.brew.stubbed) { editLink = this.props.brew.googleId + editLink; } return edit ; }, render : function(){ const titleStyle = this.props.disableMeta ? { cursor: 'default' } : {}; const titleEl = {this.props.brew.title}; return
{ this.props.disableMeta ? titleEl : {titleEl} } {this.props.brew.shareId && <> source view {this.renderEditLink()} download clone to new }
; } }); module.exports = SharePage;