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
improve tagging
ammarahm-ed6207a61c912c
diff --git a/apps/mobile/patches/react-native-actions-sheet+0.4.9.patch b/apps/mobile/patches/react-native-actions-sheet+0.4.9.patchdeleted file mode 100644index b6e647df7..000000000--- a/apps/mobile/patches/react-native-actions-sheet+0.4.9.patch+++ /dev/null@@ -1,229 +0,0 @@-diff --git a/node_modules/react-native-actions-sheet/src/index.js b/node_modules/react-native-actions-sheet/src/index.js-index dfa8fad..25f4d3f 100644---- a/node_modules/react-native-actions-sheet/src/index.js-+++ b/node_modules/react-native-actions-sheet/src/index.js-@@ -72,7 +72,7 @@ export default class ActionSheet extends Component {- */-- snapToOffset = (offset) => {-- let correction = this.state.deviceHeight * 0.1;-+ let correction = this.state.deviceHeight * 0.15;- let scrollOffset = this.props.gestureEnabled- ? offset + correction + this.props.extraScroll- : offset + correction + this.props.extraScroll;-@@ -188,23 +188,23 @@ export default class ActionSheet extends Component {- resolve(height === 0 ? 20 : height);- }- );-- }, 50);-+ }, 100);- });- };-- _showModal = async (event) => {-- let { gestureEnabled, delayActionSheetDraw, delayActionSheetDrawTime } =-- this.props;-- if (!event?.nativeEvent) return;-+ let { gestureEnabled, delayActionSheetDraw, delayActionSheetDrawTime } = this.props;--+ if (!event?.nativeEvent) return;- let height = event.nativeEvent.layout.height;--- if (this.layoutHasCalled) {- this._returnToPrevScrollPosition(height);- this.actionSheetHeight = height;- return;- } else {-- this.actionSheetHeight = height;-+-+ this.layoutHasCalled = true;-+ this.actionSheetHeight = height- let scrollOffset = this.getInitialScrollPosition();- this.isRecoiling = false;- if (Platform.OS === "ios") {-@@ -227,12 +227,11 @@ export default class ActionSheet extends Component {- this.underlayScale.setValue(1);- this.underlayTranslateY.setValue(100);- if (!gestureEnabled) {-- //DeviceEventEmitter.emit("hasReachedTop");- this.props.onPositionChanged && this.props.onPositionChanged(true);- }-- this.layoutHasCalled = true;- this.updateActionSheetPosition(scrollOffset);- }-+- };-- _openAnimation = (scrollOffset) => {-@@ -241,7 +240,7 @@ export default class ActionSheet extends Component {- if (animated) {- this.transformValue.setValue(scrollOffset);- Animated.parallel([-- Animated.spring(this.transformValue, {-+ Animated.timing(this.transformValue, {- toValue: 0,- bounciness: bounceOnOpen ? bounciness : 1,- speed: openAnimationSpeed,-@@ -277,7 +276,7 @@ export default class ActionSheet extends Component {- let { springOffset, extraScroll } = this.props;- let verticalOffset = event.nativeEvent.contentOffset.y;--- let correction = this.state.deviceHeight * 0.1;-+ let correction = this.state.deviceHeight * 0.15;- if (this.isRecoiling) return;-- if (this.prevScroll < verticalOffset) {-@@ -321,8 +320,8 @@ export default class ActionSheet extends Component {- };-- updateActionSheetPosition(scrollPosition) {-- if (!this.props.drawUnderStatusBar) return;-- if (scrollPosition > this.state.deviceHeight) {-+ if (scrollPosition >= this.state.deviceHeight - 1) {-+ if (!this.props.drawUnderStatusBar) return;- this.indicatorTranslateY.setValue(0);- } else {- this.indicatorTranslateY.setValue(-this.state.paddingTop);-@@ -330,11 +329,12 @@ export default class ActionSheet extends Component {- }-- _returnToPrevScrollPosition(height) {-- let correction = this.state.deviceHeight * 0.1;-+ let correction = this.state.deviceHeight * 0.15;- let scrollOffset =- height * this.currentOffsetFromBottom +- correction +- this.props.extraScroll;-+- this.updateActionSheetPosition(scrollOffset);- this._scrollTo(scrollOffset);- }-@@ -380,9 +380,10 @@ export default class ActionSheet extends Component {- this.targetId = event.nativeEvent.target;- this.offsetY = event.nativeEvent.contentOffset.y;--- let correction = this.state.deviceHeight * 0.1;-+ let correction = this.state.deviceHeight * 0.15;- let distanceFromTop = this.actionSheetHeight + correction - this.offsetY;--+- if (distanceFromTop < 3) {- if (this.isReachedTop) {- this.isReachedTop = true;-@@ -394,18 +395,10 @@ export default class ActionSheet extends Component {- this.props.onPositionChanged && this.props.onPositionChanged(false);- }- }-- if (this.actionSheetHeight >= this.state.deviceHeight) {-- if (!this.props.drawUnderStatusBar) return;-- /* if (-- distanceFromTop < StatusBar.currentHeight &&-- Platform.OS === "android" &&-- this.props.statusBarTranslucent-- ) {-- this.indicatorTranslateY.setValue(-- StatusBar.currentHeight - distanceFromTop-- );-- } */-+-+ if (this.actionSheetHeight >= this.state.deviceHeight - 1) {- if (distanceFromTop < this.state.paddingTop) {-+ if (!this.props.drawUnderStatusBar) return;- this.indicatorTranslateY.setValue(- -this.state.paddingTop + (this.state.paddingTop - distanceFromTop)- );-@@ -536,15 +529,22 @@ export default class ActionSheet extends Component {- this._onKeyboardHide- );- }---+ timeout = null;- _onDeviceLayout = async (_event) => {-+- let event = { ..._event };--- let safeMarginFromTop = 0;-+ if (this.timeout) {-+ clearTimeout(this.timeout);-+ }-+-+ this.timeout = setTimeout(async () => {-+ let safeMarginFromTop = 0;-+ let measuredPadding = Platform.OS === "ios" ? await this.measure() : StatusBar.currentHeight;- if (!this.props.drawUnderStatusBar) {- if (Platform.OS === "android" && !this.props.statusBarTranslucent) return;-- safeMarginFromTop =-- Platform.OS === "ios" ? await this.measure() : StatusBar.currentHeight;-+ safeMarginFromTop = measuredPadding;-+ this.indicatorTranslateY.setValue(-measuredPadding)- }-- let height = event.nativeEvent.layout.height - safeMarginFromTop;-@@ -562,16 +562,16 @@ export default class ActionSheet extends Component {- deviceHeight: height,- deviceWidth: width,- portrait: height > width,-- paddingTop:-- Platform.OS === "android"-- ? StatusBar.currentHeight-- : await this.measure(),-+ paddingTop:measuredPadding,- });-+ },1)-+-+- };-- getInitialScrollPosition() {- this._applyHeightLimiter();-- let correction = this.state.deviceHeight * 0.1;-+ let correction = this.state.deviceHeight * 0.15;- let scrollPosition = this.props.gestureEnabled- ? this.actionSheetHeight * this.props.initialOffsetFromBottom +- correction +-@@ -626,7 +626,7 @@ export default class ActionSheet extends Component {- <SafeAreaView ref={this.safeAreaViewRef} style={styles.safearea}>- <View />- </SafeAreaView>---+ {this.props.premium}- <FlatList- bounces={false}- keyboardShouldPersistTaps={keyboardShouldPersistTaps}-@@ -676,7 +676,7 @@ export default class ActionSheet extends Component {- onTouchStart={this._onTouchStart}- onTouchEnd={this._onTouchEnd}- style={{-- height: this.state.deviceHeight * 1.1,-+ height: this.state.deviceHeight * 1.15,- width: "100%",- zIndex: 10,- }}-@@ -685,13 +685,15 @@ export default class ActionSheet extends Component {- onPress={this._onTouchBackdrop}- onLongPress={this._onTouchBackdrop}- style={{-- height: this.state.deviceHeight * 1.1,-+ height: this.state.deviceHeight * 1.15,- width: "100%",- }}- />- </View>-- <Animated.View-+-+onLayout={this._showModal}- style={[- styles.container,- {-@@ -712,9 +714,8 @@ export default class ActionSheet extends Component {- ]}- >- <Animated.View-- onLayout={this._showModal}- style={{-- maxHeight: "100%",-+ maxHeight: this.state.deviceHeight,- transform: [- {- translateY: this.indicatorTranslateY,diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.jsindex b09567865..138d20383 100644--- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js+++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js@@ -1,27 +1,14 @@-import React, {createRef, useCallback, useEffect, useState} from 'react';-import {Text} from 'react-native';-import {TextInput, TouchableOpacity, View} from 'react-native';-import {ScrollView} from 'react-native-gesture-handler';-import {notesnook} from '../../../e2e/test.ids';-import {useTracked} from '../../provider';-import {eSendEvent, ToastEvent} from '../../services/EventManager';+import React, {useState} from 'react';+import {View} from 'react-native';+import {eSendEvent} from '../../services/EventManager';import Navigation from '../../services/Navigation';import {db} from '../../utils/DB';-import {eOpenTagsDialog, refreshNotesPage} from '../../utils/Events';+import {refreshNotesPage} from '../../utils/Events';import {SIZE} from '../../utils/SizeUtils';import {sleep} from '../../utils/TimeUtils';import {Button} from '../Button';-const tagsInputRef = createRef();-let prevQuery = null;-let tagToAdd = '';-let backPressCount = 0;-export const ActionSheetTagsSection = ({item, close}) => {- const [state, dispatch] = useTracked();- const {colors} = state;- const [suggestions, setSuggestions] = useState([]);- const [focused, setFocused] = useState(false);const [note, setNote] = useState(item);return note.id || note.dateCreated ? (@@ -34,66 +21,47 @@ export const ActionSheetTagsSection = ({item, close}) => {flexDirection: 'row',flexWrap: 'wrap',alignItems: 'center',+ justifyContent: 'center',}}>{note.tags.map(- (item, index) => item && <TagItem key={item} tag={item} />,+ (item, index) =>+ item && <TagItem key={item} tag={item} close={close} />,)}-- <Button- onPress={async () => {- close();- await sleep(300);- eSendEvent(eOpenTagsDialog, note);- }}- title="Add new tag"- type="accent"- icon="plus"- iconPosition="right"- height={30}- fontSize={SIZE.sm}- style={{- margin: 1,- marginRight: 5,- paddingHorizontal: 0,- borderRadius: 100,- paddingHorizontal: 12,- }}- /></View></View>) : null;};-const TagItem = ({tag}) => {+const TagItem = ({tag, close}) => {const onPress = async () => {- let params = (params = {- ...item,+ let tags = db.tags.all;+ let _tag = tags.find(t => t.title === tag);+ let params = {+ ..._tag,type: 'tag',- menu: false,get: 'tagged',- });+ };Navigation.navigate('NotesPage', params, {- heading: '#' + tag.title,- id: tag.id,- type: tag.type,+ heading: '#' + _tag.title,+ id: _tag.id,+ type: _tag.type,});eSendEvent(refreshNotesPage, params);+ await sleep(300);close();};const style = {- margin: 1,- marginRight: 5,paddingHorizontal: 0,- borderRadius: 100,paddingHorizontal: 12,+ marginVertical: 5,};return (<ButtononPress={onPress}title={'#' + tag}- type="grayBg"+ type="gray"height={30}fontSize={SIZE.sm}style={style}diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.jsindex 89bb905b3..90af18d3b 100644--- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js+++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js@@ -20,6 +20,7 @@ const ActionSheetWrapper = ({onClose,onOpen,closeOnTouchBackdrop = true,+ onHasReachedTop}) => {const [state] = useTracked();const {colors} = state;@@ -72,6 +73,7 @@ const ActionSheetWrapper = ({gestureEnabled={gestureEnabled}extraScroll={largeTablet ? 50 : 0}initialOffsetFromBottom={1}+ onPositionChanged={onHasReachedTop}closeOnTouchBackdrop={closeOnTouchBackdrop}indicatorColor={Platform.OS === 'ios'diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.jsindex 093cadf5d..db35b8658 100644--- a/apps/mobile/src/components/ActionSheetComponent/index.js+++ b/apps/mobile/src/components/ActionSheetComponent/index.js@@ -32,7 +32,11 @@ import {setColorScheme,} from '../../utils/Colors';import {db} from '../../utils/DB';-import {eOpenMoveNoteDialog, eOpenPublishNoteDialog} from '../../utils/Events';+import {+ eOpenMoveNoteDialog,+ eOpenPublishNoteDialog,+ eOpenTagsDialog,+} from '../../utils/Events';import {deleteItems} from '../../utils/functions';import {MMKV} from '../../utils/mmkv';import {SIZE} from '../../utils/SizeUtils';@@ -619,6 +623,7 @@ export const ActionSheetComponent = ({Keyboard.dismiss();}}/>+{!note || !note.id ? (<Paragraph style={{marginVertical: 10, alignSelf: 'center'}}>Start writing to save your note.@@ -723,69 +728,77 @@ export const ActionSheetComponent = ({: null}</View>)}++ {hasTags && note ? (+ <ActionSheetTagsSection+ close={close}+ item={note}+ localRefresh={localRefresh}+ />+ ) : null}+<Viewstyle={{flexDirection: 'row',+ marginTop: 5,}}>{note.type === 'note' && isPublished && (- <View+ <Button+ title="Published"+ type="shade"+ height={30}+ fontSize={SIZE.sm - 1}style={{- borderColor: colors.accent,- paddingHorizontal: 5,- borderRadius: 2.5,- justifyContent: 'center',- alignItems: 'center',- marginTop: 5,- borderWidth: 1,- height: 18,+ margin: 1,marginRight: 5,- }}>- <Paragraph- color={colors.accent}- size={SIZE.xs}- style={{- textAlignVertical: 'center',- textAlign: 'center',- }}>- Published- </Paragraph>- </View>+ paddingHorizontal: 0,+ borderRadius: 100,+ paddingHorizontal: 12,+ }}+ />)}{note.type !== 'note' || refreshing ? null : (- <TouchableOpacity- activeOpacity={0.9}- testID={notesnook.ids.dialogs.actionsheet.sync}+ <ButtononPress={async () => await Sync.run('local')}+ title={+ user && lastSynced > note.dateEdited ? 'Synced' : 'Sync Now'+ }+ type="shade"+ height={30}+ fontSize={SIZE.sm}style={{- borderColor: colors.accent,- paddingHorizontal: 5,- borderRadius: 2.5,- justifyContent: 'center',- alignItems: 'center',- marginTop: 5,- borderWidth: 1,- height: 18,- }}>- <Paragraph- color={colors.accent}- size={SIZE.xs}- style={{- textAlignVertical: 'center',- textAlign: 'center',- }}>- {user && lastSynced > note.dateEdited ? 'Synced' : 'Sync Now'}- </Paragraph>- </TouchableOpacity>+ margin: 1,+ marginRight: 5,+ paddingHorizontal: 0,+ borderRadius: 100,+ paddingHorizontal: 12,+ }}+ />)}- </View>- {refreshing ? (- <ActivityIndicator- style={{marginTop: 5, height: 20}}- size={12}- color={colors.accent}- />- ) : null}+ {note.type === 'note' && (+ <Button+ onPress={async () => {+ close();+ await sleep(300);+ eSendEvent(eOpenTagsDialog, note);+ }}+ title="Add tags"+ type="accent"+ icon="plus"+ iconPosition="right"+ height={30}+ fontSize={SIZE.sm}+ style={{+ margin: 1,+ marginRight: 5,+ paddingHorizontal: 0,+ borderRadius: 100,+ paddingHorizontal: 12,+ }}+ />+ )}+ </View></View>)}@@ -809,14 +822,6 @@ export const ActionSheetComponent = ({<ActionSheetColorsSection close={close} item={note} />) : null}- {hasTags && note ? (- <ActionSheetTagsSection- close={close}- item={note}- localRefresh={localRefresh}- />- ) : null}-{note.id && columnItems.length > 0 ? (<Viewstyle={{diff --git a/apps/mobile/src/components/TagsDialog/index.js b/apps/mobile/src/components/TagsDialog/index.jsindex f412eaa23..2872f40fd 100644--- a/apps/mobile/src/components/TagsDialog/index.js+++ b/apps/mobile/src/components/TagsDialog/index.js@@ -12,7 +12,7 @@ import ActionSheetWrapper from '../ActionSheetComponent/ActionSheetWrapper';import Input from '../Input';import {PressableButton} from '../PressableButton';import Paragraph from '../Typography/Paragraph';-+import Heading from '../Typography/Heading';const TagsDialog = () => {const [state] = useTracked();const colors = state.colors;@@ -103,8 +103,8 @@ const TagsDialog = () => {}setNote({...note, tags: note.tags ? [...note.tags, tag] : [tag]});inputRef.current?.setNativeProps({- text:""- })+ text: '',+ });try {await db.notes.note(note.id).tag(tag);useTagStore.getState().setTags();@@ -133,13 +133,12 @@ const TagsDialog = () => {width: '100%',alignSelf: 'center',paddingHorizontal: 12,- minHeight: '80%',+ minHeight:"60%"}}><Inputbutton={{icon: 'magnify',color: colors.accent,- onPress: () => {},size: SIZE.lg,}}fwdRef={inputRef}@@ -147,14 +146,23 @@ const TagsDialog = () => {onChangeText={v => {setQuery(v);}}+ onSubmit={onSubmit}height={50}- placeholder="Search or add tag"+ placeholder="Search or add a tag"/>- <ScrollView nestedScrollEnabled>+ <ScrollView+ nestedScrollEnabled+ overScrollMode="never"+ scrollToOverflowEnabled={false}+ keyboardDismissMode="none"+ keyboardShouldPersistTaps="never"+ onMomentumScrollEnd={() => {+ actionSheetRef.current?.handleChildScrollEnd();+ }}>{query ? (<PressableButton- key={"query_item"}+ key={'query_item'}customStyle={{flexDirection: 'row',marginVertical: 5,@@ -167,9 +175,29 @@ const TagsDialog = () => {<Icon name="plus" color={colors.accent} size={SIZE.lg} /></PressableButton>) : null}+ {!tags || tags.length === 0 ? (+ <View+ style={{+ width: '100%',+ height: 200,+ justifyContent: 'center',+ alignItems: 'center',+ }}>+ <Heading size={50} color={colors.icon}>+ #+ </Heading>+ <Paragraph textBreakStrategy="balanced" color={colors.icon}>+ You do not have any tags.+ </Paragraph>+ </View>+ ) : null}{tags.map(item => (- <TagItem- key={item.title} tag={item} note={note} setNote={setNote} />+ <TagItem+ key={item.title}+ tag={item}+ note={note}+ setNote={setNote}+ />))}</ScrollView></View>