Skip to content

feat: redesign insert image modal with URL embed, caption, and link options#128

Merged
wendyyuchensun merged 3 commits into
coseeing:mainfrom
wendyyuchensun:image-modal
May 19, 2026
Merged

feat: redesign insert image modal with URL embed, caption, and link options#128
wendyyuchensun merged 3 commits into
coseeing:mainfrom
wendyyuchensun:image-modal

Conversation

@wendyyuchensun
Copy link
Copy Markdown
Collaborator

@wendyyuchensun wendyyuchensun commented Apr 24, 2026

Solves #115 .

Summary

  • Rebuild the image modal around the v2 design system (BasicModal, TextInput, RadioGroup, @tabler/icons-react).
  • Add an "embed from URL" path alongside file upload, with a shared preview/error state and a role="status" live region announcing upload/embed error to screen readers
  • Add optional image caption and an external-link option (no link / with link), with URL validation; emit the new LaTeX form ![alt][[caption]](source)((targetUrl)) from edit-icons-tab.js

Design: https://www.figma.com/design/7gvWa3UzE4w5Kloy2CYGTb/%E5%B7%A5%E5%85%B7%E9%A1%9E%E8%A8%AD%E8%A8%88%E7%B3%BB%E7%B5%B1_2025?node-id=708-4804&t=uGQQmEwBkFofw7qY-0

Screenshot 2026-05-08 at 16 04 49

@wendyyuchensun wendyyuchensun force-pushed the image-modal branch 4 times, most recently from 07b602d to 50640af Compare April 26, 2026 14:02
@wendyyuchensun wendyyuchensun force-pushed the image-modal branch 18 times, most recently from f050c68 to 4ffce39 Compare May 8, 2026 06:50
@wendyyuchensun wendyyuchensun marked this pull request as ready for review May 8, 2026 07:39
@wendyyuchensun wendyyuchensun changed the title feat: update insert image modal feat: redesign insert image modal with URL embed, caption, and link options May 8, 2026
@wendyyuchensun
Copy link
Copy Markdown
Collaborator Author

wendyyuchensun commented May 8, 2026

drag & drop upload image 的區域,可以試用、討論有沒有辦法更 accessible。

按照 WCAG,理論上有下面的「選擇檔案上傳」按鈕,應就符合規範:

但覺得仍可以討論看看有沒有更好的做法~

@wendyyuchensun
Copy link
Copy Markdown
Collaborator Author

wendyyuchensun commented May 8, 2026

另外有兩個細節,目前沒有設計,會再跟設計師確認是否需要,會另外在 PR 加上:

  1. 當 image source 未輸入時,error message 與出現位置。https://coseeing.slack.com/archives/C0AABUFUQ01/p1778494797749549
  2. embed input 是否可以按 enter 輸入。 已加上

Comment thread src/components/image-upload-modal.js Outdated
Comment on lines +63 to +68
img.onload = () =>
setImageInfo({
width: img.width,
height: img.height,
size: (file.size / 1024).toFixed(0) + 'KB',
});
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一個比較極端的情境,目前 processFile 沒有取消機制,如果使用者連續換圖片(A→B),A 的 onload 可能晚於 B 的 setState 才觸發,導致 imageInfo 顯示為 A 的尺寸但預覽是 B。
可能可以用一個 requestId ref 來做個檢查

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感謝提醒,我覺得是很合理的考量。

Updated in: c755377

Comment thread src/components/image-upload-modal.js Outdated
Comment on lines +99 to +108
useEffect(() => {
if (uploadError || embedError || !previewUrl) {
onChange(null);
return;
}
onChange({
file: uploadFile,
sourceUrl: uploadFile ? null : previewUrl,
});
}, [uploadError, embedError, previewUrl, onChange, uploadFile]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit
覺得可以評估看看是不是在 processFile / handleEmbed / handleRemoveImage 等情境裡直接呼叫 onChange,就可以不用這個 useEffect。好處是避免再多一輪 render、也讓內部 state 和外部通知(onChange)一次完成

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感謝建議,make sense,而且覺得這樣改 code 比較清爽。

Updated in: fed1269

@wendyyuchensun wendyyuchensun force-pushed the image-modal branch 4 times, most recently from f079fef to 438b06b Compare May 18, 2026 13:32
@wendyyuchensun
Copy link
Copy Markdown
Collaborator Author

先 merge,讓大家可以在 stage 環境測試。有問題或新的討論會再 follow up,感謝。

@wendyyuchensun wendyyuchensun merged commit 322d3bc into coseeing:main May 19, 2026
1 check passed
@wendyyuchensun wendyyuchensun deleted the image-modal branch May 19, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants