A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
add support to take image from gallery or camera
ammarahm-ed0a64492904f6
diff --git a/apps/mobile/ios/Notesnook/Info.plist b/apps/mobile/ios/Notesnook/Info.plistindex 51e6a06f5..3503e905c 100644--- a/apps/mobile/ios/Notesnook/Info.plist+++ b/apps/mobile/ios/Notesnook/Info.plist@@ -70,10 +70,12 @@</dict></dict></dict>+ <key>NSCameraUsageDescription</key>+ <string>Take a picture and add it to your note.</string><key>NSLocationWhenInUseUsageDescription</key><string></string><key>NSPhotoLibraryUsageDescription</key>- <string>Access photos to be added to your notes</string>+ <string>Add photos from gallery to your note.</string><key>UIAppFonts</key><array><string>MaterialCommunityIcons.ttf</string>diff --git a/apps/mobile/src/components/ProgressDialog/index.js b/apps/mobile/src/components/ProgressDialog/index.jsindex 9bf7b4b8a..cfb32c793 100644--- a/apps/mobile/src/components/ProgressDialog/index.js+++ b/apps/mobile/src/components/ProgressDialog/index.js@@ -60,7 +60,7 @@ const ProgressDialog = () => {}}>{!dialogData?.noProgress ? (<ActivityIndicator size={50} color={colors.accent} />- ) : (+ ) : dialogData?.noIcon ? null : (<Iconcolor={colors.accent}name={dialogData.icon || 'check'}@@ -68,16 +68,19 @@ const ProgressDialog = () => {/>)}- <Heading> {dialogData?.title}</Heading>- <Paragraph style={{textAlign: 'center'}}>- {dialogData?.paragraph}- {!dialogData?.noProgress ? (- <Paragraph color={colors.errorText}>- {' '}- Do not close the app.- </Paragraph>- ) : null}- </Paragraph>+ {dialogData?.title && <Heading> {dialogData?.title}</Heading>}++ {dialogData?.paragraph && (+ <Paragraph style={{textAlign: 'center'}}>+ {dialogData?.paragraph}+ {!dialogData?.noProgress ? (+ <Paragraph color={colors.errorText}>+ {' '}+ Do not close the app.+ </Paragraph>+ ) : null}+ </Paragraph>+ )}</View><Viewstyle={{@@ -117,12 +120,13 @@ const ProgressDialog = () => {fontSize={SIZE.md}/>) : null}-+{dialogData?.actionsArray &&dialogData?.actionsArray.map((item) => (<ButtononPress={item.action}title={item.actionText}+ icon={item.icon && item.icon}type="accent"height={50}style={{diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/commands.js b/apps/mobile/src/views/Editor/tiny/toolbar/commands.jsindex 5d1ec8b9e..103b52cff 100644--- a/apps/mobile/src/views/Editor/tiny/toolbar/commands.js+++ b/apps/mobile/src/views/Editor/tiny/toolbar/commands.js@@ -1,5 +1,10 @@import DocumentPicker from 'react-native-document-picker';-+import {launchCamera, launchImageLibrary} from 'react-native-image-picker';+import {eSendEvent} from '../../../../services/EventManager';+import {+ eCloseProgressDialog,+ eOpenProgressDialog,+} from '../../../../utils/Events';import {formatSelection} from './constants';let RNFetchBlob;@@ -50,31 +55,91 @@ export const execCommands = {`tinymce.activeEditor.execCommand('mceInsertTable', false, { rows: ${r}, columns: ${c} })`,cl: `tinymce.activeEditor.execCommand('InsertCheckList')`,image: () => {- DocumentPicker.pick({- type: [DocumentPicker.types.images],- }).then((r) => {-- RNFetchBlob = require('rn-fetch-blob').default- RNFetchBlob.fs.readFile(r.uri, 'base64').then((read) => {- let b64 = `data:${r.type};base64, ` + read;- formatSelection(`- minifyImg(- "${b64}",- 1024,- 'image/jpeg',- (r) => {- var content = "<img style=" + "max-width:100% !important;" + "src=" + r + ">";- editor.undoManager.transact(() => editor.execCommand("mceInsertContent",false,content));+ eSendEvent(eOpenProgressDialog, {+ noProgress: true,+ noIcon: true,+ actionsArray: [+ {+ action: () => {+ eSendEvent(eCloseProgressDialog);+ launchCamera(+ {+ includeBase64: true,+ maxWidth: 1024,+ mediaType: 'photo',+ },+ (response) => {+ if (response.didCancel || response.errorMessage) {+ return;+ }+ console.log(+ response.type,+ response.errorCode,+ response.errorMessage,+ );+ let b64 = `data:${response.type};base64, ` + response.base64;+ formatSelection(`+ minifyImg(+ "${b64}",+ 1024,+ 'image/jpeg',+ (r) => {+ var content = "<img style=" + "max-width:100% !important;" + "src=" + r + ">";+ editor.undoManager.transact(() => editor.execCommand("mceInsertContent",false,content));+ },+ 0.6,+ );+ `);+ },+ );+ },+ actionText: 'Take photo',+ icon: 'camera',+ },+ {+ action: () => {+ eSendEvent(eCloseProgressDialog);+ launchImageLibrary(+ {+ includeBase64: true,+ maxWidth: 1024,+ mediaType: 'photo',+ },+ (response) => {+ if (response.didCancel || response.errorMessage) {+ return;+ }+ console.log(+ response.type,+ response.errorCode,+ response.errorMessage,+ );+ let b64 = `data:${response.type};base64, ` + response.base64;+ formatSelection(`+ minifyImg(+ "${b64}",+ 1024,+ 'image/jpeg',+ (r) => {+ var content = "<img style=" + "max-width:100% !important;" + "src=" + r + ">";+ editor.undoManager.transact(() => editor.execCommand("mceInsertContent",false,content));+ },+ 0.6,+ );+ `);+ },+ );},- 0.6,- );- `);- });+ actionText: 'Select from gallery',+ icon: 'image-multiple',+ },+ ],});++ return;},video: `tinymce.activeEditor.execCommand('mceMedia')`,- pre:`+ pre: `tinymce.activeEditor.execCommand('CodeBlock')`,-};