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
export note in html, text and md
ammarahm-ed1603f48dc9e8
diff --git a/apps/mobile/src/components/ExportDialog/index.js b/apps/mobile/src/components/ExportDialog/index.jsindex a8650ae1c..232d4e6fe 100644--- a/apps/mobile/src/components/ExportDialog/index.js+++ b/apps/mobile/src/components/ExportDialog/index.js@@ -10,7 +10,7 @@ import {import Icon from 'react-native-vector-icons/MaterialCommunityIcons';import {opacity, ph, pv, SIZE, WEIGHT} from '../../common/common';import {useTracked} from '../../provider';-import {DDS, getElevation, db} from '../../utils/utils';+import {DDS, getElevation, db, ToastEvent} from '../../utils/utils';import {Loading} from '../Loading';const {@@ -34,7 +34,7 @@ const ExportDialog = () => {const [exporting, setExporting] = useState(false);const [complete, setComplete] = useState(false);const [doneText, setDoneText] = useState(null);- const [result,setResult] = useState({})+ const [result, setResult] = useState({});useEffect(() => {eSubscribeEvent(eOpenExportDialog, open);eSubscribeEvent(eCloseExportDialog, close);@@ -57,52 +57,58 @@ const ExportDialog = () => {setNotes([]);};- var decodeHtmlEntity = function (str) {- return str.replace(/&#(\d+);/g, function (match, dec) {- return String.fromCharCode(dec);- });+ const save = async (func, mime, name) => {+ setExporting(true);+ let res;+ for (var i = 0; i < notes.length; i++) {+ let note = notes[i];+ res = await func(note);+ if (!res) {+ setExporting(false);+ return;+ }+ }+ setDoneText(+ `Note exported successfully! You can find the exported note in ${+ Platform.OS === 'ios'+ ? 'Files Manager/Notesnook'+ : `Storage/Notesnook/exported/${name}`+ }.`,+ );+ let fileData = {...res};+ fileData.type = mime;+ fileData.name = name;+ setResult(fileData);+ setComplete(true);};const actions = [{title: 'PDF',func: async () => {- setExporting(true);- let res;- for (var i = 0; i < notes.length; i++) {- let note = notes[i];- res = await storage.saveToPDF(note);- if (!res) {- setExporting(false);- return;- }- }- setDoneText(- `Note exported successfully! You can find the exported note in ${- Platform.OS === 'ios'- ? 'Files Manager/Notesnook'- : 'Storage/Notesnook/exported/PDF'- }.`,- );-- setResult(res);- setComplete(true);+ await save(storage.saveToPDF, 'application/pdf', 'PDF');},icon: 'file-pdf-box',},{title: 'Markdown',- func: () => {},+ func: async () => {+ await save(storage.saveToMarkdown, 'text/markdown', 'Markdown');+ },icon: 'language-markdown',},{title: 'Plain Text',- func: () => {},+ func: async () => {+ await save(storage.saveToText, 'text/plain', 'Text');+ },icon: 'card-text',},{title: 'HTML',- func: () => {},+ func: async () => {+ await save(storage.saveToHTML, 'text/html', 'Html');+ },icon: 'language-html5',},];@@ -141,7 +147,14 @@ const ExportDialog = () => {done={complete}doneText={doneText}onDone={() => {- RNFetchBlob.android.actionViewIntent(result.filePath, 'application/pdf');+ RNFetchBlob.android+ .actionViewIntent(result.filePath, result.type)+ .catch((e) => {+ console.log(e);+ ToastEvent.show(+ `No application found to open ${result.name} file`,+ );+ });close();}}tagline="Exporting notes..."