diff --git a/frontend/components/Document/Document.js b/frontend/components/Document/Document.js index 1dd87f0ee..5eaa33d9c 100644 --- a/frontend/components/Document/Document.js +++ b/frontend/components/Document/Document.js @@ -1,8 +1,6 @@ import React, { PropTypes } from 'react'; import { observer } from 'mobx-react'; -import moment from 'moment'; -import { Link } from 'react-router'; import PublishingInfo from 'components/PublishingInfo'; import styles from './Document.scss'; @@ -35,7 +33,7 @@ class DocumentHtml extends React.Component {
); @@ -61,9 +59,9 @@ class Document extends React.Component { ); } -}; +} export default Document; export { - DocumentHtml + DocumentHtml, }; diff --git a/frontend/scenes/DocumentScene/DocumentScene.js b/frontend/scenes/DocumentScene/DocumentScene.js index 2edc57b24..5d911db73 100644 --- a/frontend/scenes/DocumentScene/DocumentScene.js +++ b/frontend/scenes/DocumentScene/DocumentScene.js @@ -6,10 +6,10 @@ import keydown from 'react-keydown'; import _ from 'lodash'; import DocumentSceneStore, { - DOCUMENT_PREFERENCES + DOCUMENT_PREFERENCES, } from './DocumentSceneStore'; -import Layout, { HeaderAction } from 'components/Layout'; +import Layout from 'components/Layout'; import AtlasPreviewLoading from 'components/AtlasPreviewLoading'; import CenteredContent from 'components/CenteredContent'; import Document from 'components/Document'; @@ -18,8 +18,8 @@ import Flex from 'components/Flex'; import Tree from 'components/Tree'; import styles from './DocumentScene.scss'; -import classNames from 'classnames/bind'; -const cx = classNames.bind(styles); +// import classNames from 'classnames/bind'; +// const cx = classNames.bind(styles); import treeStyles from 'components/Tree/Tree.scss'; @@ -29,24 +29,27 @@ class DocumentScene extends React.Component { static propTypes = { ui: PropTypes.object.isRequired, cache: PropTypes.object.isRequired, + routeParams: PropTypes.object, + params: PropTypes.object.isRequired, + location: PropTypes.object.isRequired, } static store; - state = { - didScroll: false, - } - constructor(props) { super(props); this.store = new DocumentSceneStore( - JSON.parse(localStorage[DOCUMENT_PREFERENCES] || "{}"), + JSON.parse(localStorage[DOCUMENT_PREFERENCES] || '{}'), { cache: this.props.cache, } ); } + state = { + didScroll: false, + } + componentDidMount = () => { const { id } = this.props.routeParams; this.store.fetchDocument(id); @@ -82,8 +85,8 @@ class DocumentScene extends React.Component { const name = hash.split('#')[1]; setTimeout(() => { this.setState({ didScroll: true }); - const element = doc.getElementsByName(name)[0]; - if (element) element.scrollIntoView() + const element = window.document.getElementsByName(name)[0]; + if (element) element.scrollIntoView(); }, 0); } } @@ -101,14 +104,14 @@ class DocumentScene extends React.Component { onDelete = () => { let msg; if (this.store.document.atlas.type === 'atlas') { - msg = 'Are you sure you want to delete this document and all it\'s child documents (if any)?' + msg = 'Are you sure you want to delete this document and all it\'s child documents (if any)?'; } else { - msg = "Are you sure you want to delete this document?"; + msg = 'Are you sure you want to delete this document?'; } if (confirm(msg)) { this.store.deleteDocument(); - }; + } } onExport = () => { @@ -126,8 +129,8 @@ class DocumentScene extends React.Component { renderNode = (node) => { return ( - - {node.module.name} + + { node.module.name } ); } @@ -156,13 +159,15 @@ class DocumentScene extends React.Component { ); title = ( - {doc.atlas.name} + { doc.atlas.name } { ` / ${doc.title}` } ); titleText = `${doc.atlas.name} - ${doc.title}`; } + console.log(toJS(doc)); + return (