diff --git a/app/assets/stylesheets/markdown.scss b/app/assets/stylesheets/markdown.scss index 516ff7a8f28c3a55f06ea195b8056da37a80e649..6257c8e21febc8d718dce32edc39d89025511707 100644 --- a/app/assets/stylesheets/markdown.scss +++ b/app/assets/stylesheets/markdown.scss @@ -1,4 +1,26 @@ +.Markdown { + font-family: 'Source Serif Pro', serif; + font-size: 120%; + + line-height: 150%; +} + +// used for comments +.Markdown.MarkdownViewer--small { + font-family: inherit; + font-size: 110%; + + img { + max-width: 400px; + max-height: 400px; + } +} + .Markdown, .ReplyEditor__body.rte { + overflow-wrap: break-word; + word-wrap: break-word; + word-break: break-word; + hyphens: auto; h1, h2, h3, h4, h5, h6 { font-family: 'Source Serif Pro', serif; @@ -72,10 +94,3 @@ max-height: 75vw; } } - -.Markdown.MarkdownViewer--small { - img { - max-width: 400px; - max-height: 400px; - } -} diff --git a/app/components/cards/Comment.scss b/app/components/cards/Comment.scss index c2129d0674054625b15ed963a59a0dd173294466..460cd0e7fabd7ac969e34a755fa771b41ec9909f 100644 --- a/app/components/cards/Comment.scss +++ b/app/components/cards/Comment.scss @@ -83,8 +83,6 @@ .Comment__body { margin-left: 62px; max-width: 50rem; - font-size: 110%; - word-wrap: break-word; } .Comment__footer { diff --git a/app/components/cards/PostFull.scss b/app/components/cards/PostFull.scss index fa519e9b1e639a8b0a4e2811a09372a508557165..58db61db916309f93ca744e42105e58aefe1529c 100644 --- a/app/components/cards/PostFull.scss +++ b/app/components/cards/PostFull.scss @@ -44,16 +44,6 @@ .PostFull__body { padding: 1rem 0 2rem 0; clear: left; - - font-family: 'Source Serif Pro', serif; - font-size: 120%; - line-height: 150%; - - overflow-wrap: break-word; - word-wrap: break-word; - word-break: break-word; - hyphens: auto; - } .PostFull__footer { diff --git a/app/components/elements/ReplyEditor.jsx b/app/components/elements/ReplyEditor.jsx index b2368ff234a247b50be818183a3ad1af0815b637..372a9ea3d7ac9f61686774f71b9db5577c04ae60 100644 --- a/app/components/elements/ReplyEditor.jsx +++ b/app/components/elements/ReplyEditor.jsx @@ -24,7 +24,7 @@ let saveEditorTimeout // removes <html></html> wrapper if exists function stripHtmlWrapper(text) { - const m = text.match(/<html>([\S\s]*)<\/html>/m); + const m = text.match(/<html>\n?([\S\s]+?)\n?<\/html>/m); return m && m.length === 2 ? m[1] : text; } @@ -35,6 +35,7 @@ function addHtmlWrapper(body) { console.log(err); return body } + if(!body || body.trim() === '') body = ''; return `<html>\n${body}\n</html>`; } @@ -43,14 +44,16 @@ const isHtmlTest = text => /^<html>/.test(text) || /^<p>[\S\s]*<\/p>/.test(text) -function stateToHtml(rte_state) { - let html = rte_state.toString('html'); +function stateToHtml(state) { + let html = state.toString('html'); + if (html === '<p></p>') html = ''; if (html === '<p><br></p>') html = ''; return html } -function stateFromHtml(html) { +function stateFromHtml(html = null) { if(!RichTextEditor) return null; + if(html && html.trim() == '') html = null return html ? RichTextEditor.createValueFromString(html, 'html') : RichTextEditor.createEmptyValue() } @@ -344,7 +347,7 @@ class ReplyEditor extends React.Component { <small onClick={autoVoteOnChange}>Upvote post</small> - <input type="checkbox" {...cleanReduxInput(autoVote)} onChange={autoVoteOnChange} /> + <input type="checkbox" checked={autoVote.value} onChange={autoVoteOnChange} /> </div>} </div> {!loading && !rte && body.value && <div className={'Preview ' + vframe_section_shrink_class}>