2016-06-24 10:22:48 -07:00
|
|
|
|
|
|
|
import React from 'react'
|
|
|
|
import ReactDOM from 'react-dom'
|
|
|
|
import { Router, Route, Link, IndexRedirect, hashHistory } from 'react-router'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Examples.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import AutoMarkdown from './auto-markdown'
|
2017-03-28 12:55:48 -04:00
|
|
|
import CheckLists from './check-lists'
|
2016-07-06 14:05:35 -07:00
|
|
|
import CodeHighlighting from './code-highlighting'
|
2016-07-28 15:38:17 -07:00
|
|
|
import Embeds from './embeds'
|
2016-09-23 18:46:24 +02:00
|
|
|
import Emojis from './emojis'
|
2016-11-16 17:25:27 -08:00
|
|
|
import FocusBlur from './focus-blur'
|
2016-06-28 15:47:29 -07:00
|
|
|
import HoveringMenu from './hovering-menu'
|
2016-08-05 12:40:54 -07:00
|
|
|
import Iframes from './iframes'
|
2016-06-28 18:26:56 -07:00
|
|
|
import Images from './images'
|
2016-11-03 10:39:38 +01:00
|
|
|
import LargeDocument from './large-document'
|
2016-06-24 10:22:48 -07:00
|
|
|
import Links from './links'
|
2016-06-29 10:43:22 -07:00
|
|
|
import PasteHtml from './paste-html'
|
2016-06-24 10:22:48 -07:00
|
|
|
import PlainText from './plain-text'
|
2016-07-26 12:15:21 -07:00
|
|
|
import Plugins from './plugins'
|
2016-08-05 12:40:54 -07:00
|
|
|
import RTL from './rtl'
|
2016-07-17 15:57:27 -07:00
|
|
|
import ReadOnly from './read-only'
|
2016-06-24 10:22:48 -07:00
|
|
|
import RichText from './rich-text'
|
|
|
|
import Tables from './tables'
|
2016-08-05 12:40:54 -07:00
|
|
|
|
2016-07-18 15:05:51 -07:00
|
|
|
import DevPerformancePlain from './development/performance-plain'
|
|
|
|
import DevPerformanceRich from './development/performance-rich'
|
2016-06-24 10:22:48 -07:00
|
|
|
|
2016-07-12 22:26:57 -07:00
|
|
|
/**
|
|
|
|
* Perf.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Perf from 'react-addons-perf'
|
|
|
|
|
|
|
|
window.Perf = Perf
|
|
|
|
|
2016-06-24 10:22:48 -07:00
|
|
|
/**
|
|
|
|
* Define our example app.
|
|
|
|
*
|
|
|
|
* @type {Component} App
|
|
|
|
*/
|
|
|
|
|
|
|
|
class App extends React.Component {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the example app.
|
|
|
|
*
|
|
|
|
* @return {Element} element
|
|
|
|
*/
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2016-07-06 14:05:35 -07:00
|
|
|
<div className="app">
|
2016-12-25 21:18:39 -08:00
|
|
|
{this.renderTopBar()}
|
2016-06-24 10:22:48 -07:00
|
|
|
{this.renderTabBar()}
|
|
|
|
{this.renderExample()}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2016-12-25 21:18:39 -08:00
|
|
|
/**
|
|
|
|
* Render the top bar.
|
|
|
|
*
|
|
|
|
* @return {Element} element
|
|
|
|
*/
|
|
|
|
|
|
|
|
renderTopBar() {
|
|
|
|
return (
|
|
|
|
<div className="topbar">
|
|
|
|
<span className="topbar-title">Slate Examples</span>
|
|
|
|
<div className="topbar-links">
|
|
|
|
<a className="topbar-link" href="https://github.com/ianstormtaylor/slate">
|
|
|
|
GitHub
|
|
|
|
</a>
|
|
|
|
<a className="topbar-link" href="https://docs.slatejs.org/">
|
|
|
|
Docs
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2016-06-24 10:22:48 -07:00
|
|
|
/**
|
|
|
|
* Render the tab bar.
|
|
|
|
*
|
|
|
|
* @return {Element} element
|
|
|
|
*/
|
|
|
|
|
|
|
|
renderTabBar() {
|
|
|
|
return (
|
|
|
|
<div className="tabs">
|
2016-06-29 10:43:22 -07:00
|
|
|
{this.renderTab('Rich Text', 'rich-text')}
|
|
|
|
{this.renderTab('Plain Text', 'plain-text')}
|
|
|
|
{this.renderTab('Auto-markdown', 'auto-markdown')}
|
|
|
|
{this.renderTab('Hovering Menu', 'hovering-menu')}
|
2016-11-03 10:39:38 +01:00
|
|
|
{this.renderTab('Large Document', 'large')}
|
2016-06-29 10:43:22 -07:00
|
|
|
{this.renderTab('Links', 'links')}
|
|
|
|
{this.renderTab('Images', 'images')}
|
2016-07-28 15:38:17 -07:00
|
|
|
{this.renderTab('Embeds', 'embeds')}
|
2016-09-23 18:46:24 +02:00
|
|
|
{this.renderTab('Emojis', 'emojis')}
|
2016-06-29 10:43:22 -07:00
|
|
|
{this.renderTab('Tables', 'tables')}
|
2017-03-28 12:55:48 -04:00
|
|
|
{this.renderTab('Check Lists', 'check-lists')}
|
2016-07-06 14:05:35 -07:00
|
|
|
{this.renderTab('Code Highlighting', 'code-highlighting')}
|
2016-06-29 10:43:22 -07:00
|
|
|
{this.renderTab('Paste HTML', 'paste-html')}
|
2016-07-26 12:15:21 -07:00
|
|
|
{this.renderTab('Read-only', 'read-only')}
|
2016-07-29 12:05:01 -07:00
|
|
|
{this.renderTab('RTL', 'rtl')}
|
2016-07-26 12:15:21 -07:00
|
|
|
{this.renderTab('Plugins', 'plugins')}
|
2016-08-05 12:40:54 -07:00
|
|
|
{this.renderTab('Iframes', 'iframes')}
|
2016-11-16 17:25:27 -08:00
|
|
|
{this.renderTab('Focus & Blur', 'focus-blur')}
|
2016-06-24 10:22:48 -07:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2016-06-29 10:43:22 -07:00
|
|
|
/**
|
|
|
|
* Render a tab with `name` and `slug`.
|
|
|
|
*
|
|
|
|
* @param {String} name
|
|
|
|
* @param {String} slug
|
|
|
|
*/
|
|
|
|
|
|
|
|
renderTab(name, slug) {
|
|
|
|
return (
|
|
|
|
<Link className="tab" activeClassName="active" to={slug}>{name}</Link>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2016-06-24 10:22:48 -07:00
|
|
|
/**
|
|
|
|
* Render the example.
|
|
|
|
*
|
|
|
|
* @return {Element} element
|
|
|
|
*/
|
|
|
|
|
|
|
|
renderExample() {
|
|
|
|
return (
|
|
|
|
<div className="example">
|
|
|
|
{this.props.children}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Router.
|
|
|
|
*
|
|
|
|
* @type {Element} router
|
|
|
|
*/
|
|
|
|
|
|
|
|
const router = (
|
|
|
|
<Router history={hashHistory}>
|
|
|
|
<Route path="/" component={App}>
|
2016-07-25 16:46:17 -07:00
|
|
|
<IndexRedirect to="rich-text" />
|
2016-08-05 12:40:54 -07:00
|
|
|
|
2016-06-24 10:22:48 -07:00
|
|
|
<Route path="auto-markdown" component={AutoMarkdown} />
|
2017-03-28 12:55:48 -04:00
|
|
|
<Route path="check-lists" component={CheckLists} />
|
2016-07-25 16:46:17 -07:00
|
|
|
<Route path="code-highlighting" component={CodeHighlighting} />
|
2016-07-28 15:38:17 -07:00
|
|
|
<Route path="embeds" component={Embeds} />
|
2016-09-23 18:46:24 +02:00
|
|
|
<Route path="emojis" component={Emojis} />
|
2016-11-16 17:25:27 -08:00
|
|
|
<Route path="focus-blur" component={FocusBlur} />
|
2016-07-25 16:46:17 -07:00
|
|
|
<Route path="hovering-menu" component={HoveringMenu} />
|
2016-08-05 12:40:54 -07:00
|
|
|
<Route path="iframes" component={Iframes} />
|
2016-07-25 16:46:17 -07:00
|
|
|
<Route path="images" component={Images} />
|
2016-11-03 10:39:38 +01:00
|
|
|
<Route path="large" component={LargeDocument} />
|
2016-07-25 16:46:17 -07:00
|
|
|
<Route path="links" component={Links} />
|
|
|
|
<Route path="paste-html" component={PasteHtml} />
|
|
|
|
<Route path="plain-text" component={PlainText} />
|
2016-07-26 12:15:21 -07:00
|
|
|
<Route path="plugins" component={Plugins} />
|
2016-07-25 16:46:17 -07:00
|
|
|
<Route path="read-only" component={ReadOnly} />
|
|
|
|
<Route path="rich-text" component={RichText} />
|
2016-07-29 12:05:01 -07:00
|
|
|
<Route path="rtl" component={RTL} />
|
2016-07-25 16:46:17 -07:00
|
|
|
<Route path="tables" component={Tables} />
|
2016-08-05 12:40:54 -07:00
|
|
|
|
2016-07-25 16:46:17 -07:00
|
|
|
<Route path="dev-performance-plain" component={DevPerformancePlain} />
|
|
|
|
<Route path="dev-performance-rich" component={DevPerformanceRich} />
|
2016-06-24 10:22:48 -07:00
|
|
|
</Route>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mount the router.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const root = document.body.querySelector('main')
|
|
|
|
ReactDOM.render(router, root)
|