@zjlab-fe/data-hub-ui 0.24.0 → 0.26.0

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.
Files changed (56) hide show
  1. package/dist/types/components/file-preview/interface.d.ts +4 -0
  2. package/dist/types/components/file-preview/markdown-preview/cdn-loader.d.ts +6 -0
  3. package/dist/types/components/file-preview/markdown-preview/load-mathjax.d.ts +10 -0
  4. package/dist/types/components/file-preview/markdown-preview/rehype-math-to-text.d.ts +8 -0
  5. package/dist/types/components/file-preview/markdown-preview/use-markdown-plugins.d.ts +14 -0
  6. package/dist/types/components/file-preview/util.d.ts +1 -1
  7. package/es/components/FileUploader/FileUploadModal.js +1 -0
  8. package/es/components/FileUploader/FileUploaderImpl/FileUploaderFileReceiver.js +1 -0
  9. package/es/components/FileUploader/index.js +3 -0
  10. package/es/components/SDK-modal/index.module.scss.js +4 -2
  11. package/es/components/apply-perm-modal/index.module.scss.js +2 -1
  12. package/es/components/bench-card/index.module.scss.js +2 -1
  13. package/es/components/confirm-again/index.js +1 -0
  14. package/es/components/copy/index.module.scss.js +2 -1
  15. package/es/components/corpus-card/index.module.scss.js +4 -2
  16. package/es/components/feature-card/index.js +1 -0
  17. package/es/components/file-preview/data-table/index.module.scss.js +2 -1
  18. package/es/components/file-preview/excel-preview/index.js +6 -2
  19. package/es/components/file-preview/excel-preview/index.module.scss.js +2 -1
  20. package/es/components/file-preview/img-preview/index.js +42 -1
  21. package/es/components/file-preview/img-preview/index.module.scss.js +2 -1
  22. package/es/components/file-preview/index.js +1 -1
  23. package/es/components/file-preview/index.module.scss.js +2 -1
  24. package/es/components/file-preview/json-preview/index.js +1 -1
  25. package/es/components/file-preview/markdown-preview/index.js +22 -3
  26. package/es/components/file-preview/markdown-preview/index.module.scss.js +2 -1
  27. package/es/components/file-preview/markdown-preview/load-mathjax.js +76 -0
  28. package/es/components/file-preview/markdown-preview/rehype-math-to-text.js +28 -0
  29. package/es/components/file-preview/parquet-preview/index.js +1 -1
  30. package/es/components/file-preview/pdf-preview/index.js +2 -1
  31. package/es/components/file-preview/pdf-preview/index.module.scss.js +2 -1
  32. package/es/components/file-preview/table-preview/index.module.scss.js +2 -1
  33. package/es/components/file-preview/txt-preview/index.js +1 -1
  34. package/es/components/file-preview/util.js +2 -2
  35. package/es/components/file-uploader/components/circle-progress.js +1 -0
  36. package/es/components/file-uploader/components/uploader-drop-zone.js +2 -0
  37. package/es/components/file-uploader/components/uploader-file-item.js +2 -0
  38. package/es/components/file-uploader/components/uploader-file-list.js +2 -0
  39. package/es/components/file-uploader/components/uploader.js +2 -0
  40. package/es/components/file-uploader/components/uploading-status.js +1 -0
  41. package/es/components/floating-layer/index.js +1 -0
  42. package/es/components/header/index.module.scss.js +2 -1
  43. package/es/components/menu/index.module.scss.js +2 -1
  44. package/es/components/notion-editor/index.js +1 -0
  45. package/es/components/operator-chain/index.module.scss.js +3 -2
  46. package/es/components/permission-editor/permissionEditor/index.module.scss.js +2 -1
  47. package/es/components/popover-select/index.module.scss.js +2 -1
  48. package/es/components/radio-card/index.js +1 -0
  49. package/es/components/section-heading/index.js +1 -0
  50. package/es/components/tag-group-filter/index.module.scss.js +3 -2
  51. package/es/components/tag-view/index.module.scss.js +3 -2
  52. package/es/components/uploadDrawer/index.js +1 -0
  53. package/es/index.js +2 -0
  54. package/lib/index.js +1 -1
  55. package/package.json +3 -2
  56. package/rollup.es.config.mjs +12 -3
