diff --git a/__tests__/AddNoteScreen.test.tsx b/__tests__/AddNoteScreen.test.tsx
index 00cf76d..6b88021 100644
--- a/__tests__/AddNoteScreen.test.tsx
+++ b/__tests__/AddNoteScreen.test.tsx
@@ -63,6 +63,14 @@ describe('AddNoteScreen', () => {
expect(getByTestId('RichEditor')).toBeTruthy();
});
+ it('renders the save button', () => {
+ const routeMock = { params: { untitledNumber: 1 } };
+ const { getByTestId } = render();
+
+ // Check if the save button is rendered
+ expect(getByTestId('checklocationpermission')).toBeTruthy();
+ });
+
it('handles saveNote API error', async () => {
const routeMock = { params: { untitledNumber: 1 } };
@@ -141,7 +149,6 @@ describe("AddNoteScreen's checkLocationPermission method", () => {
await waitFor(() => {
expect(mockWriteNewNote).toHaveBeenCalledTimes(0); // Adjust expected to 0
});
- });
-
+ });
});
diff --git a/lib/screens/AddNoteScreen.tsx b/lib/screens/AddNoteScreen.tsx
index 0f2b018..bdee1c6 100644
--- a/lib/screens/AddNoteScreen.tsx
+++ b/lib/screens/AddNoteScreen.tsx
@@ -53,9 +53,9 @@ const AddNoteScreen: React.FC<{ navigation: any, route: any }> = ({ navigation,
// Add a guard check before calling editor.commands.focus()
useEffect(() => {
- if (editor?.commands?.focus) {
+ if (editor?.focus) {
const timeout = setTimeout(() => {
- editor.commands.focus();
+ editor.focus();
}, 500);
return () => clearTimeout(timeout);
}
@@ -90,18 +90,24 @@ const AddNoteScreen: React.FC<{ navigation: any, route: any }> = ({ navigation,
const addVideoToEditor = async (videoUri: string) => {
try {
- const thumbnailUri = await getThumbnail(videoUri);
+ // Get the current HTML content in the editor
+ const currentHTML = await editor.getHTML();
+
+ // Construct the video HTML tag with full width and block-level display
const videoTag = `
- `;
- editor.commands.setContent(editor.getHTML() + videoTag);
+
+

+
+ `;
+
+ // Insert the video tag into the editor content with a newline after it
+ editor.setContent(currentHTML + videoTag + '
'); // Ensure text after video starts on a new line
+
} catch (error) {
- console.error("Error adding video: ", error);
+ console.error("Error adding video:", error);
}
};
-
+
const insertAudioToEditor = (audioUri: string) => {
const audioTag = ``;
editor.commands.setContent(editor.getHTML() + audioTag);