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
refactor properties sheet
ammarahm-ed7597cc6cb2ba
diff --git a/apps/mobile/src/components/DialogManager/Recievers.js b/apps/mobile/src/components/DialogManager/Recievers.jsindex d7dd01fc1..c72c3df34 100644--- a/apps/mobile/src/components/DialogManager/Recievers.js+++ b/apps/mobile/src/components/DialogManager/Recievers.js@@ -8,24 +8,13 @@ import {eOpenActionSheet,eOpenAddNotebookDialog,eOpenAddTopicDialog,- eOpenMoveNoteDialog,+ eOpenMoveNoteDialog} from '../../utils/Events';-export const ActionSheetEvent = (- item,- colors,- tags,- rowItems,- columnItems,- extraData,-) => {+export const ActionSheetEvent = (item, buttons) => {eSendEvent(eOpenActionSheet, {item,- colors,- tags,- rowItems,- columnItems,- extraData,+ buttons});};export const ActionSheetHideEvent = () => {diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.jsindex 5e90c58d4..189f62cfa 100644--- a/apps/mobile/src/components/DialogManager/index.js+++ b/apps/mobile/src/components/DialogManager/index.js@@ -1,11 +1,11 @@-import React, { Component, createRef } from 'react';+import React, {Component, createRef} from 'react';import {eSendEvent,eSubscribeEvent,eUnSubscribeEvent,openVault} from '../../services/EventManager';-import { getCurrentColors } from '../../utils/Colors';+import {getCurrentColors} from '../../utils/Colors';import {eCloseActionSheet,eCloseAddNotebookDialog,@@ -20,12 +20,12 @@ import {eShowGetPremium,eThemeUpdated} from '../../utils/Events';-import { EditorSettings } from '../../views/Editor/EditorSettings';-import { AddNotebookDialog } from '../AddNotebookDialog';-import { AddTopicDialog } from '../AddTopicDialog';-import { AnnouncementDialog } from '../Announcements';-import { AttachmentDialog } from '../AttachmentDialog';-import { Dialog } from '../Dialog';+import {EditorSettings} from '../../views/Editor/EditorSettings';+import {AddNotebookDialog} from '../AddNotebookDialog';+import {AddTopicDialog} from '../AddTopicDialog';+import {AnnouncementDialog} from '../Announcements';+import {AttachmentDialog} from '../AttachmentDialog';+import {Dialog} from '../Dialog';import ExportDialog from '../ExportDialog';import GeneralSheet from '../GeneralSheet';import ImagePreview from '../ImagePreview';@@ -33,8 +33,8 @@ import LoginDialog from '../LoginDialog';import MergeEditor from '../MergeEditor';import MoveNoteDialog from '../MoveNoteDialog';import PremiumDialog from '../Premium';-import { Expiring } from '../Premium/expiring';-import { Properties } from '../Properties';+import {Expiring} from '../Premium/expiring';+import {Properties} from '../Properties';import PublishNoteDialog from '../PublishNoteDialog';import RateDialog from '../RateDialog';import RecoveryKeyDialog from '../RecoveryKeyDialog';@@ -42,7 +42,7 @@ import RestoreDialog from '../RestoreDialog';import ResultDialog from '../ResultDialog';import SheetWrapper from '../Sheet';import TagsDialog from '../TagsDialog';-import { VaultDialog } from '../VaultDialog';+import {VaultDialog} from '../VaultDialog';export class DialogManager extends Component {constructor(props) {@@ -53,12 +53,7 @@ export class DialogManager extends Component {item: {},actionSheetVisible: false,colors: getCurrentColors(),- actionSheetData: {- colors: false,- tags: false,- rowItems: [],- columnItems: []- },+ actionSheetButtons: [],simpleDialog: {title: '',paragraph: '',@@ -80,7 +75,7 @@ export class DialogManager extends Component {_showActionSheet = data => {this.setState({- actionSheetData: data,+ actionSheetButtons: data.buttons,item: data.item ? data.item : {},actionSheetVisible: true},@@ -232,7 +227,7 @@ export class DialogManager extends Component {};render() {- let {actionSheetData, item, simpleDialog, colors} = this.state;+ let {actionSheetButtons, item, colors} = this.state;return (<>{!this.state.actionSheetVisible ? null : (@@ -248,10 +243,7 @@ export class DialogManager extends Component {<Propertiesitem={item}getRef={() => this.actionSheet}- hasColors={actionSheetData.colors}- hasTags={actionSheetData.colors}- rowItems={actionSheetData.rowItems}- columnItems={actionSheetData.columnItems}+ rowItems={actionSheetButtons}close={value => {if (value) {this.show = value;@@ -295,8 +287,8 @@ export class DialogManager extends Component {<PublishNoteDialog /><TagsDialog /><AttachmentDialog />- <Expiring/>- <AnnouncementDialog/>+ <Expiring />+ <AnnouncementDialog /></>);}diff --git a/apps/mobile/src/components/Menu/TagsSection.js b/apps/mobile/src/components/Menu/TagsSection.jsindex e73e77a73..5cae5730e 100644--- a/apps/mobile/src/components/Menu/TagsSection.js+++ b/apps/mobile/src/components/Menu/TagsSection.js@@ -19,6 +19,7 @@ import {PressableButton} from '../PressableButton';import Seperator from '../Seperator';import Heading from '../Typography/Heading';import Paragraph from '../Typography/Paragraph';+import { Properties } from '../Properties';export const TagsSection = () => {const menuPins = useMenuStore(state => state.menuPins);@@ -154,19 +155,7 @@ const PinItem = ({item, index, onPress}) => {<PressableButtontype={headerTextState?.id === item.id ? 'grayBg' : 'gray'}onLongPress={() => {- let rowItems = [];- if (item.type === 'tag') {- rowItems = ['Add Shortcut', 'Delete', 'Rename Tag'];- ActionSheetEvent(item, false, false, rowItems);- } else if (item.type === 'notebook' || item.type === 'topic') {- rowItems =- item.type === 'topic'- ? ['Edit Topic', 'Add Shortcut', 'Delete']- : ['Edit Notebook', 'Pin', 'Add Shortcut', 'Delete'];- ActionSheetEvent(item, false, false, rowItems, {- notebookID: item.notebookId- });- }+ Properties.present(item);}}onPress={() => onPress(item)}customStyle={{diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.jsindex fe0f7b63f..2ce855aa5 100644--- a/apps/mobile/src/components/NoteItem/index.js+++ b/apps/mobile/src/components/NoteItem/index.js@@ -14,6 +14,7 @@ import {ActionIcon} from '../ActionIcon';import {Button} from '../Button';import {ActionSheetEvent} from '../DialogManager/recievers';import {TimeSince} from '../Menu/TimeSince';+import { Properties } from '../Properties';import Heading from '../Typography/Heading';import Paragraph from '../Typography/Paragraph';@@ -46,31 +47,8 @@ function navigateToTag(item) {});}-const showActionSheet = (item, isTrash) => {- let note = isTrash ? item : db.notes.note(item?.id)?.data;- let android = Platform.OS === 'android' ? ['PinToNotif'] : [];- ActionSheetEvent(- note ? note : item,- isTrash ? false : true,- isTrash ? false : true,- isTrash- ? ['PermDelete', 'Restore']- : [- 'Add to notebook',- 'Share',- 'Export',- 'Copy',- 'Publish',- 'Pin',- 'Favorite',- 'Attachments',- 'Vault',- 'Delete',- 'RemoveTopic',- 'History',- ...android- ]- );+const showActionSheet = (item) => {+ Properties.present(item);};const NoteItem = ({item, isTrash, tags, dateBy = 'dateCreated'}) => {diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.jsindex 8975acec2..30a0c3dfe 100644--- a/apps/mobile/src/components/NotebookItem/index.js+++ b/apps/mobile/src/components/NotebookItem/index.js@@ -1,17 +1,18 @@import React from 'react';-import { View } from 'react-native';+import {View} from 'react-native';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import { notesnook } from '../../../e2e/test.ids';-import { useTracked } from '../../provider';-import { useSettingStore } from '../../provider/stores';-import { eSendEvent } from '../../services/EventManager';+import {notesnook} from '../../../e2e/test.ids';+import {useTracked} from '../../provider';+import {useSettingStore} from '../../provider/stores';+import {eSendEvent} from '../../services/EventManager';import Navigation from '../../services/Navigation';-import { getTotalNotes, history } from '../../utils';-import { refreshNotesPage } from '../../utils/Events';-import { SIZE } from '../../utils/SizeUtils';-import { ActionIcon } from '../ActionIcon';-import { Button } from '../Button';-import { ActionSheetEvent } from '../DialogManager/recievers';+import {getTotalNotes, history} from '../../utils';+import {refreshNotesPage} from '../../utils/Events';+import {SIZE} from '../../utils/SizeUtils';+import {ActionIcon} from '../ActionIcon';+import {Button} from '../Button';+import {ActionSheetEvent} from '../DialogManager/recievers';+import { Properties } from '../Properties';import Heading from '../Typography/Heading';import Paragraph from '../Typography/Paragraph';@@ -29,15 +30,7 @@ export const NotebookItem = ({const topics = item.topics?.slice(0, 3) || [];const totalNotes = getTotalNotes(item);const showActionSheet = () => {- let rowItems =- item.type === 'topic'- ? ['Edit Topic', 'Add Shortcut', 'Delete']- : ['Edit Notebook', 'Pin', 'Add Shortcut', 'Delete'];- rowItems = isTrash ? ['Restore', 'PermDelete'] : rowItems;-- ActionSheetEvent(item, false, false, rowItems, {- notebookID: notebookID- });+ Properties.present(item);};const navigateToTopic = topic => {diff --git a/apps/mobile/src/components/Properties/index.js b/apps/mobile/src/components/Properties/index.jsindex a692663ea..d465e19f7 100644--- a/apps/mobile/src/components/Properties/index.js+++ b/apps/mobile/src/components/Properties/index.js@@ -1,771 +1,49 @@-import Clipboard from '@react-native-clipboard/clipboard';-import React, {useEffect, useState} from 'react';-import {- Dimensions,- Keyboard,- Platform,- ScrollView,- TouchableOpacity,- View-} from 'react-native';-import {FlatList} from 'react-native-gesture-handler';-import Share from 'react-native-share';-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import {notesnook} from '../../../e2e/test.ids';+import React from 'react';+import {ScrollView, View} from 'react-native';import {useTracked} from '../../provider';-import {Actions} from '../../provider/Actions';-import {- useMenuStore,- useSelectionStore,- useSettingStore,- useTagStore,- useUserStore-} from '../../provider/stores';import {DDS} from '../../services/DeviceDetection';-import {- eSendEvent,- eSubscribeEvent,- eUnSubscribeEvent,- openVault,- presentSheet,- ToastEvent-} from '../../services/EventManager';-import Navigation from '../../services/Navigation';-import Notifications from '../../services/Notifications';-import SettingsService from '../../services/SettingsService';-import {editing} from '../../utils';-import {- ACCENT,- COLOR_SCHEME,- COLOR_SCHEME_DARK,- COLOR_SCHEME_LIGHT,- setColorScheme-} from '../../utils/Colors';import {db} from '../../utils/database';-import {- eOpenAttachmentsDialog,- eOpenLoginDialog,- eOpenMoveNoteDialog,- eOpenPublishNoteDialog-} from '../../utils/Events';-import {deleteItems, openLinkInBrowser} from '../../utils/functions';-import {MMKV} from '../../utils/mmkv';import {SIZE} from '../../utils/SizeUtils';-import {sleep} from '../../utils/TimeUtils';-import {Button} from '../Button';-import {presentDialog} from '../Dialog/functions';-import NoteHistory from '../NoteHistory';-import {PressableButton} from '../PressableButton';+import {ActionSheetEvent} from '../DialogManager/recievers';import Heading from '../Typography/Heading';import Paragraph from '../Typography/Paragraph';import {ColorTags} from './color-tags';import {DateMeta} from './date-meta';-import { DevMode } from './dev-mode';+import {DevMode} from './dev-mode';+import {Items} from './items';import Notebooks from './notebooks';import {Synced} from './synced';import {Tags} from './tags';import {Topics} from './topics';-const w = Dimensions.get('window').width;-let htmlToText;-export const Properties = ({- close = () => {},- item,- hasColors = false,- hasTags = false,- rowItems = [],- getRef-}) => {+export const Properties = ({close = () => {}, item, rowItems = [], getRef}) => {const [state, dispatch] = useTracked();const {colors} = state;- const clearSelection = useSelectionStore(state => state.clearSelection);- const setSelectedItem = useSelectionStore(state => state.setSelectedItem);- const setMenuPins = useMenuStore(state => state.setMenuPins);- const [isPinnedToMenu, setIsPinnedToMenu] = useState(- db.settings.isPinned(item.id)- );- const [note, setNote] = useState(item);- const user = useUserStore(state => state.user);- const [notifPinned, setNotifPinned] = useState(null);- const dimensions = useSettingStore(state => state.dimensions);- const alias =- note.type === 'tag'- ? db.tags.alias(note.id)- : note.type === 'color'- ? db.colors.alias(note.id)- : note.title;-- const isPublished =item.type === "note" && db.monographs.isPublished(note.id);- const noteInTopic = item.type === "note" &&- editing.actionAfterFirstSave.type === 'topic' &&- db.notebooks- .notebook(editing.actionAfterFirstSave.notebook)- .topics.topic(editing.actionAfterFirstSave.id)- .has(item.id);-- useEffect(() => {- if (item.id === null) return;- checkNotifPinned();- if (item.type !== 'note') {- setIsPinnedToMenu(db.settings.isPinned(note.id));- }- }, [item]);-- function checkNotifPinned() {- let pinned = Notifications.getPinnedNotes();- if (!pinned) {- setNotifPinned(null);- return;- }-- let index = pinned.findIndex(notif => notif.tag === item.id);- if (index !== -1) {- setNotifPinned(pinned[index]);- } else {- setNotifPinned(null);- }- }-- const onUpdate = async type => {- if (type === 'unpin') {- await sleep(1000);-- await Notifications.get();- checkNotifPinned();- }- };-- useEffect(() => {- eSubscribeEvent('onUpdate', onUpdate);-- return () => {- eUnSubscribeEvent('onUpdate', onUpdate);- };- }, [item]);-- function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {- let newColors = setColorScheme(colors, accent);- dispatch({type: Actions.THEME, colors: newColors});- }-- const localRefresh = (type, nodispatch = false) => {- if (!note || !note.id) return;- let _item;-- switch (type) {- case 'note': {- _item = db.notes.note(note.id)?.data;- break;- }- case 'notebook': {- _item = db.notebooks.notebook(note.id)?.data;- break;- }- case 'topic': {- _item = db.notebooks.notebook(note.notebookId).topics.topic(note.title);- break;- }- }- if (!_item || !_item.id) return;-- if (!nodispatch) {- Navigation.setRoutesToUpdate([- Navigation.routeNames.NotesPage,- Navigation.routeNames.Favorites,- Navigation.routeNames.Notes,- Navigation.routeNames.Notebooks,- Navigation.routeNames.Notebook,- Navigation.routeNames.Tags,- Navigation.routeNames.Trash- ]);- }-- setNote({..._item});- };-- const rowItemsData = [- {- name: 'Dark Mode',- title: 'Dark mode',- icon: 'theme-light-dark',- func: () => {- if (!colors.night) {- MMKV.setStringAsync('theme', JSON.stringify({night: true}));- changeColorScheme(- SettingsService.get().pitchBlack- ? COLOR_SCHEME_PITCH_BLACK- : COLOR_SCHEME_DARK- );- } else {- MMKV.setStringAsync('theme', JSON.stringify({night: false}));- changeColorScheme(COLOR_SCHEME_LIGHT);- }- },- switch: true,- on: colors.night ? true : false,- close: false,- nopremium: true,- id: notesnook.ids.dialogs.actionsheet.night- },- {- name: 'Add to notebook',- title: 'Add to notebook',- icon: 'book-outline',- func: () => {- close();- clearSelection(true);- setSelectedItem(note);- setTimeout(() => {- eSendEvent(eOpenMoveNoteDialog, note);- }, 300);- }- },- {- name: 'Pin',- title: note.pinned ? 'Unpin' : 'Pin to top',- icon: note.pinned ? 'pin-off-outline' : 'pin-outline',- func: async () => {- if (!note.id) return;- close();- let type = note.type;- if (db[`${type}s`].pinned.length === 3 && !note.pinned) {- ToastEvent.show({- heading: `Cannot pin more than 3 ${type}s`,- type: 'error'- });- return;- }- await db[`${type}s`][type](note.id).pin();- localRefresh(item.type);- },- close: false,- check: true,- on: note.pinned,- nopremium: true,- id: notesnook.ids.dialogs.actionsheet.pin- },- {- name: 'Favorite',- title: !note.favorite ? 'Favorite' : 'Unfavorite',- icon: note.favorite ? 'star-off' : 'star-outline',- func: async () => {- if (!note.id) return;- close();- if (note.type === 'note') {- await db.notes.note(note.id).favorite();- } else {- await db.notebooks.notebook(note.id).favorite();- }- Navigation.setRoutesToUpdate([- Navigation.routeNames.NotesPage,- Navigation.routeNames.Favorites,- Navigation.routeNames.Notes- ]);- localRefresh(item.type, true);- },- close: false,- check: true,- on: note.favorite,- nopremium: true,- id: notesnook.ids.dialogs.actionsheet.favorite,- color: 'orange'- },- {- name: 'PinToNotif',- title:- notifPinned !== null- ? 'Unpin from Notifications'- : 'Pin to Notifications',- icon: 'bell',- on: notifPinned !== null,- func: async () => {- if (Platform.OS === 'ios') return;- if (notifPinned !== null) {- Notifications.remove(note.id, notifPinned.identifier);- await sleep(1000);- await Notifications.get();- checkNotifPinned();- return;- }- if (note.locked) return;- let text = await db.notes.note(note.id).content();- htmlToText = htmlToText || require('html-to-text');- text = htmlToText.convert(text, {- selectors: [{selector: 'img', format: 'skip'}]- });- Notifications.present({- title: note.title,- message: note.headline,- subtitle: note.headline,- bigText: text,- ongoing: true,- actions: ['UNPIN'],- tag: note.id- });- await sleep(1000);- await Notifications.get();- checkNotifPinned();- }- },-- {- name: 'Edit Notebook',- title: 'Edit notebook',- icon: 'square-edit-outline',- func: () => {- close('notebook');- }- },- {- name: 'Edit Topic',- title: 'Edit topic',- icon: 'square-edit-outline',- func: () => {- close('topic');- }- },- {- name: 'Copy',- title: 'Copy',- icon: 'content-copy',- func: async () => {- if (note.locked) {- openVault({- copyNote: true,- novault: true,- locked: true,- item: note,- title: 'Copy note',- description: 'Unlock note to copy to clipboard.'- });- } else {- let text = await db.notes.note(note.id).content();- htmlToText = htmlToText || require('html-to-text');- text = htmlToText.convert(text, {- selectors: [{selector: 'img', format: 'skip'}]- });- text = `${note.title}\n \n ${text}`;- Clipboard.setString(text);- ToastEvent.show({- heading: 'Note copied to clipboard',- type: 'success',- context: 'local'- });- }- }- },- {- name: 'Restore',- title: 'Restore ' + note.itemType,- icon: 'delete-restore',- func: async () => {- close();- await db.trash.restore(note.id);- Navigation.setRoutesToUpdate([- Navigation.routeNames.Tags,- Navigation.routeNames.Notes,- Navigation.routeNames.Notebooks,- Navigation.routeNames.NotesPage,- Navigation.routeNames.Favorites,- Navigation.routeNames.Trash- ]);- type = note.type === 'trash' ? note.itemType : note.type;-- ToastEvent.show({- heading:- type === 'note'- ? 'Note restored from trash'- : 'Notebook restored from trash',- type: 'success'- });- }- },- {- name: 'Publish',- title: isPublished ? 'Published' : 'Publish',- icon: 'cloud-upload-outline',- on: isPublished,- func: async () => {- if (!user) {- ToastEvent.show({- heading: 'Login required',- message: 'Login to publish note',- context: 'local',- func: () => {- eSendEvent(eOpenLoginDialog);- },- actionText: 'Login'- });- return;- }-- if (!user.isEmailConfirmed) {- ToastEvent.show({- heading: 'Email not verified',- message: 'Please verify your email first.',- context: 'local'- });- return;- }- if (note.locked) {- ToastEvent.show({- heading: 'Locked notes cannot be published',- type: 'error',- context: 'local'- });- return;- }- close();- await sleep(300);- eSendEvent(eOpenPublishNoteDialog, note);- }- },- {- name: 'Vault',- title: note.locked ? 'Remove from vault' : 'Add to vault',- icon: note.locked ? 'shield-off-outline' : 'shield-outline',- func: async () => {- if (!note.id) return;- if (note.locked) {- close('unlock');- } else {- db.vault- .add(note.id)- .then(r => {- let n = db.notes.note(note.id).data;- if (n.locked) {- close();- }- Navigation.setRoutesToUpdate([- Navigation.routeNames.NotesPage,- Navigation.routeNames.Favorites,- Navigation.routeNames.Notes- ]);- localRefresh(note.type);- })- .catch(async e => {- switch (e.message) {- case db.vault.ERRORS.noVault:- close('novault');- break;- case db.vault.ERRORS.vaultLocked:- close('locked');- break;- case db.vault.ERRORS.wrongPassword:- close();- break;- }- });- }- },- on: note.locked- },-- {- name: 'Add Shortcut',- title: isPinnedToMenu ? 'Remove Shortcut' : 'Add Shortcut',- icon: isPinnedToMenu ? 'link-variant-remove' : 'link-variant',- func: async () => {- close();- try {- if (isPinnedToMenu) {- await db.settings.unpin(note.id);- } else {- if (item.type === 'topic') {- await db.settings.pin(note.type, {- id: note.id,- notebookId: note.notebookId- });- } else {- await db.settings.pin(note.type, {id: note.id});- }- }- setIsPinnedToMenu(db.settings.isPinned(note.id));- setMenuPins();- } catch (e) {}- },- close: false,- check: true,- on: isPinnedToMenu,- nopremium: true,- id: notesnook.ids.dialogs.actionsheet.pinMenu- },- {- name: 'Rename Tag',- title: 'Rename tag',- icon: 'square-edit-outline',- func: async () => {- close();- await sleep(300);- presentDialog({- title: 'Rename tag',- paragraph: 'Change the title of the tag ' + alias,- positivePress: async value => {- if (!value || value === '' || value.trimStart().length == 0) return;- await db.tags.rename(note.id, db.tags.sanitize(value));- useTagStore.getState().setTags();- Navigation.setRoutesToUpdate([- Navigation.routeNames.Notes,- Navigation.routeNames.NotesPage,- Navigation.routeNames.Tags- ]);- },- input: true,- defaultValue: alias,- inputPlaceholder: 'Enter title of tag',- positiveText: 'Save'- });- }- },- {- name: 'Share',- title: 'Share',- icon: 'share-variant',- func: async () => {- if (note.locked) {- close();- openVault({- item: item,- novault: true,- locked: true,- share: true,- title: 'Share note',- description: 'Unlock note to share it.'- });- } else {- let text = await db.notes.note(note.id).export('txt');- let m = `${note.title}\n \n ${text}`;- Share.open({- title: 'Share note to',- failOnCancel: false,- message: m- });- }- }- },- {- name: 'Attachments',- title: 'Attachments',- icon: 'attachment',- func: async () => {- close();- await sleep(300);- eSendEvent(eOpenAttachmentsDialog, note);- }- },- {- name: 'Export',- title: 'Export',- icon: 'export',- func: () => {- close('export');- }- },- {- name: 'RemoveTopic',- title: 'Remove from topic',- hidden: !noteInTopic,- icon: 'minus-circle-outline',- func: async () => {- await db.notebooks- .notebook(editing.actionAfterFirstSave.notebook)- .topics.topic(editing.actionAfterFirstSave.id)- .delete(note.id);- Navigation.setRoutesToUpdate([- Navigation.routeNames.Notebooks,- Navigation.routeNames.Notes,- Navigation.routeNames.NotesPage,- Navigation.routeNames.Notebook- ]);- setNote(db.notes.note(note.id).data);- close();- }- },- {- name: 'Delete',- title:- note.type !== 'notebook' && note.type !== 'note'- ? 'Delete ' + item.type- : 'Move to trash',- icon: 'delete-outline',- type: 'error',- func: async () => {- close();- if (note.type === 'tag') {- await sleep(300);- presentDialog({- title: 'Delete tag',- paragraph: 'This tag will be removed from all notes.',- positivePress: async value => {- await db.tags.remove(note.id);- useTagStore.getState().setTags();- Navigation.setRoutesToUpdate([- Navigation.routeNames.Notes,- Navigation.routeNames.NotesPage,- Navigation.routeNames.Tags- ]);- },- positiveText: 'Delete',- positiveType: 'errorShade'- });- return;- }- if (note.locked) {- await sleep(300);- openVault({- deleteNote: true,- novault: true,- locked: true,- item: note,- title: 'Delete note',- description: 'Unlock note to delete it.'- });- } else {- try {- close();- await deleteItems(note);- } catch (e) {}- }- }- },- {- name: 'PermDelete',- title: 'Delete ' + note.itemType,- icon: 'delete',- func: async () => {- close();- await sleep(300);- presentDialog({- title: `Permanent delete`,- paragraph: `Are you sure you want to delete this ${note.itemType} permanantly from trash?`,- positiveText: 'Delete',- negativeText: 'Cancel',- positivePress: async () => {- await db.trash.delete(note.id);- Navigation.setRoutesToUpdate([Navigation.routeNames.Trash]);- useSelectionStore.getState().setSelectionMode(false);- ToastEvent.show({- heading: 'Permanantly deleted items',- type: 'success',- context: 'local'- });- },- positiveType: 'errorShade'- });- }- },- {- name: 'History',- title: 'History',- icon: 'history',- func: async () => {- close();- await sleep(300);- presentSheet({- noProgress: true,- noIcon: true,- component: ref => <NoteHistory ref={ref} note={note} />- });- }- }- ];-- let width = dimensions.width > 600 ? 600 : 500;- let columnItemsCount = DDS.isLargeTablet() ? 7 : 5;- let columnItemWidth = DDS.isTab- ? (width - 24) / columnItemsCount- : (w - 24) / columnItemsCount;-- const _renderRowItem = rowItem => (- <View- onPress={rowItem.func}- key={rowItem.name}- testID={'icon-' + rowItem.name}- style={{- alignItems: 'center',- width: columnItemWidth,- marginBottom: 10- }}>- <PressableButton- onPress={rowItem.func}- type={rowItem.on ? 'shade' : 'grayBg'}- customStyle={{- height: columnItemWidth - 12,- width: columnItemWidth - 12,- borderRadius: 5,- justifyContent: 'center',- alignItems: 'center',- textAlign: 'center',- textAlignVertical: 'center',- marginBottom: DDS.isTab ? 7 : 3.5- }}>- <Icon- name={rowItem.icon}- size={DDS.isTab ? SIZE.xxl : SIZE.lg}- color={- rowItem.on- ? colors.accent- : rowItem.name === 'Delete' || rowItem.name === 'PermDelete'- ? colors.errorText- : colors.icon- }- />- </PressableButton>-- <Paragraph size={SIZE.xs + 1} style={{textAlign: 'center'}}>- {rowItem.title}- </Paragraph>- </View>- );+ const alias =+ item.type === 'tag'+ ? db.tags.alias(item.id)+ : item.type === 'color'+ ? db.colors.alias(item.id)+ : item.title;const onScrollEnd = () => {getRef().current?.handleChildScrollEnd();};- const renderColumnItem = ({item, index}) => (- <Button- buttonType={{- text: item.on- ? colors.accent- : item.name === 'Delete' || item.name === 'PermDelete'- ? colors.errorText- : colors.pri- }}- onPress={item.func}- title={item.title}- icon={item.icon}- type={item.on ? 'shade' : 'gray'}- fontSize={SIZE.sm}- style={{- borderRadius: 0,- justifyContent: 'flex-start',- alignSelf: 'flex-start',- width: '100%'- }}- />- );-return (<ScrollViewnestedScrollEnabled- onScrollEndDrag={onScrollEnd}- onScrollAnimationEnd={onScrollEnd}onMomentumScrollEnd={onScrollEnd}keyboardShouldPersistTaps="always"keyboardDismissMode="none"- onLayout={() => {- if (!item.dateDeleted) {- localRefresh(item.type, true);- }- }}style={{backgroundColor: colors.bg,paddingHorizontal: 0,borderBottomRightRadius: DDS.isLargeTablet() ? 10 : 1,borderBottomLeftRadius: DDS.isLargeTablet() ? 10 : 1}}>- {!note || !note.id ? (+ {!item || !item.id ? (<Paragraph style={{marginVertical: 10, alignSelf: 'center'}}>Start writing to save your note.</Paragraph>@@ -780,35 +58,33 @@ export const Properties = ({paddingHorizontal: 12}}><Heading size={SIZE.lg}>- {note.type === 'tag' ? '#' : null}+ {item.type === 'tag' ? '#' : null}{alias}</Heading>- {note.headline || note.description ? (+ {item.headline || item.description ? (<Paragraph numberOfLines={2} color={colors.icon}>- {(note.type === 'notebook' || note.itemType === 'notebook') &&- note?.description- ? note.description+ {(item.type === 'notebook' || item.itemType === 'notebook') &&+ item?.description+ ? item.description: null}- {(note.type === 'note' || note.itemType === 'note') &&- note?.headline- ? note.headline+ {(item.type === 'note' || item.itemType === 'note') &&+ item?.headline+ ? item.headline: null}</Paragraph>) : null}- {hasTags && note && note.type === 'note' ? (- <Tags close={close} item={note} localRefresh={localRefresh} />- ) : null}+ {item.type === 'note' ? <Tags close={close} item={item} /> : null}- <Topics item={note} close={close} />+ <Topics item={item} close={close} /></View>- {note && note.type === 'note' ? (- <Notebooks note={note} close={close} />+ {item.type === 'note' ? (+ <Notebooks note={item} close={close} />) : null}- <DateMeta item={note} />+ <DateMeta item={item} /></View>)}@@ -819,49 +95,11 @@ export const Properties = ({}}/>- {hasColors && note.id ? <ColorTags close={close} item={note} /> : null}-- {note.id ? (- <>- {note.type === 'note' ? (- <FlatList- data={rowItemsData.filter(- i => rowItems.indexOf(i.name) > -1 && !i.hidden- )}- keyExtractor={item => item.title}- numColumns={- rowItems.length < 5 ? rowItems.length : columnItemsCount- }- style={{- marginTop: note.type !== 'note' ? 10 : 0,- paddingTop: 10- }}- columnWrapperStyle={{- justifyContent: 'flex-start'- }}- contentContainerStyle={{- alignSelf: 'center',- width: rowItems.length < 5 ? '100%' : null,- paddingLeft: rowItems.length < 5 ? 10 : 0- }}- renderItem={({item, index}) => _renderRowItem(item)}- />- ) : (- <FlatList- data={rowItemsData.filter(- i => rowItems.indexOf(i.name) > -1 && !i.hidden- )}- keyExtractor={item => item.title}- renderItem={renderColumnItem}- />- )}- </>- ) : null}+ {item.type === 'note' ? <ColorTags close={close} item={item} /> : null}+ <Items item={item} rowItems={rowItems} close={close} /><Synced item={item} close={close} />-- <DevMode item={item}/>-+ <DevMode item={item} />{DDS.isTab ? (<View@@ -873,3 +111,42 @@ export const Properties = ({</ScrollView>);};++Properties.present = (item, buttons = []) => {+ let type = item.type;+ let props = [item];+ switch (type) {+ case 'trash':+ props.push(['PermDelete', 'Restore']);+ break;+ case 'note':+ let android = Platform.OS === 'android' ? ['PinToNotif'] : [];+ props.push([+ 'Add to notebook',+ 'Share',+ 'Export',+ 'Copy',+ 'Publish',+ 'Pin',+ 'Favorite',+ 'Attachments',+ 'Vault',+ 'Delete',+ 'RemoveTopic',+ 'History',+ ...android,+ ...buttons+ ]);+ break;+ case 'notebook':+ props.push(['Edit Notebook', 'Pin', 'Add Shortcut', 'Delete']);+ break;+ case 'topic':+ props.push(['Edit Topic', 'Add Shortcut', 'Delete']);+ break;+ case 'tag':+ props.push(['Add Shortcut', 'Delete', 'Rename Tag']);+ break;+ }+ ActionSheetEvent(...props);+};diff --git a/apps/mobile/src/components/Properties/items.js b/apps/mobile/src/components/Properties/items.jsnew file mode 100644index 000000000..e70b6cd94--- /dev/null+++ b/apps/mobile/src/components/Properties/items.js@@ -0,0 +1,118 @@+import React from 'react';+import {View} from 'react-native';+import {FlatList} from 'react-native-gesture-handler';+import Icon from 'react-native-vector-icons/MaterialCommunityIcons';+import {useTracked} from '../../provider';+import {useSettingStore} from '../../provider/stores';+import {DDS} from '../../services/DeviceDetection';+import {SIZE} from '../../utils/SizeUtils';+import {Button} from '../Button';+import {PressableButton} from '../PressableButton';+import Paragraph from '../Typography/Paragraph';+import {useActions} from './use-actions';++export const Items = ({item, rowItems, close}) => {+ const [state] = useTracked();+ const {colors} = state;+ const dimensions = useSettingStore(state => state.dimensions);+ const actions= useActions({item, close});+ const data = actions.filter(i => rowItems.indexOf(i.name) > -1 && !i.hidden);++ let width = dimensions.width > 600 ? 600 : dimensions.width;+ let columnItemsCount = DDS.isLargeTablet() ? 7 : 5;+ let columnItemWidth = DDS.isTab+ ? (width - 24) / columnItemsCount+ : (width - 24) / columnItemsCount;++ const _renderRowItem = ({item, index}) => (+ <View+ onPress={item.func}+ key={item.name}+ testID={'icon-' + item.name}+ style={{+ alignItems: 'center',+ width: columnItemWidth,+ marginBottom: 10+ }}>+ <PressableButton+ onPress={item.func}+ type={item.on ? 'shade' : 'grayBg'}+ customStyle={{+ height: columnItemWidth - 12,+ width: columnItemWidth - 12,+ borderRadius: 5,+ justifyContent: 'center',+ alignItems: 'center',+ textAlign: 'center',+ textAlignVertical: 'center',+ marginBottom: DDS.isTab ? 7 : 3.5+ }}>+ <Icon+ name={item.icon}+ size={DDS.isTab ? SIZE.xxl : SIZE.lg}+ color={+ item.on+ ? colors.accent+ : item.name === 'Delete' || item.name === 'PermDelete'+ ? colors.errorText+ : colors.icon+ }+ />+ </PressableButton>++ <Paragraph size={SIZE.xs + 1} style={{textAlign: 'center'}}>+ {item.title}+ </Paragraph>+ </View>+ );++ const renderColumnItem = ({item, index}) => (+ <Button+ buttonType={{+ text: item.on+ ? colors.accent+ : item.name === 'Delete' || item.name === 'PermDelete'+ ? colors.errorText+ : colors.pri+ }}+ onPress={item.func}+ title={item.title}+ icon={item.icon}+ type={item.on ? 'shade' : 'gray'}+ fontSize={SIZE.sm}+ style={{+ borderRadius: 0,+ justifyContent: 'flex-start',+ alignSelf: 'flex-start',+ width: '100%'+ }}+ />+ );++ return item.type === 'note' ? (+ <FlatList+ data={data}+ keyExtractor={item => item.title}+ numColumns={rowItems.length < 5 ? rowItems.length : columnItemsCount}+ style={{+ marginTop: item.type !== 'note' ? 10 : 0,+ paddingTop: 10+ }}+ columnWrapperStyle={{+ justifyContent: 'flex-start'+ }}+ contentContainerStyle={{+ alignSelf: 'center',+ width: rowItems.length < 5 ? '100%' : null,+ paddingLeft: rowItems.length < 5 ? 10 : 0+ }}+ renderItem={_renderRowItem}+ />+ ) : (+ <FlatList+ data={data}+ keyExtractor={item => item.title}+ renderItem={renderColumnItem}+ />+ );+};diff --git a/apps/mobile/src/components/Properties/tags.js b/apps/mobile/src/components/Properties/tags.jsindex 8c5c2554d..080c3897a 100644--- a/apps/mobile/src/components/Properties/tags.js+++ b/apps/mobile/src/components/Properties/tags.js@@ -56,8 +56,6 @@ export const Tags = ({item, close}) => {};const TagItem = ({tag, close}) => {- const [state] = useTracked();- const {colors} = state;const onPress = async () => {let tags = db.tags.all;let _tag = tags.find(t => t.title === tag);diff --git a/apps/mobile/src/components/Properties/useActions.js b/apps/mobile/src/components/Properties/useActions.jsnew file mode 100644index 000000000..e4754912f--- /dev/null+++ b/apps/mobile/src/components/Properties/useActions.js@@ -0,0 +1,629 @@+import Clipboard from '@react-native-clipboard/clipboard';+import React, {useEffect, useState} from 'react';+import {Platform} from 'react-native';+import Share from 'react-native-share';+import {notesnook} from '../../../e2e/test.ids';+import {useTracked} from '../../provider';+import {Actions} from '../../provider/Actions';+import {+ useMenuStore,+ useSelectionStore,+ useTagStore,+ useUserStore+} from '../../provider/stores';+import {+ eSendEvent,+ eSubscribeEvent,+ eUnSubscribeEvent,+ openVault,+ presentSheet,+ ToastEvent+} from '../../services/EventManager';+import Navigation from '../../services/Navigation';+import Notifications from '../../services/Notifications';+import SettingsService from '../../services/SettingsService';+import {editing} from '../../utils';+import {+ ACCENT,+ COLOR_SCHEME,+ COLOR_SCHEME_DARK,+ COLOR_SCHEME_LIGHT,+ setColorScheme+} from '../../utils/Colors';+import {db} from '../../utils/database';+import {+ eOpenAttachmentsDialog,+ eOpenLoginDialog,+ eOpenMoveNoteDialog,+ eOpenPublishNoteDialog+} from '../../utils/Events';+import {deleteItems} from '../../utils/functions';+import {MMKV} from '../../utils/mmkv';+import {sleep} from '../../utils/TimeUtils';+import {presentDialog} from '../Dialog/functions';+import NoteHistory from '../NoteHistory';++let htmlToText;+export const useActions = ({close = () => {}, item}) => {+ const [state, dispatch] = useTracked();+ const {colors} = state;+ const clearSelection = useSelectionStore(state => state.clearSelection);+ const setSelectedItem = useSelectionStore(state => state.setSelectedItem);+ const setMenuPins = useMenuStore(state => state.setMenuPins);+ const [isPinnedToMenu, setIsPinnedToMenu] = useState(+ db.settings.isPinned(item.id)+ );++ const user = useUserStore(state => state.user);+ const [notifPinned, setNotifPinned] = useState(null);+ const alias =+ item.type === 'tag'+ ? db.tags.alias(item.id)+ : item.type === 'color'+ ? db.colors.alias(item.id)+ : item.title;++ const isPublished =+ item.type === 'note' && db.monographs.isPublished(item.id);+ const noteInTopic =+ item.type === 'note' &&+ editing.actionAfterFirstSave.type === 'topic' &&+ db.notebooks+ .notebook(editing.actionAfterFirstSave.notebook)+ .topics.topic(editing.actionAfterFirstSave.id)+ .has(item.id);++ useEffect(() => {+ if (item.id === null) return;+ checkNotifPinned();+ if (item.type !== 'note') {+ setIsPinnedToMenu(db.settings.isPinned(item.id));+ }+ }, [item]);++ function checkNotifPinned() {+ let pinned = Notifications.getPinnedNotes();+ if (!pinned) {+ setNotifPinned(null);+ return;+ }++ let index = pinned.findIndex(notif => notif.tag === item.id);+ if (index !== -1) {+ setNotifPinned(pinned[index]);+ } else {+ setNotifPinned(null);+ }+ }++ const onUpdate = async type => {+ if (type === 'unpin') {+ await sleep(1000);+ await Notifications.get();+ checkNotifPinned();+ }+ };++ useEffect(() => {+ eSubscribeEvent('onUpdate', onUpdate);++ return () => {+ eUnSubscribeEvent('onUpdate', onUpdate);+ };+ }, [item]);++ function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {+ let newColors = setColorScheme(colors, accent);+ dispatch({type: Actions.THEME, colors: newColors});+ }++ function switchTheme() {+ if (!colors.night) {+ MMKV.setStringAsync('theme', JSON.stringify({night: true}));+ let nextTheme = SettingsService.get().pitchBlack+ ? COLOR_SCHEME_PITCH_BLACK+ : COLOR_SCHEME_DARK;+ changeColorScheme(nextTheme);+ return;+ }+ MMKV.setStringAsync('theme', JSON.stringify({night: false}));+ changeColorScheme(COLOR_SCHEME_LIGHT);+ }++ function addTo() {+ close();+ clearSelection(true);+ setSelectedItem(item);+ setTimeout(() => {+ eSendEvent(eOpenMoveNoteDialog, item);+ }, 300);+ }++ async function addToFavorites() {+ if (!item.id) return;+ close();+ await db.notes.note(item.id).favorite();+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Notes+ ]);+ }++ async function pinItem() {+ if (!item.id) return;+ close();+ let type = item.type;+ if (db[`${type}s`].pinned.length === 3 && !item.pinned) {+ ToastEvent.show({+ heading: `Cannot pin more than 3 ${type}s`,+ type: 'error'+ });+ return;+ }+ await db[`${type}s`][type](item.id).pin();+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.Notebooks,+ Navigation.routeNames.Notes+ ]);+ }++ async function pinToNotifications() {+ if (Platform.OS === 'ios') return;+ if (notifPinned !== null) {+ Notifications.remove(item.id, notifPinned.identifier);+ await sleep(1000);+ await Notifications.get();+ checkNotifPinned();+ return;+ }+ if (item.locked) return;+ let text = await db.notes.note(item.id).content();+ htmlToText = htmlToText || require('html-to-text');+ text = htmlToText.convert(text, {+ selectors: [{selector: 'img', format: 'skip'}]+ });+ Notifications.present({+ title: item.title,+ message: item.headline,+ subtitle: item.headline,+ bigText: text,+ ongoing: true,+ actions: ['UNPIN'],+ tag: item.id+ });+ await sleep(1000);+ await Notifications.get();+ checkNotifPinned();+ }++ async function restoreTrashItem() {+ close();+ await db.trash.restore(item.id);+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.Tags,+ Navigation.routeNames.Notes,+ Navigation.routeNames.Notebooks,+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Trash+ ]);+ type = item.type === 'trash' ? item.itemType : item.type;+ ToastEvent.show({+ heading:+ type === 'note'+ ? 'Note restored from trash'+ : 'Notebook restored from trash',+ type: 'success'+ });+ }++ async function copyContent() {+ if (item.locked) {+ openVault({+ copyNote: true,+ novault: true,+ locked: true,+ item: item,+ title: 'Copy note',+ description: 'Unlock note to copy to clipboard.'+ });+ } else {+ let text = await db.notes.note(item.id).content();+ htmlToText = htmlToText || require('html-to-text');+ text = htmlToText.convert(text, {+ selectors: [{selector: 'img', format: 'skip'}]+ });+ text = `${item.title}\n \n ${text}`;+ Clipboard.setString(text);+ ToastEvent.show({+ heading: 'Note copied to clipboard',+ type: 'success',+ context: 'local'+ });+ }+ }++ async function publishNote() {+ if (!user) {+ ToastEvent.show({+ heading: 'Login required',+ message: 'Login to publish note',+ context: 'local',+ func: () => {+ eSendEvent(eOpenLoginDialog);+ },+ actionText: 'Login'+ });+ return;+ }++ if (!user.isEmailConfirmed) {+ ToastEvent.show({+ heading: 'Email is not verified',+ message: 'Please verify your email first.',+ context: 'local'+ });+ return;+ }+ if (item.locked) {+ ToastEvent.show({+ heading: 'Locked notes cannot be published',+ type: 'error',+ context: 'local'+ });+ return;+ }+ close();+ await sleep(300);+ eSendEvent(eOpenPublishNoteDialog, item);+ }++ async function addToVault() {+ if (!item.id) return;+ if (item.locked) {+ close('unlock');+ return;+ }+ try {+ await db.vault.add(item.id);+ let note = db.notes.note(item.id).data;+ if (note.locked) {+ close();+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Notes+ ]);+ }+ } catch (e) {+ switch (e.message) {+ case db.vault.ERRORS.noVault:+ close('novault');+ break;+ case db.vault.ERRORS.vaultLocked:+ close('locked');+ break;+ case db.vault.ERRORS.wrongPassword:+ close();+ break;+ }+ }+ }++ async function createMenuShortcut() {+ close();+ try {+ if (isPinnedToMenu) {+ await db.settings.unpin(item.id);+ return;+ } else {+ if (item.type === 'topic') {+ await db.settings.pin(item.type, {+ id: item.id,+ notebookId: item.notebookId+ });+ } else {+ await db.settings.pin(item.type, {id: item.id});+ }+ }+ setIsPinnedToMenu(db.settings.isPinned(item.id));+ setMenuPins();+ } catch (e) {}+ }++ async function renameTag() {+ close();+ await sleep(300);+ presentDialog({+ title: 'Rename tag',+ paragraph: 'Change the title of the tag ' + alias,+ positivePress: async value => {+ if (!value || value === '' || value.trimStart().length == 0) return;+ await db.tags.rename(item.id, db.tags.sanitize(value));+ useTagStore.getState().setTags();+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.Notes,+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Tags+ ]);+ },+ input: true,+ defaultValue: alias,+ inputPlaceholder: 'Enter title of tag',+ positiveText: 'Save'+ });+ }++ async function shareNote() {+ if (item.locked) {+ close();+ openVault({+ item: item,+ novault: true,+ locked: true,+ share: true,+ title: 'Share note',+ description: 'Unlock note to share it.'+ });+ } else {+ let text = await db.notes.note(item.id).export('txt');+ let m = `${item.title}\n \n ${text}`;+ Share.open({+ title: 'Share note to',+ failOnCancel: false,+ message: m+ });+ }+ }++ async function deleteItem() {+ close();+ if (item.type === 'tag') {+ await sleep(300);+ presentDialog({+ title: 'Delete tag',+ paragraph: 'This tag will be removed from all notes.',+ positivePress: async value => {+ await db.tags.remove(item.id);+ useTagStore.getState().setTags();+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.Notes,+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Tags+ ]);+ },+ positiveText: 'Delete',+ positiveType: 'errorShade'+ });+ return;+ }+ if (item.locked) {+ await sleep(300);+ openVault({+ deleteNote: true,+ novault: true,+ locked: true,+ item: item,+ title: 'Delete note',+ description: 'Unlock note to delete it.'+ });+ } else {+ try {+ close();+ await deleteItems(item);+ } catch (e) {}+ }+ }+ async function removeNoteFromTopic() {+ await db.notebooks+ .notebook(editing.actionAfterFirstSave.notebook)+ .topics.topic(editing.actionAfterFirstSave.id)+ .delete(item.id);+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.Notebooks,+ Navigation.routeNames.Notes,+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Notebook+ ]);+ close();+ }++ async function deleteTrashItem() {+ close();+ await sleep(300);+ presentDialog({+ title: `Permanent delete`,+ paragraph: `Are you sure you want to delete this ${item.itemType} permanantly from trash?`,+ positiveText: 'Delete',+ negativeText: 'Cancel',+ positivePress: async () => {+ await db.trash.delete(item.id);+ Navigation.setRoutesToUpdate([Navigation.routeNames.Trash]);+ useSelectionStore.getState().setSelectionMode(false);+ ToastEvent.show({+ heading: 'Permanantly deleted items',+ type: 'success',+ context: 'local'+ });+ },+ positiveType: 'errorShade'+ });+ }++ async function openHistory() {+ close();+ await sleep(300);+ presentSheet({+ noProgress: true,+ noIcon: true,+ component: ref => <NoteHistory ref={ref} note={item} />+ });+ }++ async function showAttachments() {+ close();+ await sleep(300);+ eSendEvent(eOpenAttachmentsDialog, item);+ }++ const actions = [+ {+ name: 'Dark Mode',+ title: 'Dark mode',+ icon: 'theme-light-dark',+ func: switchTheme,+ switch: true,+ on: colors.night ? true : false,+ close: false,+ nopremium: true,+ id: notesnook.ids.dialogs.actionsheet.night+ },+ {+ name: 'Add to notebook',+ title: 'Add to notebook',+ icon: 'book-outline',+ func: addTo+ },+ {+ name: 'Pin',+ title: item.pinned ? 'Unpin' : 'Pin to top',+ icon: item.pinned ? 'pin-off-outline' : 'pin-outline',+ func: pinItem,+ close: false,+ check: true,+ on: item.pinned,+ nopremium: true,+ id: notesnook.ids.dialogs.actionsheet.pin+ },+ {+ name: 'Favorite',+ title: !item.favorite ? 'Favorite' : 'Unfavorite',+ icon: item.favorite ? 'star-off' : 'star-outline',+ func: addToFavorites,+ close: false,+ check: true,+ on: item.favorite,+ nopremium: true,+ id: notesnook.ids.dialogs.actionsheet.favorite,+ color: 'orange'+ },+ {+ name: 'PinToNotif',+ title:+ notifPinned !== null+ ? 'Unpin from Notifications'+ : 'Pin to Notifications',+ icon: 'bell',+ on: notifPinned !== null,+ func: pinToNotifications+ },++ {+ name: 'Edit Notebook',+ title: 'Edit notebook',+ icon: 'square-edit-outline',+ func: () => close('notebook')+ },+ {+ name: 'Edit Topic',+ title: 'Edit topic',+ icon: 'square-edit-outline',+ func: () => close('topic')+ },+ {+ name: 'Copy',+ title: 'Copy',+ icon: 'content-copy',+ func: copyContent+ },+ {+ name: 'Restore',+ title: 'Restore ' + item.itemType,+ icon: 'delete-restore',+ func: restoreTrashItem+ },++ {+ name: 'Publish',+ title: isPublished ? 'Published' : 'Publish',+ icon: 'cloud-upload-outline',+ on: isPublished,+ func: publishNote+ },+ {+ name: 'Vault',+ title: item.locked ? 'Remove from vault' : 'Add to vault',+ icon: item.locked ? 'shield-off-outline' : 'shield-outline',+ func: addToVault,+ on: item.locked+ },++ {+ name: 'Add Shortcut',+ title: isPinnedToMenu ? 'Remove Shortcut' : 'Add Shortcut',+ icon: isPinnedToMenu ? 'link-variant-remove' : 'link-variant',+ func: createMenuShortcut,+ close: false,+ check: true,+ on: isPinnedToMenu,+ nopremium: true,+ id: notesnook.ids.dialogs.actionsheet.pinMenu+ },+ {+ name: 'Rename Tag',+ title: 'Rename tag',+ icon: 'square-edit-outline',+ func: renameTag+ },+ {+ name: 'Share',+ title: 'Share',+ icon: 'share-variant',+ func: shareNote+ },+ {+ name: 'Attachments',+ title: 'Attachments',+ icon: 'attachment',+ func: showAttachments+ },+ {+ name: 'Export',+ title: 'Export',+ icon: 'export',+ func: () => close('export')+ },+ {+ name: 'RemoveTopic',+ title: 'Remove from topic',+ hidden: !noteInTopic,+ icon: 'minus-circle-outline',+ func: removeNoteFromTopic+ },+ {+ name: 'Delete',+ title:+ item.type !== 'notebook' && item.type !== 'note'+ ? 'Delete ' + item.type+ : 'Move to trash',+ icon: 'delete-outline',+ type: 'error',+ func: deleteItem+ },+ {+ name: 'PermDelete',+ title: 'Delete ' + item.itemType,+ icon: 'delete',+ func: deleteTrashItem+ },+ {+ name: 'History',+ title: 'History',+ icon: 'history',+ func: openHistory+ }+ ];++ return actions+};diff --git a/apps/mobile/src/components/TagItem/index.js b/apps/mobile/src/components/TagItem/index.jsindex f49259735..befe14e80 100644--- a/apps/mobile/src/components/TagItem/index.js+++ b/apps/mobile/src/components/TagItem/index.js@@ -10,6 +10,7 @@ import {refreshNotesPage} from '../../utils/Events';import {SIZE} from '../../utils/SizeUtils';import {ActionIcon} from '../ActionIcon';import {ActionSheetEvent} from '../DialogManager/recievers';+import { Properties } from '../Properties';import Heading from '../Typography/Heading';import Paragraph from '../Typography/Paragraph';@@ -81,8 +82,7 @@ const TagItem = React.memo(name="dots-horizontal"size={SIZE.xl}onPress={() => {- let rowItems = ['Add Shortcut', 'Delete', 'Rename Tag'];- ActionSheetEvent(item, false, false, rowItems);+ Properties.present(item);}}testID={notesnook.ids.tag.menu}customStyle={{diff --git a/apps/mobile/src/views/Editor/EditorHeader.js b/apps/mobile/src/views/Editor/EditorHeader.jsindex 4e277fca4..316711238 100644--- a/apps/mobile/src/views/Editor/EditorHeader.js+++ b/apps/mobile/src/views/Editor/EditorHeader.js@@ -12,6 +12,7 @@ import {useSafeAreaInsets} from 'react-native-safe-area-context';import {notesnook} from '../../../e2e/test.ids';import {ActionIcon} from '../../components/ActionIcon';import {ActionSheetEvent} from '../../components/DialogManager/recievers';+import { Properties } from '../../components/Properties';import {useTracked} from '../../provider';import {useEditorStore,@@ -168,22 +169,7 @@ const EditorHeader = () => {safeKeyboardDismiss();editing.isFocused = true;}- let android = Platform.OS === 'android' ? ['PinToNotif'] : [];- ActionSheetEvent(note, true, true, [- 'Add to notebook',- 'Share',- 'Export',- 'Delete',- 'Copy',- 'Dark Mode',- 'Add to Vault',- 'Attachments',- 'Pin',- 'Favorite',- 'Publish',- 'History',- ...android- ]);+ Properties.present(note, ['Dark Mode']);};useEffect(() => {