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 attach file/image button in editor header
ammarahm-ed328d26aa429e
diff --git a/apps/mobile/src/views/Editor/EditorHeader.js b/apps/mobile/src/views/Editor/EditorHeader.jsindex 69ba86ed0..7c85a7580 100644--- a/apps/mobile/src/views/Editor/EditorHeader.js+++ b/apps/mobile/src/views/Editor/EditorHeader.js@@ -52,7 +52,8 @@ import tiny, {safeKeyboardDismiss} from './tiny/tiny';import {toolbarRef} from './tiny/toolbar/constants';import * as Progress from 'react-native-progress';-import { ProgressCircle } from './ProgressCircle';+import {ProgressCircle} from './ProgressCircle';+import picker from './tiny/toolbar/picker';const EditorHeader = () => {const [state] = useTracked();const {colors} = state;@@ -305,6 +306,19 @@ const EditorHeader = () => {/>)}+ {currentlyEditingNote && (+ <ActionIcon+ name="attachment"+ color={colors.pri}+ customStyle={{+ marginLeft: 10,+ borderRadius: 5+ }}+ top={50}+ onPress={picker.pick}+ />+ )}+{deviceMode !== 'mobile' && !fullscreen ? (<ActionIconname="fullscreen"@@ -332,7 +346,7 @@ const EditorHeader = () => {onPress={showActionsheet}/>- <ProgressCircle/>+ <ProgressCircle /></></View></View>diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/commands.js b/apps/mobile/src/views/Editor/tiny/toolbar/commands.jsindex e3f7fb80c..2039c3185 100644--- a/apps/mobile/src/views/Editor/tiny/toolbar/commands.js+++ b/apps/mobile/src/views/Editor/tiny/toolbar/commands.js@@ -70,8 +70,6 @@ export const execCommands = {})();`,cl: `tinymce.activeEditor.execCommand('insertCheckList')`,- filepicker: picker.file,- image: picker.image,video: `tinymce.activeEditor.execCommand('mceMedia')`,pre: `tinymce.activeEditor.execCommand('mceInsertCodeBlock')diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/config.js b/apps/mobile/src/views/Editor/tiny/toolbar/config.jsindex 784748617..ca04a9473 100644--- a/apps/mobile/src/views/Editor/tiny/toolbar/config.js+++ b/apps/mobile/src/views/Editor/tiny/toolbar/config.js@@ -330,7 +330,7 @@ export const TOOLBAR_CONFIG = [}],[- {+ /* {format: 'filepicker',type: 'format',fullname: 'Attach file',@@ -341,7 +341,7 @@ export const TOOLBAR_CONFIG = [type: 'format',fullname: 'Image',premium: true- },+ }, */{format: 'video',type: 'format',diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/picker.js b/apps/mobile/src/views/Editor/tiny/toolbar/picker.jsindex 62c4a6c58..82793f8b8 100644--- a/apps/mobile/src/views/Editor/tiny/toolbar/picker.js+++ b/apps/mobile/src/views/Editor/tiny/toolbar/picker.js@@ -99,14 +99,14 @@ const file = async () => {}let uri = Platform.OS === 'ios' ? file.fileCopyUri : file.uri;- console.log('file uri: ',uri);- uri = Platform.OS === "ios" ? santizeUri(uri) : uri;+ console.log('file uri: ', uri);+ uri = Platform.OS === 'ios' ? santizeUri(uri) : uri;showEncryptionSheet(file);let hash = await Sodium.hashFile({uri: uri,type: 'url'});- console.log('decoded uri: ',uri);+ console.log('decoded uri: ', uri);let result = await attachFile(uri, hash, file.type, file.name, 'file');console.log('attach file: ', result);@@ -146,7 +146,60 @@ const file = async () => {}};-const image = async () => {+const camera = async () => {+ try {+ await db.attachments.generateKey();+ eSendEvent(eCloseProgressDialog);+ await sleep(400);+ launchCamera(+ {+ includeBase64: true,+ maxWidth: 4000,+ maxHeight: 4000,+ quality: 0.8,+ mediaType: 'photo'+ },+ handleImageResponse+ );+ } catch (e) {+ ToastEvent.show({+ heading: e.message,+ message: 'You need internet access to attach a file',+ type: 'error',+ context: 'global'+ });+ console.log('attachment error:', e);+ }+};++const gallery = async () => {+ try {+ await db.attachments.generateKey();+ eSendEvent(eCloseProgressDialog);+ await sleep(400);+ launchImageLibrary(+ {+ includeBase64: true,+ maxWidth: 4000,+ maxHeight: 4000,+ quality: 0.8,+ mediaType: 'photo',+ selectionLimit: 1+ },+ handleImageResponse+ );+ } catch (e) {+ ToastEvent.show({+ heading: e.message,+ message: 'You need internet access to attach a file',+ type: 'error',+ context: 'global'+ });+ console.log('attachment error:', e);+ }+};++const pick = async () => {if (editing.isFocused) {safeKeyboardDismiss();await sleep(500);@@ -158,61 +211,21 @@ const image = async () => {actionsArray: [{action: async () => {- try {- await db.attachments.generateKey();- eSendEvent(eCloseProgressDialog);- await sleep(400);- launchCamera(- {- includeBase64: true,- maxWidth: 4000,- maxHeight: 4000,- quality: 0.8,- mediaType: 'photo'- },- handleImageResponse- );- } catch (e) {- ToastEvent.show({- heading: e.message,- message: 'You need internet access to attach a file',- type: 'error',- context: 'global'- });- console.log('attachment error:', e);- }+ eSendEvent(eCloseProgressDialog);+ await sleep(400);+ await file();},- actionText: 'Take photo',+ actionText: 'Attach a file',+ icon: 'file'+ },+ {+ action: camera,+ actionText: 'Open camera',icon: 'camera'},{- action: async () => {- try {- await db.attachments.generateKey();- eSendEvent(eCloseProgressDialog);- await sleep(400);- launchImageLibrary(- {- includeBase64: true,- maxWidth: 4000,- maxHeight: 4000,- quality: 0.8,- mediaType: 'photo',- selectionLimit: 1- },- handleImageResponse- );- } catch (e) {- ToastEvent.show({- heading: e.message,- message: 'You need internet access to attach a file',- type: 'error',- context: 'global'- });- console.log('attachment error:', e);- }- },- actionText: 'Select from gallery',+ action: gallery,+ actionText: 'Select image from gallery',icon: 'image-multiple'}]@@ -308,5 +321,5 @@ async function attachFile(uri, hash, type, filename) {export default {file,- image+ pick};