Skip to content

Commit

Permalink
adding back event listener + deleting on return
Browse files Browse the repository at this point in the history
  • Loading branch information
abanobmikaeel committed Oct 3, 2023
1 parent 6f6e0f3 commit b1cf926
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-ckeditor-custom",
"version": "0.3.0",
"version": "0.3.2",
"description": "A react native library to handle custom ckeditors",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
11 changes: 6 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useEffect, useRef } from 'react';
import { SafeAreaView } from 'react-native';
// import SafeAreaView from 'react-native-safe-area-view';
import { Dimensions } from 'react-native';
import { WebView, type WebViewMessageEvent } from 'react-native-webview';

Expand Down Expand Up @@ -74,11 +75,7 @@ export const CKEditor5 = ({
return () => {
if (webview) {
webview.current?.injectJavaScript(

Check failure on line 77 in src/index.tsx

View workflow job for this annotation

GitHub Actions / lint

The ref value 'webview.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy 'webview.current' to a variable inside the effect, and use that variable in the cleanup function
`(function() {
var editorElement = document.getElementById('#editor1'); // Replace 'editor' with the ID of your textarea or element
editorElement.parentNode.removeChild(editorElement);
editor.destroy();
})();`
`(function() {document.removeEventListener('message', handleMessage);})();`
);
}
};
Expand Down Expand Up @@ -109,6 +106,10 @@ export const CKEditor5 = ({
);
}
);
document.addEventListener("message", function(data) {
editor.setData(data.data);
})
// Set initial data after editor is ready
editor.setData(\`${initialData}\`);
})
Expand Down

0 comments on commit b1cf926

Please sign in to comment.