Skip to content

Commit

Permalink
Merge pull request #54 from moeen-basra/development
Browse files Browse the repository at this point in the history
fix the editor
  • Loading branch information
moeen-basra authored Mar 7, 2020
2 parents 7adcb7d + 4aac2f3 commit fff8059
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ public static function loadAllPublished(): Paginator
*
* @param string $slug
*
* @return \App\Article
* @return Article
*/
public static function loadPublished(string $slug): Article
{
return static::with([
'user' => function (Builder $query) {
'user' => function (BelongsTo $query) {
$query->select('id', 'name');
},
])
Expand Down
14 changes: 7 additions & 7 deletions resources/js/common/wysiwyg-editor/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { EditorState, convertToRaw, ContentState, convertFromHTML } from 'draft-js'
import { ContentState, convertFromHTML, convertToRaw, EditorState } from 'draft-js'
import { Editor } from 'react-draft-wysiwyg'
import draftToHtml from 'draftjs-to-html'

Expand All @@ -22,8 +22,8 @@ class WYSIWYG extends Component {
this.onEditorStateChange = this.onEditorStateChange.bind(this)
}

convertHtmlToEditorState(value) {
if (value){
convertHtmlToEditorState = (value) => {
if (value) {
const blocksFromHTML = convertFromHTML(value)
const state = ContentState.createFromBlockArray(
blocksFromHTML.contentBlocks,
Expand All @@ -34,7 +34,7 @@ class WYSIWYG extends Component {
}
}

onEditorStateChange(editorState) {
onEditorStateChange = (editorState) => {
this.setState({
editorState,
})
Expand All @@ -43,14 +43,14 @@ class WYSIWYG extends Component {
}

render() {
const { editorState } = this.state
const {editorState} = this.state
return (
<div>
<Editor
editorState={editorState}
editorState={ editorState }
wrapperClassName="demo-wrapper"
editorClassName="form-control"
onEditorStateChange={this.onEditorStateChange}
onEditorStateChange={ this.onEditorStateChange }
/>
</div>
)
Expand Down

0 comments on commit fff8059

Please sign in to comment.