@cherrystudio/file-preview 0.2.2 → 0.2.4
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 +5 -0
- package/dist/{Combination-i8Z9CJHc.js → Combination-DJvKCNHX.js} +2 -2
- package/dist/{FilePreviewTooLarge-DC7vPyMI.js → FilePreviewTooLarge-Dy7vW_Ws.js} +1 -1
- package/dist/{FilePreviewToolbarButton-ptqwCTnz.js → FilePreviewToolbarButton-B3fnHUsU.js} +25 -4
- package/dist/{ImageFilePreview-C_P1iIEi.js → ImageFilePreview-Dw1xQ7YI.js} +6 -6
- package/dist/{PdfFilePreview-CbrMcPzo.js → PdfFilePreview-z7OIP8EH.js} +26 -11
- package/dist/{PowerPointFilePreview-9E6kUy_A.js → PowerPointFilePreview-B5Mbg-MX.js} +6 -6
- package/dist/{RtfFilePreview-Bgl6lmWy.js → RtfFilePreview-CcrhWuBX.js} +3 -3
- package/dist/{SpreadsheetFilePreview-PWFG3UY3.js → SpreadsheetFilePreview-DJxlzv9k.js} +5 -5
- package/dist/{WordFilePreview-hfALJk2N.js → WordFilePreview-CQbS4yZX.js} +20 -8
- package/dist/{circle-alert-sByhBDN4.js → circle-alert-CYVQ2eOz.js} +1 -1
- package/dist/{imageFilePreviewPlugin-D6hV1Hm1.js → imageFilePreviewPlugin-C9F4L9mo.js} +1 -1
- package/dist/react.js +8 -8
- package/dist/{rotate-ccw-Bx-jjhVm.js → rotate-ccw-CA3ussD_.js} +1 -1
- package/dist/styles.css +157 -52
- package/dist/useTranslation-BKohPZAm.js +5332 -0
- package/dist/{zoom-out-B2XJ64Kx.js → zoom-out-BXB6HBfC.js} +1 -1
- package/package.json +1 -1
- package/dist/useTranslation-BJY4EKsz.js +0 -3631
package/README.md
CHANGED
|
@@ -64,6 +64,11 @@ without splitting a surrogate pair; an empty normalized excerpt produces `null`.
|
|
|
64
64
|
Callback references are stabilized inside `Preview`, so inline callbacks do not
|
|
65
65
|
reopen documents or repeat a selection notification merely because the host rendered.
|
|
66
66
|
|
|
67
|
+
DOCX text supports native selection and copying with Ctrl+C (Cmd+C on macOS),
|
|
68
|
+
including across paragraphs. Copying uses the browser selection, not the normalized
|
|
69
|
+
or length-limited reference excerpt. While paragraph picking is enabled, ending a
|
|
70
|
+
text drag preserves the existing paragraph pick; a plain click still picks or clears it.
|
|
71
|
+
|
|
67
72
|
Recognized `source.mediaType` values take precedence over the filename extension;
|
|
68
73
|
missing or unrecognized media types fall back to the extension. `supportsPreview`
|
|
69
74
|
and `canSelectPreview` accept the same optional media type as their second argument.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as useComposedRefs } from "./useTranslation-
|
|
2
|
-
import { v as useCallbackRef$1, y as Primitive } from "./FilePreviewToolbarButton-
|
|
1
|
+
import { b as useComposedRefs } from "./useTranslation-BKohPZAm.js";
|
|
2
|
+
import { v as useCallbackRef$1, y as Primitive } from "./FilePreviewToolbarButton-B3fnHUsU.js";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as usePreviewHost, d as EmptyState, h as FileWarning, t as useTranslation } from "./useTranslation-
|
|
1
|
+
import { a as usePreviewHost, d as EmptyState, h as FileWarning, t as useTranslation } from "./useTranslation-BKohPZAm.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
//#region src/formatFileSize.ts
|
|
4
4
|
function formatFileSize(size) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as useComposedRefs, f as Button, p as cn, v as createSlot, y as createSlottable } from "./useTranslation-
|
|
1
|
+
import { b as useComposedRefs, f as Button, p as cn, v as createSlot, y as createSlottable } from "./useTranslation-BKohPZAm.js";
|
|
2
2
|
import * as React$1 from "react";
|
|
3
3
|
import { useLayoutEffect } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -2584,21 +2584,40 @@ function isFunction(value) {
|
|
|
2584
2584
|
//#endregion
|
|
2585
2585
|
//#region ../ui/src/components/primitives/portal-container.tsx
|
|
2586
2586
|
var PortalContainerContext = React$1.createContext(null);
|
|
2587
|
+
var TooltipPortalContainerContext = React$1.createContext(null);
|
|
2588
|
+
var TooltipZIndexContext = React$1.createContext(void 0);
|
|
2587
2589
|
var DialogPortalContainerContext = React$1.createContext(null);
|
|
2588
2590
|
/**
|
|
2589
2591
|
* Overlays should portal into the nearest provided container, usually dialog
|
|
2590
2592
|
* content, so Radix focus traps and dismiss layers treat nested overlays as
|
|
2591
2593
|
* inside the same interaction boundary.
|
|
2594
|
+
*
|
|
2595
|
+
* @param tooltipContainer - Portal target for tooltips, which never take focus and so
|
|
2596
|
+
* can live outside a container that clips them. Defaults to `container`.
|
|
2597
|
+
* @param tooltipZIndex - z-index for tooltips portaled outside `container`, so they stack
|
|
2598
|
+
* above the surface that owns them. Omitted, tooltips keep their own z-index.
|
|
2592
2599
|
*/
|
|
2593
|
-
function PortalContainerProvider({ container, children }) {
|
|
2600
|
+
function PortalContainerProvider({ container, tooltipContainer = container, tooltipZIndex, children }) {
|
|
2594
2601
|
return /* @__PURE__ */ jsx(PortalContainerContext, {
|
|
2595
2602
|
value: container,
|
|
2596
|
-
children
|
|
2603
|
+
children: /* @__PURE__ */ jsx(TooltipPortalContainerContext, {
|
|
2604
|
+
value: tooltipContainer,
|
|
2605
|
+
children: /* @__PURE__ */ jsx(TooltipZIndexContext, {
|
|
2606
|
+
value: tooltipZIndex,
|
|
2607
|
+
children
|
|
2608
|
+
})
|
|
2609
|
+
})
|
|
2597
2610
|
});
|
|
2598
2611
|
}
|
|
2599
2612
|
function usePortalContainer() {
|
|
2600
2613
|
return React$1.use(PortalContainerContext);
|
|
2601
2614
|
}
|
|
2615
|
+
function useTooltipPortalContainer() {
|
|
2616
|
+
return React$1.use(TooltipPortalContainerContext);
|
|
2617
|
+
}
|
|
2618
|
+
function useTooltipZIndex() {
|
|
2619
|
+
return React$1.use(TooltipZIndexContext);
|
|
2620
|
+
}
|
|
2602
2621
|
/**
|
|
2603
2622
|
* Dialogs use a page-level portal target so they remain attached to their owning
|
|
2604
2623
|
* tab without inheriting the transformed content node of a parent dialog.
|
|
@@ -3362,7 +3381,8 @@ var contentStyles = "z-[80] w-fit max-w-80 origin-(--radix-tooltip-content-trans
|
|
|
3362
3381
|
var arrowStyles = "z-[80] -translate-y-px fill-neutral-900 stroke-neutral-900 stroke-2 dark:fill-neutral-100 dark:stroke-neutral-100 [paint-order:stroke_fill]";
|
|
3363
3382
|
var Tooltip = ({ children, content, title, placement, delay = 0, sideOffset = 8, showArrow = true, fullWidthTrigger = false, classNames, className, isDisabled, isOpen, onOpenChange, onClick, portalContainer, asChild = false }) => {
|
|
3364
3383
|
const tooltipContent = content ?? title;
|
|
3365
|
-
const defaultPortalContainer =
|
|
3384
|
+
const defaultPortalContainer = useTooltipPortalContainer();
|
|
3385
|
+
const zIndex = useTooltipZIndex();
|
|
3366
3386
|
const surfaceActive = React$1.use(TooltipSurfaceContext);
|
|
3367
3387
|
const disabled = !tooltipContent || isDisabled || !surfaceActive;
|
|
3368
3388
|
const { contentVisible, effectiveOpen, handleOpenChange } = useTooltipController(isOpen, onOpenChange, false, disabled);
|
|
@@ -3400,6 +3420,7 @@ var Tooltip = ({ children, content, title, placement, delay = 0, sideOffset = 8,
|
|
|
3400
3420
|
align,
|
|
3401
3421
|
sideOffset,
|
|
3402
3422
|
className: cn(contentStyles, classNames?.content, className),
|
|
3423
|
+
style: zIndex ? { zIndex } : void 0,
|
|
3403
3424
|
children: [tooltipContent, showArrow && /* @__PURE__ */ jsx(Arrow2, {
|
|
3404
3425
|
width: 12,
|
|
3405
3426
|
height: 6,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { r as readPreviewDocument, t as PreviewError } from "./source-Rx3etU3y.js";
|
|
2
|
-
import { _ as cva, a as usePreviewHost, b as useComposedRefs, d as EmptyState, g as createLucideIcon, m as LoaderCircle, p as cn, r as FilePreviewLayout, s as FilePreviewToolbar, t as useTranslation, v as createSlot } from "./useTranslation-
|
|
3
|
-
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-
|
|
4
|
-
import { S as composeEventHandlers, a as usePortalContainer, b as dispatchDiscreteCustomEvent, c as Portal$1, d as Content, f as Root2$1, g as DismissableLayer, h as useLayoutEffect2, l as Anchor, m as useId$1, o as useControllableState, p as createPopperScope, s as Presence, t as FilePreviewToolbarButton, u as Arrow, v as useCallbackRef, x as createContextScope, y as Primitive } from "./FilePreviewToolbarButton-
|
|
5
|
-
import { i as useFocusGuards, n as hideOthers, r as FocusScope, t as ReactRemoveScroll } from "./Combination-
|
|
6
|
-
import { t as imageFilePreviewPlugin } from "./imageFilePreviewPlugin-
|
|
7
|
-
import { t as FilePreviewTooLarge } from "./FilePreviewTooLarge-
|
|
2
|
+
import { _ as cva, a as usePreviewHost, b as useComposedRefs, d as EmptyState, g as createLucideIcon, m as LoaderCircle, p as cn, r as FilePreviewLayout, s as FilePreviewToolbar, t as useTranslation, v as createSlot } from "./useTranslation-BKohPZAm.js";
|
|
3
|
+
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-BXB6HBfC.js";
|
|
4
|
+
import { S as composeEventHandlers, a as usePortalContainer, b as dispatchDiscreteCustomEvent, c as Portal$1, d as Content, f as Root2$1, g as DismissableLayer, h as useLayoutEffect2, l as Anchor, m as useId$1, o as useControllableState, p as createPopperScope, s as Presence, t as FilePreviewToolbarButton, u as Arrow, v as useCallbackRef, x as createContextScope, y as Primitive } from "./FilePreviewToolbarButton-B3fnHUsU.js";
|
|
5
|
+
import { i as useFocusGuards, n as hideOthers, r as FocusScope, t as ReactRemoveScroll } from "./Combination-DJvKCNHX.js";
|
|
6
|
+
import { t as imageFilePreviewPlugin } from "./imageFilePreviewPlugin-C9F4L9mo.js";
|
|
7
|
+
import { t as FilePreviewTooLarge } from "./FilePreviewTooLarge-Dy7vW_Ws.js";
|
|
8
8
|
import * as React$1 from "react";
|
|
9
9
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
10
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { i as readPreviewRange, n as assertPreviewRange, t as PreviewError } from "./source-Rx3etU3y.js";
|
|
2
|
-
import { a as usePreviewHost, b as useComposedRefs, d as EmptyState, f as Button, g as createLucideIcon, h as FileWarning, m as LoaderCircle, o as usePreviewLogger, p as cn, r as FilePreviewLayout, s as FilePreviewToolbar, t as useTranslation, u as
|
|
3
|
-
import { n as ChevronRight, r as ChevronLeft, t as RotateCcw } from "./rotate-ccw-
|
|
4
|
-
import { t as CircleAlert } from "./circle-alert-
|
|
5
|
-
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-
|
|
6
|
-
import { S as composeEventHandlers, _ as useDismissableLayerSurface, c as Portal, g as DismissableLayer, i as useDialogPortalContainer, m as useId$1, o as useControllableState, r as PortalContainerProvider, s as Presence, t as FilePreviewToolbarButton, x as createContextScope, y as Primitive } from "./FilePreviewToolbarButton-
|
|
7
|
-
import { i as useFocusGuards, n as hideOthers, r as FocusScope, t as ReactRemoveScroll } from "./Combination-
|
|
2
|
+
import { a as usePreviewHost, b as useComposedRefs, d as EmptyState, f as Button, g as createLucideIcon, h as FileWarning, m as LoaderCircle, o as usePreviewLogger, p as cn, r as FilePreviewLayout, s as FilePreviewToolbar, t as useTranslation, u as ScrollArea, v as createSlot } from "./useTranslation-BKohPZAm.js";
|
|
3
|
+
import { n as ChevronRight, r as ChevronLeft, t as RotateCcw } from "./rotate-ccw-CA3ussD_.js";
|
|
4
|
+
import { t as CircleAlert } from "./circle-alert-CYVQ2eOz.js";
|
|
5
|
+
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-BXB6HBfC.js";
|
|
6
|
+
import { S as composeEventHandlers, _ as useDismissableLayerSurface, c as Portal, g as DismissableLayer, i as useDialogPortalContainer, m as useId$1, o as useControllableState, r as PortalContainerProvider, s as Presence, t as FilePreviewToolbarButton, x as createContextScope, y as Primitive } from "./FilePreviewToolbarButton-B3fnHUsU.js";
|
|
7
|
+
import { i as useFocusGuards, n as hideOthers, r as FocusScope, t as ReactRemoveScroll } from "./Combination-DJvKCNHX.js";
|
|
8
8
|
import { t as createPreviewSelection } from "./selection-B0INvh6t.js";
|
|
9
9
|
import { t as attachTouchPinch } from "./touchPinch-C4fl-9fg.js";
|
|
10
10
|
import * as React$1 from "react";
|
|
@@ -334,13 +334,22 @@ var dialogContentSizeClass = {
|
|
|
334
334
|
lg: "sm:max-w-xl",
|
|
335
335
|
xl: "sm:max-w-[720px]"
|
|
336
336
|
};
|
|
337
|
-
function DialogContent({ className, children, closeLabel = "Close", closeOnOverlayClick = true, showCloseButton = true, motion = "directional", overlayClassName, onPointerDown, size = "default", ref, ...props }) {
|
|
337
|
+
function DialogContent({ className, children, closeLabel = "Close", closeOnOverlayClick = true, showCloseButton = true, motion = "directional", overlayClassName, onPointerDown, size = "default", style, ref, ...props }) {
|
|
338
|
+
const dialogPortalContainer = useDialogPortalContainer();
|
|
338
339
|
const [contentElement, setContentElement] = React$1.useState(null);
|
|
340
|
+
const [contentZIndex, setContentZIndex] = React$1.useState();
|
|
339
341
|
const handleRef = React$1.useCallback((node) => {
|
|
340
342
|
setContentElement(node);
|
|
341
343
|
if (typeof ref === "function") ref(node);
|
|
342
344
|
else if (ref) ref.current = node;
|
|
343
345
|
}, [ref]);
|
|
346
|
+
React$1.useLayoutEffect(() => {
|
|
347
|
+
if (contentElement) setContentZIndex(getComputedStyle(contentElement).zIndex);
|
|
348
|
+
}, [
|
|
349
|
+
contentElement,
|
|
350
|
+
className,
|
|
351
|
+
style
|
|
352
|
+
]);
|
|
344
353
|
return /* @__PURE__ */ jsxs(DialogPortal, {
|
|
345
354
|
"data-slot": "dialog-portal",
|
|
346
355
|
children: [/* @__PURE__ */ jsx(DialogClose, {
|
|
@@ -354,11 +363,14 @@ function DialogContent({ className, children, closeLabel = "Close", closeOnOverl
|
|
|
354
363
|
}), /* @__PURE__ */ jsx(DialogContent$1, {
|
|
355
364
|
ref: handleRef,
|
|
356
365
|
"data-slot": "dialog-content",
|
|
357
|
-
className: cn("fixed top-[50%] left-[50%] z-[80] grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-3xl border-0 bg-card p-6 text-card-foreground shadow-xl [-webkit-app-region:no-drag]", "data-[state=open]:animate-in data-[state=open]:ease-[cubic-bezier(0.16,1,0.3,1)] data-[state=open]:animation-duration-[260ms] data-[state=open]:fade-in-0
|
|
366
|
+
className: cn("fixed top-[50%] left-[50%] z-[80] grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-3xl border-0 bg-card p-6 text-card-foreground shadow-xl [-webkit-app-region:no-drag]", "data-[state=open]:animate-in data-[state=open]:ease-[cubic-bezier(0.16,1,0.3,1)] data-[state=open]:animation-duration-[260ms] data-[state=open]:fade-in-0", "data-[state=closed]:animate-out data-[state=closed]:ease-[cubic-bezier(0.4,0,1,1)] data-[state=closed]:animation-duration-[200ms] data-[state=closed]:fade-out-0", motion === "directional" && "data-[state=closed]:slide-out-to-bottom-4 data-[state=open]:slide-in-from-bottom-4", "fill-mode-both motion-reduce:animate-none", dialogContentSizeClass[size], className),
|
|
358
367
|
onPointerDown: composeEventHandlers(onPointerDown, (event) => event.stopPropagation(), { checkForDefaultPrevented: false }),
|
|
368
|
+
style,
|
|
359
369
|
...props,
|
|
360
370
|
children: /* @__PURE__ */ jsxs(PortalContainerProvider, {
|
|
361
371
|
container: contentElement,
|
|
372
|
+
tooltipContainer: dialogPortalContainer,
|
|
373
|
+
tooltipZIndex: contentZIndex,
|
|
362
374
|
children: [children, showCloseButton && /* @__PURE__ */ jsxs(DialogClose, {
|
|
363
375
|
"data-slot": "dialog-close",
|
|
364
376
|
className: "absolute top-4 right-4 rounded-md opacity-70 transition-opacity hover:opacity-100 focus:outline-hidden focus-visible:bg-accent focus-visible:opacity-100 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
@@ -29047,9 +29059,12 @@ function PdfOutline({ className, items, onNavigate, status }) {
|
|
|
29047
29059
|
children: [/* @__PURE__ */ jsx("h2", {
|
|
29048
29060
|
className: "flex h-10 shrink-0 items-center border-border-subtle border-b px-3 font-medium text-sm",
|
|
29049
29061
|
children: t("file_preview.pdf.outline.title")
|
|
29050
|
-
}), /* @__PURE__ */ jsx(
|
|
29051
|
-
className: "min-h-0 flex-1
|
|
29052
|
-
|
|
29062
|
+
}), /* @__PURE__ */ jsx(ScrollArea, {
|
|
29063
|
+
className: "min-h-0 flex-1",
|
|
29064
|
+
viewportProps: {
|
|
29065
|
+
className: "px-2 py-2",
|
|
29066
|
+
style: options?.bottomInset === "content" ? { paddingBottom: "calc(0.5rem + var(--file-preview-bottom-inset, 0px))" } : void 0
|
|
29067
|
+
},
|
|
29053
29068
|
children: status === "loading" ? /* @__PURE__ */ jsx("p", {
|
|
29054
29069
|
role: "status",
|
|
29055
29070
|
className: "px-2 py-1 text-muted-foreground text-xs",
|
|
@@ -1,11 +1,11 @@
|
|
|
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 { a as usePreviewHost, d as EmptyState, h as FileWarning, m as LoaderCircle, o as usePreviewLogger, r as FilePreviewLayout, s as FilePreviewToolbar, t as useTranslation } from "./useTranslation-
|
|
4
|
-
import { n as ChevronRight, r as ChevronLeft, t as RotateCcw } from "./rotate-ccw-
|
|
5
|
-
import { t as CircleAlert } from "./circle-alert-
|
|
6
|
-
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-
|
|
7
|
-
import { t as FilePreviewToolbarButton } from "./FilePreviewToolbarButton-
|
|
8
|
-
import { t as FilePreviewTooLarge } from "./FilePreviewTooLarge-
|
|
3
|
+
import { a as usePreviewHost, d as EmptyState, h as FileWarning, m as LoaderCircle, o as usePreviewLogger, r as FilePreviewLayout, s as FilePreviewToolbar, t as useTranslation } from "./useTranslation-BKohPZAm.js";
|
|
4
|
+
import { n as ChevronRight, r as ChevronLeft, t as RotateCcw } from "./rotate-ccw-CA3ussD_.js";
|
|
5
|
+
import { t as CircleAlert } from "./circle-alert-CYVQ2eOz.js";
|
|
6
|
+
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-BXB6HBfC.js";
|
|
7
|
+
import { t as FilePreviewToolbarButton } from "./FilePreviewToolbarButton-B3fnHUsU.js";
|
|
8
|
+
import { t as FilePreviewTooLarge } from "./FilePreviewTooLarge-Dy7vW_Ws.js";
|
|
9
9
|
import { t as createPreviewSelection } from "./selection-B0INvh6t.js";
|
|
10
10
|
import { t as require_jszip_min } from "./jszip.min-uwqlc4KL.js";
|
|
11
11
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as __toESM, t as __commonJSMin } from "./rolldown-runtime-B-lAHAz2.js";
|
|
2
2
|
import { r as readPreviewDocument, t as PreviewError } from "./source-Rx3etU3y.js";
|
|
3
|
-
import { a as usePreviewHost, d as EmptyState, m as LoaderCircle, r as FilePreviewLayout, t as useTranslation } from "./useTranslation-
|
|
4
|
-
import { t as CircleAlert } from "./circle-alert-
|
|
5
|
-
import { t as FilePreviewTooLarge } from "./FilePreviewTooLarge-
|
|
3
|
+
import { a as usePreviewHost, d as EmptyState, m as LoaderCircle, r as FilePreviewLayout, t as useTranslation } from "./useTranslation-BKohPZAm.js";
|
|
4
|
+
import { t as CircleAlert } from "./circle-alert-CYVQ2eOz.js";
|
|
5
|
+
import { t as FilePreviewTooLarge } from "./FilePreviewTooLarge-Dy7vW_Ws.js";
|
|
6
6
|
import { useEffect, useRef, useState } from "react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
//#region ../../node_modules/.pnpm/rtf.js@3.0.9_patch_hash=8f9a6825a5d8d1e4c4a5911165dc7e3398199e30ca7abc009df7bd0c612f3d24/node_modules/rtf.js/dist/EMFJS.bundle.js
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "./documentAnchor-J7GGLU15.js";
|
|
2
2
|
import { r as readPreviewDocument, t as PreviewError } from "./source-Rx3etU3y.js";
|
|
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-
|
|
4
|
-
import { t as CircleAlert } from "./circle-alert-
|
|
5
|
-
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-
|
|
6
|
-
import { t as FilePreviewToolbarButton } from "./FilePreviewToolbarButton-
|
|
7
|
-
import { t as FilePreviewTooLarge } from "./FilePreviewTooLarge-
|
|
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-BKohPZAm.js";
|
|
4
|
+
import { t as CircleAlert } from "./circle-alert-CYVQ2eOz.js";
|
|
5
|
+
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-BXB6HBfC.js";
|
|
6
|
+
import { t as FilePreviewToolbarButton } from "./FilePreviewToolbarButton-B3fnHUsU.js";
|
|
7
|
+
import { t as FilePreviewTooLarge } from "./FilePreviewTooLarge-Dy7vW_Ws.js";
|
|
8
8
|
import { n as normalizeSelectionText, t as createPreviewSelection } from "./selection-B0INvh6t.js";
|
|
9
9
|
import * as React$1 from "react";
|
|
10
10
|
import React, { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
@@ -1,11 +1,11 @@
|
|
|
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 { a as usePreviewHost, d as EmptyState, m as LoaderCircle, r as FilePreviewLayout, s as FilePreviewToolbar, t as useTranslation } from "./useTranslation-
|
|
4
|
-
import { n as ChevronRight, r as ChevronLeft, t as RotateCcw } from "./rotate-ccw-
|
|
5
|
-
import { t as CircleAlert } from "./circle-alert-
|
|
6
|
-
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-
|
|
7
|
-
import { t as FilePreviewToolbarButton } from "./FilePreviewToolbarButton-
|
|
8
|
-
import { t as FilePreviewTooLarge } from "./FilePreviewTooLarge-
|
|
3
|
+
import { a as usePreviewHost, d as EmptyState, m as LoaderCircle, r as FilePreviewLayout, s as FilePreviewToolbar, t as useTranslation } from "./useTranslation-BKohPZAm.js";
|
|
4
|
+
import { n as ChevronRight, r as ChevronLeft, t as RotateCcw } from "./rotate-ccw-CA3ussD_.js";
|
|
5
|
+
import { t as CircleAlert } from "./circle-alert-CYVQ2eOz.js";
|
|
6
|
+
import { n as ZoomIn, t as ZoomOut } from "./zoom-out-BXB6HBfC.js";
|
|
7
|
+
import { t as FilePreviewToolbarButton } from "./FilePreviewToolbarButton-B3fnHUsU.js";
|
|
8
|
+
import { t as FilePreviewTooLarge } from "./FilePreviewTooLarge-Dy7vW_Ws.js";
|
|
9
9
|
import { t as createPreviewSelection } from "./selection-B0INvh6t.js";
|
|
10
10
|
import { t as attachTouchPinch } from "./touchPinch-C4fl-9fg.js";
|
|
11
11
|
import { t as require_jszip_min } from "./jszip.min-uwqlc4KL.js";
|
|
@@ -3841,6 +3841,7 @@ function WordFilePreview({ sourceId, fileName, document: previewDocument, onSele
|
|
|
3841
3841
|
const docxClassName = `docx-preview-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
3842
3842
|
const containerRef = useRef(null);
|
|
3843
3843
|
const bodyRef = useRef(null);
|
|
3844
|
+
const pressPositionRef = useRef(null);
|
|
3844
3845
|
const styleRef = useRef(null);
|
|
3845
3846
|
const renderTokenRef = useRef(0);
|
|
3846
3847
|
const fitScrollTopRef = useRef(null);
|
|
@@ -4027,9 +4028,14 @@ function WordFilePreview({ sourceId, fileName, document: previewDocument, onSele
|
|
|
4027
4028
|
return () => observer.disconnect();
|
|
4028
4029
|
}, [pageCount, loading]);
|
|
4029
4030
|
const handlePick = useCallback((event) => {
|
|
4031
|
+
const pressPosition = pressPositionRef.current;
|
|
4032
|
+
pressPositionRef.current = null;
|
|
4030
4033
|
if (!onSelection || !(event.target instanceof Element)) return;
|
|
4031
4034
|
if (event.target.closest("a[href]")) event.preventDefault();
|
|
4032
|
-
const
|
|
4035
|
+
const bodyContainer = bodyRef.current;
|
|
4036
|
+
const selection = bodyContainer?.ownerDocument.getSelection();
|
|
4037
|
+
if (pressPosition && (event.clientX !== pressPosition.x || event.clientY !== pressPosition.y) && bodyContainer && selection && !selection.isCollapsed && selection.rangeCount > 0 && selection.getRangeAt(0).intersectsNode(bodyContainer)) return;
|
|
4038
|
+
const previous = bodyContainer?.querySelector("[data-docx-picked=\"true\"]") ?? null;
|
|
4033
4039
|
const resolved = paragraphToDocxAnchor(event.target);
|
|
4034
4040
|
previous?.removeAttribute("data-docx-picked");
|
|
4035
4041
|
if (!resolved || resolved.element === previous) {
|
|
@@ -4106,9 +4112,15 @@ function WordFilePreview({ sourceId, fileName, document: previewDocument, onSele
|
|
|
4106
4112
|
"data-testid": "docx-preview-content",
|
|
4107
4113
|
"data-zoom": zoom,
|
|
4108
4114
|
"data-picker": onSelection ? "true" : void 0,
|
|
4115
|
+
onMouseDown: (event) => {
|
|
4116
|
+
pressPositionRef.current = {
|
|
4117
|
+
x: event.clientX,
|
|
4118
|
+
y: event.clientY
|
|
4119
|
+
};
|
|
4120
|
+
},
|
|
4109
4121
|
onClick: handlePick,
|
|
4110
4122
|
style: contentStyle,
|
|
4111
|
-
className: "mx-auto w-fit min-w-0 [&_.docx-preview]:box-border [&_.docx-preview]:max-w-full [&_.docx-preview-wrapper]:mx-auto [&_p[data-docx-picked=true]]:bg-primary/15 [&_p[data-docx-picked=true]]:outline [&_p[data-docx-picked=true]]:outline-1 [&_p[data-docx-picked=true]]:outline-primary/60 [&_section]:overflow-hidden [&_section]:rounded-sm [&_section]:shadow-md [&[data-picker=true]_p[data-docx-part=body]]:cursor-pointer [&[data-picker=true]_p[data-docx-part=body]:not([data-docx-picked=true]):hover]:bg-primary/10"
|
|
4123
|
+
className: "selectable mx-auto w-fit min-w-0 [&_.docx-preview]:box-border [&_.docx-preview]:max-w-full [&_.docx-preview-wrapper]:mx-auto [&_p[data-docx-picked=true]]:bg-primary/15 [&_p[data-docx-picked=true]]:outline [&_p[data-docx-picked=true]]:outline-1 [&_p[data-docx-picked=true]]:outline-primary/60 [&_section]:overflow-hidden [&_section]:rounded-sm [&_section]:shadow-md [&[data-picker=true]_p[data-docx-part=body]]:cursor-pointer [&[data-picker=true]_p[data-docx-part=body]:not([data-docx-picked=true]):hover]:bg-primary/10"
|
|
4112
4124
|
})]
|
|
4113
4125
|
}),
|
|
4114
4126
|
loading ? /* @__PURE__ */ jsxs("div", {
|
|
@@ -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-Dw1xQ7YI.js")
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
29
|
export { imageFilePreviewPlugin as t };
|
package/dist/react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as assertPreviewRange, t as PreviewError } from "./source-Rx3etU3y.js";
|
|
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-
|
|
3
|
-
import { n as DialogPortalContainerProvider, r as PortalContainerProvider, t as FilePreviewToolbarButton } from "./FilePreviewToolbarButton-
|
|
4
|
-
import { t as imageFilePreviewPlugin } from "./imageFilePreviewPlugin-
|
|
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-BKohPZAm.js";
|
|
3
|
+
import { n as DialogPortalContainerProvider, r as PortalContainerProvider, t as FilePreviewToolbarButton } from "./FilePreviewToolbarButton-B3fnHUsU.js";
|
|
4
|
+
import { t as imageFilePreviewPlugin } from "./imageFilePreviewPlugin-C9F4L9mo.js";
|
|
5
5
|
import { Component, Suspense, createContext, createElement, lazy, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
/**
|
|
@@ -32,14 +32,14 @@ var plugins = [
|
|
|
32
32
|
id: "pdf",
|
|
33
33
|
extensions: ["pdf"],
|
|
34
34
|
mediaTypes: ["application/pdf"],
|
|
35
|
-
load: () => import("./PdfFilePreview-
|
|
35
|
+
load: () => import("./PdfFilePreview-z7OIP8EH.js"),
|
|
36
36
|
supportsSelectionReference: true
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
id: "powerpoint",
|
|
40
40
|
extensions: ["pptx"],
|
|
41
41
|
mediaTypes: ["application/vnd.openxmlformats-officedocument.presentationml.presentation"],
|
|
42
|
-
load: () => import("./PowerPointFilePreview-
|
|
42
|
+
load: () => import("./PowerPointFilePreview-B5Mbg-MX.js"),
|
|
43
43
|
supportsSelectionReference: true
|
|
44
44
|
},
|
|
45
45
|
{
|
|
@@ -50,20 +50,20 @@ var plugins = [
|
|
|
50
50
|
"text/rtf",
|
|
51
51
|
"application/x-rtf"
|
|
52
52
|
],
|
|
53
|
-
load: () => import("./RtfFilePreview-
|
|
53
|
+
load: () => import("./RtfFilePreview-CcrhWuBX.js")
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
id: "spreadsheet",
|
|
57
57
|
extensions: ["xlsx"],
|
|
58
58
|
mediaTypes: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
|
|
59
|
-
load: () => import("./SpreadsheetFilePreview-
|
|
59
|
+
load: () => import("./SpreadsheetFilePreview-DJxlzv9k.js"),
|
|
60
60
|
supportsSelectionReference: true
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
id: "word",
|
|
64
64
|
extensions: ["docx"],
|
|
65
65
|
mediaTypes: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
|
|
66
|
-
load: () => import("./WordFilePreview-
|
|
66
|
+
load: () => import("./WordFilePreview-CQbS4yZX.js"),
|
|
67
67
|
supportsSelectionReference: true
|
|
68
68
|
}
|
|
69
69
|
];
|