How to use the draft-js.convertFromRaw function in draft-js

To help you get started, we’ve selected a few draft-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github udacityalumni / udacity-alumni-fe / app / src / containers / CmsEditorContainer / index.js View on Github external
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);
    }
  }
github charliewilco / downwrite / reducers / editor.ts View on Github external
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
    };
  }
github madnivek / ForeverNote / frontend / components / dashboard / notes / note_container.jsx View on Github external
const _convertFromRaw = (rawContentString) => {
  return convertFromRaw(JSON.parse(rawContentString));
};
github withspectrum / spectrum / src / components / draftjs-editor / index.js View on Github external
const toState = json => EditorState.createWithContent(convertFromRaw(json));
github tubackkhoa / tkframework / client / ui / shared / components / Text / Editor / index.jsx View on Github external
getEditorState(mode, value){
    return value
      ? EditorState.createWithContent(mode === 'html' 
        ? HTML2ContentState(value) 
        : convertFromRaw(JSON.parse(value)), decorator)   
      : EditorState.createEmpty(decorator)
  }
github OpenNeuroOrg / openneuro / packages / openneuro-app / src / scripts / datalad / dataset / comment.jsx View on Github external
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>
github este / este / components / editor / EditorMenuInput.js View on Github external
static createContentState(name: string, value: Value) {
    return Draft.convertFromRaw({
      entityMap: {},
      blocks: [
        {
          text: value.toString(),
          key: name,
          type: 'unstyled',
          depth: 0,
          entityRanges: [],
          inlineStyleRanges: [],
        },
      ],
    });
  }
github bbc / react-transcript-editor / packages / components / timed-text-editor / index.js View on Github external
loadData() {
    if (this.props.transcriptData !== null) {
      const blocks = sttJsonAdapter(
        this.props.transcriptData,
        this.props.sttJsonType
      );
      this.setState({ originalState: convertToRaw(convertFromRaw(blocks)) });
      this.setEditorContentState(blocks);
    }
  }
github rsamec / react-designer / src / components / widgets / RichTextRenderer.js View on Github external
let RichTextRenderer = (props) =&gt; {

	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'};