How to use the draft-js-export-html.stateToHTML function in draft-js-export-html

To help you get started, we’ve selected a few draft-js-export-html 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 54sword / xiaoduyu.com / src / app / components / editor / index.tsx View on Github external
function encodeAttr(text: string) {
              return text.split('&').join('&').split('<').join('<').split('>').join('>').split('"').join('"');
            }

            // return block.getText();
        
            // Otherwise, this is a one line code-block.
            return text;

          }
        }
      };


      let html = stateToHTML(content, options);

        let _html = html.replace(/<p>/gmi, '');
            _html = _html.replace(/&lt;\/p&gt;/gmi, '');

        if (!_html) {
          syncContent('', '')
          return
        }

        // console.log(html);
        
        if (markdown) {

          html = html.replace(/\&lt;\/p\&gt;\/g,'');
          html = html.replace(/\&lt;\/p\&gt;/g,'');
          html = html.replace(/&lt;[^&gt;]+&gt;/g,"");</p>
github ampproject / amp-wp / assets / src / edit-story / elements / text / edit.js View on Github external
useEffect( () => () => {
		if ( lastKnownState.current ) {
			// Remember to trim any trailing non-breaking space.
			const properties = {
				content: stateToHTML( lastKnownState.current, { defaultBlockTag: null } )
					.replace( /&nbsp;$/, '' ),
			};
			updateElementById( { elementId: id, properties } );
		}
	}, [ id, updateElementById ] );
github strues / boldr / src / cms / common / components / BoldrEditor / lib / EditorValue.js View on Github external
function toString(editorState: EditorState, format: string): string {
  const contentState = editorState.getCurrentContent();
  switch (format) {
    case 'html': {
      return stateToHTML(contentState);
    }
    // case 'markdown': {
    //   return stateToMarkdown(contentState);
    // }
    default: {
      throw new Error(`Format not supported: ${format}`);
    }
  }
}
github strues / boldr / packages / boldr-cms / src / shared / components / TextEditor / lib / EditorValue.js View on Github external
function toString(editorState: EditorState, format: string): string {
  const contentState = editorState.getCurrentContent();
  switch (format) {
    case 'html': {
      return stateToHTML(contentState);
    }
    // case 'markdown': {
    //   return stateToMarkdown(contentState);
    // }
    default: {
      throw new Error(`Format not supported: ${format}`);
    }
  }
}
github strues / boldr / src / cms / common / components / BoldrEditor / BoldrEditor.js View on Github external
this.setState({ editorState }, () => {
      // const contentState = editorState.getCurrentContent();
      const html = stateToHTML(editorState.getCurrentContent());
      this.props.onChange(html);
    });
  }
github strues / boldr / packages / boldr-editor / src / BoldrEditor.js View on Github external
this.setState({ editorState }, () => {
      // const contentState = editorState.getCurrentContent();
      const html = stateToHTML(editorState.getCurrentContent());
      this.props.onChange(html);
    });
  }
github strues / boldr / shared / components / TextEditor / TextEditor.js View on Github external
this.setState({ editorState }, () => {
      // const contentState = editorState.getCurrentContent();
      const html = stateToHTML(editorState.getCurrentContent());
      this.props.onChange(html);
    });
  }
github ld-x / last-draft / src / components / HtmlImport / HtmlImport.js View on Github external
onChange = (editorState) => {
    console.log(stateToHTML(editorState.getCurrentContent()))
    this.setState({ editorState })
  }
github Serverless-Vienna / Comments-Showcase / src / RichEditorExample.js View on Github external
_handleSubmit() {
    if (this.state.editorState.getCurrentContent().hasText()) {
      const htmlContent = stateToHTML(this.state.editorState.getCurrentContent());
      this.props.publishContent(htmlContent);
    }
  }
github oneteam-dev / oneteam-rte / src / stateToHTML.js View on Github external
export default function editorStateToHTML(editorState, checkedState) {
  const contentState = editorState.getCurrentContent();
  return stateToHTML(contentState, checkedState);
}

draft-js-export-html

DraftJS: Export ContentState to HTML

ISC
Latest version published 5 years ago

Package Health Score

59 / 100
Full package analysis

Popular draft-js-export-html functions