Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
() => {
if (editor) {
if (onDestroy) {
onDestroy(editor);
}
GrapesJS.editors = GrapesJS.editors.filter((e: any) => e !== editor);
editor.destroy();
if (document) {
const container: HTMLDivElement = document.getElementById(id) as HTMLDivElement;
if (container) {
container.innerHTML = '';
}
}
}
},
[editor, id, onDestroy],
return function cleanup() {
if (editor) {
editor.destroy();
GrapesJS.editors = GrapesJS.editors.filter((e) => e !== editor);
}
};
},
(props: IEditorProps, ref: React.Ref) => {
const {
id,
onInit,
onDestroy,
presetType,
blockManager,
storageManager,
styleManager,
width,
height,
children,
plugins: propPlugins,
} = props;
const [editor, setEditor] = React.useState(GrapesJS.editors.find((e: any) => {
return e.getContainer().id === id;
}));
const handleCleanup = React.useCallback(
() => {
if (editor) {
if (onDestroy) {
onDestroy(editor);
}
GrapesJS.editors = GrapesJS.editors.filter((e: any) => e !== editor);
editor.destroy();
if (document) {
const container: HTMLDivElement = document.getElementById(id) as HTMLDivElement;
if (container) {
container.innerHTML = '';
}