From ad6a0ebfabb3dcea1a5273c5125ac24b66e26e39 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com> Date: Mon, 5 Jun 2023 11:16:18 +0500 Subject: [PATCH] mobie: enable search in readonly mode (#2659) --- apps/mobile/app/screens/editor/index.tsx | 7 +++++-- apps/mobile/app/screens/editor/tiptap/commands.ts | 4 ++-- packages/editor-mobile/src/components/editor.tsx | 9 +++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/mobile/app/screens/editor/index.tsx b/apps/mobile/app/screens/editor/index.tsx index 36c02f99c..53f42cab4 100755 --- a/apps/mobile/app/screens/editor/index.tsx +++ b/apps/mobile/app/screens/editor/index.tsx @@ -46,6 +46,7 @@ import { useEditor } from "./tiptap/use-editor"; import { useEditorEvents } from "./tiptap/use-editor-events"; import { editorController } from "./tiptap/utils"; import { useLayoutEffect } from "react"; +import useKeyboard from "../../hooks/use-keyboard"; const style: ViewStyle = { height: "100%", @@ -232,6 +233,8 @@ const AppSection = ({ const ReadonlyButton = ({ editor }: { editor: useEditorType }) => { const readonly = useEditorStore((state) => state.readonly); + const keyboard = useKeyboard(); + const onPress = async () => { if (editor.note.current) { await db.notes?.note(editor.note.current.id).readonly(); @@ -241,7 +244,7 @@ const ReadonlyButton = ({ editor }: { editor: useEditorType }) => { } }; - return readonly && IconButton ? ( + return readonly && IconButton && !keyboard.keyboardShown ? ( { color="accent" customStyle={{ position: "absolute", - bottom: 20, + bottom: 60, width: 60, height: 60, right: 12, diff --git a/apps/mobile/app/screens/editor/tiptap/commands.ts b/apps/mobile/app/screens/editor/tiptap/commands.ts index 48871c900..2107b516b 100644 --- a/apps/mobile/app/screens/editor/tiptap/commands.ts +++ b/apps/mobile/app/screens/editor/tiptap/commands.ts @@ -217,7 +217,7 @@ typeof globalThis.statusBar !== "undefined" && statusBar.current.set({date:"",sa ); }; - updateWebclip = async ({ src, hash }: ImageAttributes) => { + updateWebclip = async ({ src, hash }: Partial) => { await this.doAsync( `editor && editor.commands.updateWebClip(${JSON.stringify({ hash @@ -225,7 +225,7 @@ typeof globalThis.statusBar !== "undefined" && statusBar.current.set({date:"",sa ); }; - updateImage = async ({ src, hash }: ImageAttributes) => { + updateImage = async ({ src, hash }: Partial) => { await this.doAsync( `editor && editor.commands.updateImage(${JSON.stringify({ hash diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx index 08276cdca..ae6141dc1 100644 --- a/packages/editor-mobile/src/components/editor.tsx +++ b/packages/editor-mobile/src/components/editor.tsx @@ -251,9 +251,14 @@ const Tiptap = ({ /> - {settings.noToolbar || !layout ? null : ( + {!layout ? null : (