@haklex/rich-renderer-file 0.37.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.
@@ -0,0 +1,3 @@
1
+ import { FileRendererProps } from '@haklex/rich-editor/renderers';
2
+ export declare function FileEditRenderer(props: FileRendererProps): import("react").JSX.Element;
3
+ //# sourceMappingURL=FileEditRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileEditRenderer.d.ts","sourceRoot":"","sources":["../src/FileEditRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AA2BvE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,+BAQxD"}
@@ -0,0 +1,91 @@
1
+ import { fileMetaText } from "@haklex/rich-editor/renderers";
2
+ import { Download, Paperclip } from "lucide-react";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/styles.css.ts
5
+ var semanticClassNames = {
6
+ card: "rr-file-card",
7
+ cardIcon: "rr-file-card-icon",
8
+ cardMeta: "rr-file-card-meta",
9
+ cardName: "rr-file-card-name",
10
+ cardSub: "rr-file-card-sub",
11
+ cardAction: "rr-file-card-action",
12
+ cardProgress: "rr-file-card-progress",
13
+ cardProgressFill: "rr-file-card-progress-fill",
14
+ chip: "rr-file-chip",
15
+ chipIcon: "rr-file-chip-icon",
16
+ chipName: "rr-file-chip-name",
17
+ editTrigger: "rr-file-edit-trigger",
18
+ editPanel: "rr-file-edit-panel",
19
+ editField: "rr-file-edit-field",
20
+ editInput: "rr-file-edit-input",
21
+ editError: "rr-file-edit-error"
22
+ };
23
+ var card = "_1rf0wm60";
24
+ var cardIcon = "_1rf0wm62";
25
+ var cardMeta = "_1rf0wm63";
26
+ var cardName = "_1rf0wm64";
27
+ var cardSub = "_1rf0wm65";
28
+ var cardAction = "_1rf0wm66";
29
+ var cardProgress = "_1rf0wm67";
30
+ var cardProgressFill = "_1rf0wm68";
31
+ var cardError = "_1rf0wm69";
32
+ var cardErrorText = "_1rf0wm6a";
33
+ var chip = "_1rf0wm6b";
34
+ var chipIcon = "_1rf0wm6c";
35
+ var chipName = "_1rf0wm6d";
36
+ var editTrigger = "_1rf0wm6e";
37
+ var editTriggerInline = "_1rf0wm6f";
38
+ var editPanel = "_1rf0wm6g";
39
+ var editField = "_1rf0wm6h";
40
+ var editFieldIcon = "_1rf0wm6i";
41
+ var editInput = "_1rf0wm6j";
42
+ var editError = "_1rf0wm6k";
43
+ //#endregion
44
+ //#region src/FileRenderer.tsx
45
+ function FileChipContent({ name }) {
46
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Paperclip, { className: `${chipIcon} ${semanticClassNames.chipIcon}` }), /* @__PURE__ */ jsx("span", {
47
+ className: `${chipName} ${semanticClassNames.chipName}`,
48
+ children: name
49
+ })] });
50
+ }
51
+ function FileCardContent({ name, size, ext }) {
52
+ const meta = fileMetaText(name, size, ext);
53
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
54
+ /* @__PURE__ */ jsx(Paperclip, { className: `${cardIcon} ${semanticClassNames.cardIcon}` }),
55
+ /* @__PURE__ */ jsxs("span", {
56
+ className: `${cardMeta} ${semanticClassNames.cardMeta}`,
57
+ children: [/* @__PURE__ */ jsx("span", {
58
+ className: `${cardName} ${semanticClassNames.cardName}`,
59
+ children: name
60
+ }), meta && /* @__PURE__ */ jsx("span", {
61
+ className: `_1rf0wm65 ${semanticClassNames.cardSub}`,
62
+ children: meta
63
+ })]
64
+ }),
65
+ /* @__PURE__ */ jsx(Download, { className: `${cardAction} ${semanticClassNames.cardAction}` })
66
+ ] });
67
+ }
68
+ function FileRenderer({ src, name, size, ext, display }) {
69
+ if (display === "inline") return /* @__PURE__ */ jsx("a", {
70
+ className: `${chip} ${semanticClassNames.chip}`,
71
+ download: name,
72
+ href: src || void 0,
73
+ rel: "noopener noreferrer",
74
+ target: "_blank",
75
+ children: /* @__PURE__ */ jsx(FileChipContent, { name })
76
+ });
77
+ return /* @__PURE__ */ jsx("a", {
78
+ className: `${card} ${semanticClassNames.card}`,
79
+ download: name,
80
+ href: src || void 0,
81
+ rel: "noopener noreferrer",
82
+ target: "_blank",
83
+ children: /* @__PURE__ */ jsx(FileCardContent, {
84
+ ext,
85
+ name,
86
+ size
87
+ })
88
+ });
89
+ }
90
+ //#endregion
91
+ export { editInput as _, cardError as a, editTriggerInline as b, cardMeta as c, cardProgressFill as d, cardSub as f, editFieldIcon as g, editField as h, card as i, cardName as l, editError as m, FileChipContent as n, cardErrorText as o, chip as p, FileRenderer as r, cardIcon as s, FileCardContent as t, cardProgress as u, editPanel as v, semanticClassNames as x, editTrigger as y };
@@ -0,0 +1,11 @@
1
+ import { FileRendererProps } from '@haklex/rich-editor/renderers';
2
+ export declare function FileChipContent({ name }: {
3
+ name: string;
4
+ }): import("react").JSX.Element;
5
+ export declare function FileCardContent({ name, size, ext, }: {
6
+ ext?: string;
7
+ name: string;
8
+ size?: number;
9
+ }): import("react").JSX.Element;
10
+ export declare function FileRenderer({ src, name, size, ext, display }: FileRendererProps): import("react").JSX.Element;
11
+ //# sourceMappingURL=FileRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileRenderer.d.ts","sourceRoot":"","sources":["../src/FileRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAMvE,wBAAgB,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,+BAOzD;AAED,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,IAAI,EACJ,GAAG,GACJ,EAAE;IACD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,+BAcA;AAED,wBAAgB,YAAY,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,iBAAiB,+BA0BhF"}
@@ -0,0 +1,3 @@
1
+ export { FileEditRenderer } from './FileEditRenderer';
2
+ export { FileRenderer } from './FileRenderer';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.mjs ADDED
@@ -0,0 +1,263 @@
1
+ import { _ as editInput, a as cardError, b as editTriggerInline, c as cardMeta, d as cardProgressFill, f as cardSub, g as editFieldIcon, h as editField, i as card, l as cardName, n as FileChipContent, o as cardErrorText, p as chip, r as FileRenderer, s as cardIcon, t as FileCardContent, u as cardProgress, v as editPanel, x as semanticClassNames, y as editTrigger } from "./FileRenderer-uBZ1oNB_.js";
2
+ import { $createFileNode, $isFileNode, fileExtFromName } from "@haklex/rich-editor/nodes";
3
+ import { useFileUpload, useFileUploadEntry } from "@haklex/rich-editor/plugins";
4
+ import { fileMetaText } from "@haklex/rich-editor/renderers";
5
+ import { useRendererMode } from "@haklex/rich-editor/static";
6
+ import { ActionBar, ActionButton, Popover, PopoverPanel, PopoverTrigger } from "@haklex/rich-editor-ui";
7
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
8
+ import { $createParagraphNode, $getNodeByKey } from "lexical";
9
+ import { AlertCircle, Download, Link2, Paperclip, Pencil, Pilcrow, RefreshCw, Trash2 } from "lucide-react";
10
+ import { useCallback, useRef, useState } from "react";
11
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
+ //#region src/FileEditRenderer.tsx
13
+ function FileEditRenderer(props) {
14
+ if (useRendererMode() !== "editor" || !props.nodeKey) return /* @__PURE__ */ jsx(FileRenderer, { ...props });
15
+ return /* @__PURE__ */ jsx(FileEditRendererInner, {
16
+ ...props,
17
+ nodeKey: props.nodeKey
18
+ });
19
+ }
20
+ function FileEditRendererInner({ src, name, size, mimeType, ext, display, nodeKey }) {
21
+ const [editor] = useLexicalComposerContext();
22
+ const editable = editor.isEditable();
23
+ const fileUpload = useFileUpload();
24
+ const uploadEntry = useFileUploadEntry(editor, nodeKey);
25
+ const fileInputRef = useRef(null);
26
+ const [open, setOpen] = useState(false);
27
+ const [editName, setEditName] = useState(name);
28
+ const [replacing, setReplacing] = useState(false);
29
+ const [replacePercent, setReplacePercent] = useState(0);
30
+ const [replaceError, setReplaceError] = useState(null);
31
+ const commitName = useCallback(() => {
32
+ const trimmed = editName.trim();
33
+ if (!trimmed || trimmed === name) {
34
+ setEditName(name);
35
+ return;
36
+ }
37
+ editor.update(() => {
38
+ const node = $getNodeByKey(nodeKey);
39
+ if ($isFileNode(node)) node.setName(trimmed);
40
+ });
41
+ }, [
42
+ editor,
43
+ editName,
44
+ name,
45
+ nodeKey
46
+ ]);
47
+ const handleDelete = useCallback(() => {
48
+ editor.update(() => {
49
+ const node = $getNodeByKey(nodeKey);
50
+ if (node) node.remove();
51
+ });
52
+ setOpen(false);
53
+ }, [editor, nodeKey]);
54
+ const handleToggleDisplay = useCallback(() => {
55
+ editor.update(() => {
56
+ const node = $getNodeByKey(nodeKey);
57
+ if (!$isFileNode(node)) return;
58
+ const payload = node.getPayload();
59
+ const nextDisplay = payload.display === "inline" ? "block" : "inline";
60
+ const replacement = $createFileNode({
61
+ ...payload,
62
+ display: nextDisplay
63
+ });
64
+ if (nextDisplay === "inline") {
65
+ const paragraph = $createParagraphNode();
66
+ paragraph.append(replacement);
67
+ node.replace(paragraph);
68
+ } else {
69
+ node.getTopLevelElementOrThrow().insertAfter(replacement);
70
+ node.remove();
71
+ }
72
+ });
73
+ setOpen(false);
74
+ }, [editor, nodeKey]);
75
+ const handleCopyLink = useCallback(() => {
76
+ if (src) navigator.clipboard.writeText(src);
77
+ setOpen(false);
78
+ }, [src]);
79
+ const handleDownload = useCallback(() => {
80
+ if (!src) return;
81
+ const anchor = document.createElement("a");
82
+ anchor.href = src;
83
+ anchor.download = name;
84
+ anchor.rel = "noopener noreferrer";
85
+ anchor.target = "_blank";
86
+ anchor.click();
87
+ }, [src, name]);
88
+ const handleReplaceFile = useCallback(async (file) => {
89
+ if (!file || !fileUpload) return;
90
+ setReplacing(true);
91
+ setReplacePercent(0);
92
+ setReplaceError(null);
93
+ try {
94
+ const result = await fileUpload(file, { onProgress: (percent) => setReplacePercent(Math.round(percent)) });
95
+ editor.update(() => {
96
+ const node = $getNodeByKey(nodeKey);
97
+ if (!$isFileNode(node)) return;
98
+ node.setFilePayload({
99
+ src: result.src,
100
+ name: file.name,
101
+ size: file.size,
102
+ mimeType: file.type || void 0,
103
+ ext: fileExtFromName(file.name)
104
+ });
105
+ });
106
+ setEditName(file.name);
107
+ setOpen(false);
108
+ } catch (err) {
109
+ console.error("[FileEditRenderer]", err);
110
+ setReplaceError("Upload failed");
111
+ } finally {
112
+ setReplacing(false);
113
+ }
114
+ }, [
115
+ editor,
116
+ fileUpload,
117
+ nodeKey
118
+ ]);
119
+ if (!editable) return /* @__PURE__ */ jsx(FileRenderer, {
120
+ display,
121
+ ext,
122
+ mimeType,
123
+ name,
124
+ size,
125
+ src
126
+ });
127
+ if (uploadEntry) return /* @__PURE__ */ jsxs("span", {
128
+ className: `${card} ${uploadEntry.status === "error" ? cardError : ""} ${semanticClassNames.card}`,
129
+ children: [
130
+ uploadEntry.status === "error" ? /* @__PURE__ */ jsx(AlertCircle, {
131
+ className: `${cardIcon} ${cardErrorText}`,
132
+ size: 20
133
+ }) : /* @__PURE__ */ jsx(Paperclip, { className: cardIcon }),
134
+ /* @__PURE__ */ jsxs("span", {
135
+ className: `${cardMeta} ${semanticClassNames.cardMeta}`,
136
+ children: [/* @__PURE__ */ jsx("span", {
137
+ className: `${cardName} ${semanticClassNames.cardName}`,
138
+ children: name
139
+ }), uploadEntry.status === "error" ? /* @__PURE__ */ jsx("span", {
140
+ className: `${cardSub} ${cardErrorText}`,
141
+ children: uploadEntry.error ?? "Upload failed"
142
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
143
+ className: `${cardSub} ${semanticClassNames.cardSub}`,
144
+ children: [/* @__PURE__ */ jsx("span", { children: "Uploading..." }), /* @__PURE__ */ jsxs("span", { children: [uploadEntry.percent, "%"] })]
145
+ }), /* @__PURE__ */ jsx("span", {
146
+ className: `${cardProgress} ${semanticClassNames.cardProgress}`,
147
+ children: /* @__PURE__ */ jsx("span", {
148
+ className: `${cardProgressFill} ${semanticClassNames.cardProgressFill}`,
149
+ style: { width: `${uploadEntry.percent}%` }
150
+ })
151
+ })] })]
152
+ }),
153
+ uploadEntry.status === "error" && /* @__PURE__ */ jsxs(ActionBar, { children: [/* @__PURE__ */ jsxs(ActionButton, {
154
+ onClick: uploadEntry.retry,
155
+ children: [/* @__PURE__ */ jsx(RefreshCw, { size: 14 }), "Retry"]
156
+ }), /* @__PURE__ */ jsx(ActionButton, {
157
+ danger: true,
158
+ onClick: uploadEntry.remove,
159
+ children: "Remove"
160
+ })] })
161
+ ]
162
+ });
163
+ const isInline = display === "inline";
164
+ return /* @__PURE__ */ jsxs(Popover, {
165
+ open,
166
+ onOpenChange: (nextOpen) => {
167
+ setOpen(nextOpen);
168
+ if (nextOpen) {
169
+ setEditName(name);
170
+ setReplaceError(null);
171
+ } else commitName();
172
+ },
173
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
174
+ nativeButton: false,
175
+ render: isInline ? /* @__PURE__ */ jsx("span", { className: `${editTriggerInline} ${semanticClassNames.editTrigger}` }) : /* @__PURE__ */ jsx("div", { className: `${editTrigger} ${semanticClassNames.editTrigger}` }),
176
+ children: isInline ? /* @__PURE__ */ jsx("span", {
177
+ className: `${chip} ${semanticClassNames.chip}`,
178
+ children: /* @__PURE__ */ jsx(FileChipContent, { name })
179
+ }) : /* @__PURE__ */ jsx("span", {
180
+ className: `${card} ${semanticClassNames.card}`,
181
+ children: /* @__PURE__ */ jsx(FileCardContent, {
182
+ ext,
183
+ name,
184
+ size
185
+ })
186
+ })
187
+ }), /* @__PURE__ */ jsxs(PopoverPanel, {
188
+ className: `${editPanel} ${semanticClassNames.editPanel}`,
189
+ side: "bottom",
190
+ sideOffset: 8,
191
+ children: [
192
+ /* @__PURE__ */ jsxs("div", {
193
+ className: `${editField} ${semanticClassNames.editField}`,
194
+ children: [/* @__PURE__ */ jsx(Pencil, {
195
+ className: editFieldIcon,
196
+ size: 14
197
+ }), /* @__PURE__ */ jsx("input", {
198
+ className: `${editInput} ${semanticClassNames.editInput}`,
199
+ placeholder: "File name",
200
+ value: editName,
201
+ onBlur: commitName,
202
+ onChange: (e) => setEditName(e.target.value),
203
+ onKeyDown: (e) => {
204
+ if (e.key === "Enter") {
205
+ e.preventDefault();
206
+ commitName();
207
+ setOpen(false);
208
+ } else if (e.key === "Escape") {
209
+ e.preventDefault();
210
+ setEditName(name);
211
+ setOpen(false);
212
+ }
213
+ }
214
+ })]
215
+ }),
216
+ fileMetaText(name, size, ext) && /* @__PURE__ */ jsx("span", {
217
+ className: "_1rf0wm65",
218
+ children: fileMetaText(name, size, ext)
219
+ }),
220
+ replaceError && /* @__PURE__ */ jsx("span", {
221
+ className: `_1rf0wm6k ${semanticClassNames.editError}`,
222
+ children: replaceError
223
+ }),
224
+ /* @__PURE__ */ jsxs(ActionBar, { children: [
225
+ fileUpload && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("input", {
226
+ ref: fileInputRef,
227
+ style: { display: "none" },
228
+ type: "file",
229
+ onChange: (e) => {
230
+ handleReplaceFile(e.currentTarget.files?.[0] ?? null);
231
+ e.currentTarget.value = "";
232
+ }
233
+ }), /* @__PURE__ */ jsxs(ActionButton, {
234
+ disabled: replacing,
235
+ onClick: () => fileInputRef.current?.click(),
236
+ children: [/* @__PURE__ */ jsx(RefreshCw, { size: 14 }), replacing ? `Uploading ${replacePercent}%` : "Replace"]
237
+ })] }),
238
+ /* @__PURE__ */ jsxs(ActionButton, {
239
+ onClick: handleToggleDisplay,
240
+ children: [/* @__PURE__ */ jsx(Pilcrow, { size: 14 }), isInline ? "To block" : "To inline"]
241
+ }),
242
+ /* @__PURE__ */ jsxs(ActionButton, {
243
+ disabled: !src,
244
+ onClick: handleCopyLink,
245
+ children: [/* @__PURE__ */ jsx(Link2, { size: 14 }), "Copy link"]
246
+ }),
247
+ /* @__PURE__ */ jsx(ActionButton, {
248
+ disabled: !src,
249
+ onClick: handleDownload,
250
+ children: /* @__PURE__ */ jsx(Download, { size: 14 })
251
+ }),
252
+ /* @__PURE__ */ jsx(ActionButton, {
253
+ danger: true,
254
+ onClick: handleDelete,
255
+ children: /* @__PURE__ */ jsx(Trash2, { size: 14 })
256
+ })
257
+ ] })
258
+ ]
259
+ })]
260
+ });
261
+ }
262
+ //#endregion
263
+ export { FileEditRenderer, FileRenderer };
@@ -0,0 +1,2 @@
1
+ :root{--rc-text:#000;--rc-text-secondary:#262626;--rc-text-tertiary:#737373;--rc-text-quaternary:#a3a3a3;--rc-bg:#fff;--rc-bg-secondary:#fafafa;--rc-bg-tertiary:#f5f5f5;--rc-fill:#e8e8e8;--rc-fill-secondary:#eee;--rc-fill-tertiary:#f5f5f5;--rc-fill-quaternary:#fafafa;--rc-border:#f5f5f5;--rc-accent:#2563eb;--rc-accent-light:#2563eb20;--rc-link:#2563eb;--rc-code-text:#404040;--rc-code-bg:#f5f5f5;--rc-hr-border:#e5e5e5;--rc-quote-border:#2563eb;--rc-quote-bg:#f5f5f5;--rc-alert-info:#006bb7;--rc-alert-warning:#c50;--rc-alert-tip:#1c0;--rc-alert-caution:#c01;--rc-alert-important:#50c;--rc-max-width:700px;--rc-shadow-top-bar:0 8px 30px #0000001f, 0 2px 8px #0000000f;--rc-shadow-modal:0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a;--rc-shadow-menu:0 1px 4px #0000000a, 0 4px 16px #00000014;--rc-space-xs:4px;--rc-space-sm:8px;--rc-space-md:16px;--rc-space-lg:24px;--rc-space-xl:32px;--rc-font-family-sans:"PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif:"Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-family-kai:"楷体", KaiTi, STKaiti, "Kaiti SC", "LXGW WenKai", "霞鹜文楷", "Noto Serif CJK SC", serif;--rc-font-mono:"SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs:.625em;--rc-font-size-xs:.75em;--rc-font-size-sm:.8125em;--rc-font-size-md:.875em;--rc-font-size-lg:1.25em;--rc-font-size-base:16px;--rc-font-size-small:14px;--rc-line-height:1.7;--rc-line-height-tight:1.4;--rc-font-family:"PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-radius-sm:4px;--rc-radius-md:8px;--rc-radius-lg:12px}:root.dark,[data-theme=dark]{--rc-text:#fafafa;--rc-text-secondary:#a3a3a3;--rc-text-tertiary:#737373;--rc-text-quaternary:#525252;--rc-bg:#0a0a0a;--rc-bg-secondary:#171717;--rc-bg-tertiary:#262626;--rc-fill:#2a2a2a;--rc-fill-secondary:#222;--rc-fill-tertiary:#1a1a1a;--rc-fill-quaternary:#141414;--rc-border:#262626;--rc-accent:#60a5fa;--rc-accent-light:#60a5fa20;--rc-link:#60a5fa;--rc-code-text:#d4d4d4;--rc-code-bg:#262626;--rc-hr-border:#262626;--rc-quote-border:#60a5fa;--rc-quote-bg:#262626;--rc-alert-info:#7db9e5;--rc-alert-warning:#da864a;--rc-alert-tip:#54da48;--rc-alert-caution:#e16973;--rc-alert-important:#9966e0;--rc-shadow-top-bar:0 8px 30px #00000073, 0 2px 8px #0000004d;--rc-shadow-modal:0 10px 15px -3px #0006, 0 4px 6px -4px #00000059;--rc-shadow-menu:0 1px 4px #00000040, 0 4px 16px #0006}.xa3az60{--rc-text:#000;--rc-text-secondary:#262626;--rc-text-tertiary:#737373;--rc-text-quaternary:#a3a3a3;--rc-bg:#fff;--rc-bg-secondary:#fafafa;--rc-bg-tertiary:#f5f5f5;--rc-fill:#e8e8e8;--rc-fill-secondary:#eee;--rc-fill-tertiary:#f5f5f5;--rc-fill-quaternary:#fafafa;--rc-border:#f5f5f5;--rc-accent:#2563eb;--rc-accent-light:#2563eb20;--rc-link:#2563eb;--rc-code-text:#404040;--rc-code-bg:#f5f5f5;--rc-hr-border:#e5e5e5;--rc-quote-border:#2563eb;--rc-quote-bg:#f5f5f5;--rc-alert-info:#006bb7;--rc-alert-warning:#c50;--rc-alert-tip:#1c0;--rc-alert-caution:#c01;--rc-alert-important:#50c;--rc-max-width:700px;--rc-shadow-top-bar:0 8px 30px #0000001f, 0 2px 8px #0000000f;--rc-shadow-modal:0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a;--rc-shadow-menu:0 1px 4px #0000000a, 0 4px 16px #00000014;--rc-space-xs:4px;--rc-space-sm:8px;--rc-space-md:16px;--rc-space-lg:24px;--rc-space-xl:32px;--rc-font-family-sans:"PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif:"Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-family-kai:"楷体", KaiTi, STKaiti, "Kaiti SC", "LXGW WenKai", "霞鹜文楷", "Noto Serif CJK SC", serif;--rc-font-mono:"SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs:.625em;--rc-font-size-xs:.75em;--rc-font-size-sm:.8125em;--rc-font-size-md:.875em;--rc-font-size-lg:1.25em;--rc-font-size-base:16px;--rc-font-size-small:14px;--rc-line-height:1.7;--rc-line-height-tight:1.4;--rc-font-family:"PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-radius-sm:4px;--rc-radius-md:8px;--rc-radius-lg:12px}.xa3az61{--rc-text:#000;--rc-text-secondary:#262626;--rc-text-tertiary:#737373;--rc-text-quaternary:#a3a3a3;--rc-bg:#fff;--rc-bg-secondary:#fafafa;--rc-bg-tertiary:#f5f5f5;--rc-fill:#e8e8e8;--rc-fill-secondary:#eee;--rc-fill-tertiary:#f5f5f5;--rc-fill-quaternary:#fafafa;--rc-border:#f5f5f5;--rc-accent:#2563eb;--rc-accent-light:#2563eb20;--rc-link:#2563eb;--rc-code-text:#404040;--rc-code-bg:#f5f5f5;--rc-hr-border:#e5e5e5;--rc-quote-border:#2563eb;--rc-quote-bg:#f5f5f5;--rc-alert-info:#006bb7;--rc-alert-warning:#c50;--rc-alert-tip:#1c0;--rc-alert-caution:#c01;--rc-alert-important:#50c;--rc-max-width:700px;--rc-shadow-top-bar:0 8px 30px #0000001f, 0 2px 8px #0000000f;--rc-shadow-modal:0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a;--rc-shadow-menu:0 1px 4px #0000000a, 0 4px 16px #00000014;--rc-space-xs:4px;--rc-space-sm:8px;--rc-space-md:16px;--rc-space-lg:24px;--rc-space-xl:32px;--rc-font-family-sans:"PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif:"Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-family-kai:"楷体", KaiTi, STKaiti, "Kaiti SC", "LXGW WenKai", "霞鹜文楷", "Noto Serif CJK SC", serif;--rc-font-mono:"SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs:.625em;--rc-font-size-xs:.75em;--rc-font-size-sm:.8125em;--rc-font-size-md:.875em;--rc-font-size-lg:1.25em;--rc-font-size-base:16px;--rc-font-size-small:14px;--rc-line-height:1.8;--rc-line-height-tight:1.4;--rc-font-family:"Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-radius-sm:4px;--rc-radius-md:8px;--rc-radius-lg:12px}.xa3az62{--rc-text:#000;--rc-text-secondary:#262626;--rc-text-tertiary:#737373;--rc-text-quaternary:#a3a3a3;--rc-bg:#fff;--rc-bg-secondary:#fafafa;--rc-bg-tertiary:#f5f5f5;--rc-fill:#e8e8e8;--rc-fill-secondary:#eee;--rc-fill-tertiary:#f5f5f5;--rc-fill-quaternary:#fafafa;--rc-border:#f5f5f5;--rc-accent:#2563eb;--rc-accent-light:#2563eb20;--rc-link:#2563eb;--rc-code-text:#404040;--rc-code-bg:#f5f5f5;--rc-hr-border:#e5e5e5;--rc-quote-border:#a3a3a3;--rc-quote-bg:#fafafa;--rc-alert-info:#006bb7;--rc-alert-warning:#c50;--rc-alert-tip:#1c0;--rc-alert-caution:#c01;--rc-alert-important:#50c;--rc-max-width:none;--rc-shadow-top-bar:0 8px 30px #0000001f, 0 2px 8px #0000000f;--rc-shadow-modal:0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a;--rc-shadow-menu:0 1px 4px #0000000a, 0 4px 16px #00000014;--rc-space-xs:2px;--rc-space-sm:4px;--rc-space-md:10px;--rc-space-lg:16px;--rc-space-xl:20px;--rc-font-family-sans:"PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-font-family-serif:"Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif;--rc-font-family-kai:"楷体", KaiTi, STKaiti, "Kaiti SC", "LXGW WenKai", "霞鹜文楷", "Noto Serif CJK SC", serif;--rc-font-mono:"SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;--rc-font-size-2xs:.625em;--rc-font-size-xs:.75em;--rc-font-size-sm:.8125em;--rc-font-size-md:.875em;--rc-font-size-lg:1.25em;--rc-font-size-base:14px;--rc-font-size-small:12px;--rc-line-height:1.5;--rc-line-height-tight:1.3;--rc-font-family:"PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji;--rc-radius-sm:3px;--rc-radius-md:6px;--rc-radius-lg:12px}.dark .xa3az60,[data-theme=dark] .xa3az60,.dark.xa3az60,[data-theme=dark].xa3az60,.dark .xa3az61,[data-theme=dark] .xa3az61,.dark.xa3az61,[data-theme=dark].xa3az61,.dark .xa3az62,[data-theme=dark] .xa3az62,.dark.xa3az62,[data-theme=dark].xa3az62{--rc-text:#fafafa;--rc-text-secondary:#a3a3a3;--rc-text-tertiary:#737373;--rc-text-quaternary:#525252;--rc-bg:#0a0a0a;--rc-bg-secondary:#171717;--rc-bg-tertiary:#262626;--rc-fill:#2a2a2a;--rc-fill-secondary:#222;--rc-fill-tertiary:#1a1a1a;--rc-fill-quaternary:#141414;--rc-border:#262626;--rc-accent:#60a5fa;--rc-accent-light:#60a5fa20;--rc-link:#60a5fa;--rc-code-text:#d4d4d4;--rc-code-bg:#262626;--rc-hr-border:#262626;--rc-quote-border:#60a5fa;--rc-quote-bg:#262626;--rc-alert-info:#7db9e5;--rc-alert-warning:#da864a;--rc-alert-tip:#54da48;--rc-alert-caution:#e16973;--rc-alert-important:#9966e0;--rc-shadow-top-bar:0 8px 30px #00000073, 0 2px 8px #0000004d;--rc-shadow-modal:0 10px 15px -3px #0006, 0 4px 6px -4px #00000059;--rc-shadow-menu:0 1px 4px #00000040, 0 4px 16px #0006}._1rf0wm60{box-sizing:border-box;border:1px solid var(--rc-border);background:var(--rc-bg);width:100%;max-width:35rem;color:var(--rc-text);font-family:var(--rc-font-family-sans);border-radius:.5rem;align-items:center;gap:.75rem;margin:1rem 0;padding:.75rem 1rem;text-decoration:none;transition:border-color .15s,background-color .15s;display:flex}a._1rf0wm60:hover{border-color:color-mix(in srgb, var(--rc-border), var(--rc-text) 25%);background-color:var(--rc-fill-tertiary)}._1rf0wm62{width:1.25rem;height:1.25rem;color:var(--rc-text-tertiary);flex:none}._1rf0wm63{flex-direction:column;flex:1;gap:.125rem;min-width:0;display:flex}._1rf0wm64{white-space:nowrap;text-overflow:ellipsis;font-size:.875rem;font-weight:500;line-height:1.4;display:block;overflow:hidden}._1rf0wm65{color:var(--rc-text-tertiary);font-variant-numeric:tabular-nums;justify-content:space-between;gap:.75rem;font-size:.75rem;line-height:1.4;display:flex}._1rf0wm66{width:1rem;height:1rem;color:var(--rc-text-quaternary);flex:none}._1rf0wm60:hover ._1rf0wm66{color:var(--rc-text)}._1rf0wm67{background:var(--rc-fill-secondary);border-radius:2px;height:3px;margin-top:.25rem;overflow:hidden}._1rf0wm68{background:var(--rc-text);border-radius:2px;height:100%;transition:width .2s;display:block}._1rf0wm69{background:#ef44440f;border-color:#fecaca}._1rf0wm6a{color:#b91c1c}._1rf0wm6b{box-sizing:border-box;border:1px solid var(--rc-border);background:var(--rc-bg);max-width:16.25rem;color:var(--rc-text);vertical-align:baseline;border-radius:.3125rem;align-items:center;gap:.25rem;padding:0 .4375rem 0 .3125rem;font-size:.85em;font-weight:500;line-height:1.35;text-decoration:none;transition:border-color .15s,background-color .15s;display:inline-flex}a._1rf0wm6b:hover{border-color:color-mix(in srgb, var(--rc-border), var(--rc-text) 25%);background-color:var(--rc-fill-tertiary)}._1rf0wm6c{width:.8125rem;height:.8125rem;color:var(--rc-text-tertiary);flex:none}._1rf0wm6d{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}._1rf0wm6e{cursor:pointer;display:block}._1rf0wm6f{cursor:pointer;display:inline-block}._1rf0wm6g{flex-direction:column;gap:.5rem;display:flex}._1rf0wm6g._1rf0wm6g{width:max-content;min-width:18rem;max-width:min(26rem,92vw)}._1rf0wm6h{align-items:center;gap:.5rem;display:flex}._1rf0wm6i{color:var(--rc-text-tertiary);flex:none}._1rf0wm6j{border:1px solid var(--rc-border);background:var(--rc-bg);min-width:0;color:var(--rc-text);border-radius:.375rem;outline:none;flex:1;padding:.375rem .5rem;font-family:inherit;font-size:.8125rem}._1rf0wm6j:focus{border-color:color-mix(in srgb, var(--rc-border), var(--rc-text) 25%)}._1rf0wm6k{color:#b91c1c;font-size:.75rem}
2
+ /*$vite$:1*/
@@ -0,0 +1,2 @@
1
+ export { FileRenderer } from './FileRenderer';
2
+ //# sourceMappingURL=static.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../src/static.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { r as FileRenderer } from "./FileRenderer-uBZ1oNB_.js";
2
+ export { FileRenderer };
@@ -0,0 +1,40 @@
1
+ export declare const semanticClassNames: {
2
+ readonly card: "rr-file-card";
3
+ readonly cardIcon: "rr-file-card-icon";
4
+ readonly cardMeta: "rr-file-card-meta";
5
+ readonly cardName: "rr-file-card-name";
6
+ readonly cardSub: "rr-file-card-sub";
7
+ readonly cardAction: "rr-file-card-action";
8
+ readonly cardProgress: "rr-file-card-progress";
9
+ readonly cardProgressFill: "rr-file-card-progress-fill";
10
+ readonly chip: "rr-file-chip";
11
+ readonly chipIcon: "rr-file-chip-icon";
12
+ readonly chipName: "rr-file-chip-name";
13
+ readonly editTrigger: "rr-file-edit-trigger";
14
+ readonly editPanel: "rr-file-edit-panel";
15
+ readonly editField: "rr-file-edit-field";
16
+ readonly editInput: "rr-file-edit-input";
17
+ readonly editError: "rr-file-edit-error";
18
+ };
19
+ export declare const card: string;
20
+ export declare const cardStatic: string;
21
+ export declare const cardIcon: string;
22
+ export declare const cardMeta: string;
23
+ export declare const cardName: string;
24
+ export declare const cardSub: string;
25
+ export declare const cardAction: string;
26
+ export declare const cardProgress: string;
27
+ export declare const cardProgressFill: string;
28
+ export declare const cardError: string;
29
+ export declare const cardErrorText: string;
30
+ export declare const chip: string;
31
+ export declare const chipIcon: string;
32
+ export declare const chipName: string;
33
+ export declare const editTrigger: string;
34
+ export declare const editTriggerInline: string;
35
+ export declare const editPanel: string;
36
+ export declare const editField: string;
37
+ export declare const editFieldIcon: string;
38
+ export declare const editInput: string;
39
+ export declare const editError: string;
40
+ //# sourceMappingURL=styles.css.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.css.d.ts","sourceRoot":"","sources":["../src/styles.css.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;CAiBrB,CAAC;AAIX,eAAO,MAAM,IAAI,QAsBf,CAAC;AAEH,eAAO,MAAM,UAAU,QAAY,CAAC;AAEpC,eAAO,MAAM,QAAQ,QAKnB,CAAC;AAEH,eAAO,MAAM,QAAQ,QAMnB,CAAC;AAEH,eAAO,MAAM,QAAQ,QAQnB,CAAC;AAEH,eAAO,MAAM,OAAO,QAQlB,CAAC;AAEH,eAAO,MAAM,UAAU,QAUrB,CAAC;AAEH,eAAO,MAAM,YAAY,QAMvB,CAAC;AAEH,eAAO,MAAM,gBAAgB,QAM3B,CAAC;AAEH,eAAO,MAAM,SAAS,QAGpB,CAAC;AAEH,eAAO,MAAM,aAAa,QAExB,CAAC;AAEH,eAAO,MAAM,IAAI,QAuBf,CAAC;AAEH,eAAO,MAAM,QAAQ,QAKnB,CAAC;AAEH,eAAO,MAAM,QAAQ,QAInB,CAAC;AAEH,eAAO,MAAM,WAAW,QAGtB,CAAC;AAEH,eAAO,MAAM,iBAAiB,QAG5B,CAAC;AAEH,eAAO,MAAM,SAAS,QAWpB,CAAC;AAEH,eAAO,MAAM,SAAS,QAIpB,CAAC;AAEH,eAAO,MAAM,aAAa,QAGxB,CAAC;AAEH,eAAO,MAAM,SAAS,QAcpB,CAAC;AAEH,eAAO,MAAM,SAAS,QAGpB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@haklex/rich-renderer-file",
3
+ "version": "0.37.0",
4
+ "description": "File attachment renderer",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/Innei/haklex.git",
8
+ "directory": "packages/rich-renderer-file"
9
+ },
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.mjs",
15
+ "types": "./dist/index.d.ts"
16
+ },
17
+ "./static": {
18
+ "import": "./dist/static.mjs",
19
+ "types": "./dist/static.d.ts"
20
+ },
21
+ "./style.css": "./dist/rich-renderer-file.css"
22
+ },
23
+ "main": "./dist/index.mjs",
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "devDependencies": {
28
+ "@base-ui/react": "^1.7.0",
29
+ "@lexical/react": "^0.49.0",
30
+ "@types/react": "^19.2.18",
31
+ "@types/react-dom": "^19.2.4",
32
+ "@vanilla-extract/css": "^1.21.2",
33
+ "@vanilla-extract/vite-plugin": "^5.2.6",
34
+ "lexical": "^0.49.0",
35
+ "react": "^19.2.8",
36
+ "react-dom": "^19.2.8",
37
+ "typescript": "^7.0.2",
38
+ "unplugin-dts": "^1.0.3",
39
+ "vite": "^8.2.2"
40
+ },
41
+ "peerDependencies": {
42
+ "@base-ui/react": ">=1.5.0",
43
+ "@lexical/react": "^0.49.0",
44
+ "lexical": "^0.49.0",
45
+ "lucide-react": "^1.0.0",
46
+ "react": ">=19",
47
+ "react-dom": ">=19",
48
+ "@haklex/rich-editor": "^0.37.0",
49
+ "@haklex/rich-editor-ui": "^0.37.0",
50
+ "@haklex/rich-style-token": "^0.37.0"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "scripts": {
56
+ "build": "vite build",
57
+ "dev:build": "vite build --watch"
58
+ },
59
+ "types": "./dist/index.d.ts"
60
+ }