@cherrystudio/file-preview 0.1.2 → 0.2.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 +23 -5
- package/dist/{Combination-BLg27FvF.js → Combination-i8Z9CJHc.js} +2 -1
- package/dist/{FilePreviewTooLarge-DkHa6toZ.js → FilePreviewTooLarge-DC7vPyMI.js} +1 -1
- package/dist/{useTranslation-DMhY277o.js → FilePreviewToolbarButton-ptqwCTnz.js} +11 -3634
- package/dist/{ImageFilePreview-Be0jdBJ-.js → ImageFilePreview-Cbw6HzIR.js} +6 -5
- package/dist/{PdfFilePreview-D3Ie0_mm.js → PdfFilePreview-DqnRzmwY.js} +7 -5
- package/dist/{PowerPointFilePreview-CyQHTp4B.js → PowerPointFilePreview-CO_N6c1I.js} +7 -5
- package/dist/RtfFilePreview-Bgl6lmWy.js +21434 -0
- package/dist/{SpreadsheetFilePreview-DJdoyeis.js → SpreadsheetFilePreview-GKeQwJL3.js} +6 -4
- package/dist/{WordFilePreview-DSqt7Uq2.js → WordFilePreview-IfWcWbwn.js} +10 -8
- package/dist/circle-alert-sByhBDN4.js +31 -0
- package/dist/{imageFilePreviewPlugin-CYLM2bwR.js → imageFilePreviewPlugin-Cif3MLQd.js} +1 -1
- package/dist/react.js +17 -6
- package/dist/{rotate-ccw-YWx7RzY9.js → rotate-ccw-Bx-jjhVm.js} +1 -1
- package/dist/{selection-CQPD5a6C.js → selection-B0INvh6t.js} +1 -31
- package/dist/styles.css +48 -1
- package/dist/useTranslation-BJY4EKsz.js +3631 -0
- package/dist/{zoom-out-DLOQGt1e.js → zoom-out-B2XJ64Kx.js} +1 -1
- package/package.json +2 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import "./documentAnchor-J7GGLU15.js";
|
|
2
2
|
import { r as readPreviewDocument, t as PreviewError } from "./source-Rx3etU3y.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-
|
|
6
|
-
import { t as
|
|
3
|
+
import { _ as cva, a as usePreviewHost, d as EmptyState, m as LoaderCircle, o as usePreviewLogger, p as cn, r as FilePreviewLayout, t as useTranslation } from "./useTranslation-BJY4EKsz.js";
|
|
4
|
+
import { t as CircleAlert } from "./circle-alert-sByhBDN4.js";
|
|
5
|
+
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-B2XJ64Kx.js";
|
|
6
|
+
import { t as FilePreviewToolbarButton } from "./FilePreviewToolbarButton-ptqwCTnz.js";
|
|
7
|
+
import { t as FilePreviewTooLarge } from "./FilePreviewTooLarge-DC7vPyMI.js";
|
|
8
|
+
import { n as normalizeSelectionText, t as createPreviewSelection } from "./selection-B0INvh6t.js";
|
|
7
9
|
import * as React$1 from "react";
|
|
8
10
|
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
9
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { i as __toESM } from "./rolldown-runtime-B-lAHAz2.js";
|
|
2
2
|
import { r as readPreviewDocument, t as PreviewError } from "./source-Rx3etU3y.js";
|
|
3
|
-
import {
|
|
4
|
-
import { n as ChevronRight, r as ChevronLeft, t as RotateCcw } from "./rotate-ccw-
|
|
5
|
-
import {
|
|
6
|
-
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-
|
|
7
|
-
import { t as
|
|
3
|
+
import { a as usePreviewHost, d as EmptyState, m as LoaderCircle, r as FilePreviewLayout, s as FilePreviewToolbar, t as useTranslation } from "./useTranslation-BJY4EKsz.js";
|
|
4
|
+
import { n as ChevronRight, r as ChevronLeft, t as RotateCcw } from "./rotate-ccw-Bx-jjhVm.js";
|
|
5
|
+
import { t as CircleAlert } from "./circle-alert-sByhBDN4.js";
|
|
6
|
+
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-B2XJ64Kx.js";
|
|
7
|
+
import { t as FilePreviewToolbarButton } from "./FilePreviewToolbarButton-ptqwCTnz.js";
|
|
8
|
+
import { t as FilePreviewTooLarge } from "./FilePreviewTooLarge-DC7vPyMI.js";
|
|
9
|
+
import { t as createPreviewSelection } from "./selection-B0INvh6t.js";
|
|
8
10
|
import { t as attachTouchPinch } from "./touchPinch-C4fl-9fg.js";
|
|
9
11
|
import { t as require_jszip_min } from "./jszip.min-uwqlc4KL.js";
|
|
10
12
|
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
11
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
//#region ../../node_modules/.pnpm/docx-preview@0.3.7_patch_hash=
|
|
14
|
+
//#region ../../node_modules/.pnpm/docx-preview@0.3.7_patch_hash=2a780ab6775f1223fd4fb6f344769f949bdf72d851058935b3f34e59b25cfabb/node_modules/docx-preview/dist/docx-preview.mjs
|
|
13
15
|
var import_jszip_min = /* @__PURE__ */ __toESM(require_jszip_min(), 1);
|
|
14
16
|
/*
|
|
15
17
|
* @license
|
|
@@ -437,7 +439,7 @@ function parseLineSpacing(elem, xml) {
|
|
|
437
439
|
before: xml.lengthAttr(elem, "before"),
|
|
438
440
|
after: xml.lengthAttr(elem, "after"),
|
|
439
441
|
line: xml.intAttr(elem, "line"),
|
|
440
|
-
lineRule: xml.attr(elem, "lineRule")
|
|
442
|
+
lineRule: xml.attr(elem, "lineRule") ?? "auto"
|
|
441
443
|
};
|
|
442
444
|
}
|
|
443
445
|
function parseRunProperties(elem, xml) {
|
|
@@ -2356,7 +2358,7 @@ var DocumentParser = class {
|
|
|
2356
2358
|
var before = globalXmlParser.lengthAttr(node, "before");
|
|
2357
2359
|
var after = globalXmlParser.lengthAttr(node, "after");
|
|
2358
2360
|
var line = globalXmlParser.intAttr(node, "line", null);
|
|
2359
|
-
var lineRule = globalXmlParser.attr(node, "lineRule");
|
|
2361
|
+
var lineRule = globalXmlParser.attr(node, "lineRule") ?? "auto";
|
|
2360
2362
|
if (before) style["margin-top"] = before;
|
|
2361
2363
|
if (after) style["margin-bottom"] = after;
|
|
2362
2364
|
if (line !== null) switch (lineRule) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { g as createLucideIcon } from "./useTranslation-BJY4EKsz.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license lucide-react v0.545.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
var CircleAlert = createLucideIcon("circle-alert", [
|
|
9
|
+
["circle", {
|
|
10
|
+
cx: "12",
|
|
11
|
+
cy: "12",
|
|
12
|
+
r: "10",
|
|
13
|
+
key: "1mglay"
|
|
14
|
+
}],
|
|
15
|
+
["line", {
|
|
16
|
+
x1: "12",
|
|
17
|
+
x2: "12",
|
|
18
|
+
y1: "8",
|
|
19
|
+
y2: "12",
|
|
20
|
+
key: "1pkeuh"
|
|
21
|
+
}],
|
|
22
|
+
["line", {
|
|
23
|
+
x1: "12",
|
|
24
|
+
x2: "12.01",
|
|
25
|
+
y1: "16",
|
|
26
|
+
y2: "16",
|
|
27
|
+
key: "4dfq90"
|
|
28
|
+
}]
|
|
29
|
+
]);
|
|
30
|
+
//#endregion
|
|
31
|
+
export { CircleAlert as t };
|
|
@@ -23,7 +23,7 @@ var imageFilePreviewPlugin = {
|
|
|
23
23
|
"image/vnd.microsoft.icon",
|
|
24
24
|
"image/svg+xml"
|
|
25
25
|
],
|
|
26
|
-
load: () => import("./ImageFilePreview-
|
|
26
|
+
load: () => import("./ImageFilePreview-Cbw6HzIR.js")
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
29
|
export { imageFilePreviewPlugin as t };
|
package/dist/react.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { n as assertPreviewRange, t as PreviewError } from "./source-Rx3etU3y.js";
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
2
|
+
import { a as usePreviewHost, c as FilePreviewToolbarPortalHost, d as EmptyState, g as createLucideIcon, h as FileWarning, i as PreviewHostContext, l as FilePreviewToolbarPortalProvider, m as LoaderCircle, n as I18nContext, p as cn, r as FilePreviewLayout, s as FilePreviewToolbar, t as useTranslation } from "./useTranslation-BJY4EKsz.js";
|
|
3
|
+
import { n as DialogPortalContainerProvider, r as PortalContainerProvider, t as FilePreviewToolbarButton } from "./FilePreviewToolbarButton-ptqwCTnz.js";
|
|
4
|
+
import { t as imageFilePreviewPlugin } from "./imageFilePreviewPlugin-Cif3MLQd.js";
|
|
4
5
|
import { Component, Suspense, createContext, createElement, lazy, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
/**
|
|
@@ -31,28 +32,38 @@ var plugins = [
|
|
|
31
32
|
id: "pdf",
|
|
32
33
|
extensions: ["pdf"],
|
|
33
34
|
mediaTypes: ["application/pdf"],
|
|
34
|
-
load: () => import("./PdfFilePreview-
|
|
35
|
+
load: () => import("./PdfFilePreview-DqnRzmwY.js"),
|
|
35
36
|
supportsSelectionReference: true
|
|
36
37
|
},
|
|
37
38
|
{
|
|
38
39
|
id: "powerpoint",
|
|
39
40
|
extensions: ["pptx"],
|
|
40
41
|
mediaTypes: ["application/vnd.openxmlformats-officedocument.presentationml.presentation"],
|
|
41
|
-
load: () => import("./PowerPointFilePreview-
|
|
42
|
+
load: () => import("./PowerPointFilePreview-CO_N6c1I.js"),
|
|
42
43
|
supportsSelectionReference: true
|
|
43
44
|
},
|
|
45
|
+
{
|
|
46
|
+
id: "rtf",
|
|
47
|
+
extensions: ["rtf"],
|
|
48
|
+
mediaTypes: [
|
|
49
|
+
"application/rtf",
|
|
50
|
+
"text/rtf",
|
|
51
|
+
"application/x-rtf"
|
|
52
|
+
],
|
|
53
|
+
load: () => import("./RtfFilePreview-Bgl6lmWy.js")
|
|
54
|
+
},
|
|
44
55
|
{
|
|
45
56
|
id: "spreadsheet",
|
|
46
57
|
extensions: ["xlsx"],
|
|
47
58
|
mediaTypes: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
|
|
48
|
-
load: () => import("./SpreadsheetFilePreview-
|
|
59
|
+
load: () => import("./SpreadsheetFilePreview-GKeQwJL3.js"),
|
|
49
60
|
supportsSelectionReference: true
|
|
50
61
|
},
|
|
51
62
|
{
|
|
52
63
|
id: "word",
|
|
53
64
|
extensions: ["docx"],
|
|
54
65
|
mediaTypes: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
|
|
55
|
-
load: () => import("./WordFilePreview-
|
|
66
|
+
load: () => import("./WordFilePreview-IfWcWbwn.js"),
|
|
56
67
|
supportsSelectionReference: true
|
|
57
68
|
}
|
|
58
69
|
];
|
|
@@ -1,34 +1,4 @@
|
|
|
1
1
|
import { n as SELECTION_EXCERPT_MAX_LENGTH } from "./documentAnchor-J7GGLU15.js";
|
|
2
|
-
import { R as createLucideIcon } from "./useTranslation-DMhY277o.js";
|
|
3
|
-
/**
|
|
4
|
-
* @license lucide-react v0.545.0 - ISC
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the ISC license.
|
|
7
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/
|
|
9
|
-
var CircleAlert = createLucideIcon("circle-alert", [
|
|
10
|
-
["circle", {
|
|
11
|
-
cx: "12",
|
|
12
|
-
cy: "12",
|
|
13
|
-
r: "10",
|
|
14
|
-
key: "1mglay"
|
|
15
|
-
}],
|
|
16
|
-
["line", {
|
|
17
|
-
x1: "12",
|
|
18
|
-
x2: "12",
|
|
19
|
-
y1: "8",
|
|
20
|
-
y2: "12",
|
|
21
|
-
key: "1pkeuh"
|
|
22
|
-
}],
|
|
23
|
-
["line", {
|
|
24
|
-
x1: "12",
|
|
25
|
-
x2: "12.01",
|
|
26
|
-
y1: "16",
|
|
27
|
-
y2: "16",
|
|
28
|
-
key: "4dfq90"
|
|
29
|
-
}]
|
|
30
|
-
]);
|
|
31
|
-
//#endregion
|
|
32
2
|
//#region src/selection.ts
|
|
33
3
|
var SELECTION_WHITESPACE = /[\t\n\v\f\r \u0085\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\u001c-\u001f]+/g;
|
|
34
4
|
function normalizeSelectionText(text) {
|
|
@@ -44,4 +14,4 @@ function createPreviewSelection(input) {
|
|
|
44
14
|
} : null;
|
|
45
15
|
}
|
|
46
16
|
//#endregion
|
|
47
|
-
export { normalizeSelectionText as n,
|
|
17
|
+
export { normalizeSelectionText as n, createPreviewSelection as t };
|
package/dist/styles.css
CHANGED
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
--container-md: 28rem;
|
|
71
71
|
--container-lg: 32rem;
|
|
72
72
|
--container-xl: 36rem;
|
|
73
|
+
--container-4xl: 56rem;
|
|
73
74
|
--text-xs: .75rem;
|
|
74
75
|
--text-xs--line-height: calc(1 / .75);
|
|
75
76
|
--text-sm: .875rem;
|
|
@@ -203,6 +204,10 @@
|
|
|
203
204
|
top: 50%;
|
|
204
205
|
}
|
|
205
206
|
|
|
207
|
+
:where(.file-preview-root):is(.top-\[calc\(1rem\+var\(--image-preview-titlebar-height\,0px\)\)\]), :where(.file-preview-root) .top-\[calc\(1rem\+var\(--image-preview-titlebar-height\,0px\)\)\] {
|
|
208
|
+
top: calc(1rem + var(--image-preview-titlebar-height, 0px));
|
|
209
|
+
}
|
|
210
|
+
|
|
206
211
|
:where(.file-preview-root):is(.right-4), :where(.file-preview-root) .right-4 {
|
|
207
212
|
right: calc(var(--spacing) * 4);
|
|
208
213
|
}
|
|
@@ -528,6 +533,10 @@
|
|
|
528
533
|
min-height: calc(var(--spacing) * 11);
|
|
529
534
|
}
|
|
530
535
|
|
|
536
|
+
:where(.file-preview-root):is(.min-h-48), :where(.file-preview-root) .min-h-48 {
|
|
537
|
+
min-height: calc(var(--spacing) * 48);
|
|
538
|
+
}
|
|
539
|
+
|
|
531
540
|
:where(.file-preview-root):is(.min-h-full), :where(.file-preview-root) .min-h-full {
|
|
532
541
|
min-height: 100%;
|
|
533
542
|
}
|
|
@@ -556,6 +565,10 @@
|
|
|
556
565
|
width: 100vw;
|
|
557
566
|
}
|
|
558
567
|
|
|
568
|
+
:where(.file-preview-root):is(.max-w-4xl), :where(.file-preview-root) .max-w-4xl {
|
|
569
|
+
max-width: var(--container-4xl);
|
|
570
|
+
}
|
|
571
|
+
|
|
559
572
|
:where(.file-preview-root):is(.max-w-80), :where(.file-preview-root) .max-w-80 {
|
|
560
573
|
max-width: calc(var(--spacing) * 80);
|
|
561
574
|
}
|
|
@@ -998,6 +1011,10 @@
|
|
|
998
1011
|
background-color: #0000;
|
|
999
1012
|
}
|
|
1000
1013
|
|
|
1014
|
+
:where(.file-preview-root):is(.bg-white), :where(.file-preview-root) .bg-white {
|
|
1015
|
+
background-color: var(--cs-white);
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1001
1018
|
:where(.file-preview-root):is(.fill-current), :where(.file-preview-root) .fill-current {
|
|
1002
1019
|
fill: currentColor;
|
|
1003
1020
|
}
|
|
@@ -1176,6 +1193,10 @@
|
|
|
1176
1193
|
overflow-wrap: break-word;
|
|
1177
1194
|
}
|
|
1178
1195
|
|
|
1196
|
+
:where(.file-preview-root):is(.wrap-anywhere), :where(.file-preview-root) .wrap-anywhere {
|
|
1197
|
+
overflow-wrap: anywhere;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1179
1200
|
:where(.file-preview-root):is(.whitespace-normal), :where(.file-preview-root) .whitespace-normal {
|
|
1180
1201
|
white-space: normal;
|
|
1181
1202
|
}
|
|
@@ -1184,6 +1205,10 @@
|
|
|
1184
1205
|
white-space: nowrap;
|
|
1185
1206
|
}
|
|
1186
1207
|
|
|
1208
|
+
:where(.file-preview-root):is(.text-black), :where(.file-preview-root) .text-black {
|
|
1209
|
+
color: var(--cs-black);
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1187
1212
|
:where(.file-preview-root):is(.text-card-foreground), :where(.file-preview-root) .text-card-foreground {
|
|
1188
1213
|
color: var(--card-foreground);
|
|
1189
1214
|
}
|
|
@@ -1652,12 +1677,17 @@
|
|
|
1652
1677
|
opacity: 1;
|
|
1653
1678
|
}
|
|
1654
1679
|
|
|
1680
|
+
:where(.file-preview-root):is(.focus-visible\:ring-1:focus-visible), :where(.file-preview-root) .focus-visible\:ring-1:focus-visible {
|
|
1681
|
+
--fp-tw-ring-shadow: var(--fp-tw-ring-inset, ) 0 0 0 calc(1px + var(--fp-tw-ring-offset-width)) var(--fp-tw-ring-color, currentcolor);
|
|
1682
|
+
box-shadow: var(--fp-tw-inset-shadow), var(--fp-tw-inset-ring-shadow), var(--fp-tw-ring-offset-shadow), var(--fp-tw-ring-shadow), var(--fp-tw-shadow);
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1655
1685
|
:where(.file-preview-root):is(.focus-visible\:ring-2:focus-visible), :where(.file-preview-root) .focus-visible\:ring-2:focus-visible {
|
|
1656
1686
|
--fp-tw-ring-shadow: var(--fp-tw-ring-inset, ) 0 0 0 calc(2px + var(--fp-tw-ring-offset-width)) var(--fp-tw-ring-color, currentcolor);
|
|
1657
1687
|
box-shadow: var(--fp-tw-inset-shadow), var(--fp-tw-inset-ring-shadow), var(--fp-tw-ring-offset-shadow), var(--fp-tw-ring-shadow), var(--fp-tw-shadow);
|
|
1658
1688
|
}
|
|
1659
1689
|
|
|
1660
|
-
:where(.file-preview-root):is(.focus-visible\:ring-ring\/50:focus-visible), :where(.file-preview-root) .focus-visible\:ring-ring\/50:focus-visible {
|
|
1690
|
+
:where(.file-preview-root):is(.focus-visible\:ring-ring:focus-visible), :where(.file-preview-root) .focus-visible\:ring-ring:focus-visible, :where(.file-preview-root):is(.focus-visible\:ring-ring\/50:focus-visible), :where(.file-preview-root) .focus-visible\:ring-ring\/50:focus-visible {
|
|
1661
1691
|
--fp-tw-ring-color: var(--ring);
|
|
1662
1692
|
}
|
|
1663
1693
|
|
|
@@ -1667,6 +1697,11 @@
|
|
|
1667
1697
|
}
|
|
1668
1698
|
}
|
|
1669
1699
|
|
|
1700
|
+
:where(.file-preview-root):is(.focus-visible\:outline-none:focus-visible), :where(.file-preview-root) .focus-visible\:outline-none:focus-visible {
|
|
1701
|
+
--fp-tw-outline-style: none;
|
|
1702
|
+
outline-style: none;
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1670
1705
|
:where(.file-preview-root):is(.focus-visible\:ring-inset:focus-visible), :where(.file-preview-root) .focus-visible\:ring-inset:focus-visible {
|
|
1671
1706
|
--fp-tw-ring-inset: inset;
|
|
1672
1707
|
}
|
|
@@ -2083,6 +2118,14 @@
|
|
|
2083
2118
|
outline-color: var(--primary);
|
|
2084
2119
|
}
|
|
2085
2120
|
|
|
2121
|
+
.\[\&_a\]\:underline a {
|
|
2122
|
+
text-decoration-line: underline;
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
.\[\&_img\]\:max-w-full img {
|
|
2126
|
+
max-width: 100%;
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2086
2129
|
.\[\&_p\[data-docx-picked\=true\]\]\:bg-primary\/15 p[data-docx-picked="true"] {
|
|
2087
2130
|
background-color: var(--primary);
|
|
2088
2131
|
}
|
|
@@ -2130,6 +2173,10 @@
|
|
|
2130
2173
|
height: 18px !important;
|
|
2131
2174
|
}
|
|
2132
2175
|
|
|
2176
|
+
.\[\&_svg\]\:max-w-full svg {
|
|
2177
|
+
max-width: 100%;
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2133
2180
|
.\[\&_svg\]\:shrink-0 svg {
|
|
2134
2181
|
flex-shrink: 0;
|
|
2135
2182
|
}
|