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

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.
@@ -31,14 +31,18 @@ const addNewWindowHint = function (html) {
31
31
  treatMissingTargetAsBlank = false,
32
32
  className = HINT_CLASS
33
33
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
34
- if (typeof html !== 'string' || html.indexOf('<a') === -1 || typeof DOMParser === 'undefined') return html;
34
+ const hasLinks = typeof html === 'string' && (html.indexOf('<a') !== -1 || html.indexOf('data-goto') !== -1);
35
+ if (!hasLinks || typeof DOMParser === 'undefined') return html;
35
36
  const doc = new DOMParser().parseFromString(`<body>${html}</body>`, 'text/html');
36
37
  const hint = newWindowHintText();
37
38
  let changed = false;
38
- doc.body.querySelectorAll('a[href]').forEach(a => {
39
- const target = (a.getAttribute('target') || (treatMissingTargetAsBlank ? '_blank' : '')).toLowerCase();
39
+ /* 時間軸的站內明細連結是不輸出 href 的 span role="link" data-goto(各站 Chronology 以 window.open 另開分頁),
40
+ 同樣要提示(2026-10-08 人工測試回饋) */
41
+ const selector = treatMissingTargetAsBlank ? 'a[href], [data-goto]' : 'a[href]';
42
+ doc.body.querySelectorAll(selector).forEach(a => {
43
+ const target = a.hasAttribute('data-goto') ? '_blank' : (a.getAttribute('target') || (treatMissingTargetAsBlank ? '_blank' : '')).toLowerCase();
40
44
  if (target !== '_blank') return;
41
- if (!a.getAttribute('rel')) a.setAttribute('rel', 'noopener noreferrer');
45
+ if (a.tagName === 'A' && !a.getAttribute('rel')) a.setAttribute('rel', 'noopener noreferrer');
42
46
  if (hasHint(a.textContent)) return;
43
47
  const span = doc.createElement('span');
44
48
  span.className = className;
@@ -1,4 +1,4 @@
1
- import { a as addNewWindowHint } from './newWindowHint-db113a69.js';
1
+ import { a as addNewWindowHint } from './newWindowHint-72ebfe3b.js';
2
2
  import '../components/globalConfig';
3
3
 
4
4
  var HtmlToReactParser = require('html-to-react').Parser;
@@ -28,14 +28,18 @@ var addNewWindowHint = function addNewWindowHint(html) {
28
28
  treatMissingTargetAsBlank = _ref$treatMissingTarg === void 0 ? false : _ref$treatMissingTarg,
29
29
  _ref$className = _ref.className,
30
30
  className = _ref$className === void 0 ? HINT_CLASS : _ref$className;
31
- if (typeof html !== 'string' || html.indexOf('<a') === -1 || typeof DOMParser === 'undefined') return html;
31
+ var hasLinks = typeof html === 'string' && (html.indexOf('<a') !== -1 || html.indexOf('data-goto') !== -1);
32
+ if (!hasLinks || typeof DOMParser === 'undefined') return html;
32
33
  var doc = new DOMParser().parseFromString("<body>".concat(html, "</body>"), 'text/html');
33
34
  var hint = newWindowHintText();
34
35
  var changed = false;
35
- doc.body.querySelectorAll('a[href]').forEach(function (a) {
36
- var target = (a.getAttribute('target') || (treatMissingTargetAsBlank ? '_blank' : '')).toLowerCase();
36
+ /* 時間軸的站內明細連結是不輸出 href 的 span role="link" data-goto(各站 Chronology 以 window.open 另開分頁),
37
+ 同樣要提示(2026-10-08 人工測試回饋) */
38
+ var selector = treatMissingTargetAsBlank ? 'a[href], [data-goto]' : 'a[href]';
39
+ doc.body.querySelectorAll(selector).forEach(function (a) {
40
+ var target = a.hasAttribute('data-goto') ? '_blank' : (a.getAttribute('target') || (treatMissingTargetAsBlank ? '_blank' : '')).toLowerCase();
37
41
  if (target !== '_blank') return;
38
- if (!a.getAttribute('rel')) a.setAttribute('rel', 'noopener noreferrer');
42
+ if (a.tagName === 'A' && !a.getAttribute('rel')) a.setAttribute('rel', 'noopener noreferrer');
39
43
  if (hasHint(a.textContent)) return;
40
44
  var span = doc.createElement('span');
41
45
  span.className = className;
@@ -1,6 +1,6 @@
1
1
  import { d as _objectSpread2, b as _slicedToArray } from './_rollupPluginBabelHelpers-9802e640.js';
2
2
  import { getIntl } from '../components/globalConfig';
3
- import { a as addNewWindowHint, n as newWindowHintText } from './newWindowHint-db113a69.js';
3
+ import { a as addNewWindowHint, n as newWindowHintText } from './newWindowHint-72ebfe3b.js';
4
4
 
5
5
  var TIMELINE_HINT_CLASS = 'tl-newwindow-hint';
6
6
 
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.139",
4
+ "version": "2.0.1-beta.140",
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",