11import React , { Component } from "react" ;
22import { Card , Button } from "react-bootstrap" ;
33import "./ReadMe.scss" ;
4- import { Editor } from "@tinymce/tinymce-react" ;
54import { updateProfile , getProfile } from "../../actions/usersAction" ;
65import { connect } from "react-redux" ;
6+ import ReadMeEditor from './ReadMeEditor'
7+ import ReadMePreview from './ReadMePreview'
78
89class ReadMe extends Component {
910 constructor ( props ) {
1011 super ( props ) ;
11- this . state = {
12- longDescription : true ,
13- displayEditor : false ,
14- currentText : "" ,
15- firstName : "" ,
16- lastName : "" ,
17- shortDesc : "" ,
18- location : "" ,
19- github : "" ,
20- fb : "" ,
21- linkedIn : "" ,
22- designation : "" ,
23- website : "" ,
24- longDesc : "" ,
25- canChangeName : "" ,
26- } ;
27- }
28-
29- componentDidMount ( ) {
3012 const userProfile = this . props . userProfile ;
3113 const about = userProfile . info ?. about ;
3214 let longDescription = true ;
3315 if ( ! about . hasOwnProperty ( "longDescription" ) ) {
3416 longDescription = false ;
3517 }
3618
37- this . setState ( {
19+ this . state = {
20+ longDescription : true ,
21+ displayEditor : false ,
22+ currentText : "" ,
3823 firstName : userProfile . name ?. firstName ,
3924 lastName : userProfile . name ?. lastName ,
4025 website : about ?. website ,
@@ -43,7 +28,7 @@ class ReadMe extends Component {
4328 shortDesc : about ?. shortDescription ,
4429 location : about ?. location ,
4530 longDescription : longDescription ,
46- } ) ;
31+ } ;
4732 }
4833
4934 handleCreateReadMe = ( ) => {
@@ -127,22 +112,7 @@ class ReadMe extends Component {
127112 </ Button >
128113 </ Card . Body >
129114 </ Card >
130- < Editor
131- value = { this . state . longDesc }
132- disabled = { true }
133- apiKey = "lvp9xf6bvvm3nkaupm67ffzf50ve8femuaztgg7rkgkmsws3"
134- init = { {
135- height : "100%" ,
136- width : "100%" ,
137- menubar : false ,
138- plugins : [
139- "advlist autolink lists link image charmap print preview anchor" ,
140- "searchreplace visualblocks code fullscreen" ,
141- "insertdatetime media table paste code help wordcount" ,
142- ] ,
143- toolbar : false ,
144- } }
145- />
115+ < ReadMePreview longDesc = { this . state . longDesc } />
146116 </ div >
147117 ) : displayEditor ? (
148118 < div className = "editorContainer" >
@@ -158,66 +128,7 @@ class ReadMe extends Component {
158128 </ Button >
159129 </ Card . Body >
160130 </ Card >
161- < Editor
162- value = { this . state . longDesc }
163- apiKey = "lvp9xf6bvvm3nkaupm67ffzf50ve8femuaztgg7rkgkmsws3"
164- init = { {
165- height : "100%" ,
166- width : "100%" ,
167- menubar : false ,
168- plugins : [
169- "advlist autolink lists link image charmap print preview anchor" ,
170- "searchreplace visualblocks code fullscreen" ,
171- "insertdatetime media table paste code help wordcount" ,
172- "textpattern" ,
173- ] ,
174- textpattern_patterns : [
175- { start : "#" , format : "h1" } ,
176- { start : "##" , format : "h2" } ,
177- { start : "###" , format : "h3" } ,
178- { start : "####" , format : "h4" } ,
179- { start : "#####" , format : "h5" } ,
180- { start : "######" , format : "h6" } ,
181- { start : "* " , cmd : "InsertUnorderedList" } ,
182- { start : "- " , cmd : "InsertUnorderedList" } ,
183- {
184- start : "1. " ,
185- cmd : "InsertOrderedList" ,
186- value : { "list-style-type" : "decimal" } ,
187- } ,
188- {
189- start : "1) " ,
190- cmd : "InsertOrderedList" ,
191- value : { "list-style-type" : "decimal" } ,
192- } ,
193- {
194- start : "a. " ,
195- cmd : "InsertOrderedList" ,
196- value : { "list-style-type" : "lower-alpha" } ,
197- } ,
198- {
199- start : "a) " ,
200- cmd : "InsertOrderedList" ,
201- value : { "list-style-type" : "lower-alpha" } ,
202- } ,
203- {
204- start : "i. " ,
205- cmd : "InsertOrderedList" ,
206- value : { "list-style-type" : "lower-roman" } ,
207- } ,
208- {
209- start : "i) " ,
210- cmd : "InsertOrderedList" ,
211- value : { "list-style-type" : "lower-roman" } ,
212- } ,
213- ] ,
214- toolbar :
215- "undo redo | formatselect | bold italic backcolor | \
216- alignleft aligncenter alignright alignjustify | \
217- bullist numlist outdent indent | removeformat | help" ,
218- } }
219- onEditorChange = { this . handleEditorChange }
220- />
131+ < ReadMeEditor longDesc = { this . state . longDesc } onEditorChange = { this . handleEditorChange } />
221132 </ div >
222133 ) : (
223134 < Card className = "readmeCard" style = { { backgroundColor : "#E8F1FD" } } >
0 commit comments