one-design-next 0.0.111 → 0.0.113
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.
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* iframe 导航守卫:
|
|
3
3
|
*
|
|
4
|
-
* PreviewPanel 渲染 text/html 时使用
|
|
4
|
+
* PreviewPanel 渲染 text/html 时使用
|
|
5
|
+
* sandbox="allow-scripts allow-same-origin" 的 iframe(same-origin 兼容数据万象等预览),
|
|
5
6
|
* 内部链接默认被沙箱拦截(既不响应点击,也不能逃逸到顶层)。
|
|
6
7
|
* 通过 `allowedNavigateDomains` 白名单放行特定域名:命中白名单的链接
|
|
7
8
|
* 在点击时以新窗口打开,其余链接继续拦截。
|
|
@@ -19,7 +20,7 @@ export declare function isDomainAllowed(hostname: string | null | undefined, all
|
|
|
19
20
|
/**
|
|
20
21
|
* 将导航守卫脚本注入 HTML,返回新的 srcDoc 字符串。
|
|
21
22
|
*
|
|
22
|
-
* 脚本逻辑(依赖 sandbox 已放行 allow-scripts / allow-popups /
|
|
23
|
+
* 脚本逻辑(依赖 sandbox 已放行 allow-scripts / allow-same-origin / allow-popups /
|
|
23
24
|
* allow-popups-to-escape-sandbox):
|
|
24
25
|
* - 锚点(`#xxx`)或非链接元素:不拦截,保留默认行为;
|
|
25
26
|
* - href 无法解析,或协议非 http/https(如 javascript:、data:):拦截;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* iframe 导航守卫:
|
|
4
4
|
*
|
|
5
|
-
* PreviewPanel 渲染 text/html 时使用
|
|
5
|
+
* PreviewPanel 渲染 text/html 时使用
|
|
6
|
+
* sandbox="allow-scripts allow-same-origin" 的 iframe(same-origin 兼容数据万象等预览),
|
|
6
7
|
* 内部链接默认被沙箱拦截(既不响应点击,也不能逃逸到顶层)。
|
|
7
8
|
* 通过 `allowedNavigateDomains` 白名单放行特定域名:命中白名单的链接
|
|
8
9
|
* 在点击时以新窗口打开,其余链接继续拦截。
|
|
@@ -33,7 +34,7 @@ export function isDomainAllowed(hostname, allowedDomains) {
|
|
|
33
34
|
/**
|
|
34
35
|
* 将导航守卫脚本注入 HTML,返回新的 srcDoc 字符串。
|
|
35
36
|
*
|
|
36
|
-
* 脚本逻辑(依赖 sandbox 已放行 allow-scripts / allow-popups /
|
|
37
|
+
* 脚本逻辑(依赖 sandbox 已放行 allow-scripts / allow-same-origin / allow-popups /
|
|
37
38
|
* allow-popups-to-escape-sandbox):
|
|
38
39
|
* - 锚点(`#xxx`)或非链接元素:不拦截,保留默认行为;
|
|
39
40
|
* - href 无法解析,或协议非 http/https(如 javascript:、data:):拦截;
|
|
@@ -81,7 +81,8 @@ export interface PreviewPanelProps {
|
|
|
81
81
|
/**
|
|
82
82
|
* HTML 预览(`text/html`)时允许跳转的域名白名单。
|
|
83
83
|
*
|
|
84
|
-
* iframe 默认 `sandbox="allow-scripts"
|
|
84
|
+
* iframe 默认 `sandbox="allow-scripts allow-same-origin"`(含 same-origin 以兼容数据万象等预览脚本),
|
|
85
|
+
* 内部链接一律被沙箱拦截;
|
|
85
86
|
* 传入本配置后,命中白名单的链接在点击时会以新窗口打开,其余链接保持拦截。
|
|
86
87
|
* 支持精确匹配与子域名匹配(如 `example.com` 可放行 `www.example.com`),
|
|
87
88
|
* 忽略大小写;协议仅放行 `http:` / `https:`,`javascript:` 等始终拦截。
|
|
@@ -454,7 +454,7 @@ export function PreviewPanel(_ref2) {
|
|
|
454
454
|
onScroll: handlePreviewScroll
|
|
455
455
|
}, activeTab.type === 'text/html' ? /*#__PURE__*/React.createElement("iframe", {
|
|
456
456
|
srcDoc: htmlSrcDoc,
|
|
457
|
-
sandbox: hasNavGuard ? 'allow-scripts allow-popups allow-popups-to-escape-sandbox' : 'allow-scripts',
|
|
457
|
+
sandbox: hasNavGuard ? 'allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox' : 'allow-scripts allow-same-origin',
|
|
458
458
|
"data-odn-preview-panel-iframe": true,
|
|
459
459
|
"data-odn-preview-panel-iframe-nav-guard": hasNavGuard || undefined,
|
|
460
460
|
title: activeTab.name
|