Ejemplo n.º 1
0
 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 (document) {
     document.documentElement.classList.remove('no-scroll');
   }
   if (action && action === 'edit') {
     this.handleUpdateArticleSubmission(article);
   } else {
     this.handleNewArticleSubmission(article);
   }
 }
Ejemplo n.º 2
0
 handlePreviewArticle() {
   const {
     editorState,
     editorTitle,
     actions,
   } = this.props;
   const rawState = editorStateToJSON(editorState);
   const blockArray = convertFromRaw(JSON.parse(rawState));
   const markdown = stateToMarkdown(blockArray);
   actions.cmsSetPreviewState({ markdown, title: editorTitle });
 }