@@ -1,6 +1,10 @@
1
1
  export interface IFilePreviewProps {
2
+ /** 文件扩展名,如果传入了该值,则以该扩展名的格式展示,否则按照filePath的扩展名展示 */
3
+ ext?: string;
2
4
  /** 文件url */
3
5
  filePath?: string;
6
+ /** 自定义HTTP请求头,比如:认证信息 */
7
+ httpHeaders?: Record<string, string>;
4
8
  /**
5
9
  * 已有数据,展示成Table
6
10
  */
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 从 esm.sh CDN 动态加载 ESM 模块,带缓存
3
+ * @param name - npm 包名
4
+ * @param version - 版本号(如 '7' 表示 7.x latest)
5
+ */
6
+ export declare function loadPlugin<T = any>(name: string, version: string): Promise<T>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 从 CDN 加载全局 MathJax 脚本
3
+ * 配置支持 $...$ 和 $$...$$ 行内/块级公式
4
+ */
5
+ export declare function loadMathjax(): Promise<void>;
6
+ /**
7
+ * 在指定容器内对 MathJax 公式重新排版
8
+ * 通常在 DOM 更新后调用
9
+ */
10
+ export declare function typesetMathjax(container: HTMLElement): Promise<void>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * remark 插件:将 remark-math 解析的 math/inlineMath mdast 节点转回
3
+ * 带 $ 定界符的 text 节点,供全局 MathJax 后处理渲染
4
+ *
5
+ * 必须在 remark-rehype 转换之前执行,因为 mdast→hAST 阶段
6
+ * 无法识别 math 节点类型,会静默丢弃
7
+ */
8
+ export declare function remarkMathToText(): (tree: any) => void;
@@ -0,0 +1,14 @@
1
+ export interface MarkdownPlugins {
2
+ rehypeRaw: any;
3
+ remarkGfm: any;
4
+ remarkMath: any;
5
+ rehypeKatex: any;
6
+ }
7
+ interface UsePluginsResult {
8
+ plugins: MarkdownPlugins | null;
9
+ loading: boolean;
10
+ error: Error | null;
11
+ }
12
+ /** 从 CDN 异步加载 markdown 渲染所需的 unified 插件 */
13
+ export declare function useMarkdownPlugins(): UsePluginsResult;
14
+ export {};
@@ -5,4 +5,4 @@ export declare function appendAsset(assetUrlArr: string[]): Promise<unknown>;
5
5
  * @param {string} fileUrl - 文件地址
6
6
  * @returns {Promise<string>} 解码后的正常字符串
7
7
  */
8
- export declare function fetchFileWithAutoCode(fileUrl: string): Promise<string>;
8
+ export declare function fetchFileWithAutoCode(fileUrl: string, httpHeaders?: Record<string, string>): Promise<string>;
@@ -1,5 +1,6 @@
1
1
  import { __rest } from 'tslib';
2
2
  import { jsx } from 'react/jsx-runtime';
3
+ import './utils/modalConfig.css.js';
3
4
  import { Modal, Alert, Button } from 'antd';
4
5
  import { useContext } from 'react';
5
6
  import { UploadStoreContext, TEMP_STORE } from './UploadStoreProvider/UploadStoreProvider.js';
@@ -1,5 +1,6 @@
1
1
  import { __awaiter } from 'tslib';
2
2
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+ import './FileUploaderFileReceiver.css.js';
3
4
  import { App } from 'antd';
4
5
  import { useRef, useMemo } from 'react';
5
6
  import '../utils/checkExpiryTime.js';
@@ -1,9 +1,12 @@
1
+ import './index.css.js';
1
2
  export { default as UploadStoreProvider } from './UploadStoreProvider/UploadStoreProvider.js';
2
3
  import FileUploader from './FileUploader.js';
3
4
  import 'tslib';
4
5
  import 'react/jsx-runtime';
6
+ import './utils/modalConfig.css.js';
5
7
  import 'antd';
6
8
  import 'react';
9
+ import './FileUploaderImpl/FileUploaderFileReceiver.css.js';
7
10
  import './utils/checkExpiryTime.js';
8
11
  import './types.js';
9
12
  import './FileUploaderImpl/FileUploaderListItem.js';
@@ -44,6 +44,8 @@ style.textContent = `.index-module__modal___P--8v .ant-modal-title {
44
44
  color: #1775fe;
45
45
  }`;
46
46
  document.head.appendChild(style);
47
- var codeBlock = "index-module__codeBlock___QOg38";var loading = "index-module__loading___JWS7C";var errorText = "index-module__errorText___YBeKO";var codeContent = "index-module__codeContent___BmCSu";var documentLink = "index-module__documentLink___PX-ly";var documentLinkAnchor = "index-module__documentLinkAnchor___HAHYt";
48
47
 
49
- export { codeBlock, codeContent, documentLink, documentLinkAnchor, errorText, loading };
48
+ var modal = "index-module__modal___P--8v";var codeBlock = "index-module__codeBlock___QOg38";var loading = "index-module__loading___JWS7C";var errorText = "index-module__errorText___YBeKO";var codeContent = "index-module__codeContent___BmCSu";var documentLink = "index-module__documentLink___PX-ly";var documentLinkAnchor = "index-module__documentLinkAnchor___HAHYt";
49
+ var styles = {"modal":"index-module__modal___P--8v","codeBlock":"index-module__codeBlock___QOg38","loading":"index-module__loading___JWS7C","errorText":"index-module__errorText___YBeKO","codeContent":"index-module__codeContent___BmCSu","documentLink":"index-module__documentLink___PX-ly","documentLinkAnchor":"index-module__documentLinkAnchor___HAHYt"};
50
+
51
+ export { codeBlock, codeContent, styles as default, documentLink, documentLinkAnchor, errorText, loading, modal };
@@ -92,5 +92,6 @@ style.textContent = `@charset "UTF-8";
92
92
  document.head.appendChild(style);
93
93
 
94
94
  var permModal = "index-module__permModal___4Ukdb";var noModalWrap = "index-module__noModalWrap___v6QCa";var title = "index-module__title___V39im";var content = "index-module__content___e307P";var footer = "index-module__footer___B5SEp";var permFunModal = "index-module__permFunModal___t0q5w";
95
+ var styles = {"permModal":"index-module__permModal___4Ukdb","noModalWrap":"index-module__noModalWrap___v6QCa","title":"index-module__title___V39im","content":"index-module__content___e307P","footer":"index-module__footer___B5SEp","permFunModal":"index-module__permFunModal___t0q5w"};
95
96
 
96
- export { content, footer, noModalWrap, permFunModal, permModal, title };
97
+ export { content, styles as default, footer, noModalWrap, permFunModal, permModal, title };
@@ -44,5 +44,6 @@ style.textContent = `.index-module__t-card-base___s99hJ {
44
44
  document.head.appendChild(style);
45
45
 
46
46
  var t_card_base = "index-module__t-card-base___s99hJ";var bgblue = "index-module__bgblue___j--gQ";var bgpurple = "index-module__bgpurple___4vuIR";var w_card_base = "index-module__w-card-base___iMmt5";
47
+ var styles = {"t-card-base":"index-module__t-card-base___s99hJ","bgblue":"index-module__bgblue___j--gQ","bgpurple":"index-module__bgpurple___4vuIR","w-card-base":"index-module__w-card-base___iMmt5"};
47
48
 
48
- export { bgblue, bgpurple, t_card_base as "t-card-base", w_card_base as "w-card-base" };
49
+ export { bgblue, bgpurple, styles as default, t_card_base as "t-card-base", w_card_base as "w-card-base" };
@@ -1,6 +1,7 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { Modal } from 'antd';
3
3
  import classNames from 'classnames';
4
+ import './index.scss.js';
4
5
 
5
6
  function ConfirmAgain(props) {
6
7
  var _a;
@@ -11,5 +11,6 @@ style.textContent = `.index-module__icon___cJc9L {
11
11
  document.head.appendChild(style);
12
12
 
13
13
  var icon = "index-module__icon___cJc9L";
14
+ var styles = {"icon":"index-module__icon___cJc9L"};
14
15
 
15
- export { icon };
16
+ export { styles as default, icon };
@@ -166,6 +166,8 @@ style.textContent = `@charset "UTF-8";
166
166
  border-radius: 20px;
167
167
  }`;
168
168
  document.head.appendChild(style);
169
- var new_task_card_item = "index-module__new-task-card-item___4Ij8K";var card_actived = "index-module__card-actived___Ds-rJ";var new_task_card_header = "index-module__new-task-card-header___YNZyQ";var new_task_card_title = "index-module__new-task-card-title___ij3JL";var new_task_card_update_time = "index-module__new-task-card-update-time___-v0WT";var new_task_card_update_time_icon = "index-module__new-task-card-update-time-icon___1BRTB";var new_task_card_update_time_text = "index-module__new-task-card-update-time-text___JDOy0";var new_task_card_description = "index-module__new-task-card-description___a-I9s";var new_task_card_tags = "index-module__new-task-card-tags___kIHzm";var new_task_card_tags_visible = "index-module__new-task-card-tags-visible___r4txK";var new_task_card_tags_measure = "index-module__new-task-card-tags-measure___B-jpV";var new_task_card_tag_measure_item = "index-module__new-task-card-tag-measure-item___yWIae";var new_task_card_tags_popover_content = "index-module__new-task-card-tags-popover-content___rrMoB";var new_task_card_tags_ellipsis = "index-module__new-task-card-tags-ellipsis___GVtdA";
170
169
 
171
- export { card_actived as "card-actived", new_task_card_description as "new-task-card-description", new_task_card_header as "new-task-card-header", new_task_card_item as "new-task-card-item", new_task_card_tag_measure_item as "new-task-card-tag-measure-item", new_task_card_tags as "new-task-card-tags", new_task_card_tags_ellipsis as "new-task-card-tags-ellipsis", new_task_card_tags_measure as "new-task-card-tags-measure", new_task_card_tags_popover_content as "new-task-card-tags-popover-content", new_task_card_tags_visible as "new-task-card-tags-visible", new_task_card_title as "new-task-card-title", new_task_card_update_time as "new-task-card-update-time", new_task_card_update_time_icon as "new-task-card-update-time-icon", new_task_card_update_time_text as "new-task-card-update-time-text" };
170
+ var new_task_cards_container = "index-module__new-task-cards-container___ydHyH";var new_task_card_item = "index-module__new-task-card-item___4Ij8K";var card_actived = "index-module__card-actived___Ds-rJ";var new_task_card_header = "index-module__new-task-card-header___YNZyQ";var new_task_card_title = "index-module__new-task-card-title___ij3JL";var new_task_card_update_time = "index-module__new-task-card-update-time___-v0WT";var new_task_card_update_time_icon = "index-module__new-task-card-update-time-icon___1BRTB";var new_task_card_update_time_text = "index-module__new-task-card-update-time-text___JDOy0";var new_task_card_description = "index-module__new-task-card-description___a-I9s";var new_task_card_tags = "index-module__new-task-card-tags___kIHzm";var new_task_card_tags_visible = "index-module__new-task-card-tags-visible___r4txK";var new_task_card_tags_measure = "index-module__new-task-card-tags-measure___B-jpV";var new_task_card_tag_measure_item = "index-module__new-task-card-tag-measure-item___yWIae";var new_task_card_tags_popover_content = "index-module__new-task-card-tags-popover-content___rrMoB";var new_task_card_tags_ellipsis = "index-module__new-task-card-tags-ellipsis___GVtdA";var new_task_card_empty_title = "index-module__new-task-card-empty-title___di6z-";var card_detail_btn = "index-module__card-detail-btn___QHpSP";
171
+ var styles = {"new-task-cards-container":"index-module__new-task-cards-container___ydHyH","new-task-card-item":"index-module__new-task-card-item___4Ij8K","card-actived":"index-module__card-actived___Ds-rJ","new-task-card-header":"index-module__new-task-card-header___YNZyQ","new-task-card-title":"index-module__new-task-card-title___ij3JL","new-task-card-update-time":"index-module__new-task-card-update-time___-v0WT","new-task-card-update-time-icon":"index-module__new-task-card-update-time-icon___1BRTB","new-task-card-update-time-text":"index-module__new-task-card-update-time-text___JDOy0","new-task-card-description":"index-module__new-task-card-description___a-I9s","new-task-card-tags":"index-module__new-task-card-tags___kIHzm","new-task-card-tags-visible":"index-module__new-task-card-tags-visible___r4txK","new-task-card-tags-measure":"index-module__new-task-card-tags-measure___B-jpV","new-task-card-tag-measure-item":"index-module__new-task-card-tag-measure-item___yWIae","new-task-card-tags-popover-content":"index-module__new-task-card-tags-popover-content___rrMoB","new-task-card-tags-ellipsis":"index-module__new-task-card-tags-ellipsis___GVtdA","new-task-card-empty-title":"index-module__new-task-card-empty-title___di6z-","card-detail-btn":"index-module__card-detail-btn___QHpSP"};
172
+
173
+ export { card_actived as "card-actived", card_detail_btn as "card-detail-btn", styles as default, new_task_card_description as "new-task-card-description", new_task_card_empty_title as "new-task-card-empty-title", new_task_card_header as "new-task-card-header", new_task_card_item as "new-task-card-item", new_task_card_tag_measure_item as "new-task-card-tag-measure-item", new_task_card_tags as "new-task-card-tags", new_task_card_tags_ellipsis as "new-task-card-tags-ellipsis", new_task_card_tags_measure as "new-task-card-tags-measure", new_task_card_tags_popover_content as "new-task-card-tags-popover-content", new_task_card_tags_visible as "new-task-card-tags-visible", new_task_card_title as "new-task-card-title", new_task_card_update_time as "new-task-card-update-time", new_task_card_update_time_icon as "new-task-card-update-time-icon", new_task_card_update_time_text as "new-task-card-update-time-text", new_task_cards_container as "new-task-cards-container" };
@@ -1,6 +1,7 @@
1
1
  import { __rest } from 'tslib';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import React from 'react';
4
+ import './index.css.js';
4
5
  import { cn } from '../../lib/utils.js';
5
6
  import { FeatureCardContext } from './context.js';
6
7
  import { getRootSizeClasses, getAlignClass, getTitleSizeClasses, getDescriptionSizeClasses, getIconAlignClass, getIconRoundedClass, getIconSizeClasses } from './classNames.js';
@@ -50,5 +50,6 @@ style.textContent = `@charset "UTF-8";
50
50
  document.head.appendChild(style);
51
51
 
52
52
  var table = "index-module__table___LFpqo";var cell = "index-module__cell___MtAcf";var textContent = "index-module__textContent___yk5fQ";var pagination = "index-module__pagination___wbe3v";var downloadTip = "index-module__downloadTip___TI7NB";
53
+ var styles = {"table":"index-module__table___LFpqo","cell":"index-module__cell___MtAcf","textContent":"index-module__textContent___yk5fQ","pagination":"index-module__pagination___wbe3v","downloadTip":"index-module__downloadTip___TI7NB"};
53
54
 
54
- export { cell, downloadTip, pagination, table, textContent };
55
+ export { cell, styles as default, downloadTip, pagination, table, textContent };
@@ -34,7 +34,7 @@ function getEncoding(blob) {
34
34
  function ExcelPreview(props) {
35
35
  var _a;
36
36
  const ref = useRef(null);
37
- const ext = getFileExt(props.filePath);
37
+ const ext = props.ext || getFileExt(props.filePath);
38
38
  const [csvData, setCsvData] = useState();
39
39
  const [csvContainerHeight, setCsvContainerHeight] = useState();
40
40
  const [csvContainerWidth, setCsvContainerWidth] = useState();
@@ -45,7 +45,11 @@ function ExcelPreview(props) {
45
45
  'https://haina-datahub.zero2x.org/ossRoute/frontend/resources/npm/xlsx/0.18.5/dist/xlsx.full.min.js',
46
46
  'https://haina-datahub.zero2x.org/ossRoute/frontend/resources/npm/papaparse/5.5.2/papaparse.min.js',
47
47
  ]).then(() => __awaiter(this, void 0, void 0, function* () {
48
- fetch(props.filePath)
48
+ const fetchOptions = {};
49
+ if (props.httpHeaders) {
50
+ fetchOptions.headers = props.httpHeaders;
51
+ }
52
+ fetch(props.filePath, fetchOptions)
49
53
  .then((response) => __awaiter(this, void 0, void 0, function* () {
50
54
  if (ext === 'csv') {
51
55
  const blob = yield response.blob();
@@ -7,5 +7,6 @@ style.textContent = `.index-module__wrap___X1wOS {
7
7
  document.head.appendChild(style);
8
8
 
9
9
  var wrap = "index-module__wrap___X1wOS";
10
+ var styles = {"wrap":"index-module__wrap___X1wOS"};
10
11
 
11
- export { wrap };
12
+ export { styles as default, wrap };
@@ -1,7 +1,48 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { wrap, img } from './index.module.scss.js';
3
+ import { useState, useRef, useEffect } from 'react';
3
4
 
4
5
  function ImgPreview(props) {
6
+ const { filePath, httpHeaders } = props;
7
+ const [imgSrc, setImgSrc] = useState('');
8
+ const objectUrlRef = useRef('');
9
+ useEffect(() => {
10
+ if (!filePath) {
11
+ return;
12
+ }
13
+ if (!httpHeaders || Object.keys(httpHeaders).length === 0) {
14
+ setImgSrc(filePath);
15
+ return;
16
+ }
17
+ const controller = new AbortController();
18
+ fetch(filePath, {
19
+ headers: httpHeaders,
20
+ signal: controller.signal,
21
+ })
22
+ .then((res) => {
23
+ if (!res.ok) {
24
+ throw new Error(`HTTP ${res.status}`);
25
+ }
26
+ return res.blob();
27
+ })
28
+ .then((blob) => {
29
+ const url = URL.createObjectURL(blob);
30
+ objectUrlRef.current = url;
31
+ setImgSrc(url);
32
+ })
33
+ .catch((e) => {
34
+ var _a;
35
+ if (e.name !== 'AbortError') {
36
+ (_a = props === null || props === void 0 ? void 0 : props.onError) === null || _a === void 0 ? void 0 : _a.call(props, e);
37
+ }
38
+ });
39
+ return () => {
40
+ controller.abort();
41
+ if (objectUrlRef.current) {
42
+ URL.revokeObjectURL(objectUrlRef.current);
43
+ }
44
+ };
45
+ }, []);
5
46
  // eslint-disable-next-line
6
47
  const onError = (e) => {
7
48
  var _a;
@@ -12,7 +53,7 @@ function ImgPreview(props) {
12
53
  var _a;
13
54
  (_a = props === null || props === void 0 ? void 0 : props.onSuccess) === null || _a === void 0 ? void 0 : _a.call(props);
14
55
  };
15
- return (jsx("div", { className: wrap, children: jsx("img", { src: props.filePath, onError: onError, onLoad: onLoad, className: img }) }));
56
+ return (jsx("div", { className: wrap, children: imgSrc && jsx("img", { src: imgSrc, onError: onError, onLoad: onLoad, className: img }) }));
16
57
  }
17
58
 
18
59
  export { ImgPreview as default };
@@ -13,5 +13,6 @@ style.textContent = `.index-module__wrap___qyJ-P {
13
13
  document.head.appendChild(style);
14
14
 
15
15
  var wrap = "index-module__wrap___qyJ-P";var img = "index-module__img___DXNGo";
16
+ var styles = {"wrap":"index-module__wrap___qyJ-P","img":"index-module__img___DXNGo"};
16
17
 
17
- export { img, wrap };
18
+ export { styles as default, img, wrap };
@@ -43,7 +43,7 @@ function InnerFilePreview(props) {
43
43
  result = jsx(JsonPreview, Object.assign({}, props, { onError: onError, onSuccess: onSuccess }));
44
44
  }
45
45
  else if (filePath) {
46
- const ext = getFileExt(filePath).toLowerCase();
46
+ const ext = props.ext || getFileExt(filePath).toLowerCase();
47
47
  const spin = (jsx("div", { className: spinWrap, children: jsx(Spin, {}) }));
48
48
  let innerPreview = null;
49
49
  let canPreview = true;
@@ -28,5 +28,6 @@ style.textContent = `.index-module__wrap___UpLkF {
28
28
  document.head.appendChild(style);
29
29
 
30
30
  var wrap = "index-module__wrap___UpLkF";var spinWrap = "index-module__spinWrap___qNaoa";var modalWrap = "index-module__modalWrap___CKrVC";
31
+ var styles = {"wrap":"index-module__wrap___UpLkF","spinWrap":"index-module__spinWrap___qNaoa","modalWrap":"index-module__modalWrap___CKrVC"};
31
32
 
32
- export { modalWrap, spinWrap, wrap };
33
+ export { styles as default, modalWrap, spinWrap, wrap };
@@ -83,7 +83,7 @@ function JsonPreview(props) {
83
83
  value = props.jsonConfig.data;
84
84
  }
85
85
  else {
86
- value = yield fetchFileWithAutoCode(props.filePath);
86
+ value = yield fetchFileWithAutoCode(props.filePath, props.httpHeaders);
87
87
  }
88
88
  try {
89
89
  const json = typeof value === 'string' ? JSON.parse(value) : value;
@@ -5,8 +5,9 @@ import ReactMarkdown from 'react-markdown';
5
5
  import rehypeRaw from 'rehype-raw';
6
6
  import remarkGfm from 'remark-gfm';
7
7
  import remarkMath from 'remark-math';
8
- import rehypeMathjax from 'rehype-mathjax';
9
8
  import { fetchFileWithAutoCode } from '../util.js';
9
+ import { typesetMathjax } from './load-mathjax.js';
10
+ import { remarkMathToText } from './rehype-math-to-text.js';
10
11
  import { wrap } from './index.module.scss.js';
11
12
 
12
13
  function processMarkdownImages(input) {
@@ -24,6 +25,18 @@ function processMarkdownImages(input) {
24
25
  }
25
26
  });
26
27
  }
28
+ /** 将 \(...\) 和 \[...\] 转换为 remark-math 能识别的 $/$$ 定界符 */
29
+ function normalizeMathDelimiters(input) {
30
+ return (input
31
+ // \[...\] → $$...$$ (块级公式,跨行)
32
+ .replace(/\\\[([\s\S]*?)\\\]/g, (_, inner) => {
33
+ return `$$\n${inner.trim()}\n$$`;
34
+ })
35
+ // \(...\) → $...$ (行内公式,单行)
36
+ .replace(/\\\(([^\n]*?)\\\)/g, (_, inner) => {
37
+ return `$${inner.trim()}$`;
38
+ }));
39
+ }
27
40
  function MDPreview(props) {
28
41
  const ref = useRef(null);
29
42
  const [content, setContent] = useState('');
@@ -32,10 +45,11 @@ function MDPreview(props) {
32
45
  // 测试vditor预览大小超过1MB的markdown文件非常耗时(超过10s)
33
46
  var _a, _b;
34
47
  try {
35
- let result = yield fetchFileWithAutoCode(props.filePath);
48
+ let result = yield fetchFileWithAutoCode(props.filePath, props.httpHeaders);
36
49
  // const start = new Date().getTime();
37
50
  // console.log('+++ start', start);
38
51
  result = processMarkdownImages(result);
52
+ result = normalizeMathDelimiters(result);
39
53
  // const end = new Date().getTime();
40
54
  // console.log('+++ end', end);
41
55
  // console.log(`processMarkdownImages time: ${end - start}ms`);
@@ -47,7 +61,12 @@ function MDPreview(props) {
47
61
  }
48
62
  }))();
49
63
  }, []);
50
- return (jsx("div", { ref: ref, style: { height: '100%', overflow: 'auto' }, className: wrap, children: content ? (jsx(ReactMarkdown, { className: "markdown-body", remarkPlugins: [remarkMath, remarkGfm], rehypePlugins: [rehypeRaw, rehypeMathjax], children: content })) : null }));
64
+ useEffect(() => {
65
+ if (content && ref.current) {
66
+ typesetMathjax(ref.current);
67
+ }
68
+ }, [content]);
69
+ return (jsx("div", { ref: ref, style: { height: '100%', overflow: 'auto' }, className: wrap, children: content ? (jsx(ReactMarkdown, { className: "markdown-body", remarkPlugins: [remarkMath, remarkGfm, remarkMathToText], rehypePlugins: [rehypeRaw], children: content })) : null }));
51
70
  }
52
71
 
53
72
  export { MDPreview as default };
@@ -1051,5 +1051,6 @@ style.textContent = `.index-module__wrap___d8k-1 .markdown-body {
1051
1051
  document.head.appendChild(style);
1052
1052
 
1053
1053
  var wrap = "index-module__wrap___d8k-1";
1054
+ var styles = {"wrap":"index-module__wrap___d8k-1"};
1054
1055
 
1055
- export { wrap };
1056
+ export { styles as default, wrap };
@@ -0,0 +1,76 @@
1
+ import { __awaiter } from 'tslib';
2
+
3
+ let loaded = false;
4
+ let loading = null;
5
+ /**
6
+ * 从 CDN 加载全局 MathJax 脚本
7
+ * 配置支持 $...$ 和 $$...$$ 行内/块级公式
8
+ */
9
+ function loadMathjax() {
10
+ var _a;
11
+ // 宿主项目已自行配置并加载全局 MathJax,直接复用
12
+ if ((_a = window.MathJax) === null || _a === void 0 ? void 0 : _a.typesetPromise) {
13
+ loaded = true;
14
+ return Promise.resolve();
15
+ }
16
+ if (loaded)
17
+ return Promise.resolve();
18
+ if (loading)
19
+ return loading;
20
+ loading = new Promise((resolve, reject) => {
21
+ // 先写入 MathJax 配置
22
+ const scriptConfig = document.createElement('script');
23
+ scriptConfig.textContent = `
24
+ window.MathJax = {
25
+ tex: {
26
+ inlineMath: [['$', '$'], ['\\\\(', '\\\\)']],
27
+ displayMath: [['$$', '$$'], ['\\\\[', '\\\\]']],
28
+ processEscapes: true
29
+ },
30
+ options: {
31
+ enableMenu: false,
32
+ ignoreHtmlClass: 'no-mathjax',
33
+ processHtmlClass: 'mathjax-process'
34
+ },
35
+ startup: {
36
+ pageReady: function () {
37
+ return MathJax.startup.defaultPageReady();
38
+ }
39
+ }
40
+ };
41
+ `;
42
+ document.head.appendChild(scriptConfig);
43
+ // 加载 MathJax 核心脚本
44
+ const script = document.createElement('script');
45
+ script.src =
46
+ 'https://haina-datahub.zero2x.org/ossRoute/frontend/resources/npm/mathjax/3.2.2/es5/tex-mml-chtml.js';
47
+ script.async = true;
48
+ script.onload = () => {
49
+ loaded = true;
50
+ resolve();
51
+ };
52
+ script.onerror = () => reject(new Error('Failed to load MathJax from CDN'));
53
+ document.head.appendChild(script);
54
+ });
55
+ return loading;
56
+ }
57
+ /**
58
+ * 在指定容器内对 MathJax 公式重新排版
59
+ * 通常在 DOM 更新后调用
60
+ */
61
+ function typesetMathjax(container) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ var _a;
64
+ try {
65
+ yield loadMathjax();
66
+ if ((_a = window.MathJax) === null || _a === void 0 ? void 0 : _a.typesetPromise) {
67
+ yield window.MathJax.typesetPromise([container]);
68
+ }
69
+ }
70
+ catch (_b) {
71
+ // 静默失败,不阻塞渲染
72
+ }
73
+ });
74
+ }
75
+
76
+ export { loadMathjax, typesetMathjax };
@@ -0,0 +1,28 @@
1
+ import { visit } from 'unist-util-visit';
2
+
3
+ /**
4
+ * remark 插件:将 remark-math 解析的 math/inlineMath mdast 节点转回
5
+ * 带 $ 定界符的 text 节点,供全局 MathJax 后处理渲染
6
+ *
7
+ * 必须在 remark-rehype 转换之前执行,因为 mdast→hAST 阶段
8
+ * 无法识别 math 节点类型,会静默丢弃
9
+ */
10
+ function remarkMathToText() {
11
+ // eslint-disable-next-line
12
+ return (tree) => {
13
+ // eslint-disable-next-line
14
+ visit(tree, (node) => {
15
+ if (node.type === 'math' || node.type === 'inlineMath') {
16
+ const delimiter = node.type === 'inlineMath' ? '$' : '$$';
17
+ node.type = 'text';
18
+ node.value = `${delimiter}${node.value}${delimiter}`;
19
+ // 清除 remark-math 设置的 hAST 提示(hName, hProperties, hChildren)
20
+ // 否则 remark-rehype 仍会按 <code> 元素渲染,而不是纯文本
21
+ delete node.data;
22
+ delete node.meta;
23
+ }
24
+ });
25
+ };
26
+ }
27
+
28
+ export { remarkMathToText };
@@ -21,7 +21,7 @@ function ParquetPreview(props) {
21
21
  (() => __awaiter(this, void 0, void 0, function* () {
22
22
  var _a, _b, _c, _d;
23
23
  try {
24
- const resp = yield fetch(props.filePath);
24
+ const resp = yield fetch(props.filePath, { headers: props.httpHeaders });
25
25
  const parquetUint8Array = new Uint8Array(yield resp.arrayBuffer());
26
26
  // const start = new Date().getTime();
27
27
  ffiTable = readParquet(parquetUint8Array).intoFFI();
@@ -61,7 +61,7 @@ function roundToDivide(x, div) {
61
61
  return r === 0 ? x : Math.round(x - r + div);
62
62
  }
63
63
  function PdfPreview(props) {
64
- const { filePath } = props;
64
+ const { filePath, httpHeaders } = props;
65
65
  const pdfContainer = useRef(null);
66
66
  const pageSize = 3;
67
67
  const lastScrollTop = useRef(0);
@@ -192,6 +192,7 @@ function PdfPreview(props) {
192
192
  url: filePath,
193
193
  cMapUrl: 'https://haina-datahub.zero2x.org/ossRoute/frontend/resources/npm/pdfjs-dist/4.7.76/cmaps/',
194
194
  cMapPacked: true,
195
+ httpHeaders,
195
196
  })
196
197
  // eslint-disable-next-line
197
198
  .promise.then((doc) => {
@@ -12,5 +12,6 @@ style.textContent = `.index-module__wrap___eXiLF {
12
12
  document.head.appendChild(style);
13
13
 
14
14
  var wrap = "index-module__wrap___eXiLF";
15
+ var styles = {"wrap":"index-module__wrap___eXiLF"};
15
16
 
16
- export { wrap };
17
+ export { styles as default, wrap };
@@ -7,5 +7,6 @@ style.textContent = `.index-module__wrap___YSAno {
7
7
  document.head.appendChild(style);
8
8
 
9
9
  var wrap = "index-module__wrap___YSAno";
10
+ var styles = {"wrap":"index-module__wrap___YSAno"};
10
11
 
11
- export { wrap };
12
+ export { styles as default, wrap };
@@ -9,7 +9,7 @@ function TxtPreview(props) {
9
9
  (() => __awaiter(this, void 0, void 0, function* () {
10
10
  var _a, _b;
11
11
  try {
12
- const result = yield fetchFileWithAutoCode(props.filePath);
12
+ const result = yield fetchFileWithAutoCode(props.filePath, props.httpHeaders);
13
13
  setContent(result);
14
14
  (_a = props === null || props === void 0 ? void 0 : props.onSuccess) === null || _a === void 0 ? void 0 : _a.call(props);
15
15
  }
@@ -59,9 +59,9 @@ function appendAsset(assetUrlArr) {
59
59
  * @param {string} fileUrl - 文件地址
60
60
  * @returns {Promise<string>} 解码后的正常字符串
61
61
  */
62
- function fetchFileWithAutoCode(fileUrl) {
62
+ function fetchFileWithAutoCode(fileUrl, httpHeaders) {
63
63
  return __awaiter(this, void 0, void 0, function* () {
64
- const response = yield fetch(fileUrl);
64
+ const response = yield fetch(fileUrl, { headers: httpHeaders });
65
65
  if (!response.ok)
66
66
  throw new Error(`请求失败:${response.status}`);
67
67
  const arrayBuffer = yield response.arrayBuffer();
@@ -1,4 +1,5 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import './circle-progress.css.js';
2
3
 
3
4
  // Circle Progress Component
4
5
  function CircleProgress({ percent, isFailed, isSuccess, }) {
@@ -3,6 +3,8 @@ import { useRef, useCallback } from 'react';
3
3
  import UploadIcon from './icons.js';
4
4
  import { useDropZone } from './hooks/use-drop-zone.js';
5
5
  import { useFileValidation } from './hooks/use-file-validation.js';
6
+ import './theme.css.js';
7
+ import './uploader-drop-zone.css.js';
6
8
 
7
9
  function UploaderDropZone(props) {
8
10
  const { accept = '', maxSize, maxFiles, directory = false, disabled = false, dragAreaDescription = '点击或拖拽上传文件', icon, classNames, onDrop, fileValidation, onError, } = props;
@@ -3,6 +3,8 @@ import { UploadStatus } from '../constants.js';
3
3
  import { CircleProgress } from './circle-progress.js';
4
4
  import { FileIcon, PauseIcon, ResumeIcon, CloseIcon } from './icons.js';
5
5
  import { UploadingStatus } from './uploading-status.js';
6
+ import './theme.css.js';
7
+ import './uploader-file-item.css.js';
6
8
 
7
9
  function UploaderFileItem(props) {
8
10
  const { file, classNames, onCancel, onRemove, onPause, onResume } = props;
@@ -1,5 +1,7 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { useUpload } from '../hooks/use-upload.js';
3
+ import './theme.css.js';
4
+ import './uploader-file-list.css.js';
3
5
 
4
6
  /**
5
7
  * Simple file list component that displays all uploaded files.
@@ -1,4 +1,6 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import './theme.css.js';
3
+ import './uploader.css.js';
2
4
  import { useEffect, useCallback } from 'react';
3
5
  import { DEFAULT_MAX_FILE_SIZE } from '../constants.js';
4
6
  import { UploaderDropZone } from './uploader-drop-zone.js';
@@ -1,5 +1,6 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { useState, useEffect } from 'react';
3
+ import './uploading-status.css.js';
3
4
 
4
5
  const UPLOADING_MESSAGES = [
5
6
  '上传中',
@@ -1,5 +1,6 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { useState, useEffect } from 'react';
3
+ import './index.scss.js';
3
4
  import closeBtn from '../../assets/closeBtn.png.js';
4
5
  import classNames from 'classnames';
5
6
 
@@ -12,5 +12,6 @@ style.textContent = `.index-module__wrap___mhkN0 {
12
12
  document.head.appendChild(style);
13
13
 
14
14
  var wrap = "index-module__wrap___mhkN0";var logo = "index-module__logo___CzVkn";
15
+ var styles = {"wrap":"index-module__wrap___mhkN0","logo":"index-module__logo___CzVkn"};
15
16
 
16
- export { logo, wrap };
17
+ export { styles as default, logo, wrap };