Skip to content

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

mobile: add support /now /time in title

Ammar Ahmedaefce1ee6770
diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx
index ffe3fb5a3..9e4415371 100644
--- a/packages/editor-mobile/src/components/editor.tsx
+++ b/packages/editor-mobile/src/components/editor.tsx
@@ -211,6 +211,8 @@ const Tiptap = ({ settings }: { settings: Settings }) => {
controller={controllerRef}
title={controller.title}
fontFamily={settings.fontFamily}
+ dateFormat={settings.dateFormat}
+ timeFormat={settings.timeFormat}
/>
<StatusBar container={containerRef} />
</>
diff --git a/packages/editor-mobile/src/components/title.tsx b/packages/editor-mobile/src/components/title.tsx
index dbbcb78fe..056baaa44 100644
--- a/packages/editor-mobile/src/components/title.tsx
+++ b/packages/editor-mobile/src/components/title.tsx
@@ -21,18 +21,23 @@ import { getFontById } from "@notesnook/editor";
import React, { RefObject, useCallback, useEffect, useRef } from "react";
import { EditorController } from "../hooks/useEditorController";
import styles from "./styles.module.css";
+import { replaceDateTime } from "@notesnook/editor/dist/extensions/date-time";
function Title({
controller,
title,
titlePlaceholder,
readonly,
- fontFamily
+ fontFamily,
+ dateFormat,
+ timeFormat
}: {
controller: RefObject<EditorController>;
title: string;
titlePlaceholder: string;
readonly: boolean;
fontFamily: string;
+ dateFormat: string;
+ timeFormat: string;
}) {
const titleRef = useRef<HTMLTextAreaElement>(null);
const titleSizeDiv = useRef<HTMLDivElement>(null);
@@ -128,6 +133,11 @@ function Title({
onChange={(event) => {
resizeTextarea();
if (!emitUpdate.current) return;
+ event.target.value = replaceDateTime(
+ event.target.value,
+ dateFormat,
+ timeFormat as "12-hour" | "24-hour"
+ );
controller.current?.titleChange(event.target.value);
}}
placeholder={titlePlaceholder}