Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleSubmit() {
const {
action,
editorTitle,
editorState,
modal,
} = this.props;
const json = editorStateToJSON(editorState);
const blockArray = convertFromRaw(JSON.parse(json));
const content = stateToMarkdown(blockArray);
const article = inputToArticle({
json,
content,
title: editorTitle,
status: modal.status,
spotlighted: modal.spotlighted,
tags: modal.selectedTags,
feature_image: modal.featureImage || '',
});
if (action && action === 'edit') {
this.handleUpdateArticleSubmission(article);
} else {
this.handleNewArticleSubmission(article);
}
}
export function initializer(initialData: { entry: Entry }): IEditorState {
console.log("EDITOR_INITIALIZER", initialData);
if (initialData) {
const draft = markdownToDraft(initialData.entry.content);
const editorState = Draft.EditorState.createWithContent(
Draft.convertFromRaw(draft)
);
return {
editorState,
title: initialData.entry.title,
publicStatus: initialData.entry.public,
initialFocus: false
};
} else {
return {
editorState: null,
title: null,
publicStatus: null,
initialFocus: false
};
}
const _convertFromRaw = (rawContentString) => {
return convertFromRaw(JSON.parse(rawContentString));
};
const toState = json => EditorState.createWithContent(convertFromRaw(json));
getEditorState(mode, value){
return value
? EditorState.createWithContent(mode === 'html'
? HTML2ContentState(value)
: convertFromRaw(JSON.parse(value)), decorator)
: EditorState.createEmpty(decorator)
}
const Comment = ({ datasetId, data, children }) => {
const [replyMode, setReplyMode] = useState(false)
const [editMode, setEditMode] = useState(false)
const parsedText = JSON.parse(data.text)
const editorState = EditorState.createWithContent(convertFromRaw(parsedText))
return (
<>
<div>
<div>
{`By ${data.user.email} - ${distanceInWordsToNow(
data.createDate,
)} ago`}
</div>
<div>
<img src="{userUtil.generateGravatarUrl(data.user)}">
{editMode ? (
</div></div>
static createContentState(name: string, value: Value) {
return Draft.convertFromRaw({
entityMap: {},
blocks: [
{
text: value.toString(),
key: name,
type: 'unstyled',
depth: 0,
entityRanges: [],
inlineStyleRanges: [],
},
],
});
}
loadData() {
if (this.props.transcriptData !== null) {
const blocks = sttJsonAdapter(
this.props.transcriptData,
this.props.sttJsonType
);
this.setState({ originalState: convertToRaw(convertFromRaw(blocks)) });
this.setEditorContentState(blocks);
}
}
let RichTextRenderer = (props) => {
var style = props.style || {};
styleFont(style, props.font);
//size
if (props.height) style.height = props.height;
if (props.width) style.width = props.width;
var htmlContent = props.content !== undefined ? stateToHTML(convertFromRaw(props.content)) : ['type your content'];
return (
<div style="{style}">
</div>
);
}
//RichEditorRenderer.defaultProps = {content:'type your content'};