Skip to content

Commit

Permalink
Merge pull request #39 from Aar-if/main
Browse files Browse the repository at this point in the history
css issue fix
  • Loading branch information
itsvick authored Oct 15, 2024
2 parents f718ce0 + 6de8f60 commit 2d348bd
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/components/QuestionSetEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ const QuestionSetEditor: React.FC = () => {
};

loadAssets();

return () => {
const editorCss = document.getElementById("sunbird-editor-css");
const editorScript = document.getElementById("sunbird-editor-js");

if (editorCss) document.head.removeChild(editorCss);
if (editorScript) document.body.removeChild(editorScript);
};
}, []);

// Initialize the editor only after assets are loaded
Expand All @@ -166,12 +174,15 @@ const QuestionSetEditor: React.FC = () => {
JSON.stringify(questionSetEditorConfig)
);

questionsetEditorElement.addEventListener("editorEmitter", (event: any) => {
console.log("Editor event:", event);
if (event.detail?.action === "backContent") {
window.history.back();
questionsetEditorElement.addEventListener(
"editorEmitter",
(event: any) => {
console.log("Editor event:", event);
if (event.detail?.action === "backContent") {
window.history.back();
}
}
});
);

editorRef.current.appendChild(questionsetEditorElement);
isAppendedRef.current = true;
Expand All @@ -180,11 +191,7 @@ const QuestionSetEditor: React.FC = () => {

return (
<div>
{assetsLoaded ? (
<div ref={editorRef}></div>
) : (
<p>Loading editor...</p>
)}
{assetsLoaded ? <div ref={editorRef}></div> : <p>Loading editor...</p>}
</div>
);
};
Expand Down

0 comments on commit 2d348bd

Please sign in to comment.