Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
render() {
const {
editorState,
editorTitle,
isValid,
onChangeTitle,
onSubmit,
onChangeContent,
onTapToPreview,
} = this.props;
const stateForEditor = editorState ? editorState : editorStateFromRaw(null);
return (
<div>
<div>
<input placeholder="Title" value="{editorTitle}" type="titleInput">
</div>
<div>
onChangeContent(state)}</div></div>
import React, { Component } from 'react';
import { EditorState, convertToRaw, convertFromRaw } from 'draft-js';
import { MegadraftEditor, editorStateFromRaw } from 'megadraft';
import Button from '../Button/Button';
import LoadJSON from '../LoadJSON/LoadJSON';
import Preview from '../Preview/Preview';
import ForkRibbon from '../ForkRibbon/ForkRibbon';
import sample from '../sample';
import './App.css';
import '../../node_modules/megadraft/dist/css/megadraft.css';
const intialState = editorStateFromRaw(sample);
class App extends Component {
state = {
editorState: intialState,
raw: convertToRaw(intialState.getCurrentContent()),
paste: false,
};
handleUpdate = (editorState) => {
this.setState({
editorState,
raw: convertToRaw(editorState.getCurrentContent()),
paste: false,
});
};
import * as types from './constants';
import update from 'react-addons-update';
import { editorStateFromRaw } from 'megadraft';
export const initialState = {
article: {
id: null,
action: null,
},
editorState: editorStateFromRaw(null),
editorTitle: null,
preview: {
isPreviewing: false,
content: null,
title: null,
},
isValid: false,
isLoading: false,
error: null,
message: null,
modal: {
isShowing: false,
status: 0,
spotlighted: false,
selectedTags: [],
featureImage: null,
$set: action.action,
},
},
});
case types.CMS_SET_FEATURE_IMAGE:
return update(state, {
modal: modalReducer(state.modal, action),
});
case types.CMS_SET_STATE_FROM_ARTICLE:
const rawContent = JSON.parse(action.article.json);
return update(state, {
isValid: {
$set: true,
},
editorState: {
$set: editorStateFromRaw(rawContent),
},
editorTitle: {
$set: action.article.title,
},
modal: {
$set: modalReducer(state.modal, action),
},
});
default:
return state;
}
};