Skip to content

Commit d2ba03f

Browse files
committed
fix: change style for markdown text
1 parent 3be31bc commit d2ba03f

File tree

3 files changed

+220
-18
lines changed

3 files changed

+220
-18
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"html-webpack-plugin": "^2.30.1",
5656
"ignore-styles": "^1.2.0",
5757
"jsdom": "^7.2.2",
58-
"marked": "^2.0.0",
5958
"mocha": "^2.4.5",
6059
"mocha-jsdom": "~1.1.0",
6160
"nock": "^8.0.0",

src/components/MarkdownText/MarkdownText.jsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import React, { Component } from 'react'
22
import styles from './MarkdownText.scss'
33
import PropTypes from 'prop-types'
44
import EasyMDE from 'easymde'
5-
import marked from 'marked'
6-
import cn from 'classnames'
7-
import _ from 'lodash'
5+
import { markdownToHTML } from '../../helpers/markdownToState'
86

97
class MarkdownText extends Component {
108
constructor (props) {
@@ -13,7 +11,8 @@ class MarkdownText extends Component {
1311
isChanged: false
1412
}
1513
this.blurTheField = this.blurTheField.bind(this)
16-
this.updateDescriptionThrottled = _.throttle(this.updateDescription.bind(this), 10000) // 10s
14+
this.updateDescriptionThrottled = this.updateDescription.bind(this)
15+
// this.updateDescriptionThrottled = _.throttle(this.updateDescription.bind(this), 10000) // 10s
1716
}
1817

1918
blurTheField () {
@@ -41,13 +40,13 @@ class MarkdownText extends Component {
4140
}
4241
})
4342
} else {
44-
this.ref.current.innerHTML = value ? marked(value) : ''
43+
this.ref.current.innerHTML = value ? markdownToHTML(value) : ''
4544
}
4645
}
4746

