@eternalheart/react-file-preview 1.2.0 → 1.3.1
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.
- package/README.md +67 -2
- package/README.zh-CN.md +67 -2
- package/lib/FilePreviewContent.d.ts +7 -0
- package/lib/FilePreviewContent.d.ts.map +1 -1
- package/lib/FilePreviewEmbed.d.ts +5 -0
- package/lib/FilePreviewEmbed.d.ts.map +1 -1
- package/lib/FilePreviewModal.d.ts +5 -0
- package/lib/FilePreviewModal.d.ts.map +1 -1
- package/lib/components/ResizableSplit.d.ts +29 -0
- package/lib/components/ResizableSplit.d.ts.map +1 -0
- package/lib/i18n/LocaleContext.d.ts +25 -0
- package/lib/i18n/LocaleContext.d.ts.map +1 -0
- package/lib/index.cjs +246 -53
- package/lib/index.cjs.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.mjs +27591 -32868
- package/lib/index.mjs.map +1 -1
- package/lib/renderers/Audio/index.d.ts.map +1 -1
- package/lib/renderers/Csv/index.d.ts +7 -0
- package/lib/renderers/Csv/index.d.ts.map +1 -0
- package/lib/renderers/Docx/index.d.ts.map +1 -1
- package/lib/renderers/Epub/index.d.ts +2 -2
- package/lib/renderers/Epub/index.d.ts.map +1 -1
- package/lib/renderers/Epub/toolbar.d.ts +2 -0
- package/lib/renderers/Epub/toolbar.d.ts.map +1 -1
- package/lib/renderers/Image/index.d.ts.map +1 -1
- package/lib/renderers/Image/toolbar.d.ts +2 -0
- package/lib/renderers/Image/toolbar.d.ts.map +1 -1
- package/lib/renderers/Json/index.d.ts.map +1 -1
- package/lib/renderers/Markdown/index.d.ts.map +1 -1
- package/lib/renderers/Mobi/index.d.ts +15 -0
- package/lib/renderers/Mobi/index.d.ts.map +1 -0
- package/lib/renderers/Mobi/toolbar.d.ts +13 -0
- package/lib/renderers/Mobi/toolbar.d.ts.map +1 -0
- package/lib/renderers/Msg/index.d.ts.map +1 -1
- package/lib/renderers/Pdf/index.d.ts.map +1 -1
- package/lib/renderers/Pdf/toolbar.d.ts +2 -0
- package/lib/renderers/Pdf/toolbar.d.ts.map +1 -1
- package/lib/renderers/Pptx/index.d.ts.map +1 -1
- package/lib/renderers/Subtitle/index.d.ts +7 -0
- package/lib/renderers/Subtitle/index.d.ts.map +1 -0
- package/lib/renderers/Text/index.d.ts +2 -0
- package/lib/renderers/Text/index.d.ts.map +1 -1
- package/lib/renderers/Text/toolbar.d.ts +12 -0
- package/lib/renderers/Text/toolbar.d.ts.map +1 -0
- package/lib/renderers/Unsupported/index.d.ts.map +1 -1
- package/lib/renderers/Video/index.d.ts.map +1 -1
- package/lib/renderers/Xlsx/index.d.ts.map +1 -1
- package/lib/renderers/Xml/index.d.ts +7 -0
- package/lib/renderers/Xml/index.d.ts.map +1 -0
- package/lib/renderers/Zip/index.d.ts +12 -0
- package/lib/renderers/Zip/index.d.ts.map +1 -0
- package/lib/renderers/Zip/toolbar.d.ts +13 -0
- package/lib/renderers/Zip/toolbar.d.ts.map +1 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -307,7 +307,27 @@ const files = [
|
|
|
307
307
|
### Code & Text
|
|
308
308
|
- **Markdown**: GitHub Flavored Markdown, code highlighting
|
|
309
309
|
- **Code Files**: JS, TS, Python, Java, C++, Go, Rust, and 40+ languages
|
|
310
|
-
- **
|
|
310
|
+
- **Config/Logs**: YAML, TOML, INI, ENV, LOG, DIFF, PATCH, etc.
|
|
311
|
+
|
|
312
|
+
### Structured Data
|
|
313
|
+
- **JSON**: Auto formatting + syntax highlighting
|
|
314
|
+
- **CSV/TSV**: Zero-dependency parser, table view with headers and row/column stats
|
|
315
|
+
- **XML**: `DOMParser` validation + pretty print + syntax highlighting
|
|
316
|
+
|
|
317
|
+
### Subtitles & Lyrics
|
|
318
|
+
- **SRT / WebVTT**: Zero-dependency parser, structured cue list (index, time range, text)
|
|
319
|
+
- **LRC / Enhanced LRC**: Lyric files with `[mm:ss.xx]` line stamps (and inline `<mm:ss.xx>` per-word stamps for ELRC), with `[ti:][ar:][al:]` metadata header
|
|
320
|
+
- **ASS / SSA**: Advanced SubStation Alpha — extracts Dialogue events, strips `\N` `\h` and `{...}` override codes, surfaces Style names
|
|
321
|
+
- **TTML / DFXP**: W3C / Apple Music XML captions, supports `begin` / `end` / `dur` and `<br/>`
|
|
322
|
+
|
|
323
|
+
### Archives
|
|
324
|
+
- **ZIP**: Tree view + inline preview for text/code/image entries, download fallback for other types
|
|
325
|
+
|
|
326
|
+
### Outlook Email
|
|
327
|
+
- **MSG**: Headers, body rendering, attachment list
|
|
328
|
+
|
|
329
|
+
### E-books
|
|
330
|
+
- **EPUB**: Chapter navigation, pagination
|
|
311
331
|
|
|
312
332
|
## 🎮 API Reference
|
|
313
333
|
|
|
@@ -321,6 +341,8 @@ const files = [
|
|
|
321
341
|
| `onClose` | `() => void` | ✅ | Close callback |
|
|
322
342
|
| `onNavigate` | `(index: number) => void` | ❌ | Navigation callback |
|
|
323
343
|
| `customRenderers` | `CustomRenderer[]` | ❌ | Custom renderers for specific file types |
|
|
344
|
+
| `locale` | `Locale` | ❌ | UI language (`'zh-CN'` default, `'en-US'` built-in) |
|
|
345
|
+
| `messages` | `Partial<Record<Locale, Partial<Messages>>>` | ❌ | Custom translation overrides |
|
|
324
346
|
|
|
325
347
|
### FilePreviewEmbed Props
|
|
326
348
|
|
|
@@ -334,6 +356,8 @@ const files = [
|
|
|
334
356
|
| `height` | `number \| string` | ❌ | `'100%'` | Container height |
|
|
335
357
|
| `className` | `string` | ❌ | - | Extra class on the root wrapper |
|
|
336
358
|
| `style` | `CSSProperties` | ❌ | - | Extra inline style on the root wrapper |
|
|
359
|
+
| `locale` | `Locale` | ❌ | `'zh-CN'` | UI language (`'zh-CN'` or `'en-US'`) |
|
|
360
|
+
| `messages` | `Partial<Record<Locale, Partial<Messages>>>` | ❌ | - | Custom translation overrides |
|
|
337
361
|
|
|
338
362
|
> `FilePreviewEmbed` has no `isOpen` / `onClose`. To hide/show it, conditionally render it from the parent. It also hides the close button in the toolbar.
|
|
339
363
|
|
|
@@ -422,7 +446,48 @@ const files = [
|
|
|
422
446
|
#### Text Files
|
|
423
447
|
- **Markdown**: File extensions `.md` or `.markdown`
|
|
424
448
|
- **Code**: Auto-detected by file extension (`.js`, `.ts`, `.py`, `.java`, etc.)
|
|
425
|
-
- **
|
|
449
|
+
- **Config / Logs**: `.yaml`, `.yml`, `.toml`, `.ini`, `.conf`, `.env`, `.log`, `.diff`, `.patch`
|
|
450
|
+
- **Plain Text**: `text/plain`
|
|
451
|
+
|
|
452
|
+
#### Structured Data
|
|
453
|
+
- **JSON**: `application/json` (.json)
|
|
454
|
+
- **CSV / TSV**: `text/csv` (.csv), `text/tab-separated-values` (.tsv)
|
|
455
|
+
- **XML**: `application/xml`, `text/xml` (.xml)
|
|
456
|
+
|
|
457
|
+
#### Subtitles & Lyrics
|
|
458
|
+
- **SRT**: `application/x-subrip` (.srt)
|
|
459
|
+
- **WebVTT**: `text/vtt` (.vtt)
|
|
460
|
+
- **LRC**: (.lrc)
|
|
461
|
+
- **Enhanced LRC**: (.elrc)
|
|
462
|
+
- **ASS / SSA**: (.ass, .ssa)
|
|
463
|
+
- **TTML / DFXP**: `application/ttml+xml` (.ttml, .dfxp)
|
|
464
|
+
|
|
465
|
+
#### Archives
|
|
466
|
+
- **ZIP**: `application/zip`, `application/x-zip-compressed` (.zip)
|
|
467
|
+
|
|
468
|
+
#### Outlook Email
|
|
469
|
+
- **MSG**: `application/vnd.ms-outlook` (.msg)
|
|
470
|
+
|
|
471
|
+
#### E-books
|
|
472
|
+
- **EPUB**: `application/epub+zip` (.epub)
|
|
473
|
+
|
|
474
|
+
## 🌐 Internationalization (i18n)
|
|
475
|
+
|
|
476
|
+
Built-in support for Chinese (default) and English. Zero external dependencies.
|
|
477
|
+
|
|
478
|
+
```tsx
|
|
479
|
+
// Switch to English
|
|
480
|
+
<FilePreviewModal files={files} locale="en-US" ... />
|
|
481
|
+
|
|
482
|
+
// Override specific translations
|
|
483
|
+
<FilePreviewModal
|
|
484
|
+
files={files}
|
|
485
|
+
locale="en-US"
|
|
486
|
+
messages={{ 'en-US': { 'toolbar.zoom_in': 'Zoom ++' } }}
|
|
487
|
+
/>
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
Use `useTranslator()` hook in custom renderers to access the translation function.
|
|
426
491
|
|
|
427
492
|
## 🎨 Custom Styling
|
|
428
493
|
|
package/README.zh-CN.md
CHANGED
|
@@ -305,7 +305,27 @@ const files = [
|
|
|
305
305
|
### 代码 & 文本
|
|
306
306
|
- **Markdown**: GitHub Flavored Markdown,代码高亮
|
|
307
307
|
- **代码文件**: JS, TS, Python, Java, C++, Go, Rust 等 40+ 种语言
|
|
308
|
-
-
|
|
308
|
+
- **配置 / 日志**: YAML, TOML, INI, ENV, LOG, DIFF, PATCH 等
|
|
309
|
+
|
|
310
|
+
### 结构化数据
|
|
311
|
+
- **JSON**: 自动格式化 + 语法高亮
|
|
312
|
+
- **CSV / TSV**: 零依赖解析,表格视图 + 行列统计
|
|
313
|
+
- **XML**: `DOMParser` 校验 + 自动缩进 + 语法高亮
|
|
314
|
+
|
|
315
|
+
### 字幕 / 歌词
|
|
316
|
+
- **SRT / WebVTT**: 零依赖解析,结构化 cue 列表(索引、时间区间、文本)
|
|
317
|
+
- **LRC / Enhanced LRC**: 歌词文件,`[mm:ss.xx]` 行时间戳(ELRC 额外支持行内 `<mm:ss.xx>` 逐字时间戳),自动解析 `[ti:][ar:][al:]` 等元数据
|
|
318
|
+
- **ASS / SSA**: Advanced SubStation Alpha,提取 Dialogue 事件,自动剥离 `\N` `\h` 与 `{...}` 样式覆盖码,展示 Style 标签
|
|
319
|
+
- **TTML / DFXP**: W3C / Apple Music 使用的 XML 字幕,支持 `begin` / `end` / `dur` 与 `<br/>`
|
|
320
|
+
|
|
321
|
+
### 压缩包
|
|
322
|
+
- **ZIP**: 树形目录 + 内嵌预览文本/代码/图片,其他类型可下载导出
|
|
323
|
+
|
|
324
|
+
### Outlook 邮件
|
|
325
|
+
- **MSG**: 邮件头、正文、附件列表
|
|
326
|
+
|
|
327
|
+
### 电子书
|
|
328
|
+
- **EPUB**: 章节导航、翻页
|
|
309
329
|
|
|
310
330
|
## 🎮 API 参考
|
|
311
331
|
|
|
@@ -319,6 +339,8 @@ const files = [
|
|
|
319
339
|
| `onClose` | `() => void` | ✅ | 关闭回调 |
|
|
320
340
|
| `onNavigate` | `(index: number) => void` | ❌ | 导航回调 |
|
|
321
341
|
| `customRenderers` | `CustomRenderer[]` | ❌ | 自定义渲染器 |
|
|
342
|
+
| `locale` | `Locale` | ❌ | 界面语言(默认 `'zh-CN'`,内置 `'en-US'`) |
|
|
343
|
+
| `messages` | `Partial<Record<Locale, Partial<Messages>>>` | ❌ | 自定义翻译覆盖 |
|
|
322
344
|
|
|
323
345
|
### FilePreviewEmbed Props
|
|
324
346
|
|
|
@@ -332,6 +354,8 @@ const files = [
|
|
|
332
354
|
| `height` | `number \| string` | ❌ | `'100%'` | 容器高度 |
|
|
333
355
|
| `className` | `string` | ❌ | - | 根节点额外 className |
|
|
334
356
|
| `style` | `CSSProperties` | ❌ | - | 根节点额外内联样式 |
|
|
357
|
+
| `locale` | `Locale` | ❌ | `'zh-CN'` | 界面语言(`'zh-CN'` 或 `'en-US'`) |
|
|
358
|
+
| `messages` | `Partial<Record<Locale, Partial<Messages>>>` | ❌ | - | 自定义翻译覆盖 |
|
|
335
359
|
|
|
336
360
|
> `FilePreviewEmbed` 没有 `isOpen` / `onClose`,若要显示/隐藏,请在父组件中条件渲染。同时它不会显示工具栏上的关闭按钮。
|
|
337
361
|
|
|
@@ -420,7 +444,48 @@ const files = [
|
|
|
420
444
|
#### 文本文件
|
|
421
445
|
- **Markdown**: 文件扩展名 `.md` 或 `.markdown`
|
|
422
446
|
- **代码**: 根据文件扩展名自动识别 (`.js`, `.ts`, `.py`, `.java`, 等)
|
|
423
|
-
-
|
|
447
|
+
- **配置 / 日志**: `.yaml`, `.yml`, `.toml`, `.ini`, `.conf`, `.env`, `.log`, `.diff`, `.patch`
|
|
448
|
+
- **纯文本**: `text/plain`
|
|
449
|
+
|
|
450
|
+
#### 结构化数据
|
|
451
|
+
- **JSON**: `application/json` (.json)
|
|
452
|
+
- **CSV / TSV**: `text/csv` (.csv), `text/tab-separated-values` (.tsv)
|
|
453
|
+
- **XML**: `application/xml`, `text/xml` (.xml)
|
|
454
|
+
|
|
455
|
+
#### 字幕 / 歌词
|
|
456
|
+
- **SRT**: `application/x-subrip` (.srt)
|
|
457
|
+
- **WebVTT**: `text/vtt` (.vtt)
|
|
458
|
+
- **LRC**: (.lrc)
|
|
459
|
+
- **Enhanced LRC**: (.elrc)
|
|
460
|
+
- **ASS / SSA**: (.ass, .ssa)
|
|
461
|
+
- **TTML / DFXP**: `application/ttml+xml` (.ttml, .dfxp)
|
|
462
|
+
|
|
463
|
+
#### 压缩包
|
|
464
|
+
- **ZIP**: `application/zip`, `application/x-zip-compressed` (.zip)
|
|
465
|
+
|
|
466
|
+
#### Outlook 邮件
|
|
467
|
+
- **MSG**: `application/vnd.ms-outlook` (.msg)
|
|
468
|
+
|
|
469
|
+
#### 电子书
|
|
470
|
+
- **EPUB**: `application/epub+zip` (.epub)
|
|
471
|
+
|
|
472
|
+
## 🌐 国际化(i18n)
|
|
473
|
+
|
|
474
|
+
内置中文(默认)和英文,零外部依赖。
|
|
475
|
+
|
|
476
|
+
```tsx
|
|
477
|
+
// 切换为英文
|
|
478
|
+
<FilePreviewModal files={files} locale="en-US" ... />
|
|
479
|
+
|
|
480
|
+
// 自定义覆盖某些翻译
|
|
481
|
+
<FilePreviewModal
|
|
482
|
+
files={files}
|
|
483
|
+
locale="en-US"
|
|
484
|
+
messages={{ 'en-US': { 'toolbar.zoom_in': 'Zoom ++' } }}
|
|
485
|
+
/>
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
在自定义渲染器中可通过 `useTranslator()` hook 获取翻译函数。
|
|
424
489
|
|
|
425
490
|
## 🎨 自定义样式
|
|
426
491
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type Locale, type Messages } from '@eternalheart/file-preview-core';
|
|
2
3
|
import { PreviewFileInput, CustomRenderer } from './types';
|
|
3
4
|
export interface FilePreviewContentProps {
|
|
4
5
|
files: PreviewFileInput[];
|
|
@@ -9,6 +10,12 @@ export interface FilePreviewContentProps {
|
|
|
9
10
|
mode?: 'modal' | 'embed';
|
|
10
11
|
/** 关闭回调,仅 modal 模式使用 */
|
|
11
12
|
onClose?: () => void;
|
|
13
|
+
/** ZIP 嵌套深度(内部使用),超过上限时不再递归渲染 ZIP */
|
|
14
|
+
zipNestingDepth?: number;
|
|
15
|
+
/** 国际化语言,默认 'zh-CN' */
|
|
16
|
+
locale?: Locale;
|
|
17
|
+
/** 用户自定义翻译字典,浅合并到内置字典之上 */
|
|
18
|
+
messages?: Partial<Record<Locale, Partial<Messages>>>;
|
|
12
19
|
}
|
|
13
20
|
export declare const FilePreviewContent: React.FC<FilePreviewContentProps>;
|
|
14
21
|
//# sourceMappingURL=FilePreviewContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePreviewContent.d.ts","sourceRoot":"","sources":["../src/FilePreviewContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FilePreviewContent.d.ts","sourceRoot":"","sources":["../src/FilePreviewContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAGjF,OAAO,EAAiC,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAmB,MAAM,iCAAiC,CAAC;AAU7H,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAyB3D,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,iCAAiC;IACjC,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACzB,wBAAwB;IACxB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,qCAAqC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uBAAuB;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;CACvD;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAqehE,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PreviewFileInput, CustomRenderer } from './types';
|
|
2
|
+
import type { Locale, Messages } from '@eternalheart/file-preview-core';
|
|
2
3
|
interface FilePreviewEmbedProps {
|
|
3
4
|
files: PreviewFileInput[];
|
|
4
5
|
currentIndex?: number;
|
|
@@ -10,6 +11,10 @@ interface FilePreviewEmbedProps {
|
|
|
10
11
|
height?: number | string;
|
|
11
12
|
className?: string;
|
|
12
13
|
style?: React.CSSProperties;
|
|
14
|
+
/** 国际化语言,默认 'zh-CN' */
|
|
15
|
+
locale?: Locale;
|
|
16
|
+
/** 用户自定义翻译字典 */
|
|
17
|
+
messages?: Partial<Record<Locale, Partial<Messages>>>;
|
|
13
18
|
}
|
|
14
19
|
export declare const FilePreviewEmbed: React.FC<FilePreviewEmbedProps>;
|
|
15
20
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePreviewEmbed.d.ts","sourceRoot":"","sources":["../src/FilePreviewEmbed.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"FilePreviewEmbed.d.ts","sourceRoot":"","sources":["../src/FilePreviewEmbed.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE3D,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAExE,UAAU,qBAAqB;IAC7B,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,uBAAuB;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,uBAAuB;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,uBAAuB;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;CACvD;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA8B5D,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PreviewFileInput, CustomRenderer } from './types';
|
|
2
|
+
import type { Locale, Messages } from '@eternalheart/file-preview-core';
|
|
2
3
|
interface FilePreviewModalProps {
|
|
3
4
|
files: PreviewFileInput[];
|
|
4
5
|
currentIndex: number;
|
|
@@ -6,6 +7,10 @@ interface FilePreviewModalProps {
|
|
|
6
7
|
onClose: () => void;
|
|
7
8
|
onNavigate?: (index: number) => void;
|
|
8
9
|
customRenderers?: CustomRenderer[];
|
|
10
|
+
/** 国际化语言,默认 'zh-CN' */
|
|
11
|
+
locale?: Locale;
|
|
12
|
+
/** 用户自定义翻译字典 */
|
|
13
|
+
messages?: Partial<Record<Locale, Partial<Messages>>>;
|
|
9
14
|
}
|
|
10
15
|
export declare const FilePreviewModal: React.FC<FilePreviewModalProps>;
|
|
11
16
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePreviewModal.d.ts","sourceRoot":"","sources":["../src/FilePreviewModal.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"FilePreviewModal.d.ts","sourceRoot":"","sources":["../src/FilePreviewModal.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE3D,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAExE,UAAU,qBAAqB;IAC7B,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,uBAAuB;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;CACvD;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAkE5D,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ResizableSplitProps {
|
|
3
|
+
/** 左侧内容 */
|
|
4
|
+
left: React.ReactNode;
|
|
5
|
+
/** 右侧内容 */
|
|
6
|
+
right: React.ReactNode;
|
|
7
|
+
/** 左侧初始宽度(px);传入 storageKey 时会从 localStorage 读取 */
|
|
8
|
+
initialLeftWidth?: number;
|
|
9
|
+
/** 左侧最小宽度(px) */
|
|
10
|
+
minLeftWidth?: number;
|
|
11
|
+
/** 左侧最大宽度(px),同时不超过 `容器宽 - minRightWidth - 分隔线宽` */
|
|
12
|
+
maxLeftWidth?: number;
|
|
13
|
+
/** 右侧至少保留的宽度(px) */
|
|
14
|
+
minRightWidth?: number;
|
|
15
|
+
/** localStorage 持久化 key;不传则不持久化 */
|
|
16
|
+
storageKey?: string;
|
|
17
|
+
/** 启用横向拖动的媒体查询,默认 `(min-width: 768px)` */
|
|
18
|
+
desktopMedia?: string;
|
|
19
|
+
/** 容器额外类名 */
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 通用可拖动分隔布局:
|
|
24
|
+
* - 桌面端(由 `desktopMedia` 判定)横向分两栏,中间分隔线可左右拖动调整左栏宽度
|
|
25
|
+
* - 移动端退化为上下堆叠,不显示分隔线
|
|
26
|
+
* - 可选 `storageKey` 将宽度持久化到 localStorage
|
|
27
|
+
*/
|
|
28
|
+
export declare const ResizableSplit: React.FC<ResizableSplitProps>;
|
|
29
|
+
//# sourceMappingURL=ResizableSplit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResizableSplit.d.ts","sourceRoot":"","sources":["../../src/components/ResizableSplit.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAExE,MAAM,WAAW,mBAAmB;IAClC,WAAW;IACX,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,WAAW;IACX,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,mDAAmD;IACnD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAoGxD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type Locale, type Messages, type Translator } from '@eternalheart/file-preview-core';
|
|
3
|
+
export interface LocaleContextValue {
|
|
4
|
+
locale: Locale;
|
|
5
|
+
t: Translator;
|
|
6
|
+
}
|
|
7
|
+
export interface LocaleProviderProps {
|
|
8
|
+
/** 当前语言,默认 'zh-CN' */
|
|
9
|
+
locale?: Locale;
|
|
10
|
+
/** 用户自定义字典,浅合并到内置字典之上 */
|
|
11
|
+
messages?: Partial<Record<Locale, Partial<Messages>>>;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare const LocaleProvider: React.FC<LocaleProviderProps>;
|
|
15
|
+
/**
|
|
16
|
+
* 获取翻译函数。任意位置调用都安全:
|
|
17
|
+
* - 在 LocaleProvider 下 → 用 provider 提供的 translator
|
|
18
|
+
* - 否则 → 回落到 zh-CN 兜底 translator
|
|
19
|
+
*/
|
|
20
|
+
export declare function useTranslator(): Translator;
|
|
21
|
+
/**
|
|
22
|
+
* 获取当前 locale。在 Provider 之外返回 'zh-CN'。
|
|
23
|
+
*/
|
|
24
|
+
export declare function useLocale(): Locale;
|
|
25
|
+
//# sourceMappingURL=LocaleContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocaleContext.d.ts","sourceRoot":"","sources":["../../src/i18n/LocaleContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,UAAU,EAChB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,UAAU,CAAC;CACf;AAID,MAAM,WAAW,mBAAmB;IAClC,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAWxD,CAAC;AAcF;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAG1C;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAGlC"}
|