1
1
mirror of https://github.com/jxnblk/mdx-deck.git synced 2024-09-20 19:37:27 +03:00

Merge branch 'master' into pdf

This commit is contained in:
Brent Jackson 2018-07-31 19:14:21 -04:00
commit 13ddefd6cb
8 changed files with 54 additions and 6 deletions

View File

@ -1,5 +1,7 @@
site
docs
coverage
test
.babelrc
.travis.yml
CHANGELOG.md

View File

@ -1,6 +1,17 @@
# Changelog
## v1.1.3 2018-07-31
- Add emoji support
- Update `.npmignore`
## v1.1.2 2018-07-31
- Fix `--no-open` option
- Add ability to ignore key events
- Normalize newlines for cross-platform compatibility
## v1.1.1 2018-07-31
- Fix for supporting markdown tables

14
cli.js
View File

@ -4,6 +4,9 @@ const meow = require('meow')
const open = require('react-dev-utils/openBrowser')
const chalk = require('chalk')
const ok = require('ok-cli')
const remark = {
emoji: require('remark-emoji')
}
const pkg = require('./package.json')
const config = require('pkg-conf').sync('mdx-deck')
@ -39,7 +42,14 @@ const getConfig = conf => {
].map(require.resolve)
}
},
require.resolve('./lib/loader.js'),
{
loader: require.resolve('./lib/loader.js'),
options: {
mdPlugins: [
remark.emoji
]
}
}
]
}
]
@ -163,7 +173,7 @@ switch (cmd) {
ok(opts)
.then(res => {
const url = 'http://localhost:' + res.port
open(url)
if (opts.open) open(url)
log('listening on', chalk.magenta(url))
})
.catch(err => {

View File

@ -43,5 +43,5 @@ import Box from 'superbox'
---
export default Layout
# Get started
# Get started :sunglasses:
[GitHub](https://github.com/jxnblk/mdx-deck)

View File

@ -1,6 +1,8 @@
const { getOptions } = require('loader-utils')
const mdx = require('@mdx-js/mdx')
const matter = require('gray-matter')
const stringifyObject = require('stringify-object')
const normalizeNewline = require('normalize-newline')
const EXREG = /export\sdefault\s\(/g
const MODREG = /^(import|export)\s/
@ -8,12 +10,14 @@ const SLIDEREG = /\n---\n/
module.exports = async function (src) {
const callback = this.async()
const options = getOptions(this) || {}
const { data, content } = matter(src)
const inlineModules = []
const slides = content.split(SLIDEREG)
.map(str => mdx.sync(str))
const slides = normalizeNewline(content)
.split(SLIDEREG)
.map(str => mdx.sync(str, options))
.map(str => str.trim())
.map(str => str.replace(EXREG, '('))
.map(str => {

View File

@ -1,6 +1,6 @@
{
"name": "mdx-deck",
"version": "1.1.1",
"version": "1.1.3",
"description": "MDX-based slide deck presentations",
"main": "dist/index.js",
"bin": {
@ -24,14 +24,17 @@
"chalk": "^2.4.1",
"clipboardy": "^1.2.3",
"gray-matter": "^4.0.1",
"loader-utils": "^1.1.0",
"lodash.debounce": "^4.0.8",
"meow": "^5.0.0",
"normalize-newline": "^3.0.0",
"ok-cli": "^3.0.4",
"pkg-conf": "^2.1.0",
"prop-types": "^15.6.2",
"puppeteer": "^1.6.1",
"react": "^16.4.1",
"react-dev-utils": "^5.0.1",
"remark-emoji": "^2.0.1",
"stringify-object": "^3.2.2",
"styled-components": ">=3.0.0",
"styled-system": "^3.0.2",

View File

@ -174,6 +174,7 @@ export class SlideDeck extends React.Component {
components: defaultComponents,
width: '100vw',
height: '100vh',
ignoreKeyEvents: false
}
state = {
@ -184,6 +185,10 @@ export class SlideDeck extends React.Component {
update = fn => this.setState(fn)
handleKeyDown = e => {
if (this.props.ignoreKeyEvents) {
return
}
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return
switch (e.key) {
case 'ArrowRight':

View File

@ -521,6 +521,19 @@ describe('components', () => {
expect(root.state.index).toBe(0)
})
test('ignoreKeyEvents does not fire handle events when set to true', () => {
window.history.pushState(null, null, '/#1')
const root = renderIntoDocument(
<SlideDeck ignoreKeyEvents={true} slides={[() => false, () => false]} />
)
const e = new KeyboardEvent('keydown', {
key: 'ArrowLeft'
})
expect(root.state.index).toBe(1)
document.body.dispatchEvent(e)
expect(root.state.index).toBe(1)
})
test.skip('handles hashchange events', () => {
window.history.pushState(null, null, '/')
const root = renderIntoDocument(