eddyter 1.3.80 → 1.3.81
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/dist/{ImageResizer-o0eMm1Mg.js → ImageResizer-Bt7kgv0a.js} +1 -1
- package/dist/assets/style.css +1 -1
- package/dist/components/FileView/index.d.ts +2 -0
- package/dist/editorConfig.d.ts +1 -0
- package/dist/{generateDocxThumbnail-CuC4oE4q.js → generateDocxThumbnail-DCh0DpQm.js} +1 -1
- package/dist/{generatePdfThumbnail-Be9_gTd2.js → generatePdfThumbnail-D8k_mO4q.js} +1 -1
- package/dist/{generateXlsxThumbnail-BHmQkbG6.js → generateXlsxThumbnail-Db5nhXLN.js} +1 -1
- package/dist/{html2pdf.bundle.min-__2qz-Dv.js → html2pdf.bundle.min-CYrTiP9i.js} +1 -1
- package/dist/{index-BiGNE0nG.js → index-20I04v1t.js} +11512 -11122
- package/dist/{index-BjjpBGeH.js → index-Bgccl9jH.js} +154 -154
- package/dist/{index-0dB2NNlO.js → index-CQWxSXxG.js} +2 -2
- package/dist/index-DYduXrLZ.js +157 -0
- package/dist/index.js +1 -1
- package/dist/nodes/FileNode.d.ts +8 -2
- package/dist/plugins/FloatingFileMenuPlugin.d.ts +3 -0
- package/dist/plugins/WordCountPlugin.d.ts +4 -1
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/index-BTnX5edL.js +0 -131
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as x, Fragment as rt, jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import { I as it } from "./ImageResizer-
|
|
2
|
+
import { I as it } from "./ImageResizer-Bt7kgv0a.js";
|
|
3
3
|
import { CodeNode as ot } from "@lexical/code";
|
|
4
4
|
import { LinkNode as nt } from "@lexical/link";
|
|
5
5
|
import { AutoFocusPlugin as ct } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
@@ -15,7 +15,7 @@ import { useLexicalNodeSelection as ht } from "@lexical/react/useLexicalNodeSele
|
|
|
15
15
|
import { mergeRegister as pt } from "@lexical/utils";
|
|
16
16
|
import { $getSelection as L, $isNodeSelection as h, $setSelection as O, SELECTION_CHANGE_COMMAND as bt, COMMAND_PRIORITY_LOW as f, CLICK_COMMAND as Ct, DRAGSTART_COMMAND as xt, KEY_DELETE_COMMAND as Nt, KEY_BACKSPACE_COMMAND as vt, KEY_ENTER_COMMAND as Et, KEY_ESCAPE_COMMAND as Rt, RootNode as yt, TextNode as At, LineBreakNode as kt, ParagraphNode as St, $getNodeByKey as A, $isParagraphNode as T } from "lexical";
|
|
17
17
|
import { useRef as P, useState as w, useCallback as N, useEffect as Dt } from "react";
|
|
18
|
-
import { G as v, W as Lt, l as Pt, A as Mt, m as _t, n as $t, T as zt, x as It, L as Wt, i as Ot } from "./index-
|
|
18
|
+
import { G as v, W as Lt, l as Pt, A as Mt, m as _t, n as $t, T as zt, x as It, L as Wt, i as Ot } from "./index-20I04v1t.js";
|
|
19
19
|
function ie({
|
|
20
20
|
src: j,
|
|
21
21
|
nodeKey: g,
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { jsx as r, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import { useLexicalComposerContext as B } from "@lexical/react/LexicalComposerContext";
|
|
3
|
+
import { $getNodeByKey as b } from "lexical";
|
|
4
|
+
import { useState as E, useEffect as N } from "react";
|
|
5
|
+
import { v as y, w as k, x as I, F as x, y as T, z as W } from "./index-20I04v1t.js";
|
|
6
|
+
function $(e, t) {
|
|
7
|
+
const c = e.split(".").pop()?.toLowerCase();
|
|
8
|
+
return c === "pdf" || t.startsWith("data:application/pdf") ? "pdf" : c === "docx" || t.startsWith("data:application/vnd.openxmlformats") && e.toLowerCase().endsWith(".docx") ? "docx" : c === "xlsx" || c === "xls" || t.startsWith("data:application/vnd.openxmlformats-officedocument.spreadsheetml") || t.startsWith("data:application/vnd.ms-excel") ? "xlsx" : null;
|
|
9
|
+
}
|
|
10
|
+
function z(e, t) {
|
|
11
|
+
const [c, n] = E(null);
|
|
12
|
+
return N(() => {
|
|
13
|
+
const d = e && t ? $(t, e) : null;
|
|
14
|
+
if (!e || !t || !d) {
|
|
15
|
+
n(null);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
let l = !1;
|
|
19
|
+
return d === "pdf" ? import("./generatePdfThumbnail-D8k_mO4q.js").then(({ generatePdfThumbnail: o }) => o(e)).then((o) => {
|
|
20
|
+
l || n(o);
|
|
21
|
+
}).catch(() => {
|
|
22
|
+
l || n(null);
|
|
23
|
+
}) : d === "docx" ? import("./generateDocxThumbnail-DCh0DpQm.js").then(({ generateDocxThumbnail: o }) => o(e)).then((o) => {
|
|
24
|
+
l || n(o);
|
|
25
|
+
}).catch(() => {
|
|
26
|
+
l || n(null);
|
|
27
|
+
}) : d === "xlsx" && import("./generateXlsxThumbnail-Db5nhXLN.js").then(({ generateXlsxThumbnail: o }) => o(e)).then((o) => {
|
|
28
|
+
l || n(o);
|
|
29
|
+
}).catch(() => {
|
|
30
|
+
l || n(null);
|
|
31
|
+
}), () => {
|
|
32
|
+
l = !0, n(null);
|
|
33
|
+
};
|
|
34
|
+
}, [e, t]), c;
|
|
35
|
+
}
|
|
36
|
+
const R = (e) => e ? e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : e < 1024 * 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(1)} MB` : `${(e / (1024 * 1024 * 1024)).toFixed(1)} GB` : "", D = (e) => {
|
|
37
|
+
const t = e.split(".");
|
|
38
|
+
return t.length > 1 ? t[t.length - 1].toLowerCase() : "";
|
|
39
|
+
}, F = (e) => {
|
|
40
|
+
const t = D(e);
|
|
41
|
+
return t === "pdf" || t === "docx" || t === "xlsx" || t === "xls";
|
|
42
|
+
}, C = (e) => {
|
|
43
|
+
const t = D(e);
|
|
44
|
+
return ["pdf", "doc", "docx", "txt", "odt"].includes(t) ? /* @__PURE__ */ r(x, { className: "cteditor-w-8 cteditor-h-8 cteditor-text-blue-600" }) : ["xls", "xlsx", "csv"].includes(t) ? /* @__PURE__ */ r(x, { className: "cteditor-w-8 cteditor-h-8 cteditor-text-green-600" }) : ["ppt", "pptx"].includes(t) ? /* @__PURE__ */ r(x, { className: "cteditor-w-8 cteditor-h-8 cteditor-text-red-600" }) : ["zip", "rar", "7z", "tar", "gz"].includes(t) ? /* @__PURE__ */ r(T, { className: "cteditor-w-8 cteditor-h-8 cteditor-text-orange-500" }) : /* @__PURE__ */ r(W, { className: "cteditor-w-8 cteditor-h-8 cteditor-text-gray-500" });
|
|
45
|
+
}, H = ({
|
|
46
|
+
src: e,
|
|
47
|
+
fileName: t,
|
|
48
|
+
fileSize: c,
|
|
49
|
+
displayType: n = "card",
|
|
50
|
+
nodeKey: d
|
|
51
|
+
}) => {
|
|
52
|
+
const l = n === "inline" ? "inline" : "card", [o] = B(), u = z(F(t) ? e : void 0, t);
|
|
53
|
+
if (N(() => {
|
|
54
|
+
u && o.update(() => {
|
|
55
|
+
const a = b(d);
|
|
56
|
+
y(a) && a.setPreviewDataUrl(u);
|
|
57
|
+
});
|
|
58
|
+
}, [o, d, u]), !e || !t)
|
|
59
|
+
return console.error("FileView: Missing required props", { src: e, fileName: t, fileSize: c, nodeKey: d }), /* @__PURE__ */ r("div", { className: "cteditor-inline-flex cteditor-items-center cteditor-gap-3 cteditor-px-4 cteditor-py-3 cteditor-my-2 cteditor-border cteditor-border-destructive cteditor-rounded-lg cteditor-bg-destructive/10", children: /* @__PURE__ */ r("div", { className: "cteditor-text-sm cteditor-text-destructive", children: "Error loading file" }) });
|
|
60
|
+
const f = (a) => {
|
|
61
|
+
a.preventDefault(), a.stopPropagation();
|
|
62
|
+
try {
|
|
63
|
+
if (e.startsWith("data:")) {
|
|
64
|
+
const i = e.split(","), h = i[0].match(/:(.*?);/), L = h ? h[1] : "application/octet-stream", w = atob(i[1]);
|
|
65
|
+
let m = w.length;
|
|
66
|
+
const v = new Uint8Array(m);
|
|
67
|
+
for (; m--; )
|
|
68
|
+
v[m] = w.charCodeAt(m);
|
|
69
|
+
const j = new Blob([v], { type: L }), g = URL.createObjectURL(j), s = document.createElement("a");
|
|
70
|
+
s.href = g, s.download = t, s.style.display = "none", document.body.appendChild(s), s.click(), document.body.removeChild(s), setTimeout(() => URL.revokeObjectURL(g), 100);
|
|
71
|
+
} else {
|
|
72
|
+
const i = document.createElement("a");
|
|
73
|
+
i.href = e, i.download = t, i.style.display = "none", i.target = "_blank", document.body.appendChild(i), i.click(), document.body.removeChild(i);
|
|
74
|
+
}
|
|
75
|
+
} catch (i) {
|
|
76
|
+
console.error("Error downloading file:", i), window.open(e, "_blank");
|
|
77
|
+
}
|
|
78
|
+
}, P = (a) => {
|
|
79
|
+
a.preventDefault(), a.stopPropagation(), o.update(() => {
|
|
80
|
+
const i = b(d);
|
|
81
|
+
y(i) && i.remove();
|
|
82
|
+
});
|
|
83
|
+
}, U = F(t) && u;
|
|
84
|
+
return l === "inline" ? /* @__PURE__ */ p(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
className: "cteditor-inline-flex cteditor-items-center cteditor-gap-2 cteditor-py-1.5 cteditor-px-3 cteditor-my-0.5 cteditor-rounded-full cteditor-bg-muted hover:cteditor-bg-accent/50 cteditor-transition-colors cteditor-cursor-pointer cteditor-max-w-full cteditor-border cteditor-border-border",
|
|
88
|
+
role: "button",
|
|
89
|
+
tabIndex: 0,
|
|
90
|
+
"data-lexical-node-key": d,
|
|
91
|
+
children: [
|
|
92
|
+
/* @__PURE__ */ r("span", { className: "cteditor-flex-shrink-0 *:cteditor-size-5", children: C(t) }),
|
|
93
|
+
/* @__PURE__ */ r("span", { className: "cteditor-flex-1 cteditor-min-w-0 cteditor-text-sm cteditor-font-medium cteditor-text-foreground cteditor-truncate", children: t }),
|
|
94
|
+
/* @__PURE__ */ r(
|
|
95
|
+
"button",
|
|
96
|
+
{
|
|
97
|
+
type: "button",
|
|
98
|
+
onClick: f,
|
|
99
|
+
className: "cteditor-p-1 cteditor-rounded-md hover:cteditor-bg-accent cteditor-transition-colors cteditor-flex-shrink-0",
|
|
100
|
+
"aria-label": "Download file",
|
|
101
|
+
title: "Download file",
|
|
102
|
+
children: /* @__PURE__ */ r(k, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-muted-foreground" })
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
) : /* @__PURE__ */ p(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
className: "cteditor-inline-flex cteditor-flex-col cteditor-gap-2 cteditor-py-2 cteditor-px-2 cteditor-my-2 cteditor-border cteditor-border-border cteditor-rounded-lg cteditor-bg-background hover:cteditor-bg-accent/50 cteditor-transition-colors cteditor-cursor-pointer cteditor-max-w-[240px] cteditor-mr-1.5",
|
|
111
|
+
role: "button",
|
|
112
|
+
tabIndex: 0,
|
|
113
|
+
"data-lexical-node-key": d,
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ r("div", { className: "cteditor-w-full cteditor-aspect-[120/88] cteditor-rounded cteditor-overflow-hidden cteditor-bg-muted cteditor-flex cteditor-items-center cteditor-justify-center", children: U ? /* @__PURE__ */ r(
|
|
116
|
+
"img",
|
|
117
|
+
{
|
|
118
|
+
src: u,
|
|
119
|
+
alt: "",
|
|
120
|
+
className: "cteditor-w-full cteditor-h-full cteditor-object-cover"
|
|
121
|
+
}
|
|
122
|
+
) : /* @__PURE__ */ r("div", { className: "*:cteditor-size-8", children: C(t) }) }),
|
|
123
|
+
/* @__PURE__ */ p("div", { className: "cteditor-flex cteditor-items-start cteditor-gap-2 cteditor-w-full", children: [
|
|
124
|
+
/* @__PURE__ */ p("div", { className: "cteditor-flex-1 cteditor-min-w-0", children: [
|
|
125
|
+
/* @__PURE__ */ r("div", { className: "cteditor-font-medium cteditor-text-xs cteditor-text-foreground cteditor-truncate", children: t }),
|
|
126
|
+
c && /* @__PURE__ */ r("div", { className: "cteditor-text-xs cteditor-text-muted-foreground", children: R(c) })
|
|
127
|
+
] }),
|
|
128
|
+
/* @__PURE__ */ p("div", { className: "cteditor-flex cteditor-gap-1 cteditor-flex-shrink-0", children: [
|
|
129
|
+
/* @__PURE__ */ r(
|
|
130
|
+
"button",
|
|
131
|
+
{
|
|
132
|
+
onClick: f,
|
|
133
|
+
className: "cteditor-p-1 cteditor-rounded-md hover:cteditor-bg-accent cteditor-transition-colors",
|
|
134
|
+
"aria-label": "Download file",
|
|
135
|
+
title: "Download file",
|
|
136
|
+
children: /* @__PURE__ */ r(k, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-muted-foreground" })
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ r(
|
|
140
|
+
"button",
|
|
141
|
+
{
|
|
142
|
+
onClick: P,
|
|
143
|
+
className: "cteditor-p-1 cteditor-rounded-md hover:cteditor-bg-destructive hover:cteditor-text-destructive-foreground cteditor-transition-colors",
|
|
144
|
+
"aria-label": "Delete file",
|
|
145
|
+
title: "Delete file",
|
|
146
|
+
children: /* @__PURE__ */ r(I, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-muted-foreground" })
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
] })
|
|
150
|
+
] })
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
export {
|
|
156
|
+
H as default
|
|
157
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as a, K as r, M as t, N as s, O as o, P as d, Q as v, R as u, U as f, V as n, X as l, Y as w } from "./index-
|
|
1
|
+
import { J as a, K as r, M as t, N as s, O as o, P as d, Q as v, R as u, U as f, V as n, X as l, Y as w } from "./index-20I04v1t.js";
|
|
2
2
|
export {
|
|
3
3
|
a as ConfigurableEditor,
|
|
4
4
|
r as ConfigurableEditorWithAuth,
|
package/dist/nodes/FileNode.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { DecoratorNode, DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from '../../node_modules/lexical';
|
|
2
|
+
export type FileDisplayType = "card" | "inline";
|
|
2
3
|
export interface FilePayload {
|
|
3
4
|
src: string;
|
|
4
5
|
fileName: string;
|
|
5
6
|
fileSize?: number;
|
|
7
|
+
displayType?: FileDisplayType;
|
|
6
8
|
key?: NodeKey;
|
|
7
9
|
}
|
|
8
10
|
export type SerializedFileNode = Spread<{
|
|
9
11
|
src: string;
|
|
10
12
|
fileName: string;
|
|
11
13
|
fileSize?: number;
|
|
14
|
+
displayType?: FileDisplayType;
|
|
12
15
|
}, SerializedLexicalNode>;
|
|
13
16
|
export declare class FileNode extends DecoratorNode<JSX.Element> {
|
|
14
17
|
__src: string;
|
|
15
18
|
__fileName: string;
|
|
16
19
|
__fileSize?: number;
|
|
20
|
+
__displayType: FileDisplayType;
|
|
17
21
|
/** Optional first-page thumbnail (e.g. PDF); used in exportDOM for preview */
|
|
18
22
|
__previewDataUrl?: string;
|
|
19
23
|
static getType(): string;
|
|
@@ -22,8 +26,10 @@ export declare class FileNode extends DecoratorNode<JSX.Element> {
|
|
|
22
26
|
exportDOM(): DOMExportOutput;
|
|
23
27
|
private formatFileSize;
|
|
24
28
|
static importDOM(): DOMConversionMap | null;
|
|
25
|
-
constructor(src: string, fileName: string, fileSize?: number, key?: NodeKey);
|
|
29
|
+
constructor(src: string, fileName: string, fileSize?: number, displayType?: FileDisplayType, key?: NodeKey);
|
|
26
30
|
exportJSON(): SerializedFileNode;
|
|
31
|
+
getDisplayType(): FileDisplayType;
|
|
32
|
+
setDisplayType(displayType: FileDisplayType): void;
|
|
27
33
|
createDOM(config: EditorConfig): HTMLElement;
|
|
28
34
|
updateDOM(): false;
|
|
29
35
|
getSrc(): string;
|
|
@@ -32,5 +38,5 @@ export declare class FileNode extends DecoratorNode<JSX.Element> {
|
|
|
32
38
|
setPreviewDataUrl(url: string): void;
|
|
33
39
|
decorate(): JSX.Element;
|
|
34
40
|
}
|
|
35
|
-
export declare function $createFileNode({ src, fileName, fileSize, key, }: FilePayload): FileNode;
|
|
41
|
+
export declare function $createFileNode({ src, fileName, fileSize, displayType, key, }: FilePayload): FileNode;
|
|
36
42
|
export declare function $isFileNode(node: LexicalNode | null | undefined): node is FileNode;
|
package/dist/types.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export interface ToolbarProps {
|
|
|
37
37
|
enableHtmlViewToggle?: boolean;
|
|
38
38
|
enableNotePanels?: boolean;
|
|
39
39
|
enableAutocompleteToggle?: boolean;
|
|
40
|
+
enableInlineAutocompleteToggle?: boolean;
|
|
40
41
|
enableHeadings?: boolean;
|
|
41
42
|
enableLists?: boolean;
|
|
42
43
|
enableBlockquote?: boolean;
|
|
@@ -142,6 +143,7 @@ export interface EditorConfigTypes {
|
|
|
142
143
|
enableHtmlViewToggle: boolean;
|
|
143
144
|
enableNotePanels: boolean;
|
|
144
145
|
enableAutocompleteToggle: boolean;
|
|
146
|
+
enableInlineAutocompleteToggle?: boolean;
|
|
145
147
|
enableHeadings: boolean;
|
|
146
148
|
enableLists: boolean;
|
|
147
149
|
enableBlockquote: boolean;
|
package/package.json
CHANGED
package/dist/index-BTnX5edL.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { jsx as i, jsxs as p } from "react/jsx-runtime";
|
|
2
|
-
import { useLexicalComposerContext as U } from "@lexical/react/LexicalComposerContext";
|
|
3
|
-
import { $getNodeByKey as v } from "lexical";
|
|
4
|
-
import { useState as N, useEffect as y } from "react";
|
|
5
|
-
import { v as w, w as L, x as E, F as g, y as j, z as B } from "./index-BiGNE0nG.js";
|
|
6
|
-
function W(t, e) {
|
|
7
|
-
const l = t.split(".").pop()?.toLowerCase();
|
|
8
|
-
return l === "pdf" || e.startsWith("data:application/pdf") ? "pdf" : l === "docx" || e.startsWith("data:application/vnd.openxmlformats") && t.toLowerCase().endsWith(".docx") ? "docx" : l === "xlsx" || l === "xls" || e.startsWith("data:application/vnd.openxmlformats-officedocument.spreadsheetml") || e.startsWith("data:application/vnd.ms-excel") ? "xlsx" : null;
|
|
9
|
-
}
|
|
10
|
-
function $(t, e) {
|
|
11
|
-
const [l, d] = N(null);
|
|
12
|
-
return y(() => {
|
|
13
|
-
const s = t && e ? W(e, t) : null;
|
|
14
|
-
if (!t || !e || !s) {
|
|
15
|
-
d(null);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
let c = !1;
|
|
19
|
-
return s === "pdf" ? import("./generatePdfThumbnail-Be9_gTd2.js").then(({ generatePdfThumbnail: o }) => o(t)).then((o) => {
|
|
20
|
-
c || d(o);
|
|
21
|
-
}).catch(() => {
|
|
22
|
-
c || d(null);
|
|
23
|
-
}) : s === "docx" ? import("./generateDocxThumbnail-CuC4oE4q.js").then(({ generateDocxThumbnail: o }) => o(t)).then((o) => {
|
|
24
|
-
c || d(o);
|
|
25
|
-
}).catch(() => {
|
|
26
|
-
c || d(null);
|
|
27
|
-
}) : s === "xlsx" && import("./generateXlsxThumbnail-BHmQkbG6.js").then(({ generateXlsxThumbnail: o }) => o(t)).then((o) => {
|
|
28
|
-
c || d(o);
|
|
29
|
-
}).catch(() => {
|
|
30
|
-
c || d(null);
|
|
31
|
-
}), () => {
|
|
32
|
-
c = !0, d(null);
|
|
33
|
-
};
|
|
34
|
-
}, [t, e]), l;
|
|
35
|
-
}
|
|
36
|
-
const z = (t) => t ? t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : t < 1024 * 1024 * 1024 ? `${(t / (1024 * 1024)).toFixed(1)} MB` : `${(t / (1024 * 1024 * 1024)).toFixed(1)} GB` : "", k = (t) => {
|
|
37
|
-
const e = t.split(".");
|
|
38
|
-
return e.length > 1 ? e[e.length - 1].toLowerCase() : "";
|
|
39
|
-
}, b = (t) => {
|
|
40
|
-
const e = k(t);
|
|
41
|
-
return e === "pdf" || e === "docx" || e === "xlsx" || e === "xls";
|
|
42
|
-
}, R = (t) => {
|
|
43
|
-
const e = k(t);
|
|
44
|
-
return ["pdf", "doc", "docx", "txt", "odt"].includes(e) ? /* @__PURE__ */ i(g, { className: "cteditor-w-8 cteditor-h-8 cteditor-text-blue-500" }) : ["xls", "xlsx", "csv"].includes(e) ? /* @__PURE__ */ i(g, { className: "cteditor-w-8 cteditor-h-8 cteditor-text-green-600" }) : ["zip", "rar", "7z", "tar", "gz"].includes(e) ? /* @__PURE__ */ i(j, { className: "cteditor-w-8 cteditor-h-8 cteditor-text-orange-500" }) : /* @__PURE__ */ i(B, { className: "cteditor-w-8 cteditor-h-8 cteditor-text-gray-500" });
|
|
45
|
-
}, _ = ({ src: t, fileName: e, fileSize: l, nodeKey: d }) => {
|
|
46
|
-
const [s] = U(), c = $(b(e) ? t : void 0, e);
|
|
47
|
-
if (y(() => {
|
|
48
|
-
c && s.update(() => {
|
|
49
|
-
const n = v(d);
|
|
50
|
-
w(n) && n.setPreviewDataUrl(c);
|
|
51
|
-
});
|
|
52
|
-
}, [s, d, c]), !t || !e)
|
|
53
|
-
return console.error("FileView: Missing required props", { src: t, fileName: e, fileSize: l, nodeKey: d }), /* @__PURE__ */ i("div", { className: "cteditor-inline-flex cteditor-items-center cteditor-gap-3 cteditor-px-4 cteditor-py-3 cteditor-my-2 cteditor-border cteditor-border-destructive cteditor-rounded-lg cteditor-bg-destructive/10", children: /* @__PURE__ */ i("div", { className: "cteditor-text-sm cteditor-text-destructive", children: "Error loading file" }) });
|
|
54
|
-
const o = (n) => {
|
|
55
|
-
n.preventDefault(), n.stopPropagation();
|
|
56
|
-
try {
|
|
57
|
-
if (t.startsWith("data:")) {
|
|
58
|
-
const r = t.split(","), f = r[0].match(/:(.*?);/), D = f ? f[1] : "application/octet-stream", m = atob(r[1]);
|
|
59
|
-
let u = m.length;
|
|
60
|
-
const x = new Uint8Array(u);
|
|
61
|
-
for (; u--; )
|
|
62
|
-
x[u] = m.charCodeAt(u);
|
|
63
|
-
const P = new Blob([x], { type: D }), h = URL.createObjectURL(P), a = document.createElement("a");
|
|
64
|
-
a.href = h, a.download = e, a.style.display = "none", document.body.appendChild(a), a.click(), document.body.removeChild(a), setTimeout(() => URL.revokeObjectURL(h), 100);
|
|
65
|
-
} else {
|
|
66
|
-
const r = document.createElement("a");
|
|
67
|
-
r.href = t, r.download = e, r.style.display = "none", r.target = "_blank", document.body.appendChild(r), r.click(), document.body.removeChild(r);
|
|
68
|
-
}
|
|
69
|
-
} catch (r) {
|
|
70
|
-
console.error("Error downloading file:", r), window.open(t, "_blank");
|
|
71
|
-
}
|
|
72
|
-
}, F = (n) => {
|
|
73
|
-
n.preventDefault(), n.stopPropagation(), s.update(() => {
|
|
74
|
-
const r = v(d);
|
|
75
|
-
w(r) && r.remove();
|
|
76
|
-
});
|
|
77
|
-
}, C = b(e) && c;
|
|
78
|
-
return /* @__PURE__ */ p(
|
|
79
|
-
"div",
|
|
80
|
-
{
|
|
81
|
-
className: "cteditor-inline-flex cteditor-flex-col cteditor-gap-2 cteditor-py-2 cteditor-px-2 cteditor-my-2 cteditor-border cteditor-border-border cteditor-rounded-lg cteditor-bg-background hover:cteditor-bg-accent/50 cteditor-transition-colors cteditor-cursor-pointer cteditor-max-w-[240px]",
|
|
82
|
-
onClick: o,
|
|
83
|
-
role: "button",
|
|
84
|
-
tabIndex: 0,
|
|
85
|
-
onKeyDown: (n) => {
|
|
86
|
-
(n.key === "Enter" || n.key === " ") && (n.preventDefault(), o(n));
|
|
87
|
-
},
|
|
88
|
-
children: [
|
|
89
|
-
/* @__PURE__ */ i("div", { className: "cteditor-w-full cteditor-aspect-[120/88] cteditor-rounded cteditor-overflow-hidden cteditor-bg-muted cteditor-flex cteditor-items-center cteditor-justify-center", children: C ? /* @__PURE__ */ i(
|
|
90
|
-
"img",
|
|
91
|
-
{
|
|
92
|
-
src: c,
|
|
93
|
-
alt: "",
|
|
94
|
-
className: "cteditor-w-full cteditor-h-full cteditor-object-cover"
|
|
95
|
-
}
|
|
96
|
-
) : /* @__PURE__ */ i("div", { className: "*:cteditor-size-8", children: R(e) }) }),
|
|
97
|
-
/* @__PURE__ */ p("div", { className: "cteditor-flex cteditor-items-start cteditor-gap-2 cteditor-w-full", children: [
|
|
98
|
-
/* @__PURE__ */ p("div", { className: "cteditor-flex-1 cteditor-min-w-0", children: [
|
|
99
|
-
/* @__PURE__ */ i("div", { className: "cteditor-font-medium cteditor-text-xs cteditor-text-foreground cteditor-truncate", children: e }),
|
|
100
|
-
l && /* @__PURE__ */ i("div", { className: "cteditor-text-xs cteditor-text-muted-foreground", children: z(l) })
|
|
101
|
-
] }),
|
|
102
|
-
/* @__PURE__ */ p("div", { className: "cteditor-flex cteditor-gap-1 cteditor-flex-shrink-0", children: [
|
|
103
|
-
/* @__PURE__ */ i(
|
|
104
|
-
"button",
|
|
105
|
-
{
|
|
106
|
-
onClick: o,
|
|
107
|
-
className: "cteditor-p-1 cteditor-rounded-md hover:cteditor-bg-accent cteditor-transition-colors",
|
|
108
|
-
"aria-label": "Download file",
|
|
109
|
-
title: "Download file",
|
|
110
|
-
children: /* @__PURE__ */ i(L, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-muted-foreground" })
|
|
111
|
-
}
|
|
112
|
-
),
|
|
113
|
-
/* @__PURE__ */ i(
|
|
114
|
-
"button",
|
|
115
|
-
{
|
|
116
|
-
onClick: F,
|
|
117
|
-
className: "cteditor-p-1 cteditor-rounded-md hover:cteditor-bg-destructive hover:cteditor-text-destructive-foreground cteditor-transition-colors",
|
|
118
|
-
"aria-label": "Delete file",
|
|
119
|
-
title: "Delete file",
|
|
120
|
-
children: /* @__PURE__ */ i(E, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-muted-foreground" })
|
|
121
|
-
}
|
|
122
|
-
)
|
|
123
|
-
] })
|
|
124
|
-
] })
|
|
125
|
-
]
|
|
126
|
-
}
|
|
127
|
-
);
|
|
128
|
-
};
|
|
129
|
-
export {
|
|
130
|
-
_ as default
|
|
131
|
-
};
|