Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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(/<\/p>/gmi, '');
if (!_html) {
syncContent('', '')
return
}
// console.log(html);
if (markdown) {
html = html.replace(/\<\/p\>\/g,'');
html = html.replace(/\<\/p\>/g,'');
html = html.replace(/<[^>]+>/g,"");</p>
useEffect( () => () => {
if ( lastKnownState.current ) {
// Remember to trim any trailing non-breaking space.
const properties = {
content: stateToHTML( lastKnownState.current, { defaultBlockTag: null } )
.replace( / $/, '' ),
};
updateElementById( { elementId: id, properties } );
}
}, [ id, updateElementById ] );
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}`);
}
}
}
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}`);
}
}
}
this.setState({ editorState }, () => {
// const contentState = editorState.getCurrentContent();
const html = stateToHTML(editorState.getCurrentContent());
this.props.onChange(html);
});
}
this.setState({ editorState }, () => {
// const contentState = editorState.getCurrentContent();
const html = stateToHTML(editorState.getCurrentContent());
this.props.onChange(html);
});
}
this.setState({ editorState }, () => {
// const contentState = editorState.getCurrentContent();
const html = stateToHTML(editorState.getCurrentContent());
this.props.onChange(html);
});
}
onChange = (editorState) => {
console.log(stateToHTML(editorState.getCurrentContent()))
this.setState({ editorState })
}
_handleSubmit() {
if (this.state.editorState.getCurrentContent().hasText()) {
const htmlContent = stateToHTML(this.state.editorState.getCurrentContent());
this.props.publishContent(htmlContent);
}
}
export default function editorStateToHTML(editorState, checkedState) {
const contentState = editorState.getCurrentContent();
return stateToHTML(contentState, checkedState);
}