This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/app/index.js

141 lines
4.9 KiB
JavaScript
Raw Normal View History

2017-05-12 00:23:56 +00:00
// @flow
import * as React from 'react';
2016-02-27 21:53:11 +00:00
import { render } from 'react-dom';
import { Provider } from 'mobx-react';
2017-05-17 07:11:13 +00:00
import {
BrowserRouter as Router,
Switch,
Route,
Redirect,
} from 'react-router-dom';
2016-02-27 21:53:11 +00:00
import stores from 'stores';
2017-10-27 05:42:08 +00:00
import globalStyles from 'shared/styles/globals';
2017-11-10 21:53:51 +00:00
import 'shared/styles/prism.css';
2016-02-27 21:53:11 +00:00
2016-04-29 05:25:37 +00:00
import Home from 'scenes/Home';
import Dashboard from 'scenes/Dashboard';
import Starred from 'scenes/Starred';
import Drafts from 'scenes/Drafts';
import Collection from 'scenes/Collection';
Slate editor (#38) * WIP: Slate editor * WIP * Focus at start / end working * ah ha * Super basic floating toolbar * Nested list editing * Pulling more logic into plugins * inline code markdown * Backspace at end of code block should remove mark * Ensure there is always an empty line at editor end * Add keyboard shortcuts for bold, italic, underline * Add strikethrough shortcode and toolbar * Toolbar to declarative Fixed paragraph styling Removed unused stuffs * Super basic link editing * Split Toolbar, now possible to edit and remove links * Add new link to selection from toolbar working * Ensure toolbar doesn't extend off screen * Fix minor js issues, disable formatting of document title * Boom, icons * Remove codemirror, fix MD parsing issues * CMD+S now saves inplace * Add --- shortcut for horizontal rule * Improved styling for link editor * Add header anchors in readOnly * More readable core text color * Restored image file uploading :tada: * Add support for inline md syntax, ** __ etc * Centered * Flooooow * Checklist support * Upgrade edit list plugin * Finally. Allow keydown within rich textarea * Update Markdown serializer * Cleanup, remove async editor loading * Editor > MarkdownEditor Fixed unsaved changes warning triggered when all changes are saved * MOAR typing * Combine edit and view * Fixed checkboxes still editable in readOnly * wip * Breadcrumb Restored scroll * Move document scene actions to menu * Added: Support for code blocks, syntax highlighting * Cleanup * > styled component * Prevent CMD+Enter from adding linebreak * Show image uploading in layout activity indicator * Upgrade editor deps * Improve link toolbar. Only one scenario where it's not working now
2017-05-18 02:36:31 +00:00
import Document from 'scenes/Document';
2016-07-18 03:59:32 +00:00
import Search from 'scenes/Search';
import Settings from 'scenes/Settings';
2018-05-25 06:23:05 +00:00
import Members from 'scenes/Settings/Members';
import Slack from 'scenes/Settings/Slack';
2018-05-23 06:01:49 +00:00
import Shares from 'scenes/Settings/Shares';
import Tokens from 'scenes/Settings/Tokens';
2017-02-10 03:57:35 +00:00
import Error404 from 'scenes/Error404';
2016-08-01 16:18:27 +00:00
2017-11-13 00:08:55 +00:00
import ErrorBoundary from 'components/ErrorBoundary';
2017-07-03 05:16:48 +00:00
import ScrollToTop from 'components/ScrollToTop';
import Layout from 'components/Layout';
2017-12-19 06:55:14 +00:00
import Auth from 'components/Auth';
import RouteSidebarHidden from 'components/RouteSidebarHidden';
2017-09-04 21:48:56 +00:00
import { matchDocumentSlug } from 'utils/routeHelpers';
2016-06-26 05:43:28 +00:00
let DevTools;
if (__DEV__) {
2016-08-03 12:00:17 +00:00
DevTools = require('mobx-react-devtools').default; // eslint-disable-line global-require
2016-06-26 05:43:28 +00:00
}
2016-06-05 21:38:14 +00:00
2017-05-17 07:11:13 +00:00
const notFoundSearch = () => <Search notFound />;
const DocumentNew = () => <Document newDocument />;
2017-07-03 18:17:29 +00:00
const RedirectDocument = ({ match }: { match: Object }) => (
<Redirect to={`/doc/${match.params.documentSlug}`} />
2017-07-03 18:17:29 +00:00
);
2016-06-05 01:28:14 +00:00
2017-10-27 05:42:08 +00:00
globalStyles();
2018-05-05 23:16:08 +00:00
const element = document.getElementById('root');
if (element) {
render(
<React.Fragment>
<ErrorBoundary>
<Provider {...stores}>
<Router>
<ScrollToTop>
<Switch>
<Route exact path="/" component={Home} />
<Route exact path="/share/:shareId" component={Document} />
2018-05-05 23:16:08 +00:00
<Auth>
<Layout>
<Switch>
<Route exact path="/dashboard" component={Dashboard} />
<Route exact path="/starred" component={Starred} />
<Route exact path="/drafts" component={Drafts} />
<Route exact path="/settings" component={Settings} />
2018-05-25 06:23:05 +00:00
<Route
exact
path="/settings/members"
component={Members}
/>
2018-05-23 06:01:49 +00:00
<Route exact path="/settings/shares" component={Shares} />
2018-05-05 23:16:08 +00:00
<Route exact path="/settings/tokens" component={Tokens} />
<Route
exact
path="/settings/integrations/slack"
component={Slack}
/>
<Route
exact
path="/collections/:id"
component={Collection}
/>
<Route
exact
path={`/d/${matchDocumentSlug}`}
component={RedirectDocument}
/>
<Route
exact
path={`/doc/${matchDocumentSlug}`}
component={Document}
/>
<Route
exact
path={`/doc/${matchDocumentSlug}/move`}
component={Document}
/>
<Route exact path="/search" component={Search} />
<Route exact path="/search/:query" component={Search} />
<Route path="/404" component={Error404} />
<RouteSidebarHidden
exact
path={`/doc/${matchDocumentSlug}/edit`}
component={Document}
/>
<RouteSidebarHidden
exact
path="/collections/:id/new"
component={DocumentNew}
/>
<Route component={notFoundSearch} />
</Switch>
</Layout>
</Auth>
</Switch>
</ScrollToTop>
</Router>
</Provider>
</ErrorBoundary>
{DevTools && <DevTools position={{ bottom: 0, right: 0 }} />}
</React.Fragment>,
element
);
}
window.addEventListener('load', async () => {
// installation does not use Google Analytics, or tracking is blocked on client
// no point loading the rest of the analytics bundles
if (!process.env.GOOGLE_ANALYTICS_ID || !window.ga) return;
// https://github.com/googleanalytics/autotrack/issues/137#issuecomment-305890099
await import('autotrack/autotrack.js');
window.ga('require', 'outboundLinkTracker');
window.ga('require', 'urlChangeTracker');
});