Skip to content

Commit

Permalink
fix(docz-theme-default): add prop to keep codemirror last line
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Aug 30, 2018
1 parent 04d1e1a commit 5c1e813
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ interface PreProps {
indentUnit?: number
onChange?: (code: string) => any
language?: string
withLastLine?: boolean
}

export const Editor: SFC<PreProps> = ({
Expand All @@ -144,6 +145,7 @@ export const Editor: SFC<PreProps> = ({
className,
editorClassName,
language: defaultLanguage,
withLastLine,
...props
}) => {
const code = getChildren(children)
Expand All @@ -169,7 +171,7 @@ export const Editor: SFC<PreProps> = ({
className={editorClassName}
onViewportChange={() => console.log('helo')}
editorDidMount={(editor: any) => {
if (editor && props.readOnly) {
if (editor && !withLastLine && props.readOnly) {
const lastLine = editor.lastLine()
editor.doc.replaceRange(
'',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ export class Render extends Component<RenderComponentProps, RenderState> {
{this.state.code}
</Jsx>
) : (
<Pre editorClassName={editorClassName} actions={<Fragment />}>
<Pre
editorClassName={editorClassName}
actions={<Fragment />}
withLastLine
>
{this.html}
</Pre>
)}
Expand Down

0 comments on commit 5c1e813

Please sign in to comment.