@daoyi/nmtl-ui 2.0.1-beta.138 → 2.0.1-beta.139

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -78,7 +78,7 @@ var zhtw = {
78
78
  "chronology.zoomIn": "放大時間刻度",
79
79
  "chronology.zoomOut": "縮小時間刻度",
80
80
  "chronology.backToStart": "回到第一張",
81
- "chronology.driveImage": "{title}相關圖片",
81
+ "chronology.drivePreview": "「{title}」的 Google 雲端硬碟預覽",
82
82
  "chronology.openDriveFile": "在 Google 雲端硬碟檢視原始檔案",
83
83
  "aria.newWindow": "(另開新視窗)",
84
84
  "aria.vcode.image": "驗證碼圖片,如無法辨識可刷新驗證碼",
@@ -217,7 +217,7 @@ var zhcn = {
217
217
  "chronology.zoomIn": "放大时间刻度",
218
218
  "chronology.zoomOut": "缩小时间刻度",
219
219
  "chronology.backToStart": "回到第一张",
220
- "chronology.driveImage": "{title}相关图片",
220
+ "chronology.drivePreview": "「{title}」的 Google 云端硬盘预览",
221
221
  "chronology.openDriveFile": "在 Google 云端硬盘查看原始文件",
222
222
  "aria.newWindow": "(另开新视窗)",
223
223
  "aria.vcode.image": "验证码图片,如无法辨识可刷新验证码",
@@ -358,7 +358,7 @@ var enus = {
358
358
  "chronology.zoomIn": "Zoom in the timeline",
359
359
  "chronology.zoomOut": "Zoom out the timeline",
360
360
  "chronology.backToStart": "Back to the first slide",
361
- "chronology.driveImage": "Image related to {title}",
361
+ "chronology.drivePreview": "Google Drive preview of “{title}”",
362
362
  "chronology.openDriveFile": "View the original file on Google Drive",
363
363
  "aria.newWindow": " (opens in new window)",
364
364
  "aria.vcode.image": "CAPTCHA image, refresh if unreadable",
@@ -6,24 +6,24 @@ var TIMELINE_HINT_CLASS = 'tl-newwindow-hint';
6
6
 
7
7
  /* https://drive.google.com/file/d/{id}/preview(或 /view) */
8
8
  var DRIVE_FILE = /^https?:\/\/drive\.google\.com\/file\/d\/([\w-]+)/i;
9
- /* 套件以網址結尾判斷是不是圖片(MediaType.js 的 /(jpg|...)(\?.*)?$/);縮圖網址沒有副檔名,
10
- 補 #.jpg 讓它走圖片類型(# 之後不會送到伺服器) */
9
+ /* 套件只認得分享網址(…/view?usp=sharing)為 Google Doc 類型、嵌入 /preview 的 iframe;資料裡也有 /preview 等寫法,統一 */
10
+ var driveShare = function driveShare(id) {
11
+ return "https://drive.google.com/file/d/".concat(id, "/view?usp=sharing");
12
+ };
13
+ /* 時間刻度標記的小縮圖;# 之後不送伺服器,.jpg 讓套件當圖片處理 */
11
14
  var driveThumbnail = function driveThumbnail(id) {
12
- return "https://drive.google.com/thumbnail?id=".concat(id, "&sz=w1000#.jpg");
15
+ return "https://drive.google.com/thumbnail?id=".concat(id, "&sz=w400#.jpg");
13
16
  };
14
17
  var driveView = function driveView(id) {
15
18
  return "https://drive.google.com/file/d/".concat(id, "/view");
16
19
  };
17
- var stripTags = function stripTags(html) {
18
- return String(html || '').replace(/<[^>]*>/g, '').trim();
19
- };
20
20
  var hint = function hint(html) {
21
21
  return addNewWindowHint(html, {
22
22
  treatMissingTargetAsBlank: true,
23
23
  className: TIMELINE_HINT_CLASS
24
24
  });
25
25
  };
26
- var prepareMedia = function prepareMedia(media, headline) {
26
+ var prepareMedia = function prepareMedia(media) {
27
27
  if (!media || typeof media.url !== 'string') return media;
28
28
  var match = DRIVE_FILE.exec(media.url);
29
29
  if (!match) return _objectSpread2(_objectSpread2({}, media), {}, {
@@ -33,23 +33,13 @@ var prepareMedia = function prepareMedia(media, headline) {
33
33
  id = _match[1];
34
34
  var _getIntl = getIntl(),
35
35
  formatMessage = _getIntl.formatMessage;
36
- /* 雲端硬碟的檔案多半是圖片、少數是影片,無法從網址判斷 → 用詞不限定影片(2026-10-08 人工測試回饋)。
37
- 縮圖就是檔案內容本身:alt 優先用圖說(通常是圖片的說明與來源),沒有圖說才用「{標題}相關圖片」 */
38
- var alt = stripTags(media.caption) || formatMessage({
39
- id: 'chronology.driveImage'
40
- }, {
41
- title: stripTags(headline)
42
- });
43
36
  var open = "<a href=\"".concat(driveView(id), "\" target=\"_blank\" rel=\"noopener noreferrer\">").concat(formatMessage({
44
37
  id: 'chronology.openDriveFile'
45
38
  }), "<span class=\"").concat(TIMELINE_HINT_CLASS, "\">").concat(newWindowHintText(), "</span></a>");
46
39
  return _objectSpread2(_objectSpread2({}, media), {}, {
47
- url: driveThumbnail(id),
40
+ url: driveShare(id),
48
41
  thumbnail: driveThumbnail(id),
49
- alt: alt,
50
- /* 套件沒有 title 時拿圖說當圖片 title,會帶進連結文字,但圖片本身不是連結 */
51
- title: alt,
52
- /* 連結放在圖說,不包在圖片上:同一個目的地只留一個連結,文字也看得到 */
42
+ /* 預覽器對鍵盤與報讀軟體隱藏,圖說的連結是它們的替代入口 */
53
43
  caption: [open, hint(media.caption)].filter(Boolean).join('<br />'),
54
44
  link: undefined
55
45
  });
@@ -62,7 +52,7 @@ var prepareSlide = function prepareSlide(slide) {
62
52
  }) : slide.text;
63
53
  return _objectSpread2(_objectSpread2({}, slide), {}, {
64
54
  text: text,
65
- media: prepareMedia(slide.media, slide.text && slide.text.headline)
55
+ media: prepareMedia(slide.media)
66
56
  });
67
57
  };
68
58
 
@@ -14,6 +14,7 @@ var MENU_BUTTON_LABELS = [['.tl-icon-zoom-in', 'chronology.zoomIn'], ['.tl-icon-
14
14
  * 5. 下方時間刻度的事件標記:原本只能滑鼠點選。改為 tablist/tab(只有目前事件可 Tab 到),
15
15
  * 方向鍵/Home/End/PageUp/PageDown 換到對應事件
16
16
  * 6. 放大、縮小、回到第一張:原本是沒有名稱的 span,補 role="button"、tabindex、名稱,Enter/空白鍵可操作
17
+ * 8. Google 雲端硬碟預覽器 iframe:tabindex="-1"+aria-hidden(見 prepareTimelineData 檔頭 GN1210200E)
17
18
  * 7. 套件在 document 上監聽左右鍵換頁(每建一次就多綁一個、從不移除),焦點在頁籤、搜尋框等時間軸外的元件時
18
19
  * 按左右鍵也會換投影片 → 只有焦點在這個時間軸的箭頭上才讓它生效
19
20
  * @param {object} timeline new Timeline(...) 的實例
@@ -60,6 +61,21 @@ var syncTimelineA11y = function syncTimelineA11y(timeline, root) {
60
61
  });
61
62
  });
62
63
  };
64
+ /* 8. Google 雲端硬碟預覽器(iframe):會把 Tab 攔在內部循環(鍵盤陷阱)→ 不讓鍵盤進入、對報讀軟體隱藏,
65
+ 改由圖說的「在 Google 雲端硬碟檢視原始檔案」連結提供;滑鼠仍可在頁內縮放、翻頁 */
66
+ var syncIframes = function syncIframes() {
67
+ root.querySelectorAll('.tl-slide iframe[src*="drive.google.com"]').forEach(function (frame) {
68
+ frame.setAttribute('tabindex', '-1');
69
+ frame.setAttribute('aria-hidden', 'true');
70
+ /* 套件會拿圖說(含「在 Google 雲端硬碟檢視原始檔案」連結文字)當 title,改成描述這個預覽器 */
71
+ var slide = frame.closest('.tl-slide');
72
+ var title = t('chronology.drivePreview', {
73
+ title: text(slide && slide.querySelector('.tl-headline:not(.tl-headline-date)'))
74
+ });
75
+ if (frame.getAttribute('title') !== title) frame.setAttribute('title', title);
76
+ });
77
+ };
78
+
63
79
  /* 3. 「上一張」移到投影片內容之前;兩個箭頭都是絕對定位,畫面不變 */
64
80
  var orderNav = function orderNav() {
65
81
  var prev = root.querySelector('.tl-slidenav-previous');
@@ -214,6 +230,7 @@ var syncTimelineA11y = function syncTimelineA11y(timeline, root) {
214
230
  /* changed:只有真正換頁(change 事件)才播報,初次載入與重建不播 */
215
231
  var apply = function apply(changed) {
216
232
  orderNav();
233
+ syncIframes();
217
234
  syncMenuButtons();
218
235
  var currentId = currentIdOf();
219
236
  /* 剛載入時 current_id 可能還是空的:先不動 inert,避免把畫面上的這張也設成 inert */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@daoyi/nmtl-ui",
3
3
  "packageManager": "pnpm@10.34.5",
4
- "version": "2.0.1-beta.138",
4
+ "version": "2.0.1-beta.139",
5
5
  "description": "This project is to be used as a starter kit for building React component using Storybook and Rollup",
6
6
  "author": "daoyi",
7
7
  "main": "lib/index.js",