Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: tipmanager

ammarahm-edf2b86b49da7b
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index fb456b9bb..de7fcb507 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -9,6 +9,7 @@ import { DDS } from './src/services/DeviceDetection';
import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from './src/services/EventManager';
import Notifications from './src/services/Notifications';
import SettingsService from './src/services/SettingsService';
+import { TipManager } from './src/services/tip-manager';
import { Tracker } from './src/utils';
import { db } from './src/utils/database';
import { eDispatchAction } from './src/utils/Events';
@@ -74,6 +75,7 @@ const App = () => {
if (SettingsService.get().appLockMode && SettingsService.get().appLockMode !== 'none') {
setVerifyUser(true);
}
+ await TipManager.init();
await loadDatabase();
useUserStore.getState().setUser(await db.user.getUser());
if (SettingsService.get().telemetry) {
diff --git a/apps/mobile/src/components/Button/index.js b/apps/mobile/src/components/Button/index.js
index 77e23216c..e579a005e 100644
--- a/apps/mobile/src/components/Button/index.js
+++ b/apps/mobile/src/components/Button/index.js
@@ -3,7 +3,7 @@ import { ActivityIndicator } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { useTracked } from '../../provider';
import { BUTTON_TYPES, showTooltip } from '../../utils';
-import { ph, SIZE } from '../../utils/SizeUtils';
+import { SIZE } from '../../utils/SizeUtils';
import { PressableButton } from '../PressableButton';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
diff --git a/apps/mobile/src/components/CustomTabs/index.js b/apps/mobile/src/components/CustomTabs/index.js
index 97dbac8ee..3667a0ec2 100644
--- a/apps/mobile/src/components/CustomTabs/index.js
+++ b/apps/mobile/src/components/CustomTabs/index.js
@@ -259,6 +259,7 @@ export default class CustomTabs extends Component {
keyboardShouldPersistTaps="always"
showsHorizontalScrollIndicator={false}
disableIntervalMomentum={true}
+ disableVirtualization={true}
decelerationRate="fast"
snapToAlignment="start"
snapToOffsets={[this.props.offsets.a, this.props.offsets.b, this.props.offsets.c]}
diff --git a/apps/mobile/src/components/Dialog/functions.ts b/apps/mobile/src/components/Dialog/functions.ts
index 14883237c..9306cc7e9 100644
--- a/apps/mobile/src/components/Dialog/functions.ts
+++ b/apps/mobile/src/components/Dialog/functions.ts
@@ -25,7 +25,7 @@ type DialogInfo = {
context: 'global' | 'local';
};
-export function presentDialog(data: DialogInfo): void {
+export function presentDialog(data: Partial<DialogInfo>): void {
eSendEvent(eOpenSimpleDialog, data);
}
diff --git a/apps/mobile/src/components/GeneralSheet/index.js b/apps/mobile/src/components/GeneralSheet/index.js
index c825c1696..c1c63f976 100644
--- a/apps/mobile/src/components/GeneralSheet/index.js
+++ b/apps/mobile/src/components/GeneralSheet/index.js
@@ -82,8 +82,8 @@ const GeneralSheet = ({ context = 'global' }) => {
return !visible || !dialogData ? null : (
<SheetWrapper
fwdRef={actionSheetRef}
- gestureEnabled={!dialogData?.progress && !dialogData.disableClosing}
- closeOnTouchBackdrop={!dialogData?.progress && !dialogData.disableClosing}
+ gestureEnabled={!dialogData?.progress && !dialogData?.disableClosing}
+ closeOnTouchBackdrop={!dialogData?.progress && !dialogData?.disableClosing}
onClose={() => {
dialogData.onClose && dialogData.onClose();
setVisible(false);
diff --git a/apps/mobile/src/components/SimpleList/empty.js b/apps/mobile/src/components/SimpleList/empty.js
index 6d5045c4b..776e9b70e 100644
--- a/apps/mobile/src/components/SimpleList/empty.js
+++ b/apps/mobile/src/components/SimpleList/empty.js
@@ -1,13 +1,16 @@
import React from 'react';
-import { ActivityIndicator, useWindowDimensions, View } from 'react-native';
+import { ActivityIndicator, Image, useWindowDimensions, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { notesnook } from '../../../e2e/test.ids';
import { useTracked } from '../../provider';
+import { TipManager, useTip } from '../../services/tip-manager';
+import { getElevation } from '../../utils';
import { COLORS_NOTE } from '../../utils/Colors';
import { normalize, SIZE } from '../../utils/SizeUtils';
import { Button } from '../Button';
import { Placeholder } from '../ListPlaceholders';
import Seperator from '../Seperator';
+import { Tip } from '../Tip';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
@@ -16,72 +19,86 @@ export const Empty = ({ loading = true, placeholderData, absolute, headerProps,
const { colors } = state;
const insets = useSafeAreaInsets();
const { height } = useWindowDimensions();
+ const tip = useTip(
+ screen === 'Notes' ? 'first-note' : placeholderData.type || type,
+ screen === 'Notes' ? 'notes' : null
+ );
return (
<View
style={[
{
- backgroundColor: colors.bg,
position: absolute ? 'absolute' : 'relative',
zIndex: absolute ? 10 : null,
- height: height - 250 - insets.top,
- width: '100%'
+ height: height - 140 - insets.top,
+ width: '80%',
+ justifyContent: 'center',
+ alignSelf: 'center'
}
]}
>
- <View
- style={{
- flexGrow: 1,
- justifyContent: 'center',
- alignItems: 'center'
- }}
- >
- <Placeholder
- color={COLORS_NOTE[headerProps.color?.toLowerCase()] || colors.accent}
- w={normalize(150)}
- h={normalize(150)}
- type={screen === 'Favorites' ? 'favorites' : type}
+ <Tip
+ color={COLORS_NOTE[headerProps.color?.toLowerCase()] ? headerProps.color : 'accent'}
+ tip={tip}
+ />
+ {!loading ? (
+ <Button
+ type="accent"
+ title={placeholderData.button}
+ iconPosition="right"
+ icon="arrow-right"
+ onPress={placeholderData.action}
+ accentColor={COLORS_NOTE[headerProps.color?.toLowerCase()] ? headerProps.color : 'accent'}
+ accentText="light"
+ style={{
+ marginTop: 10,
+ alignSelf: 'flex-start',
+ borderRadius: 100,
+ height: 40
+ }}
/>
- <Heading>{placeholderData.heading}</Heading>
- <Paragraph
- textBreakStrategy="balanced"
+ ) : (
+ <ActivityIndicator
style={{
- textAlign: 'center',
- width: '80%'
+ height: 35
}}
- color={colors.icon}
- >
- {loading ? placeholderData.loading : placeholderData.paragraph}
- </Paragraph>
- <Seperator />
- {placeholderData.button && !loading ? (
- <Button
- onPress={placeholderData.action}
- title={placeholderData.button}
- icon={placeholderData.buttonIcon || 'plus'}
- testID={notesnook.buttons.add}
- type="accent"
- fontSize={SIZE.md}
- accentColor="bg"
- accentText={
- COLORS_NOTE[headerProps.color?.toLowerCase()] ? headerProps.color : 'accent'
- }
- />
- ) : loading ? (
- <ActivityIndicator
- style={{
- height: 35
- }}
- color={COLORS_NOTE[headerProps.color?.toLowerCase()] || colors.accent}
- />
- ) : (
- <View
- style={{
- height: 35
- }}
- />
- )}
- </View>
+ color={COLORS_NOTE[headerProps.color?.toLowerCase()] || colors.accent}
+ />
+ )}
</View>
);
};
+
+/**
+ * Make a tips manager.
+ * The tip manager stores many tips. Each tip has following values
+ * 1. Text
+ * 2. contexts: An array of context strings. // Places where the tip can be shown
+ * 3. Button if any.
+ * 4. Image/Gif asset.
+ *
+ * Tip manager adds the following methods -> get(context). Returns a random tip for the following context.
+ *
+ * Tips can be shown in a sheet or in a list. For sheets, GeneralSheet can be used to
+ * render tips.
+ *
+ * Where can the tips be shown and how?
+ * 1. When transitioning, show tips in a sheet. Make sure its useful
+ * 2. Replace placeholders with tips.
+ * 3. Show tips in editor placeholder.
+ * 4. Show tips between list items?
+ *
+ * Tooltips.
+ * Small tooltips can be shown in initial render first time.
+ * Especially for items that are not shown on blank page. Should be
+ * in places where it makes sense and does not interrupt the user.
+ *
+ * Can also be shown when first time entering a screen that
+ * has something that the user might not know of. Like sorting and side menu.
+ *
+ * Todo:
+ * 1. Make a tip manager.
+ * 2. Make a list of tips.
+ * 3. Add images for those tips.
+ * 4. Show tips
+ */
diff --git a/apps/mobile/src/components/Tip/index.tsx b/apps/mobile/src/components/Tip/index.tsx
new file mode 100644
index 000000000..cf7e6322d
--- /dev/null
+++ b/apps/mobile/src/components/Tip/index.tsx
@@ -0,0 +1,145 @@
+import React from 'react';
+import { Image, TextStyle, View, ViewStyle } from 'react-native';
+import { useTracked } from '../../provider';
+import { presentSheet } from '../../services/EventManager';
+import { TTip } from '../../services/tip-manager';
+import { SIZE } from '../../utils/SizeUtils';
+import { Button } from '../Button';
+import Seperator from '../Seperator';
+import Paragraph from '../Typography/Paragraph';
+
+export const Tip = ({
+ tip,
+ style,
+ neverShowAgain,
+ noImage,
+ textStyle,
+ color
+}: {
+ tip: TTip;
+ style?: ViewStyle;
+ textStyle?: TextStyle;
+ neverShowAgain: boolean;
+ noImage?: boolean;
+ color?: string;
+}) => {
+ const [state] = useTracked();
+ const { colors } = state;
+
+ return tip ? (
+ <View
+ style={[
+ {
+ borderRadius: 10,
+ padding: 12,
+ width: '100%',
+ alignSelf: 'center',
+ paddingVertical: 12,
+ backgroundColor: colors.nav
+ },
+ style
+ ]}
+ >
+ <View
+ style={{
+ flexDirection: 'row',
+ justifyContent: 'space-between'
+ }}
+ >
+ <Button
+ //@ts-ignore
+ title="TIP"
+ type="grayAccent"
+ icon="information"
+ fontSize={SIZE.xs}
+ iconSize={SIZE.xs}
+ accentText={color}
+ style={{
+ width: null,
+ height: 22,
+ paddingHorizontal: 4,
+ alignSelf: 'flex-start',
+ borderRadius: 100,
+ borderWidth: 1,
+ //@ts-ignore
+ borderColor: colors[color]
+ }}
+ />
+
+ {neverShowAgain && (
+ <Button
+ //@ts-ignore
+ title="Never show again"
+ type="grayBg"
+ icon="close"
+ fontSize={SIZE.xs}
+ iconSize={SIZE.xs}
+ style={{
+ width: null,
+ height: 25,
+ paddingHorizontal: 4,
+ alignSelf: 'flex-start',
+ borderRadius: 100,
+ borderWidth: 1,
+ borderColor: colors.icon
+ }}
+ />
+ )}
+ </View>
+
+ <Seperator half />
+ <Paragraph style={textStyle} color={colors.pri} size={SIZE.md}>
+ {tip.text}
+ </Paragraph>
+ {tip.image && !noImage && (
+ <Image
+ source={{ uri: tip.image }}
+ style={{
+ width: '100%',
+ height: 200,
+ marginTop: 10,
+ borderRadius: 10,
+ alignSelf: 'center'
+ }}
+ />
+ )}
+
+ {tip.button && (
+ <Button
+ //@ts-ignore
+ title={tip.button.title}
+ type="accent"
+ icon={tip.button.icon}
+ accentText="white"
+ accentColor={color}
+ style={{
+ marginTop: 10
+ }}
+ onPress={() => {
+ switch (tip.button?.action) {
+ default:
+ break;
+ }
+ }}
+ />
+ )}
+ </View>
+ ) : null;
+};
+
+Tip.present = (tip: TTip) => {
+ if (!tip) return;
+ console.log(tip);
+ presentSheet({
+ component: (
+ <Tip
+ tip={tip}
+ neverShowAgain={true}
+ style={{
+ backgroundColor: 'transparent',
+ paddingHorizontal: 12
+ }}
+ />
+ )
+ });
+};
diff --git a/apps/mobile/src/components/Walkthrough/index.tsx b/apps/mobile/src/components/Walkthrough/index.tsx
new file mode 100644
index 000000000..e1cfde340
--- /dev/null
+++ b/apps/mobile/src/components/Walkthrough/index.tsx
@@ -0,0 +1,115 @@
+import React, { useState } from 'react';
+import { Image, LayoutAnimation, View } from 'react-native';
+import { eSendEvent, presentSheet } from '../../services/EventManager';
+import { eCloseProgressDialog } from '../../utils/Events';
+import { MMKV } from '../../utils/mmkv';
+import { SIZE } from '../../utils/SizeUtils';
+import { sleep } from '../../utils/TimeUtils';
+import { Button } from '../Button';
+import Heading from '../Typography/Heading';
+import Paragraph from '../Typography/Paragraph';
+import walkthroughs, { TStep } from './walkthroughs';
+
+export const Walkthrough = ({ steps }: { steps: TStep[] }) => {
+ const [step, setStep] = useState<TStep>(steps && steps[0]);
+
+ const next = () => {
+ let index = steps.findIndex(s => s.text === step.text);
+ LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
+ setStep(steps[index + 1]);
+ };
+
+ return (
+ <View
+ style={{
+ justifyContent: 'center',
+ alignItems: 'center',
+ padding: 12,
+ paddingBottom: 0
+ }}
+ >
+ <Image
+ source={{ uri: step.image }}
+ style={{
+ width: '100%',
+ height: 200,
+ borderRadius: 10,
+ alignSelf: 'center',
+ marginBottom: 10
+ }}
+ />
+ <Heading>{step.title}</Heading>
+ <Paragraph
+ style={{
+ textAlign: 'center',
+ alignSelf: 'center',
+ maxWidth: '80%'
+ }}
+ size={SIZE.md}
+ >
+ {step.text}
+ </Paragraph>
+
+ <Button
+ //@ts-ignore
+ style={{
+ borderRadius: 100,
+ height: 40,
+ marginTop: 10
+ }}
+ onPress={async () => {
+ switch (step.button?.type) {
+ case 'next':
+ next();
+ return;
+ case 'done':
+ eSendEvent(eCloseProgressDialog);
+ await sleep(300);
+ step.button?.action && step.button.action();
+ return;
+ }
+ }}
+ width={250}
+ title={step.button?.title}
+ type="accent"
+ />
+
+ <Button
+ //@ts-ignore
+ style={{
+ borderRadius: 100,
+ height: 40,
+ marginTop: 10
+ }}
+ onPress={async () => {
+ eSendEvent(eCloseProgressDialog);
+ }}
+ width={250}
+ title="Skip"
+ type="grayBg"
+ />
+ </View>
+ );
+};
+
+Walkthrough.present = async (id: 'notebooks') => {
+ let walkthroughState = await MMKV.getItem('walkthroughState');
+ if (walkthroughState) {
+ walkthroughState = JSON.parse(walkthroughState);
+ } else {
+ //@ts-ignore
+ walkthroughState = {};
+ }
+ //@ts-ignore
+ if (walkthroughState[id]) return;
+ //@ts-ignore
+ walkthroughState[id] = true;
+ //MMKV.setItem('walkthroughState', JSON.stringify(walkthroughState));
+ //@ts-ignore
+ let walkthrough = walkthroughs[id];
+ if (!walkthrough) return;
+ presentSheet({
+ component: <Walkthrough steps={walkthrough.steps} />,
+ disableClosing: true
+ });
+};
diff --git a/apps/mobile/src/components/Walkthrough/walkthroughs.ts b/apps/mobile/src/components/Walkthrough/walkthroughs.ts
new file mode 100644
index 000000000..c05b43c90
--- /dev/null
+++ b/apps/mobile/src/components/Walkthrough/walkthroughs.ts
@@ -0,0 +1,51 @@
+import { eSendEvent } from '../../services/EventManager';
+import { eOpenAddNotebookDialog } from '../../utils/Events';
+
+export type TStep = {
+ text: string;
+ image: string;
+ title: string;
+ button?: {
+ type: 'next' | 'done';
+ title: string;
+ action?: () => void;
+ };
+};
+
+const notebooks: { id: string; steps: TStep[] } = {
+ id: 'notebooks',
+ steps: [
+ {
+ title: 'Notebooks',
+ text: 'Organize your notes in a simple and easy way with Notebooks',
+ image: 'https://picsum.photos/400/500',
+ button: {
+ type: 'next',
+ title: 'Next'
+ }
+ },
+ {
+ title: 'Topics',
+ text: 'Notebooks can have unlimited topics.',
+ image: 'https://picsum.photos/400/500',
+ button: {
+ type: 'next',
+ title: 'Next'
+ }
+ },
+ {
+ title: 'Quick access',
+ text: 'You can make shortcuts of topics and notebooks in side menu for quick access',
+ image: 'https://picsum.photos/400/500',
+ button: {
+ type: 'done',
+ title: 'Add your first notebook',
+ action: () => {
+ eSendEvent(eOpenAddNotebookDialog);
+ }
+ }
+ }
+ ]
+};
+
+export default { notebooks };
diff --git a/apps/mobile/src/services/tipmanager.ts b/apps/mobile/src/services/tipmanager.ts
new file mode 100644
index 000000000..517ab5b48
--- /dev/null
+++ b/apps/mobile/src/services/tipmanager.ts
@@ -0,0 +1,167 @@
+import { useEffect, useRef, useState } from 'react';
+import { MMKV } from '../utils/mmkv';
+
+//@ts-ignore
+Array.prototype.sample = function () {
+ return this[Math.floor(Math.random() * this.length)];
+};
+
+export type TipButton = {
+ title: string;
+ type?: string;
+ action: string;
+ icon?: string;
+};
+type Context =
+ | 'list'
+ | 'notes'
+ | 'notebooks'
+ | 'notebook'
+ | 'tags'
+ | 'open-editor'
+ | 'exit-editor'
+ | 'sidemenu'
+ | 'properties'
+ | 'first-note'
+ | 'first-editor-launch'
+ | 'monographs';
+
+export type TTip = {
+ text: string;
+ contexts: Context[];
+ image: string;
+ button?: TipButton;
+};
+
+const tips: TTip[] = [
+ {
+ text: 'You can swipe left anywhere in the app to start a new note',
+ image: 'https://picsum.photos/400/500',
+ contexts: ['notes', 'first-note']
+ },
+ {
+ text: 'Long press on any item in list to open quick actions menu.',
+ image: 'https://picsum.photos/400/500',
+ contexts: ['notes', 'notebook', 'notebook', 'tags']
+ },
+ {
+ text: 'Monographs enable you to share your notes in a secure and private way',
+ image: 'https://picsum.photos/400/500',
+ contexts: ['monographs']
+ },
+ {
+ text: 'Monographs can be encrypted with a secret key and shared with anyone',
+ image: 'https://picsum.photos/400/500',
+ contexts: ['monographs']
+ }
+];
+
+type Popup = {
+ id: string;
+ text: string;
+};
+
+const popups: Popup[] = [
+ {
+ id: 'sortmenu',
+ text: 'Click here to sort your notes'
+ }
+];
+const destructiveContexts = ['first-note'];
+
+let tipState = {};
+let popState = {};
+
+const placeholderTips = [
+ `Privacy is really important and a must have. Many people take this lightly but remember. Privacy is everything.`,
+ `Notes can be pinned in notifications from Properties.`
+];
+
+export class TipManager {
+ static async init() {
+ let tipStateJson = await MMKV.getItem('tipState');
+ if (tipStateJson) {
+ tipState = JSON.parse(tipStateJson);
+ } else {
+ //@ts-ignore
+ tipState = {};
+ }
+
+ let popStateJson = await MMKV.getItem('popupState');
+ if (popStateJson) {
+ popState = JSON.parse(popStateJson);
+ } else {
+ //@ts-ignore
+ popState = {};
+ }
+ console.log('tipState:', tipState, 'popupState:', popState);
+ }
+
+ static tip(context: Context) {
+ if (destructiveContexts.indexOf(context) > -1) {
+ //@ts-ignore
+ if (tipState[context]) return;
+ //@ts-ignore
+ tipState[context] = true;
+ MMKV.setItem('tipState', JSON.stringify(tipState));
+ }
+
+ let tipsForCtx = tips.filter(tip => tip.contexts.indexOf(context) > -1);
+
+ //@ts-ignore
+ return tipsForCtx.sample();
+ }
+
+ static popup(id: string) {
+ let pop = popups.find(p => p.id === id);
+ //@ts-ignore
+ if (popState[id]) return null;
+ //@ts-ignore
+ popState[id] = true;
+ MMKV.setItem('popupState', JSON.stringify(popState));
+ return pop;
+ }
+
+ static placeholderTip() {
+ //@ts-ignore
+ return placeholderTips.sample();
+ }
+}
+
+export const useTip = (
+ context: Context,
+ fallback: Context,
+ options: {
+ rotate: boolean;
+ delay: number;
+ }
+) => {
+ const [tip, setTip] = useState(TipManager.tip(context) || TipManager.tip(fallback));
+ const intervalRef = useRef<any>(null);
+
+ useEffect(() => {
+ setTip(TipManager.tip(context) || TipManager.tip(fallback));
+
+ if (options?.rotate) {
+ if (intervalRef.current) clearInterval(intervalRef.current);
+ intervalRef.current = setInterval(() => {
+ setTip(TipManager.tip(context) || TipManager.tip(fallback));
+ }, options.delay || 5000);
+ }
+ return () => {
+ clearInterval(intervalRef.current);
+ };
+ }, [context, fallback]);
+
+ return tip;
+};
+
+export const usePopup = (id: Context) => {
+ const [popup, setPopup] = useState(TipManager.popup(id));
+
+ useEffect(() => {
+ setPopup(TipManager.popup(id));
+ }, [id]);
+
+ return popup;
+};
diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js
index c98b65fb3..6dc501aa6 100644
--- a/apps/mobile/src/views/Editor/Functions.js
+++ b/apps/mobile/src/views/Editor/Functions.js
@@ -11,6 +11,7 @@ import {
} from '../../services/EventManager';
import Navigation from '../../services/Navigation';
import PremiumService from '../../services/PremiumService';
+import { TipManager } from '../../services/tip-manager';
import { editing } from '../../utils';
import { COLORS_NOTE, COLOR_SCHEME } from '../../utils/Colors';
import { hexToRGBA } from '../../utils/ColorUtils';
@@ -63,6 +64,7 @@ let waitForContent = false;
let prevNoteContent = null;
let sessionId = null;
let historySessionId = null;
+let placeholderTip = TipManager.placeholderTip();
export function startClosingSession() {
closingSession = true;
@@ -688,6 +690,8 @@ export async function clearEditor() {
tiny.call(EditorWebView, tiny.reset());
//EditorWebView.current?.reload();
await waitForEvent('resetcomplete');
+ placeholderTip = TipManager.placeholderTip();
+ tiny.call(EditorWebView, tiny.setPlaceholder(placeholderTip));
editing.focusType = null;
eSendEvent('historyEvent', {
undo: 0,
@@ -911,6 +915,7 @@ export async function onWebViewLoad(premium, colors) {
}, 300);
eSendEvent('updateTags');
setColors(colors);
+ tiny.call(EditorWebView, tiny.setPlaceholder(placeholderTip));
}
async function restoreEditorState() {
diff --git a/apps/mobile/src/views/Editor/tiny/tiny.js b/apps/mobile/src/views/Editor/tiny/tiny.js
index fdaa21449..05451cd4c 100644
--- a/apps/mobile/src/views/Editor/tiny/tiny.js
+++ b/apps/mobile/src/views/Editor/tiny/tiny.js
@@ -2,6 +2,8 @@ import { Platform } from 'react-native';
import { editing } from '../../../utils';
import { EditorWebView, getWebviewInit, post, textInput } from '../Functions';
+const placeholders = ['hello world', 'this \n that'];
+
const reset = id => `
sessionId = null;
document.getElementById("titleInput").value = '';
@@ -25,6 +27,11 @@ toggleNode(".tag-bar-parent","hide");
clearNode(".tag-bar");
`;
+const setPlaceholder = placeholder => `
+editor.dom.setAttrib(editor.dom.doc.body, 'data-mce-placeholder', '${placeholder}');
+editor.dom.setAttrib(editor.dom.doc.body, 'aria-placeholder', '${placeholder}');
+`;
+
const removeMarkdown = `
if (globalThis.tinymce && tinymce.activeEditor) {
tinymce.activeEditor.plugins.textpattern.setPatterns("")
@@ -245,5 +252,6 @@ export default {
onKeyboardShow,
pre,
setMarkdown,
- removeMarkdown
+ removeMarkdown,
+ setPlaceholder
};
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index 204b6088b..27df7469c 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -16,6 +16,8 @@ import { db } from '../../utils/database';
import { eOnLoadNote } from '../../utils/Events';
import { tabBarRef } from '../../utils/Refs';
import { getNote } from '../Editor/Functions';
+import { Tip } from '../../components/Tip';
+import { TipManager } from '../../services/tip-manager';
export const Home = ({ navigation }) => {
const notes = useNoteStore(state => state.notes);
@@ -81,8 +83,6 @@ export const Home = ({ navigation }) => {
};
const _onPressBottomButton = React.useCallback(async () => {
- eSendEvent('session_expired');
- return;
if (!DDS.isTab) {
if (getNote()) {
eSendEvent(eOnLoadNote, { type: 'new' });
diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js
index ddd30ada0..4ac3b273a 100644
--- a/apps/mobile/src/views/Notes/index.js
+++ b/apps/mobile/src/views/Notes/index.js
@@ -3,6 +3,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
import { ContainerBottomButton } from '../../components/Container/ContainerBottomButton';
import { ContainerTopSection } from '../../components/Container/ContainerTopSection';
import { Header } from '../../components/Header';
+import { MoveNotes } from '../../components/MoveNoteDialog/movenote';
import SelectionHeader from '../../components/SelectionHeader';
import SimpleList from '../../components/SimpleList';
import { useTracked } from '../../provider';
@@ -194,18 +195,19 @@ export const Notes = ({ route, navigation }) => {
params.current?.get === 'monographs'
? 'You have not published any notes as monographs yet.'
: 'You have not added any notes yet.',
- button: params.current?.get === 'monographs' ? 'Learn about monographs' : 'Add your first Note',
+ button:
+ params.current?.get === 'monographs' ? 'Learn more about monographs' : 'Add your first Note',
action: _onPressBottomButton,
buttonIcon: params.current?.get === 'monographs' ? 'information-outline' : null,
loading:
- params.current?.get === 'monographs' ? 'Loading published notes' : 'Loading your notes.'
+ params.current?.get === 'monographs' ? 'Loading published notes' : 'Loading your notes.',
+ type: params.current?.get === 'monographs' ? 'monographs' : null
};
const isFocused = () => navigation.isFocused();
const headerRightButtons = [
{
- icon: 'pencil',
title: 'Edit topic',
func: () => {
if (params.current?.type !== 'topic') return;
@@ -214,6 +216,13 @@ export const Notes = ({ route, navigation }) => {
toEdit: params.current
});
}
+ },
+ {
+ title: 'Move notes',
+ func: () => {
+ if (params.current?.type !== 'topic') return;
+ MoveNotes.present(db.notebooks.notebook(params.current?.notebookId).data, params.current);
+ }
}
];