4847
render () {
49-
const { isPrivate, readOnly, placeholder, className } = this.props
50-
return (<div className={cn(className, styles.editor, { [styles.isPrivate]: isPrivate })}>
48+
const { readOnly, placeholder } = this.props
49+
return (<div className={styles.editor}>
5150
{readOnly ? (
5251
<div ref="textarea" />
5352
) : (
@@ -61,14 +60,12 @@ class MarkdownText extends Component {
6160
}
6261

6362
MarkdownText.defaultProps = {
64-
isPrivate: false,
6563
readOnly: false
6664
}
6765

6866
MarkdownText.propTypes = {
6967
onChange: PropTypes.func.isRequired,
7068
value: PropTypes.string,
71-
isPrivate: PropTypes.bool,
7269
placeholder: PropTypes.string,
7370
readOnly: PropTypes.bool
7471
}

src/components/MarkdownText/MarkdownText.scss

Lines changed: 214 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,226 @@
33
.editor {
44
@include roboto-light();
55

6-
width: 100%;
7-
// margin: 0 30px;
86
border-radius: 2px;
97
font-size: 16px;
108
max-height: 410px;
119
display: flex;
12-
flex-direction: column;
13-
overflow: auto;
14-
15-
&.isPrivate {
16-
max-height: 205px;
17-
}
1810

1911
:global {
12+
.EasyMDEContainer {
13+
display: flex;
14+
width: 100%;
15+
flex-direction: column;
16+
overflow: auto;
17+
18+
// preview styles
19+
.h1,.h2,.h3,.h4,.h5,.h6,h1,h2,h3,h4,h5,h6 {
20+
text-align:initial;
21+
margin-bottom: .5rem;
22+
font-weight: 500;
23+
line-height: 1.2
24+
}
25+
26+
.h1,h1 {
27+
font-size: 2.5rem
28+
}
29+
30+
.h2,h2 {
31+
font-size: 2rem
32+
}
33+
34+
.h3,h3 {
35+
font-size: 1.75rem
36+
}
37+
38+
.h4,h4 {
39+
font-size: 1.5rem
40+
}
41+
42+
.h5,h5 {
43+
font-size: 1.25rem
44+
}
45+
46+
.h6,h6 {
47+
font-size: 1rem
48+
}
49+
h1,h2,h3,h4,h5,h6 {
50+
margin-top: 0;
51+
margin-bottom: .5rem
52+
}
53+
54+
p {
55+
margin-top: 0;
56+
margin-bottom: 1rem
57+
}
58+
59+
60+
dl,ol,ul {
61+
margin-top: 0;
62+
margin-bottom: 1rem;
63+
padding: revert;
64+
}
65+
ul {
66+
list-style-type: disc;
67+
}
68+
ul ul {
69+
list-style-type: circle;
70+
}
71+
ul ul ul {
72+
list-style-type: square;
73+
}
74+
ol {
75+
list-style-type: decimal;
76+
}
77+
78+
ol ol,ol ul,ul ol,ul ul {
79+
margin-bottom: 0
80+
}
81+
82+
dt {
83+
font-weight: 700
84+
}
85+
86+
dd {
87+
margin-bottom: .5rem;
88+
margin-left: 0
89+
}
90+
91+
blockquote {
92+
margin: 0 0 1rem
93+
}
94+
95+
b,strong {
96+
font-weight: bolder
97+
}
98+
99+
small {
100+
font-size: 80%
101+
}
102+
103+
sub,sup {
104+
position: relative;
105+
font-size: 75%;
106+
line-height: 0;
107+
vertical-align: initial
108+
}
109+
110+
sub {
111+
bottom: -.25em
112+
}
113+
114+
sup {
115+
top: -.5em
116+
}
117+
118+
a {
119+
color: #007bff;
120+
text-decoration: none;
121+
background-color: initial
122+
}
123+
124+
a:hover {
125+
color: #0056b3;
126+
text-decoration: underline
127+
}
128+
129+
a:not([href]),a:not([href]):hover {
130+
color: inherit;
131+
text-decoration: none
132+
}
133+
134+
code,kbd,pre,samp {
135+
font-family: SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;
136+
font-size: 1em
137+
}
138+
139+
pre {
140+
margin-top: 0;
141+
margin-bottom: 1rem;
142+
overflow: auto
143+
}
144+
145+
figure {
146+
margin: 0 0 1rem
147+
}
148+
149+
img {
150+
border-style: none
151+
}
152+
153+
img,svg {
154+
vertical-align: middle
155+
}
156+
157+
svg {
158+
overflow: hidden
159+
}
160+
161+
table {
162+
border-collapse: collapse
163+
}
164+
165+
caption {
166+
padding-top: .75rem;
167+
padding-bottom: .75rem;
168+
color: #6c757d;
169+
text-align: left;
170+
caption-side: bottom
171+
}
172+
173+
th {
174+
text-align: inherit
175+
}
176+
177+
178+
small {
179+
font-size: 80%;
180+
font-weight: 400
181+
}
182+
183+
mark {
184+
padding: .2em;
185+
background-color: #fcf8e3
186+
}
187+
188+
code {
189+
font-size: 87.5%;
190+
color: #e83e8c;
191+
word-wrap: break-word
192+
}
193+
194+
a>code {
195+
color: inherit
196+
}
197+
198+
kbd {
199+
padding: .2rem .4rem;
200+
font-size: 87.5%;
201+
color: #fff;
202+
background-color: #212529;
203+
border-radius: .2rem
204+
}
205+
206+
kbd kbd {
207+
padding: 0;
208+
font-size: 100%;
209+
font-weight: 700
210+
}
211+
212+
pre {
213+
display: block;
214+
font-size: 87.5%;
215+
color: #212529
216+
}
217+
218+
pre code {
219+
font-size: inherit;
220+
color: inherit;
221+
word-break: normal
222+
}
223+
224+
}
225+
20226
.CodeMirror.CodeMirror-wrap {
21227
min-height: 0;
22228
flex: 1;

0 commit comments

Comments
 (0)