diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx index 5669e17b..a913ae07 100644 --- a/apps/web/src/components/EditorPane.tsx +++ b/apps/web/src/components/EditorPane.tsx @@ -4,6 +4,7 @@ import { NodeViewWrapper, ReactNodeViewRenderer, useEditor, EditorContent, type import StarterKit from "@tiptap/starter-kit"; import Image from "@tiptap/extension-image"; import Placeholder from "@tiptap/extension-placeholder"; +import { useTranslation } from "react-i18next"; import { ChevronLeft, ChevronRight, @@ -68,7 +69,12 @@ const MOBILE_DRAFT_PERSIST_DELAY_MS = 800; const DEFAULT_IMAGE_WIDTH_PERCENT = 72; const MIN_IMAGE_WIDTH_PERCENT = 25; const MAX_IMAGE_WIDTH_PERCENT = 100; -const IMAGE_WIDTH_PRESETS = [35, 50, 72, 100]; +const IMAGE_WIDTH_PRESETS = [ + { width: 35, labelKey: "editor.imageSizeSmall" }, + { width: 50, labelKey: "editor.imageSizeMedium" }, + { width: 72, labelKey: "editor.imageSizeLarge" }, + { width: 100, labelKey: "editor.imageSizeFull" }, +] as const; type NoteSearchMatch = { from: number; @@ -234,6 +240,7 @@ const parseImageWidth = (value: unknown) => { }; const ResizableImageNodeView = ({ editor, node, selected, updateAttributes }: NodeViewProps) => { + const { t } = useTranslation(); const wrapperRef = useRef(null); const [previewWidth, setPreviewWidth] = useState(null); const nodeWidth = parseImageWidth(node.attrs.width) ?? DEFAULT_IMAGE_WIDTH_PERCENT; @@ -309,25 +316,26 @@ const ResizableImageNodeView = ({ editor, node, selected, updateAttributes }: No {alt} {editable && selected && (
-
+
{IMAGE_WIDTH_PRESETS.map((preset) => ( ))}
diff --git a/apps/web/src/i18n/resources/en-US.ts b/apps/web/src/i18n/resources/en-US.ts index 7b0dbe96..38c22f8a 100644 --- a/apps/web/src/i18n/resources/en-US.ts +++ b/apps/web/src/i18n/resources/en-US.ts @@ -368,6 +368,10 @@ export const enUS = { editor: { imageScale: "Image scale", scaleTo: "Scale to {{percent}}%", + imageSizeSmall: "Small", + imageSizeMedium: "Medium", + imageSizeLarge: "Large", + imageSizeFull: "Full", resizeImage: "Drag to resize image width", currentNotebook: "Current notebook", close: "Close", diff --git a/apps/web/src/i18n/resources/zh-CN.ts b/apps/web/src/i18n/resources/zh-CN.ts index 65ce53a6..11238f6e 100644 --- a/apps/web/src/i18n/resources/zh-CN.ts +++ b/apps/web/src/i18n/resources/zh-CN.ts @@ -368,6 +368,10 @@ export const zhCN = { editor: { imageScale: "图片缩放", scaleTo: "缩放到 {{percent}}%", + imageSizeSmall: "较小", + imageSizeMedium: "适中", + imageSizeLarge: "较大", + imageSizeFull: "铺满", resizeImage: "拖拽调整图片宽度", currentNotebook: "所在笔记本", close: "关闭", diff --git a/apps/web/src/styles/globals.css b/apps/web/src/styles/globals.css index af8e594d..c8699385 100644 --- a/apps/web/src/styles/globals.css +++ b/apps/web/src/styles/globals.css @@ -252,22 +252,34 @@ textarea { .ProseMirror .edgeever-image-preset { display: inline-flex; - min-width: 2rem; - height: 1.75rem; + min-width: 3rem; + min-height: 2.5rem; + flex-direction: column; align-items: center; justify-content: center; + gap: 0.15rem; border-radius: 6px; color: #475569; font-size: 0.75rem; font-weight: 700; } +.ProseMirror .edgeever-image-preset-percent { + color: #94a3b8; + font-size: 0.625rem; + font-weight: 600; +} + .ProseMirror .edgeever-image-preset:hover, .ProseMirror .edgeever-image-preset.is-active { background: var(--brand-green-muted); color: var(--brand-green-text); } +.ProseMirror .edgeever-image-preset.is-active .edgeever-image-preset-percent { + color: var(--brand-green-text); +} + .ProseMirror .edgeever-image-resize-handle { width: 1.75rem; height: 1.75rem;