Skip to content

Commit

Permalink
video insertion now works on the Add Notes screen
Browse files Browse the repository at this point in the history
  • Loading branch information
AmarHadzic committed Oct 14, 2024
1 parent 9db4be1 commit 45200b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
11 changes: 9 additions & 2 deletions __tests__/AddNoteScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ describe('AddNoteScreen', () => {
expect(getByTestId('RichEditor')).toBeTruthy();
});

it('renders the save button', () => {
const routeMock = { params: { untitledNumber: 1 } };
const { getByTestId } = render(<AddNoteScreen route={routeMock as any} />);

// Check if the save button is rendered
expect(getByTestId('checklocationpermission')).toBeTruthy();
});


it('handles saveNote API error', async () => {
const routeMock = { params: { untitledNumber: 1 } };
Expand Down Expand Up @@ -141,7 +149,6 @@ describe("AddNoteScreen's checkLocationPermission method", () => {
await waitFor(() => {
expect(mockWriteNewNote).toHaveBeenCalledTimes(0); // Adjust expected to 0
});
});

});

});
20 changes: 11 additions & 9 deletions lib/screens/AddNoteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,20 @@ const AddNoteScreen: React.FC<{ navigation: any, route: any }> = ({ navigation,

const addVideoToEditor = async (videoUri: string) => {
try {
const thumbnailUri = await getThumbnail(videoUri);
const videoTag = `
<video width="320" height="240" controls poster="${thumbnailUri}">
<source src="${videoUri}" type="video/mp4">
Your browser does not support the video tag.
</video>`;
editor.commands.setContent(editor.getHTML() + videoTag);
// Append the video to the existing content
editor.setImage(videoUri);

editor.injectCSS(`
video {
width: 100px !important;
height: 100px !important;
}
`);
} catch (error) {
console.error("Error adding video: ", error);
console.error("Error adding video:", error);
}
};

const insertAudioToEditor = (audioUri: string) => {
const audioTag = `<audio controls src="${audioUri}"></audio>`;
editor.commands.setContent(editor.getHTML() + audioTag);
Expand Down

0 comments on commit 45200b0

Please sign in to comment.