Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/components/Editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class Editor extends Component {
}

onKeyDown = evt => {
if (this.props.onKeyDown) {
this.props.onKeyDown(evt)
}
if (evt.keyCode === 9) { // Tab Key
document.execCommand('insertHTML', false, '&#009')
evt.preventDefault()
Expand All @@ -125,6 +128,9 @@ class Editor extends Component {
}

onKeyUp = evt => {
if (this.props.onKeyUp) {
this.props.onKeyUp(evt)
}
if (
evt.keyCode === 91 || // left cmd
evt.keyCode === 93 || // right cmd
Expand Down Expand Up @@ -158,7 +164,10 @@ class Editor extends Component {
this._doUndo = 0
}

onClick = () => {
onClick = evt => {
if (this.props.onClick) {
this.props.onClick(evt)
}
this.undoTimestamp = 0 // Reset timestamp
this.selection = selectionRange(this.ref)
}
Expand Down Expand Up @@ -188,11 +197,13 @@ class Editor extends Component {
}

render() {
const { contentEditable, className, style } = this.props
const { contentEditable, className, style, ...rest } = this.props
const { html } = this.state
delete rest.code

return (
<pre
{...rest}
ref={this.onRef}
className={cn('prism-code', className)}
style={style}
Expand Down
5 changes: 2 additions & 3 deletions src/components/Live/LiveEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import React from 'react'
import { LiveContextTypes } from './LiveProvider'
import Editor from '../Editor'

const LiveEditor = ({ className, style }, { live }) => (
const LiveEditor = (props, { live }) => (
<Editor
className={className}
style={style}
{...props}
code={live.code}
onChange={live.onChange}
/>
Expand Down