@cherrystudio/file-preview 0.2.1 → 0.2.3
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
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.
|
|
@@ -101,8 +106,7 @@ PDF workers belong to individual previews and never change pdf.js global options
|
|
|
101
106
|
Cleanup awaits the pdf.js loading task's destruction before terminating its worker,
|
|
102
107
|
allowing document fonts to be released. There is no forced teardown timeout: an
|
|
103
108
|
already-unresponsive worker can leave that destruction promise pending.
|
|
104
|
-
Translations use an independent i18next instance with resources for
|
|
105
|
-
languages; other locales fall back to English.
|
|
109
|
+
Translations use an independent i18next instance with resources for 14 languages; other locales fall back to English.
|
|
106
110
|
|
|
107
111
|
`FilePreviewLayout.Shell` owns the shared header and toolbar placement.
|
|
108
112
|
`FilePreviewLayout`, `FilePreviewToolbar` and its portal provider/host are also used
|
|
@@ -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", {
|
package/dist/react.js
CHANGED
|
@@ -63,7 +63,7 @@ var plugins = [
|
|
|
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-Do062CDe.js"),
|
|
67
67
|
supportsSelectionReference: true
|
|
68
68
|
}
|
|
69
69
|
];
|
|
@@ -2670,6 +2670,42 @@ var catalogs = {
|
|
|
2670
2670
|
"xlsx_preview.formula_not_evaluated": "Impossible d’évaluer la formule",
|
|
2671
2671
|
"xlsx_preview.sheet_tabs_label": "Feuilles"
|
|
2672
2672
|
},
|
|
2673
|
+
"it-it": {
|
|
2674
|
+
"common.close": "Chiudi",
|
|
2675
|
+
"common.loading": "Caricamento...",
|
|
2676
|
+
"common.next": "Avanti",
|
|
2677
|
+
"common.previous": "Indietro",
|
|
2678
|
+
"file_preview.load_error.description": "Impossibile caricare il contenuto dell'anteprima.",
|
|
2679
|
+
"file_preview.load_error.title": "Anteprima non riuscita",
|
|
2680
|
+
"file_preview.loading": "Caricamento dell'anteprima...",
|
|
2681
|
+
"file_preview.pdf.outline.empty": "Questo PDF non contiene un indice.",
|
|
2682
|
+
"file_preview.pdf.outline.load_error": "Impossibile caricare l'indice.",
|
|
2683
|
+
"file_preview.pdf.outline.title": "Indice",
|
|
2684
|
+
"file_preview.pdf.page_number": "Numero di pagina",
|
|
2685
|
+
"file_preview.pdf.too_large.description": "Una parte di questo PDF è troppo grande per visualizzarne l'anteprima in modo sicuro nell'app.",
|
|
2686
|
+
"file_preview.pdf.too_large.title": "Impossibile visualizzare l'anteprima di questo PDF",
|
|
2687
|
+
"file_preview.powerpoint.zip_limit.description": "Questo file PowerPoint supera i limiti di sicurezza dell'app per l'anteprima.",
|
|
2688
|
+
"file_preview.powerpoint.zip_limit.title": "Impossibile visualizzare l'anteprima di questo file PowerPoint",
|
|
2689
|
+
"file_preview.too_large.action": "Apri con l'app predefinita",
|
|
2690
|
+
"file_preview.too_large.description": "La dimensione del file {{size}} supera il limite di {{limit}} per l'anteprima.",
|
|
2691
|
+
"file_preview.too_large.title": "File troppo grande per l'anteprima",
|
|
2692
|
+
"file_preview.unsupported.action": "Apri con l'app predefinita",
|
|
2693
|
+
"file_preview.unsupported.description": "L'anteprima di questo tipo di file non è ancora supportata.",
|
|
2694
|
+
"file_preview.unsupported.title": "Anteprima non disponibile",
|
|
2695
|
+
"preview.flip_horizontal": "Rifletti orizzontalmente",
|
|
2696
|
+
"preview.flip_vertical": "Rifletti verticalmente",
|
|
2697
|
+
"preview.label": "Anteprima",
|
|
2698
|
+
"preview.reset": "Reimposta",
|
|
2699
|
+
"preview.rotate_left": "Ruota a sinistra",
|
|
2700
|
+
"preview.rotate_right": "Ruota a destra",
|
|
2701
|
+
"preview.zoom_in": "Ingrandisci",
|
|
2702
|
+
"preview.zoom_out": "Riduci",
|
|
2703
|
+
"xlsx_preview.chart": "Grafico",
|
|
2704
|
+
"xlsx_preview.chart_unsupported": "Questo tipo di grafico non è ancora supportato",
|
|
2705
|
+
"xlsx_preview.error.description": "Impossibile visualizzare l'anteprima di questo foglio di calcolo.",
|
|
2706
|
+
"xlsx_preview.formula_not_evaluated": "Impossibile valutare la formula",
|
|
2707
|
+
"xlsx_preview.sheet_tabs_label": "Fogli"
|
|
2708
|
+
},
|
|
2673
2709
|
"ja-jp": {
|
|
2674
2710
|
"common.close": "閉じる",
|
|
2675
2711
|
"common.loading": "読み込み中...",
|