From d2fc58c82d8ebadb02fc3de190e1cf652aa67970 Mon Sep 17 00:00:00 2001 From: tianma-if Date: Sun, 19 Jul 2026 12:23:01 +0800 Subject: [PATCH] release: prepare v0.4.5 mobile core --- apps/mobile/app.json | 4 +- apps/mobile/package.json | 2 +- .../src/components/LocalTiptapEditor.tsx | 57 ++++++--- .../MobileStandaloneEditorParts.tsx | 113 ++++++++---------- .../MobileStandaloneTiptapEditor.tsx | 12 +- packages/shared/package.json | 1 + packages/shared/src/mobile-editor.test.mjs | 42 +++++++ packages/shared/src/mobile-editor.ts | 70 +++++++++++ 8 files changed, 209 insertions(+), 92 deletions(-) create mode 100644 packages/shared/src/mobile-editor.test.mjs create mode 100644 packages/shared/src/mobile-editor.ts diff --git a/apps/mobile/app.json b/apps/mobile/app.json index 8033d4e6..140d66ca 100644 --- a/apps/mobile/app.json +++ b/apps/mobile/app.json @@ -3,7 +3,7 @@ "name": "EdgeEver", "slug": "edgeever", "scheme": "edgeever", - "version": "0.4.4", + "version": "0.4.5", "orientation": "portrait", "userInterfaceStyle": "light", "newArchEnabled": true, @@ -13,7 +13,7 @@ }, "android": { "package": "org.edgeever.mobile", - "versionCode": 10, + "versionCode": 11, "adaptiveIcon": { "backgroundColor": "#f8fafc" } diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 29bdabae..972a7029 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -1,6 +1,6 @@ { "name": "@edgeever/mobile", - "version": "0.4.4", + "version": "0.4.5", "private": true, "type": "module", "main": "expo-router/entry", diff --git a/apps/mobile/src/components/LocalTiptapEditor.tsx b/apps/mobile/src/components/LocalTiptapEditor.tsx index 604d07c5..f5818af6 100644 --- a/apps/mobile/src/components/LocalTiptapEditor.tsx +++ b/apps/mobile/src/components/LocalTiptapEditor.tsx @@ -5,6 +5,15 @@ import Placeholder from "@tiptap/extension-placeholder"; import { EditorContent, useEditor, useEditorState } from "@tiptap/react"; import StarterKit from "@tiptap/starter-kit"; import type { TiptapDoc } from "@edgeever/shared"; +import { + MOBILE_EDITOR_ACTIVE_FLAGS, + MOBILE_EDITOR_TOOLBAR_ACTIONS, + getMobileEditorInputAttributes, + getMobileEditorPlaceholder, + getMobileEditorToolbarActionLabel, + getMobileEditorToolbarLabel, + type MobileEditorToolbarActionId, +} from "@edgeever/shared/mobile-editor"; import { useDOMImperativeHandle, type DOMImperativeFactory, type DOMProps } from "expo/dom"; import { useCallback, useEffect, useMemo, useRef, type ReactNode, type Ref } from "react"; @@ -65,19 +74,12 @@ export default function LocalTiptapEditor(props: LocalTiptapEditorProps) { StarterKit, protectedImageExtension, Placeholder.configure({ - placeholder: props.locale === "en-US" ? "Start writing..." : "开始记录...", + placeholder: getMobileEditorPlaceholder(props.locale), }), ], content: resolveImageSources(props.content, props.baseUrl), editorProps: { - attributes: { - autocapitalize: "sentences", - autocomplete: "on", - autocorrect: "on", - class: "edgeever-editor-content", - inputmode: "text", - spellcheck: "true", - }, + attributes: getMobileEditorInputAttributes("edgeever-editor-content"), }, onUpdate: ({ editor: activeEditor }) => { if (changeTimerRef.current !== null) { @@ -174,9 +176,9 @@ export default function LocalTiptapEditor(props: LocalTiptapEditorProps) { const toolbarState = useEditorState({ editor, selector: ({ editor: activeEditor }) => - (activeEditor?.isActive("bold") ? 1 : 0) | - (activeEditor?.isActive("bulletList") ? 8 : 0) | - (activeEditor?.isActive("blockquote") ? 16 : 0), + (activeEditor?.isActive("bold") ? MOBILE_EDITOR_ACTIVE_FLAGS.bold : 0) | + (activeEditor?.isActive("bulletList") ? MOBILE_EDITOR_ACTIVE_FLAGS.bulletList : 0) | + (activeEditor?.isActive("blockquote") ? MOBILE_EDITOR_ACTIVE_FLAGS.blockquote : 0), }); const insertImage = async () => { @@ -189,15 +191,34 @@ export default function LocalTiptapEditor(props: LocalTiptapEditorProps) { } }; + const toolbarIcons: Record = { + image: , + bold: , + bulletList: , + blockquote: , + horizontalRule: , + }; + const toolbarHandlers: Record void> = { + image: () => void insertImage(), + bold: () => editor?.chain().focus().toggleBold().run(), + bulletList: () => editor?.chain().focus().toggleBulletList().run(), + blockquote: () => editor?.chain().focus().toggleBlockquote().run(), + horizontalRule: () => editor?.chain().focus().setHorizontalRule().run(), + }; + return (
-
- } label={props.locale === "en-US" ? "Upload image" : "上传图片"} onRun={() => void insertImage()} /> - } label={props.locale === "en-US" ? "Bold" : "加粗"} onRun={() => editor?.chain().focus().toggleBold().run()} /> - } label={props.locale === "en-US" ? "Bullet list" : "无序列表"} onRun={() => editor?.chain().focus().toggleBulletList().run()} /> - } label={props.locale === "en-US" ? "Quote" : "引用"} onRun={() => editor?.chain().focus().toggleBlockquote().run()} /> - } label={props.locale === "en-US" ? "Horizontal rule" : "分割线"} onRun={() => editor?.chain().focus().setHorizontalRule().run()} /> +
+ {MOBILE_EDITOR_TOOLBAR_ACTIONS.map((action) => ( + 0 && Boolean(toolbarState & action.activeFlag)} + icon={toolbarIcons[action.id]} + label={getMobileEditorToolbarActionLabel(action.id, props.locale)} + onRun={toolbarHandlers[action.id]} + /> + ))}
diff --git a/apps/web/src/components/MobileStandaloneEditorParts.tsx b/apps/web/src/components/MobileStandaloneEditorParts.tsx index c80deb59..8736376b 100644 --- a/apps/web/src/components/MobileStandaloneEditorParts.tsx +++ b/apps/web/src/components/MobileStandaloneEditorParts.tsx @@ -1,4 +1,10 @@ import { Bold, Check, ChevronDown, ImagePlus, List, Minus, Quote } from "lucide-react"; +import { + MOBILE_EDITOR_TOOLBAR_ACTIONS, + getMobileEditorToolbarActionLabel, + type MobileEditorToolbarActionId, +} from "@edgeever/shared/mobile-editor"; +import type { ReactNode } from "react"; import type { NotebookMoveOption } from "@/lib/app-helpers"; import type { MobileEditorSaveState } from "@/lib/mobile-editor-standalone"; @@ -46,68 +52,51 @@ export const MobileEditorToolbar = ({ onToggleBulletList: () => void; onToggleBlockquote: () => void; onSetHorizontalRule: () => void; -}) => ( -
- - - - - -
-); +}) => { + const icons: Record = { + image: