Skip to content

Commit f050c68

Browse files
feat: update insert image modal
1 parent 3d1b839 commit f050c68

5 files changed

Lines changed: 451 additions & 209 deletions

File tree

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
11
{
2-
"title": "Upload Image",
2+
"title": "Insert Image",
3+
"imageSource": "Image source — upload a file or embed from URL",
34
"dimensions": "Dimensions",
45
"fileSize": "File Size",
56
"altText": "Alt Text",
6-
"altTextPlaceholder": "Enter the alt text for the image",
7+
"altTextPlaceholder": "Enter a description of the image content",
78
"cancel": "Cancel",
89
"confirm": "Confirm",
9-
"chooseFile": "Choose File",
10+
"chooseFile": "Choose File to Upload",
1011
"imagePreview": "Image Preview",
11-
"replaceImage": "Replace Image",
12-
"required": "Required",
12+
"removeImage": "Remove Image",
13+
"optional": "(Optional)",
1314
"altTextRequired": "Alt text is required",
14-
"modalDescription": "Upload an image to add it to your document. You can replace an existing image by uploading a new one.",
15-
"fileSizeExceeds": "File size exceeds {{maxSize}} MB"
15+
"dropTitle": "Drag & drop to upload",
16+
"dropMeta": "Max size: {{maxSize}}MB Recommended: 1200 x 800 px Formats: jpg/jpeg, png",
17+
"dropMetaShort": "Max {{maxSize}}MB, jpg or png",
18+
"uploadFailed": "Image upload failed",
19+
"uploadFailedHint": "Drop another file or embed from a URL",
20+
"announceEmbedded": "Image embedded: {{url}}",
21+
"announceUploadFailed": "Image upload failed. File size limit: {{maxSize}}MB. Supported formats: jpg/jpeg, png",
22+
"announceEmbedFailed": "Image embed failed. Please check the URL",
23+
"embedFromUrl": "Embed Image from URL",
24+
"embedHint": "No file size limit. Recommended for large images.",
25+
"embedUrlPlaceholder": "Enter image URL",
26+
"embed": "Embed",
27+
"embedLoadFailed": "Image failed to load",
28+
"embedLoadFailedHint": "Check the URL or upload a file instead",
29+
"caption": "Image Caption",
30+
"captionPlaceholder": "Enter a caption to display below the image",
31+
"externalLink": "External Link",
32+
"noLink": "No Link",
33+
"withLink": "With Link",
34+
"targetUrl": "Link URL",
35+
"targetUrlPlaceholder": "Enter the URL to open when clicking the image",
36+
"targetUrlRequired": "Link URL is required",
37+
"targetUrlInvalid": "Please enter a valid URL (e.g. https://example.com)"
1638
}
Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
11
{
2-
"title": "上傳圖片",
3-
"dimensions": "尺寸",
2+
"title": "插入圖片",
3+
"imageSource": "圖片來源(選擇上傳檔案或嵌入連結)",
4+
"dimensions": "檔案尺寸",
45
"fileSize": "檔案大小",
56
"altText": "替代文字",
6-
"altTextPlaceholder": "輸入圖片的替代文字",
7+
"altTextPlaceholder": "請輸入描述圖片內容的文字",
78
"cancel": "取消",
89
"confirm": "確認",
9-
"chooseFile": "選擇檔案",
10+
"chooseFile": "選擇檔案上傳",
1011
"imagePreview": "圖片預覽",
1112
"removeImage": "移除圖片",
12-
"modalDescription": "在此上傳圖片並添加替代文字描述",
13-
"replaceImage": "替換圖片",
14-
"required": "必填",
13+
"optional": "(選填)",
1514
"altTextRequired": "請輸入替代文字",
16-
"fileSizeExceeds": "檔案大小超過 {{maxSize}} MB"
15+
"dropTitle": "拖曳檔案上傳",
16+
"dropMeta": "大小限制:{{maxSize}}MB 建議尺寸:1200 x 800 px 支援格式:jpg/jpeg, png",
17+
"dropMetaShort": "上限 {{maxSize}}MB,jpg 或 png",
18+
"uploadFailed": "圖片上傳失敗",
19+
"uploadFailedHint": "請重新拖曳上傳或改以連結嵌入",
20+
"announceEmbedded": "已嵌入圖片:{{url}}",
21+
"announceUploadFailed": "圖片上傳失敗。檔案大小限制:{{maxSize}}MB,支援格式:jpg/jpeg, png",
22+
"announceEmbedFailed": "圖片嵌入失敗,請檢查嵌入連結",
23+
"embedFromUrl": "從連結嵌入圖片",
24+
"embedHint": "無檔案大小限制,如有大型圖檔建議使用連結嵌入",
25+
"embedUrlPlaceholder": "請輸入圖片連結網址",
26+
"embed": "嵌入",
27+
"embedLoadFailed": "圖片嵌入失敗",
28+
"embedLoadFailedHint": "請檢查連結或改以檔案上傳",
29+
"caption": "圖片說明",
30+
"captionPlaceholder": "請輸入顯示於圖片下方的上下文說明",
31+
"externalLink": "圖片外連連結",
32+
"noLink": "不含連結",
33+
"withLink": "含連結",
34+
"targetUrl": "外連網址",
35+
"targetUrlPlaceholder": "請輸入點擊圖片後開啟的網址",
36+
"targetUrlRequired": "外連網址為必填",
37+
"targetUrlInvalid": "請輸入有效的網址(例如:https://example.com)"
1738
}

src/components/edit-icons-tab.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,23 @@ const EditIconsTab = ({ insertLatex, addImageToExport }) => {
5252
);
5353

5454
const handleImageConfirm = useCallback(
55-
(file, altText) => {
56-
const fileID = generateUniqueId();
55+
({ file, sourceUrl, altText, display, targetUrl }) => {
56+
let source;
57+
if (file) {
58+
const fileID = generateUniqueId();
59+
source = fileID;
60+
const fileType = file.type.split('/')[1];
61+
addImageToExport(fileID, fileType, file);
62+
} else {
63+
source = sourceUrl;
64+
}
65+
const displayPart = display ? `[[${display}]]` : '';
66+
const targetPart = targetUrl ? `((${targetUrl}))` : '';
5767
insertLatex({
5868
id: 'insert_image_file',
59-
latex: `![${altText}](${fileID})`,
69+
latex: `![${altText}]${displayPart}(${source})${targetPart}`,
6070
offset: -1,
6171
});
62-
const fileType = file.type.split('/')[1];
63-
addImageToExport(fileID, fileType, file);
6472
},
6573
[insertLatex, addImageToExport]
6674
);

0 commit comments

Comments
 (0)