Skip to content

Commit 79c838d

Browse files
Merge pull request #130 from gmal1/master
add syntax highlighting
2 parents 02c0d55 + ae463ee commit 79c838d

File tree

4 files changed

+186
-30
lines changed

4 files changed

+186
-30
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
"build": "cross-env NODE_ENV=production webpack --config webpack.config.production.js",
6464
"build-bin": "electron-builder -mwl",
6565
"test": "cross-env NODE_ENV=test jest",
66-
"linter": "eslint src"
66+
"linter": "eslint src",
67+
"develop": "concurrently \"yarn run dev\" \"yarn run electron\""
6768
},
6869
"bin": {
6970
"reactype": "./index.js"
@@ -91,8 +92,8 @@
9192
"cli-spinner": "^0.2.8",
9293
"commander": "^2.17.1",
9394
"d3": "^5.9.2",
94-
"enzyme": "^3.4.1",
9595
"electron-reload": "^1.4.0",
96+
"enzyme": "^3.4.1",
9697
"konva": "^2.1.7",
9798
"localforage": "^1.7.2",
9899
"lodash.throttle": "^4.1.1",
@@ -105,6 +106,7 @@
105106
"react-konva": "^1.7.12",
106107
"react-redux": "^5.0.7",
107108
"react-sortable-tree": "^2.2.0",
109+
"react-syntax-highlighter": "^10.2.1",
108110
"redux": "^4.0.0",
109111
"redux-devtools-extension": "^2.13.5",
110112
"redux-logger": "^3.0.6",

src/actionTypes/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ export const ADD_PROP = 'ADD_PROP';
2626
export const DELETE_ALL_DATA = 'DELETE_ALL_DATA';
2727
export const CHANGE_IMAGE_PATH = 'CHANGE_IMAGE_PATH';
2828
export const UPDATE_HTML_ATTR = 'UPDATE_HTML_ATTR';
29-
export const UPDATE_CHILDREN_SORT = 'UPDATE_CHILDREN_SORT';
29+
export const UPDATE_CHILDREN_SORT = 'UPDATE_CHILDREN_SORT'

src/components/CodePreview.tsx

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import React, { Component, Fragment } from 'react';
1+
import React, { Component } from 'react';
22
import { format } from 'prettier';
33
import componentRender from '../utils/componentRender.util.ts';
44
import { ComponentInt, ComponentsInt } from '../utils/Interfaces.ts';
55
/** ** SortCHildren will be fixed , dont XXX the file *** */
66
// import SortChildren from './SortChildren.jsx';
7+
import SyntaxHighlighter from 'react-syntax-highlighter';
8+
import { hybrid } from 'react-syntax-highlighter/dist/styles/hljs/';
79

810
type Props = {
911
focusComponent: ComponentInt;
@@ -16,30 +18,17 @@ class CodePreview extends Component<Props> {
1618
const components: ComponentsInt = this.props.components;
1719

1820
return (
19-
<Fragment>
20-
{/* <SortChildren /> */}
21-
<div
22-
style={{
23-
width: '800px',
24-
height: '290px',
25-
direction: 'rtl',
26-
paddingLeft: '20px',
27-
color: '#D3D3D3',
28-
fontSize: 16,
29-
overflow: 'auto',
30-
}}
31-
>
32-
<pre style={{ direction: 'ltr' }}>
33-
{format(componentRender(focusComponent, components), {
34-
singleQuote: true,
35-
trailingComma: 'es5',
36-
bracketSpacing: true,
37-
jsxBracketSameLine: true,
38-
parser: 'typescript',
39-
})}
40-
</pre>
41-
</div>
42-
</Fragment>
21+
<div
22+
style={{
23+
height: '290px',
24+
paddingLeft: '30px',
25+
overflow: 'auto'
26+
}}
27+
>
28+
<SyntaxHighlighter style={hybrid}>
29+
{format(componentRender(focusComponent, components))}
30+
</SyntaxHighlighter>
31+
</div>
4332
);
4433
}
4534
}

0 commit comments

Comments
 (0)