@eternalheart/react-file-preview 1.4.0 → 1.5.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.
- package/README.md +437 -60
- package/README.zh-CN.md +437 -60
- package/lib/FilePreviewContent.d.ts +1 -0
- package/lib/FilePreviewContent.d.ts.map +1 -1
- package/lib/FilePreviewEmbed.d.ts +2 -0
- package/lib/FilePreviewEmbed.d.ts.map +1 -1
- package/lib/FilePreviewModal.d.ts +2 -0
- package/lib/FilePreviewModal.d.ts.map +1 -1
- package/lib/chunks/index-2sX2d4iv.mjs +291 -0
- package/lib/chunks/index-2sX2d4iv.mjs.map +1 -0
- package/lib/chunks/index-Bdj8_B80.mjs +120 -0
- package/lib/chunks/index-Bdj8_B80.mjs.map +1 -0
- package/lib/chunks/index-CCcZzLUM.mjs +107 -0
- package/lib/chunks/index-CCcZzLUM.mjs.map +1 -0
- package/lib/chunks/{index-CzM2mxrD.mjs → index-CKdQL1Bk.mjs} +130 -128
- package/lib/chunks/{index-CzM2mxrD.mjs.map → index-CKdQL1Bk.mjs.map} +1 -1
- package/lib/chunks/index-CQYrhe7Z.mjs +275 -0
- package/lib/chunks/index-CQYrhe7Z.mjs.map +1 -0
- package/lib/chunks/{index-DuP0Tlpo.mjs → index-CRZqNMQ7.mjs} +43 -41
- package/lib/chunks/index-CRZqNMQ7.mjs.map +1 -0
- package/lib/chunks/{index-Cp68OevR.mjs → index-CTghYlSh.mjs} +1299 -1297
- package/lib/chunks/{index-Cp68OevR.mjs.map → index-CTghYlSh.mjs.map} +1 -1
- package/lib/chunks/index-CuTz7dbd.mjs +313 -0
- package/lib/chunks/index-CuTz7dbd.mjs.map +1 -0
- package/lib/chunks/index-CuWzRQZw.mjs +116 -0
- package/lib/chunks/index-CuWzRQZw.mjs.map +1 -0
- package/lib/chunks/index-Cz23v-TW.mjs +2409 -0
- package/lib/chunks/index-Cz23v-TW.mjs.map +1 -0
- package/lib/chunks/{index-kALp0tqz.mjs → index-D-Is8qvU.mjs} +22 -20
- package/lib/chunks/index-D-Is8qvU.mjs.map +1 -0
- package/lib/chunks/index-Da3FN2-3.mjs +359 -0
- package/lib/chunks/index-Da3FN2-3.mjs.map +1 -0
- package/lib/chunks/index-Dc6q1OKl.mjs +78 -0
- package/lib/chunks/index-Dc6q1OKl.mjs.map +1 -0
- package/lib/chunks/{index-10O8tfTH.mjs → index-DoGKcq9y.mjs} +194 -192
- package/lib/chunks/index-DoGKcq9y.mjs.map +1 -0
- package/lib/chunks/{index-C_BJatqr.mjs → index-DzCLf1Db.mjs} +42 -40
- package/lib/chunks/index-DzCLf1Db.mjs.map +1 -0
- package/lib/chunks/index-FomaQSaL.mjs +329 -0
- package/lib/chunks/index-FomaQSaL.mjs.map +1 -0
- package/lib/chunks/{index-DaAXRBWL.mjs → index-OXjOFggq.mjs} +864 -862
- package/lib/chunks/{index-DaAXRBWL.mjs.map → index-OXjOFggq.mjs.map} +1 -1
- package/lib/chunks/index-WLepq2g2.mjs +200 -0
- package/lib/chunks/index-WLepq2g2.mjs.map +1 -0
- package/lib/chunks/{index-DoFsoBKL.mjs → index-_B5marES.mjs} +27 -25
- package/lib/chunks/index-_B5marES.mjs.map +1 -0
- package/lib/chunks/useShikiHighlight-Bbs8Fbqs.mjs +36 -0
- package/lib/chunks/useShikiHighlight-Bbs8Fbqs.mjs.map +1 -0
- package/lib/components/preview/FilePreviewToolbar.d.ts +1 -0
- package/lib/components/preview/FilePreviewToolbar.d.ts.map +1 -1
- package/lib/components/preview/ToolbarButton.d.ts +3 -1
- package/lib/components/preview/ToolbarButton.d.ts.map +1 -1
- package/lib/hooks/index.d.ts +0 -6
- package/lib/hooks/index.d.ts.map +1 -1
- package/lib/hooks/useShikiHighlight.d.ts +3 -1
- package/lib/hooks/useShikiHighlight.d.ts.map +1 -1
- package/lib/index.cjs +32 -30
- package/lib/index.cjs.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.mjs +1 -1
- package/lib/renderers/Audio/index.d.ts +2 -1
- package/lib/renderers/Audio/index.d.ts.map +1 -1
- package/lib/renderers/Csv/index.d.ts +2 -1
- package/lib/renderers/Csv/index.d.ts.map +1 -1
- package/lib/renderers/Docx/index.d.ts +2 -1
- package/lib/renderers/Docx/index.d.ts.map +1 -1
- package/lib/renderers/Epub/index.d.ts +2 -3
- package/lib/renderers/Epub/index.d.ts.map +1 -1
- package/lib/renderers/Font/index.d.ts +2 -1
- package/lib/renderers/Font/index.d.ts.map +1 -1
- package/lib/renderers/Image/index.d.ts +6 -7
- package/lib/renderers/Image/index.d.ts.map +1 -1
- package/lib/renderers/Json/index.d.ts +2 -1
- package/lib/renderers/Json/index.d.ts.map +1 -1
- package/lib/renderers/Markdown/index.d.ts +2 -2
- package/lib/renderers/Markdown/index.d.ts.map +1 -1
- package/lib/renderers/Mobi/index.d.ts +2 -3
- package/lib/renderers/Mobi/index.d.ts.map +1 -1
- package/lib/renderers/Msg/index.d.ts +2 -1
- package/lib/renderers/Msg/index.d.ts.map +1 -1
- package/lib/renderers/Pdf/index.d.ts +4 -8
- package/lib/renderers/Pdf/index.d.ts.map +1 -1
- package/lib/renderers/Pptx/index.d.ts +2 -1
- package/lib/renderers/Pptx/index.d.ts.map +1 -1
- package/lib/renderers/Subtitle/index.d.ts +2 -1
- package/lib/renderers/Subtitle/index.d.ts.map +1 -1
- package/lib/renderers/Text/index.d.ts +2 -3
- package/lib/renderers/Text/index.d.ts.map +1 -1
- package/lib/renderers/Video/index.d.ts +2 -1
- package/lib/renderers/Video/index.d.ts.map +1 -1
- package/lib/renderers/Xlsx/index.d.ts +2 -1
- package/lib/renderers/Xlsx/index.d.ts.map +1 -1
- package/lib/renderers/Xml/index.d.ts +2 -1
- package/lib/renderers/Xml/index.d.ts.map +1 -1
- package/lib/renderers/Zip/index.d.ts +7 -2
- package/lib/renderers/Zip/index.d.ts.map +1 -1
- package/lib/renderers/base.types.d.ts +38 -0
- package/lib/renderers/base.types.d.ts.map +1 -0
- package/lib/renderers/registry.d.ts +36 -0
- package/lib/renderers/registry.d.ts.map +1 -0
- package/lib/renderers/toolbar.types.d.ts +2 -0
- package/lib/renderers/toolbar.types.d.ts.map +1 -1
- package/lib/toolbar/renderItems.d.ts.map +1 -1
- package/package.json +3 -3
- package/lib/chunks/index-0v5STX5f.mjs +0 -105
- package/lib/chunks/index-0v5STX5f.mjs.map +0 -1
- package/lib/chunks/index-10O8tfTH.mjs.map +0 -1
- package/lib/chunks/index-BCyv1HM9.mjs +0 -175
- package/lib/chunks/index-BCyv1HM9.mjs.map +0 -1
- package/lib/chunks/index-Bo90aGhy.mjs +0 -114
- package/lib/chunks/index-Bo90aGhy.mjs.map +0 -1
- package/lib/chunks/index-CEeKt7L3.mjs +0 -2808
- package/lib/chunks/index-CEeKt7L3.mjs.map +0 -1
- package/lib/chunks/index-CWKbnvW6.mjs +0 -270
- package/lib/chunks/index-CWKbnvW6.mjs.map +0 -1
- package/lib/chunks/index-C_BJatqr.mjs.map +0 -1
- package/lib/chunks/index-Cbz5Z6ZK.mjs +0 -263
- package/lib/chunks/index-Cbz5Z6ZK.mjs.map +0 -1
- package/lib/chunks/index-DTYBFuAH.mjs +0 -357
- package/lib/chunks/index-DTYBFuAH.mjs.map +0 -1
- package/lib/chunks/index-DoFsoBKL.mjs.map +0 -1
- package/lib/chunks/index-DuP0Tlpo.mjs.map +0 -1
- package/lib/chunks/index-Dv3RQz86.mjs +0 -270
- package/lib/chunks/index-Dv3RQz86.mjs.map +0 -1
- package/lib/chunks/index-QfpHck8N.mjs +0 -55
- package/lib/chunks/index-QfpHck8N.mjs.map +0 -1
- package/lib/chunks/index-gjSQeou7.mjs +0 -194
- package/lib/chunks/index-gjSQeou7.mjs.map +0 -1
- package/lib/chunks/index-kALp0tqz.mjs.map +0 -1
- package/lib/chunks/index-kCeSnFs-.mjs +0 -54
- package/lib/chunks/index-kCeSnFs-.mjs.map +0 -1
- package/lib/chunks/useShikiHighlight-BA9qgdGA.mjs +0 -23
- package/lib/chunks/useShikiHighlight-BA9qgdGA.mjs.map +0 -1
- package/lib/hooks/rendererReducer.d.ts +0 -10
- package/lib/hooks/rendererReducer.d.ts.map +0 -1
- package/lib/hooks/types.d.ts +0 -152
- package/lib/hooks/types.d.ts.map +0 -1
- package/lib/hooks/useBookRenderer.d.ts +0 -14
- package/lib/hooks/useBookRenderer.d.ts.map +0 -1
- package/lib/hooks/useFilePreviewState.d.ts +0 -10
- package/lib/hooks/useFilePreviewState.d.ts.map +0 -1
- package/lib/hooks/useImageAutoFit.d.ts +0 -13
- package/lib/hooks/useImageAutoFit.d.ts.map +0 -1
- package/lib/hooks/useToolbarConfig.d.ts +0 -25
- package/lib/hooks/useToolbarConfig.d.ts.map +0 -1
- package/lib/renderers/Epub/toolbar.d.ts +0 -13
- package/lib/renderers/Epub/toolbar.d.ts.map +0 -1
- package/lib/renderers/Image/toolbar.d.ts +0 -15
- package/lib/renderers/Image/toolbar.d.ts.map +0 -1
- package/lib/renderers/Markdown/toolbar.d.ts +0 -9
- package/lib/renderers/Markdown/toolbar.d.ts.map +0 -1
- package/lib/renderers/Mobi/toolbar.d.ts +0 -13
- package/lib/renderers/Mobi/toolbar.d.ts.map +0 -1
- package/lib/renderers/Pdf/toolbar.d.ts +0 -16
- package/lib/renderers/Pdf/toolbar.d.ts.map +0 -1
- package/lib/renderers/Text/toolbar.d.ts +0 -12
- package/lib/renderers/Text/toolbar.d.ts.map +0 -1
- package/lib/renderers/Zip/toolbar.d.ts +0 -13
- package/lib/renderers/Zip/toolbar.d.ts.map +0 -1
- package/lib/toolbar/registry.d.ts +0 -51
- package/lib/toolbar/registry.d.ts.map +0 -1
package/lib/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as r, e as i, f as o, L as l, v as P, V as d, g as f,
|
|
1
|
+
import { d as r, e as i, f as o, L as l, v as P, V as d, g as f, W as m, w as n, h as t, u as F } from "./chunks/index-Cz23v-TW.mjs";
|
|
2
2
|
import * as e from "pdfjs-dist/build/pdf.mjs";
|
|
3
3
|
export {
|
|
4
4
|
r as FilePreviewContent,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { RendererHandle } from '../base.types';
|
|
1
2
|
interface AudioRendererProps {
|
|
2
3
|
url: string;
|
|
3
4
|
fileName: string;
|
|
4
5
|
}
|
|
5
|
-
export declare const AudioRenderer:
|
|
6
|
+
export declare const AudioRenderer: import("react").ForwardRefExoticComponent<AudioRendererProps & import("react").RefAttributes<RendererHandle>>;
|
|
6
7
|
export {};
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Audio/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Audio/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAgJpD,UAAU,kBAAkB;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,aAAa,+GAuVxB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import 'x-data-spreadsheet/dist/xspreadsheet.css';
|
|
2
|
+
import type { RendererHandle } from '../base.types';
|
|
2
3
|
interface CsvRendererProps {
|
|
3
4
|
url: string;
|
|
4
5
|
fileName: string;
|
|
5
6
|
}
|
|
6
|
-
export declare const CsvRenderer:
|
|
7
|
+
export declare const CsvRenderer: import("react").ForwardRefExoticComponent<CsvRendererProps & import("react").RefAttributes<RendererHandle>>;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Csv/index.tsx"],"names":[],"mappings":"AAEA,OAAO,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Csv/index.tsx"],"names":[],"mappings":"AAEA,OAAO,0CAA0C,CAAC;AAUlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,WAAW,6GAsLtB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { RendererHandle } from '../base.types';
|
|
1
2
|
interface DocxRendererProps {
|
|
2
3
|
url: string;
|
|
3
4
|
}
|
|
4
|
-
export declare const DocxRenderer:
|
|
5
|
+
export declare const DocxRenderer: import("react").ForwardRefExoticComponent<DocxRendererProps & import("react").RefAttributes<RendererHandle>>;
|
|
5
6
|
export {};
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Docx/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Docx/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,UAAU,iBAAiB;IACzB,GAAG,EAAE,MAAM,CAAC;CACb;AAeD,eAAO,MAAM,YAAY,8GA4IvB,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { RendererHandle } from '../base.types';
|
|
1
2
|
export interface TocItem {
|
|
2
3
|
label: string;
|
|
3
4
|
href: string;
|
|
4
5
|
subitems?: TocItem[];
|
|
5
6
|
}
|
|
6
|
-
export interface EpubRendererHandle {
|
|
7
|
+
export interface EpubRendererHandle extends RendererHandle {
|
|
7
8
|
prevPage: () => void;
|
|
8
9
|
nextPage: () => void;
|
|
9
10
|
toggleFullWidth: () => void;
|
|
@@ -11,8 +12,6 @@ export interface EpubRendererHandle {
|
|
|
11
12
|
}
|
|
12
13
|
interface EpubRendererProps {
|
|
13
14
|
url: string;
|
|
14
|
-
onChapterChange?: (current: number, total: number) => void;
|
|
15
|
-
onFullWidthChange?: (isFullWidth: boolean) => void;
|
|
16
15
|
}
|
|
17
16
|
export declare const EpubRenderer: import("react").ForwardRefExoticComponent<EpubRendererProps & import("react").RefAttributes<EpubRendererHandle>>;
|
|
18
17
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Epub/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Epub/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAkBpD,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,UAAU,iBAAiB;IACzB,GAAG,EAAE,MAAM,CAAC;CACb;AA8BD,eAAO,MAAM,YAAY,kHA8bxB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { RendererHandle } from '../base.types';
|
|
2
3
|
export interface FontRendererProps {
|
|
3
4
|
url: string;
|
|
4
5
|
}
|
|
5
|
-
export declare const FontRenderer: React.
|
|
6
|
+
export declare const FontRenderer: React.ForwardRefExoticComponent<FontRendererProps & React.RefAttributes<RendererHandle>>;
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Font/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Font/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoF,MAAM,OAAO,CAAC;AAOzG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAqBpD,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;CACb;AAyBD,eAAO,MAAM,YAAY,0FA8SvB,CAAC"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { PreviewFile } from '@eternalheart/file-preview-core';
|
|
2
|
+
import type { RendererHandle } from '../base.types';
|
|
3
|
+
export interface ImageRendererHandle extends RendererHandle {
|
|
4
|
+
fitToWidth: () => void;
|
|
5
|
+
resetView: () => void;
|
|
6
|
+
}
|
|
2
7
|
interface ImageRendererProps {
|
|
3
8
|
url: string;
|
|
4
|
-
zoom: number;
|
|
5
|
-
rotation: number;
|
|
6
|
-
resetKey?: number;
|
|
7
9
|
fileSize?: number;
|
|
8
10
|
file?: PreviewFile | File;
|
|
9
|
-
onZoomChange?: (zoom: number) => void;
|
|
10
|
-
onNaturalWidthChange?: (width: number) => void;
|
|
11
|
-
onNaturalHeightChange?: (height: number) => void;
|
|
12
11
|
}
|
|
13
|
-
export declare const ImageRenderer:
|
|
12
|
+
export declare const ImageRenderer: import("react").ForwardRefExoticComponent<ImageRendererProps & import("react").RefAttributes<ImageRendererHandle>>;
|
|
14
13
|
export {};
|
|
15
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Image/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Image/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAoBpD,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,UAAU,kBAAkB;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC3B;AAED,eAAO,MAAM,aAAa,oHAqlBxB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { RendererHandle } from '../base.types';
|
|
1
2
|
interface JsonRendererProps {
|
|
2
3
|
url: string;
|
|
3
4
|
fileName: string;
|
|
4
5
|
}
|
|
5
|
-
export declare const JsonRenderer:
|
|
6
|
+
export declare const JsonRenderer: import("react").ForwardRefExoticComponent<JsonRendererProps & import("react").RefAttributes<RendererHandle>>;
|
|
6
7
|
export {};
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Json/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Json/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,UAAU,iBAAiB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAwJD,eAAO,MAAM,YAAY,8GAoDvB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { RendererHandle } from '../base.types';
|
|
1
2
|
import 'katex/dist/katex.min.css';
|
|
2
3
|
interface MarkdownRendererProps {
|
|
3
4
|
url: string;
|
|
4
|
-
viewMode?: 'preview' | 'source';
|
|
5
5
|
}
|
|
6
|
-
export declare const MarkdownRenderer:
|
|
6
|
+
export declare const MarkdownRenderer: import("react").ForwardRefExoticComponent<MarkdownRendererProps & import("react").RefAttributes<RendererHandle>>;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Markdown/index.tsx"],"names":[],"mappings":"AAYA,OAAO,0BAA0B,CAAC;AAElC,UAAU,qBAAqB;IAC7B,GAAG,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Markdown/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,0BAA0B,CAAC;AAElC,UAAU,qBAAqB;IAC7B,GAAG,EAAE,MAAM,CAAC;CACb;AA6ED,eAAO,MAAM,gBAAgB,kHAsP3B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import 'foliate-js/view.js';
|
|
2
|
-
|
|
2
|
+
import type { RendererHandle } from '../base.types';
|
|
3
|
+
export interface MobiRendererHandle extends RendererHandle {
|
|
3
4
|
prevPage: () => void;
|
|
4
5
|
nextPage: () => void;
|
|
5
6
|
toggleFullWidth: () => void;
|
|
@@ -7,8 +8,6 @@ export interface MobiRendererHandle {
|
|
|
7
8
|
}
|
|
8
9
|
interface MobiRendererProps {
|
|
9
10
|
url: string;
|
|
10
|
-
onChapterChange?: (current: number, total: number) => void;
|
|
11
|
-
onFullWidthChange?: (isFullWidth: boolean) => void;
|
|
12
11
|
}
|
|
13
12
|
export declare const MobiRenderer: import("react").ForwardRefExoticComponent<MobiRendererProps & import("react").RefAttributes<MobiRendererHandle>>;
|
|
14
13
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Mobi/index.tsx"],"names":[],"mappings":"AASA,OAAO,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Mobi/index.tsx"],"names":[],"mappings":"AASA,OAAO,oBAAoB,CAAC;AAK5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AA6BpD,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,UAAU,iBAAiB;IACzB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,YAAY,kHAuZxB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { RendererHandle } from '../base.types';
|
|
1
2
|
interface MsgRendererProps {
|
|
2
3
|
url: string;
|
|
3
4
|
}
|
|
4
|
-
export declare const MsgRenderer:
|
|
5
|
+
export declare const MsgRenderer: import("react").ForwardRefExoticComponent<MsgRendererProps & import("react").RefAttributes<RendererHandle>>;
|
|
5
6
|
export {};
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Msg/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Msg/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,CAAC;CACb;AAoGD,eAAO,MAAM,WAAW,6GAiStB,CAAC"}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
+
import type { RendererHandle } from '../base.types';
|
|
2
|
+
export interface PdfRendererHandle extends RendererHandle {
|
|
3
|
+
}
|
|
1
4
|
interface PdfRendererProps {
|
|
2
5
|
url: string;
|
|
3
|
-
zoom: number;
|
|
4
|
-
currentPage: number;
|
|
5
|
-
showOutline?: boolean;
|
|
6
|
-
onPageChange: (page: number) => void;
|
|
7
|
-
onTotalPagesChange: (total: number) => void;
|
|
8
|
-
onPageWidthChange?: (width: number) => void;
|
|
9
|
-
onToggleOutline?: () => void;
|
|
10
6
|
}
|
|
11
|
-
export declare const PdfRenderer:
|
|
7
|
+
export declare const PdfRenderer: import("react").ForwardRefExoticComponent<PdfRendererProps & import("react").RefAttributes<PdfRendererHandle>>;
|
|
12
8
|
export {};
|
|
13
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Pdf/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Pdf/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAiCpD,MAAM,WAAW,iBAAkB,SAAQ,cAAc;CAExD;AAED,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,WAAW,gHAmlBtB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { RendererHandle } from '../base.types';
|
|
1
2
|
interface PptxRendererProps {
|
|
2
3
|
url: string;
|
|
3
4
|
/** 是否平铺展示所有页面,默认 true */
|
|
4
5
|
tiled?: boolean;
|
|
5
6
|
}
|
|
6
|
-
export declare const PptxRenderer:
|
|
7
|
+
export declare const PptxRenderer: import("react").ForwardRefExoticComponent<PptxRendererProps & import("react").RefAttributes<RendererHandle>>;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Pptx/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Pptx/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,UAAU,iBAAiB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,yBAAyB;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,YAAY,8GA8TvB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { RendererHandle } from '../base.types';
|
|
1
2
|
interface SubtitleRendererProps {
|
|
2
3
|
url: string;
|
|
3
4
|
fileName: string;
|
|
4
5
|
}
|
|
5
|
-
export declare const SubtitleRenderer:
|
|
6
|
+
export declare const SubtitleRenderer: import("react").ForwardRefExoticComponent<SubtitleRendererProps & import("react").RefAttributes<RendererHandle>>;
|
|
6
7
|
export {};
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Subtitle/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Subtitle/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,UAAU,qBAAqB;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAkBD,eAAO,MAAM,gBAAgB,kHAsI3B,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import type { RendererHandle } from '../base.types';
|
|
1
2
|
interface TextRendererProps {
|
|
2
3
|
url: string;
|
|
3
4
|
fileName: string;
|
|
4
|
-
wordWrap?: boolean;
|
|
5
|
-
htmlPreview?: boolean;
|
|
6
5
|
}
|
|
7
|
-
export declare const TextRenderer:
|
|
6
|
+
export declare const TextRenderer: import("react").ForwardRefExoticComponent<TextRendererProps & import("react").RefAttributes<RendererHandle>>;
|
|
8
7
|
export {};
|
|
9
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Text/index.tsx"],"names":[],"mappings":"AAOA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Text/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,UAAU,iBAAiB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,YAAY,8GA8KvB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import 'video.js/dist/video-js.css';
|
|
2
|
+
import type { RendererHandle } from '../base.types';
|
|
2
3
|
interface VideoRendererProps {
|
|
3
4
|
url: string;
|
|
4
5
|
fileName?: string;
|
|
5
6
|
}
|
|
6
|
-
export declare const VideoRenderer:
|
|
7
|
+
export declare const VideoRenderer: import("react").ForwardRefExoticComponent<VideoRendererProps & import("react").RefAttributes<RendererHandle>>;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Video/index.tsx"],"names":[],"mappings":"AAEA,OAAO,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Video/index.tsx"],"names":[],"mappings":"AAEA,OAAO,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD,UAAU,kBAAkB;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAmCD,eAAO,MAAM,aAAa,+GAyJxB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import 'x-data-spreadsheet/dist/xspreadsheet.css';
|
|
2
|
+
import type { RendererHandle } from '../base.types';
|
|
2
3
|
interface XlsxRendererProps {
|
|
3
4
|
url: string;
|
|
4
5
|
}
|
|
5
|
-
export declare const XlsxRenderer:
|
|
6
|
+
export declare const XlsxRenderer: import("react").ForwardRefExoticComponent<XlsxRendererProps & import("react").RefAttributes<RendererHandle>>;
|
|
6
7
|
export {};
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Xlsx/index.tsx"],"names":[],"mappings":"AAGA,OAAO,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Xlsx/index.tsx"],"names":[],"mappings":"AAGA,OAAO,0CAA0C,CAAC;AAKlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,UAAU,iBAAiB;IACzB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,YAAY,8GA2NvB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { RendererHandle } from '../base.types';
|
|
1
2
|
interface XmlRendererProps {
|
|
2
3
|
url: string;
|
|
3
4
|
fileName: string;
|
|
4
5
|
}
|
|
5
|
-
export declare const XmlRenderer:
|
|
6
|
+
export declare const XmlRenderer: import("react").ForwardRefExoticComponent<XmlRendererProps & import("react").RefAttributes<RendererHandle>>;
|
|
6
7
|
export {};
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Xml/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Xml/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AA2CD,eAAO,MAAM,WAAW,6GA6EtB,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RendererHandle } from '../base.types';
|
|
3
|
+
export interface ZipToolbarStats {
|
|
4
|
+
files: number;
|
|
5
|
+
dirs: number;
|
|
6
|
+
size: number;
|
|
7
|
+
}
|
|
3
8
|
interface ZipRendererProps {
|
|
4
9
|
url: string;
|
|
5
10
|
/** ZIP 嵌套深度(由 FilePreviewContent 传入) */
|
|
@@ -7,6 +12,6 @@ interface ZipRendererProps {
|
|
|
7
12
|
/** 解析完成后向外回报统计信息(files / dirs / size),供工具栏展示 */
|
|
8
13
|
onStatsChange?: (stats: ZipToolbarStats | null) => void;
|
|
9
14
|
}
|
|
10
|
-
export declare const ZipRenderer: React.
|
|
15
|
+
export declare const ZipRenderer: React.ForwardRefExoticComponent<ZipRendererProps & React.RefAttributes<RendererHandle>>;
|
|
11
16
|
export {};
|
|
12
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Zip/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/Zip/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAgBpD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAOD,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,CAAC;CACzD;AA4HD,eAAO,MAAM,WAAW,yFAwPtB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ToolbarGroup } from './toolbar.types';
|
|
2
|
+
/**
|
|
3
|
+
* 渲染器统一接口
|
|
4
|
+
*
|
|
5
|
+
* 所有渲染器都应通过 forwardRef 暴露此接口,使主组件能够:
|
|
6
|
+
* 1. 获取工具栏配置(必需)
|
|
7
|
+
* 2. 订阅工具栏状态变化(可选,用于实时更新)
|
|
8
|
+
*/
|
|
9
|
+
export interface RendererHandle {
|
|
10
|
+
/**
|
|
11
|
+
* 获取当前工具栏配置
|
|
12
|
+
*
|
|
13
|
+
* @returns 工具栏按钮组配置数组
|
|
14
|
+
*/
|
|
15
|
+
getToolbarGroups: () => ToolbarGroup[];
|
|
16
|
+
/**
|
|
17
|
+
* 订阅工具栏状态变化事件(可选)
|
|
18
|
+
*
|
|
19
|
+
* 当渲染器内部状态变化导致工具栏需要更新时,会调用所有订阅的监听器。
|
|
20
|
+
* 这比轮询更高效,能实现实时更新(~1ms 延迟 vs 100ms 轮询延迟)。
|
|
21
|
+
*
|
|
22
|
+
* @param listener - 状态变化时的回调函数
|
|
23
|
+
* @returns 取消订阅的函数,调用后将停止接收通知
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const unsubscribe = rendererRef.current?.onToolbarChange?.(() => {
|
|
28
|
+
* const groups = rendererRef.current.getToolbarGroups();
|
|
29
|
+
* setToolbarGroups(groups);
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // 组件卸载时清理订阅
|
|
33
|
+
* return () => unsubscribe?.();
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
onToolbarChange?: (listener: () => void) => (() => void);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=base.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.types.d.ts","sourceRoot":"","sources":["../../src/renderers/base.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,YAAY,EAAE,CAAC;IAEvC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;CAC1D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { LazyExoticComponent, ComponentType } from 'react';
|
|
2
|
+
import type { FileType, PreviewFile } from '@eternalheart/file-preview-core';
|
|
3
|
+
/**
|
|
4
|
+
* 渲染器上下文:主组件传递给 getProps 的环境信息
|
|
5
|
+
*/
|
|
6
|
+
export interface RendererContext {
|
|
7
|
+
/** 解析后的 URL(可能是 blob URL) */
|
|
8
|
+
resolvedUrl: string;
|
|
9
|
+
/** ZIP 嵌套深度 */
|
|
10
|
+
zipNestingDepth: number;
|
|
11
|
+
/** 当前文件对象 */
|
|
12
|
+
currentFile: PreviewFile;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 内置渲染器配置
|
|
16
|
+
*/
|
|
17
|
+
export interface BuiltinRendererConfig {
|
|
18
|
+
/** 匹配的文件类型 */
|
|
19
|
+
fileType: FileType;
|
|
20
|
+
/** 渲染器组件(懒加载) */
|
|
21
|
+
component: LazyExoticComponent<ComponentType<any>>;
|
|
22
|
+
/** 计算传给组件的 props */
|
|
23
|
+
getProps: (ctx: RendererContext) => Record<string, any>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 内置渲染器注册表
|
|
27
|
+
*
|
|
28
|
+
* 新增渲染器:
|
|
29
|
+
* 1. 在 src/renderers/<Type>/index.tsx 创建渲染器
|
|
30
|
+
* 2. 在 src/renderers/lazy.tsx 添加懒加载导出
|
|
31
|
+
* 3. 在此注册表添加配置
|
|
32
|
+
*
|
|
33
|
+
* 主组件 FilePreviewContent.tsx 无需修改
|
|
34
|
+
*/
|
|
35
|
+
export declare const BUILTIN_RENDERERS: BuiltinRendererConfig[];
|
|
36
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/renderers/registry.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAsB7E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa;IACb,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,cAAc;IACd,QAAQ,EAAE,QAAQ,CAAC;IACnB,iBAAiB;IACjB,SAAS,EAAE,mBAAmB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;IACnD,oBAAoB;IACpB,QAAQ,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzD;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,EAAE,qBAAqB,EAyIpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar.types.d.ts","sourceRoot":"","sources":["../../src/renderers/toolbar.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAI9D,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB"}
|
|
1
|
+
{"version":3,"file":"toolbar.types.d.ts","sourceRoot":"","sources":["../../src/renderers/toolbar.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kDAAkD;IAClD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAI9D,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderItems.d.ts","sourceRoot":"","sources":["../../src/toolbar/renderItems.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG/D;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EAAE,EACtB,YAAY,EAAE,MAAM,GACnB,KAAK,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"renderItems.d.ts","sourceRoot":"","sources":["../../src/toolbar/renderItems.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG/D;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EAAE,EACtB,YAAY,EAAE,MAAM,GACnB,KAAK,CAAC,SAAS,CA2BjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eternalheart/react-file-preview",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "A modern, feature-rich file preview component for React with support for images, videos, audio, PDFs, Office documents (Word, Excel, PowerPoint), Markdown, and code files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.cjs",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"build:esm": "vite build --mode esm",
|
|
61
61
|
"build:cjs": "vite build --mode cjs",
|
|
62
62
|
"build": "pnpm --filter @eternalheart/file-preview-core build && pnpm build:esm && pnpm build:cjs && tsc --project tsconfig.json",
|
|
63
|
-
"dev": "
|
|
63
|
+
"dev": "vite build --mode esm --watch --emptyOutDir false",
|
|
64
64
|
"prepublishOnly": "pnpm build",
|
|
65
65
|
"version:patch": "npm version patch",
|
|
66
66
|
"version:minor": "npm version minor",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"lucide-react": "^0.460.0",
|
|
93
93
|
"mammoth": "^1.8.0",
|
|
94
94
|
"opentype.js": "^2.0.0",
|
|
95
|
-
"pdfjs-dist": "
|
|
95
|
+
"pdfjs-dist": "6.1.200",
|
|
96
96
|
"pptx-preview": "^1.0.7",
|
|
97
97
|
"react-markdown": "^10.1.0",
|
|
98
98
|
"rehype-katex": "^7.0.1",
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { jsx as t, jsxs as G } from "react/jsx-runtime";
|
|
2
|
-
import { useState as l, useRef as P, useEffect as E, useCallback as T } from "react";
|
|
3
|
-
import D from "mammoth";
|
|
4
|
-
import { u as N, a as I } from "./index-CEeKt7L3.mjs";
|
|
5
|
-
import { R as S } from "./RendererError-D5i8eSpN.mjs";
|
|
6
|
-
const v = 1123, H = 60, _ = 50, k = v - H * 2, R = 24, b = {
|
|
7
|
-
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
8
|
-
lineHeight: "1.8",
|
|
9
|
-
color: "#333"
|
|
10
|
-
}, B = ({ url: i }) => {
|
|
11
|
-
const c = N(), p = I(), [n, u] = l(""), [A, d] = l(!0), [h, m] = l(null), [x, g] = l([]), f = P(null);
|
|
12
|
-
E(() => {
|
|
13
|
-
if (!i) return;
|
|
14
|
-
(async () => {
|
|
15
|
-
d(!0), m(null), u("");
|
|
16
|
-
try {
|
|
17
|
-
const e = await p(i);
|
|
18
|
-
if (!e.ok)
|
|
19
|
-
throw new Error("文件加载失败");
|
|
20
|
-
const r = await e.arrayBuffer(), s = await D.convertToHtml({ arrayBuffer: r });
|
|
21
|
-
u(s.value);
|
|
22
|
-
} catch (e) {
|
|
23
|
-
console.error("Docx 解析错误:", e), m(c("docx.parse_failed"));
|
|
24
|
-
} finally {
|
|
25
|
-
d(!1);
|
|
26
|
-
}
|
|
27
|
-
})();
|
|
28
|
-
}, [i, p, c]);
|
|
29
|
-
const y = T(() => {
|
|
30
|
-
const o = f.current;
|
|
31
|
-
if (!o || !n) return;
|
|
32
|
-
const e = Array.from(o.children);
|
|
33
|
-
if (e.length === 0) {
|
|
34
|
-
g([n]);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const r = [[]];
|
|
38
|
-
let s = 0;
|
|
39
|
-
for (const a of e) {
|
|
40
|
-
const w = a.offsetHeight;
|
|
41
|
-
s > 0 && s + w > k && (r.push([]), s = 0), r[r.length - 1].push(a.outerHTML), s += w;
|
|
42
|
-
}
|
|
43
|
-
r.length === 0 && r.push([]), g(r.map((a) => a.join("")));
|
|
44
|
-
}, [n]);
|
|
45
|
-
return E(() => {
|
|
46
|
-
!n || !f.current || requestAnimationFrame(() => {
|
|
47
|
-
y();
|
|
48
|
-
});
|
|
49
|
-
}, [n, y]), A ? /* @__PURE__ */ t("div", { className: "rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full", children: /* @__PURE__ */ t("div", { className: "rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin" }) }) : h ? /* @__PURE__ */ t(S, { message: h }) : /* @__PURE__ */ G(
|
|
50
|
-
"div",
|
|
51
|
-
{
|
|
52
|
-
className: "rfp-w-full rfp-h-full rfp-overflow-auto rfp-py-6 rfp-px-4",
|
|
53
|
-
style: { background: "rgba(0, 0, 0, 0.15)" },
|
|
54
|
-
children: [
|
|
55
|
-
/* @__PURE__ */ t(
|
|
56
|
-
"div",
|
|
57
|
-
{
|
|
58
|
-
ref: f,
|
|
59
|
-
dangerouslySetInnerHTML: { __html: n },
|
|
60
|
-
style: {
|
|
61
|
-
...b,
|
|
62
|
-
position: "absolute",
|
|
63
|
-
visibility: "hidden",
|
|
64
|
-
width: `${794 - _ * 2}px`,
|
|
65
|
-
pointerEvents: "none"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
),
|
|
69
|
-
/* @__PURE__ */ t(
|
|
70
|
-
"div",
|
|
71
|
-
{
|
|
72
|
-
className: "rfp-flex rfp-flex-col rfp-items-center",
|
|
73
|
-
style: { gap: `${R}px` },
|
|
74
|
-
children: (x.length > 0 ? x : [""]).map((o, e) => /* @__PURE__ */ t(
|
|
75
|
-
"div",
|
|
76
|
-
{
|
|
77
|
-
style: {
|
|
78
|
-
width: "100%",
|
|
79
|
-
maxWidth: "794px",
|
|
80
|
-
minHeight: `${v}px`,
|
|
81
|
-
background: "white",
|
|
82
|
-
boxShadow: "0 4px 6px rgba(0, 0, 0, 0.07), 0 10px 20px rgba(0, 0, 0, 0.10)",
|
|
83
|
-
flexShrink: 0,
|
|
84
|
-
padding: `${H}px ${_}px`
|
|
85
|
-
},
|
|
86
|
-
children: /* @__PURE__ */ t(
|
|
87
|
-
"div",
|
|
88
|
-
{
|
|
89
|
-
dangerouslySetInnerHTML: { __html: o },
|
|
90
|
-
style: b
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
},
|
|
94
|
-
e
|
|
95
|
-
))
|
|
96
|
-
}
|
|
97
|
-
)
|
|
98
|
-
]
|
|
99
|
-
}
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
export {
|
|
103
|
-
B as DocxRenderer
|
|
104
|
-
};
|
|
105
|
-
//# sourceMappingURL=index-0v5STX5f.mjs.map
|