@epam/ai-dial-attachment-canvas 1.1.16 → 1.1.18
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/{LazyContentBoundary-tNE1ExbI.js → LazyContentBoundary-Df8cBJYi.js} +2 -3
- package/{PdfContent-BoAtghsO.js → PdfContent-DbeinXjr.js} +86 -87
- package/{attachment-canvas-BgwyzrRC.js → attachment-canvas-BNS10ZnJ.js} +1 -2
- package/index.js +21 -26
- package/{ooxml-highlight-surfaces-BzgOKpBV.js → ooxml-highlight-surfaces-wb4asEn3.js} +8 -17
- package/package.json +3 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./attachment-canvas-
|
|
1
|
+
import { n as e, r as t, t as n } from "./attachment-canvas-BNS10ZnJ.js";
|
|
2
2
|
import { MIMEType as r, ensureDownloadFilename as i, mergeClasses as a, triggerAnchorDownload as o, triggerBlobDownload as s } from "@epam/ai-dial-chat-shared";
|
|
3
3
|
import { Button as c, Spinner as l } from "@epam/ai-dial-ui-kit";
|
|
4
4
|
import { Component as u, Suspense as d } from "react";
|
|
5
5
|
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
6
|
-
|
|
6
|
+
// src/utils/download.ts
|
|
7
7
|
var m = {
|
|
8
8
|
[t.Docx]: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
9
9
|
[t.Xlsx]: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
@@ -163,5 +163,4 @@ var m = {
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
|
-
//#endregion
|
|
167
166
|
export { g as a, v as i, b as n, h as o, y as r, x as t };
|
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
import "./PdfContent.css";
|
|
2
|
-
import { a as e, n as t, r as n } from "./LazyContentBoundary-
|
|
2
|
+
import { a as e, n as t, r as n } from "./LazyContentBoundary-Df8cBJYi.js";
|
|
3
3
|
import { mergeClasses as r } from "@epam/ai-dial-chat-shared";
|
|
4
4
|
import { DIAL_ICON_SIZE as i, DIAL_KIT_ICON_STROKE as a, Dropdown as o, ElementSize as s, FabButton as c, Input as ee } from "@epam/ai-dial-ui-kit";
|
|
5
|
-
import { IconMenu2 as te, IconX as
|
|
6
|
-
import { useCallback as
|
|
7
|
-
import { jsx as
|
|
8
|
-
import { DocumentPreview as
|
|
9
|
-
var
|
|
5
|
+
import { IconMenu2 as te, IconX as l } from "@tabler/icons-react";
|
|
6
|
+
import { useCallback as u, useEffect as d, useId as ne, useRef as f, useState as p } from "react";
|
|
7
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
8
|
+
import { DocumentPreview as re, PageThumbnail as g } from "@epam/ai-dial-react-pdf-highlighter";
|
|
9
|
+
var ie = { viewer: "_viewer_1gfxm_1" }, _ = null, ae = (e) => (_ ||= new Promise((t, n) => {
|
|
10
10
|
try {
|
|
11
11
|
t(e());
|
|
12
12
|
} catch (e) {
|
|
13
13
|
n(e);
|
|
14
14
|
}
|
|
15
15
|
}).catch((e) => {
|
|
16
|
-
throw
|
|
17
|
-
}),
|
|
18
|
-
let [
|
|
19
|
-
|
|
20
|
-
if (!
|
|
21
|
-
|
|
16
|
+
throw _ = null, e;
|
|
17
|
+
}), _), oe = 15, v = 3, se = 172, ce = 400, y = 150, le = 60, b = ({ url: _, highlights: b, selectedHighlightId: x, selectedPageNumber: S, loadPdf: ue, configurePdfWorker: C, hideHeader: de = !1, labels: { thumbnailsLabel: fe = "Thumbnails", showThumbnailsLabel: pe = "Show thumbnails", hideThumbnailsLabel: me = "Hide thumbnails", pageNumberLabel: he = "Page number", loadingLabel: ge = "Loading…", errorLabel: _e = "Failed to load content", retryLabel: ve = "Retry" } = {} }) => {
|
|
18
|
+
let [w, T] = p(() => C ? "preparing" : "ready"), [ye, be] = p(0);
|
|
19
|
+
d(() => {
|
|
20
|
+
if (!C) return;
|
|
21
|
+
T("preparing");
|
|
22
22
|
let e = !1;
|
|
23
|
-
return
|
|
24
|
-
e ||
|
|
23
|
+
return ae(C).then(() => {
|
|
24
|
+
e || T("ready");
|
|
25
25
|
}).catch(() => {
|
|
26
|
-
e ||
|
|
26
|
+
e || T("error");
|
|
27
27
|
}), () => {
|
|
28
28
|
e = !0;
|
|
29
29
|
};
|
|
30
|
-
}, [
|
|
31
|
-
let xe =
|
|
30
|
+
}, [C, ye]);
|
|
31
|
+
let xe = u(() => {
|
|
32
32
|
be((e) => e + 1);
|
|
33
|
-
}, []), E =
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
N(
|
|
33
|
+
}, []), E = ne(), [D, Se] = p(0), [O, k] = p(/* @__PURE__ */ new Map()), [A, j] = p(!1), [M, N] = p(() => S ?? (x ? b.find((e) => e.id === x)?.bboxes[0]?.page ?? 1 : 1)), P = f(null), F = f(null), [Ce, I] = p([]), [L, we] = p(se), [R, z] = p(ce), [Te, B] = p(0), V = f(!1), H = f(0), U = f(null);
|
|
34
|
+
d(() => {
|
|
35
|
+
if (S != null) {
|
|
36
|
+
N(S);
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
if (!
|
|
40
|
-
let e =
|
|
39
|
+
if (!x) return;
|
|
40
|
+
let e = b.find((e) => e.id === x)?.bboxes[0]?.page;
|
|
41
41
|
e != null && N(e);
|
|
42
42
|
}, [
|
|
43
|
+
S,
|
|
43
44
|
x,
|
|
44
|
-
b
|
|
45
|
-
|
|
46
|
-
]), u(() => {
|
|
45
|
+
b
|
|
46
|
+
]), d(() => {
|
|
47
47
|
let e = F.current;
|
|
48
48
|
if (!A || !e) return;
|
|
49
49
|
let t = new ResizeObserver((e) => {
|
|
50
50
|
let t = e[0]?.contentRect.height;
|
|
51
|
-
t &&
|
|
51
|
+
t && z(t);
|
|
52
52
|
});
|
|
53
53
|
return t.observe(e), () => t.disconnect();
|
|
54
54
|
}, [A]);
|
|
55
|
-
let Ee =
|
|
55
|
+
let Ee = u((e) => {
|
|
56
56
|
if (!e || V.current) return;
|
|
57
57
|
let t = e.getBoundingClientRect().height;
|
|
58
58
|
t > 0 && (V.current = !0, we(t));
|
|
59
|
-
}, []), De =
|
|
59
|
+
}, []), De = u((e) => {
|
|
60
60
|
H.current = e.currentTarget.scrollTop, U.current ??= requestAnimationFrame(() => {
|
|
61
61
|
U.current = null, B(H.current);
|
|
62
62
|
});
|
|
63
63
|
}, []);
|
|
64
|
-
|
|
64
|
+
d(() => () => {
|
|
65
65
|
U.current != null && cancelAnimationFrame(U.current);
|
|
66
66
|
}, []);
|
|
67
|
-
let W =
|
|
67
|
+
let W = u((e) => {
|
|
68
68
|
if (D === 0) return;
|
|
69
69
|
let t = Math.max(0, (M - 1) * L - e.clientHeight / 2 + L / 2);
|
|
70
70
|
H.current = t, B(t), e.scrollTop = t;
|
|
@@ -72,19 +72,19 @@ var oe = { viewer: "_viewer_1gfxm_1" }, h = null, g = (e) => (h ||= new Promise(
|
|
|
72
72
|
M,
|
|
73
73
|
D,
|
|
74
74
|
L
|
|
75
|
-
]), Oe =
|
|
75
|
+
]), Oe = u((e) => {
|
|
76
76
|
F.current = e, e && W(e);
|
|
77
77
|
}, [W]);
|
|
78
|
-
|
|
78
|
+
d(() => {
|
|
79
79
|
let e = F.current;
|
|
80
80
|
e && W(e);
|
|
81
81
|
}, [W]);
|
|
82
|
-
let G = Math.max(0, Math.floor(
|
|
83
|
-
|
|
82
|
+
let G = Math.max(0, Math.floor(Te / L) - v), ke = Math.ceil(R / L) + 6, K = Math.min(D - 1, G + ke);
|
|
83
|
+
d(() => {
|
|
84
84
|
if (D === 0) return;
|
|
85
|
-
let e = Math.min(D,
|
|
85
|
+
let e = Math.min(D, oe);
|
|
86
86
|
I(Array.from({ length: e }, (e, t) => t + 1));
|
|
87
|
-
}, [D]),
|
|
87
|
+
}, [D]), d(() => {
|
|
88
88
|
if (!A || D === 0) return;
|
|
89
89
|
let e = setTimeout(() => {
|
|
90
90
|
I((e) => {
|
|
@@ -92,23 +92,23 @@ var oe = { viewer: "_viewer_1gfxm_1" }, h = null, g = (e) => (h ||= new Promise(
|
|
|
92
92
|
for (let e = G + 1; e <= K + 1; e++) t.has(e) || (t.add(e), n = !0);
|
|
93
93
|
return n ? Array.from(t).sort((e, t) => e - t) : e;
|
|
94
94
|
});
|
|
95
|
-
},
|
|
95
|
+
}, y);
|
|
96
96
|
return () => clearTimeout(e);
|
|
97
97
|
}, [
|
|
98
98
|
A,
|
|
99
99
|
G,
|
|
100
100
|
K,
|
|
101
101
|
D
|
|
102
|
-
]),
|
|
102
|
+
]), d(() => {
|
|
103
103
|
if (D === 0) return;
|
|
104
104
|
let e = setTimeout(() => {
|
|
105
|
-
let e = Math.ceil(R / L / 2) +
|
|
105
|
+
let e = Math.ceil(R / L / 2) + v, t = Math.max(0, M - 1 - e), n = Math.min(D - 1, M - 1 + e);
|
|
106
106
|
I((e) => {
|
|
107
107
|
let r = new Set(e), i = !1;
|
|
108
108
|
for (let e = t + 1; e <= n + 1; e++) r.has(e) || (r.add(e), i = !0);
|
|
109
109
|
return i ? Array.from(r).sort((e, t) => e - t) : e;
|
|
110
110
|
});
|
|
111
|
-
},
|
|
111
|
+
}, y);
|
|
112
112
|
return () => clearTimeout(e);
|
|
113
113
|
}, [
|
|
114
114
|
M,
|
|
@@ -116,12 +116,12 @@ var oe = { viewer: "_viewer_1gfxm_1" }, h = null, g = (e) => (h ||= new Promise(
|
|
|
116
116
|
R,
|
|
117
117
|
L
|
|
118
118
|
]);
|
|
119
|
-
let Ae =
|
|
119
|
+
let Ae = u((e) => {
|
|
120
120
|
k((t) => new Map([...t, ...e]));
|
|
121
|
-
}, []), [q, je] =
|
|
121
|
+
}, []), [q, je] = p(!1), Me = u((e) => {
|
|
122
122
|
P.current = e, je(!0);
|
|
123
|
-
}, []), J =
|
|
124
|
-
|
|
123
|
+
}, []), J = f(null);
|
|
124
|
+
d(() => {
|
|
125
125
|
if (!q) return;
|
|
126
126
|
let e = J.current, t = e?.querySelector(".pdf-container"), n = e?.querySelector(".pdf-highlight-viewer");
|
|
127
127
|
if (!t || !n) return;
|
|
@@ -134,31 +134,31 @@ var oe = { viewer: "_viewer_1gfxm_1" }, h = null, g = (e) => (h ||= new Promise(
|
|
|
134
134
|
i.observe(t), i.observe(n);
|
|
135
135
|
let a = P.current?.getZoom(), o = 0, s, c = () => {
|
|
136
136
|
let e = P.current?.getZoom();
|
|
137
|
-
e !== a && (a = e, o =
|
|
137
|
+
e !== a && (a = e, o = le), o > 0 && (r(), --o), s = requestAnimationFrame(c);
|
|
138
138
|
};
|
|
139
139
|
return s = requestAnimationFrame(c), () => {
|
|
140
140
|
cancelAnimationFrame(s), i.disconnect();
|
|
141
141
|
};
|
|
142
|
-
}, [q]),
|
|
143
|
-
if (!q ||
|
|
142
|
+
}, [q]), d(() => {
|
|
143
|
+
if (!q || x || S != null) return;
|
|
144
144
|
let e = requestAnimationFrame(() => {
|
|
145
145
|
P.current?.navigateToPage(1);
|
|
146
146
|
});
|
|
147
147
|
return () => cancelAnimationFrame(e);
|
|
148
148
|
}, [
|
|
149
149
|
q,
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
x,
|
|
151
|
+
S
|
|
152
152
|
]);
|
|
153
|
-
let Y =
|
|
153
|
+
let Y = u((e) => {
|
|
154
154
|
N(e), P.current?.navigateToPage(e);
|
|
155
|
-
}, []), Ne =
|
|
155
|
+
}, []), Ne = u((e) => {
|
|
156
156
|
N(e);
|
|
157
|
-
}, []), [X, Z] =
|
|
158
|
-
|
|
157
|
+
}, []), [X, Z] = p(() => String(M));
|
|
158
|
+
d(() => {
|
|
159
159
|
Z(String(M));
|
|
160
160
|
}, [M]);
|
|
161
|
-
let Q =
|
|
161
|
+
let Q = u((e) => {
|
|
162
162
|
let t = Number(e);
|
|
163
163
|
Number.isInteger(t) && t >= 1 && t <= D ? Y(t) : Z(String(M));
|
|
164
164
|
}, [
|
|
@@ -166,17 +166,17 @@ var oe = { viewer: "_viewer_1gfxm_1" }, h = null, g = (e) => (h ||= new Promise(
|
|
|
166
166
|
M,
|
|
167
167
|
Y
|
|
168
168
|
]);
|
|
169
|
-
if (!
|
|
170
|
-
if (
|
|
171
|
-
if (
|
|
172
|
-
errorLabel:
|
|
173
|
-
retryLabel:
|
|
169
|
+
if (!_) return null;
|
|
170
|
+
if (w === "preparing") return /* @__PURE__ */ m(n, { loadingLabel: ge });
|
|
171
|
+
if (w === "error") return /* @__PURE__ */ m(t, {
|
|
172
|
+
errorLabel: _e,
|
|
173
|
+
retryLabel: ve,
|
|
174
174
|
onRetry: xe
|
|
175
175
|
});
|
|
176
176
|
let $ = [];
|
|
177
|
-
for (let e = G + 1; e <= K + 1 && e <= D; e++) $.push(/* @__PURE__ */
|
|
177
|
+
for (let e = G + 1; e <= K + 1 && e <= D; e++) $.push(/* @__PURE__ */ m("div", {
|
|
178
178
|
ref: e === G + 1 ? Ee : void 0,
|
|
179
|
-
children: /* @__PURE__ */
|
|
179
|
+
children: /* @__PURE__ */ m(g, {
|
|
180
180
|
pageNum: e,
|
|
181
181
|
onSelectPage: Y,
|
|
182
182
|
isSelected: M === e,
|
|
@@ -185,22 +185,22 @@ var oe = { viewer: "_viewer_1gfxm_1" }, h = null, g = (e) => (h ||= new Promise(
|
|
|
185
185
|
})
|
|
186
186
|
}, e));
|
|
187
187
|
let Pe = G * L, Fe = Math.max(0, D - K - 1) * L;
|
|
188
|
-
return /* @__PURE__ */
|
|
188
|
+
return /* @__PURE__ */ h("div", {
|
|
189
189
|
className: "relative flex h-full overflow-hidden",
|
|
190
|
-
children: [D > 0 && /* @__PURE__ */
|
|
190
|
+
children: [D > 0 && /* @__PURE__ */ m("div", {
|
|
191
191
|
className: "absolute start-3 top-3 z-10",
|
|
192
|
-
children: /* @__PURE__ */
|
|
192
|
+
children: /* @__PURE__ */ m(o, {
|
|
193
193
|
open: A,
|
|
194
194
|
onOpenChange: j,
|
|
195
195
|
placement: "bottom-start",
|
|
196
196
|
matchReferenceWidth: !1,
|
|
197
|
-
renderOverlay: () => /* @__PURE__ */
|
|
197
|
+
renderOverlay: () => /* @__PURE__ */ h("div", {
|
|
198
198
|
className: "flex w-36 flex-col",
|
|
199
|
-
children: [/* @__PURE__ */
|
|
199
|
+
children: [/* @__PURE__ */ m("div", {
|
|
200
200
|
className: "shrink-0 p-1",
|
|
201
|
-
children: /* @__PURE__ */
|
|
201
|
+
children: /* @__PURE__ */ m(ee, {
|
|
202
202
|
size: s.Small,
|
|
203
|
-
"aria-label":
|
|
203
|
+
"aria-label": he,
|
|
204
204
|
value: X,
|
|
205
205
|
postfix: `/ ${D}`,
|
|
206
206
|
inputMode: "numeric",
|
|
@@ -210,40 +210,40 @@ var oe = { viewer: "_viewer_1gfxm_1" }, h = null, g = (e) => (h ||= new Promise(
|
|
|
210
210
|
e.key === "Enter" && Q(X);
|
|
211
211
|
}
|
|
212
212
|
})
|
|
213
|
-
}), /* @__PURE__ */
|
|
213
|
+
}), /* @__PURE__ */ h("div", {
|
|
214
214
|
ref: Oe,
|
|
215
215
|
id: E,
|
|
216
216
|
role: "region",
|
|
217
|
-
"aria-label":
|
|
217
|
+
"aria-label": fe,
|
|
218
218
|
onScroll: De,
|
|
219
219
|
className: "max-h-[70vh] min-h-0 overflow-y-auto overflow-x-hidden p-1 [scrollbar-gutter:stable]",
|
|
220
220
|
children: [
|
|
221
|
-
/* @__PURE__ */
|
|
221
|
+
/* @__PURE__ */ m("div", { style: { height: Pe } }),
|
|
222
222
|
$,
|
|
223
|
-
/* @__PURE__ */
|
|
223
|
+
/* @__PURE__ */ m("div", { style: { height: Fe } })
|
|
224
224
|
]
|
|
225
225
|
})]
|
|
226
226
|
}),
|
|
227
|
-
children: /* @__PURE__ */
|
|
228
|
-
icon:
|
|
227
|
+
children: /* @__PURE__ */ m(c, {
|
|
228
|
+
icon: m(A ? l : te, {
|
|
229
229
|
size: i.LG,
|
|
230
230
|
stroke: a,
|
|
231
231
|
"aria-hidden": !0
|
|
232
232
|
}),
|
|
233
|
-
"aria-label": A ?
|
|
233
|
+
"aria-label": A ? me : pe,
|
|
234
234
|
"aria-expanded": A,
|
|
235
235
|
"aria-controls": A ? E : void 0
|
|
236
236
|
})
|
|
237
237
|
})
|
|
238
|
-
}), /* @__PURE__ */
|
|
238
|
+
}), /* @__PURE__ */ m("div", {
|
|
239
239
|
ref: J,
|
|
240
|
-
className: r("min-w-0 flex-1 overflow-hidden",
|
|
241
|
-
children: /* @__PURE__ */
|
|
242
|
-
fileUrl:
|
|
243
|
-
loadFileCb:
|
|
244
|
-
highlights:
|
|
245
|
-
selectedHighlightId:
|
|
246
|
-
selectedPageNumber:
|
|
240
|
+
className: r("min-w-0 flex-1 overflow-hidden", ie.viewer),
|
|
241
|
+
children: /* @__PURE__ */ m(re, {
|
|
242
|
+
fileUrl: _,
|
|
243
|
+
loadFileCb: ue ?? e,
|
|
244
|
+
highlights: b,
|
|
245
|
+
selectedHighlightId: x,
|
|
246
|
+
selectedPageNumber: S,
|
|
247
247
|
showOccurrences: !1,
|
|
248
248
|
onTotalPagesChange: Se,
|
|
249
249
|
thumbnailPageNumbers: Ce,
|
|
@@ -251,10 +251,9 @@ var oe = { viewer: "_viewer_1gfxm_1" }, h = null, g = (e) => (h ||= new Promise(
|
|
|
251
251
|
onViewerReady: Me,
|
|
252
252
|
onCurrentPageChange: Ne,
|
|
253
253
|
viewerOptions: { enableVirtualScrolling: !0 },
|
|
254
|
-
containerClassName:
|
|
254
|
+
containerClassName: de ? "[&>div:first-child]:hidden" : void 0
|
|
255
255
|
})
|
|
256
256
|
})]
|
|
257
257
|
});
|
|
258
258
|
};
|
|
259
|
-
|
|
260
|
-
export { y as PdfContent };
|
|
259
|
+
export { b as PdfContent };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/types/attachment-canvas.ts
|
|
2
2
|
var e = /* @__PURE__ */ function(e) {
|
|
3
3
|
return e.PlainText = "plain_text", e.Image = "image", e.Audio = "audio", e.Markdown = "markdown", e.MarkdownTable = "markdown_table", e.Json = "json", e.Pdf = "pdf", e.Ooxml = "ooxml", e.Code = "code", e.Html = "html", e.Visualizer = "visualizer", e.GroupedVisualizer = "grouped_visualizer", e.McpApp = "mcp_app", e.Unsupported = "unsupported", e.Error = "error", e;
|
|
4
4
|
}({}), t = /* @__PURE__ */ function(e) {
|
|
@@ -10,5 +10,4 @@ var e = /* @__PURE__ */ function(e) {
|
|
|
10
10
|
}({}), i = /* @__PURE__ */ function(e) {
|
|
11
11
|
return e.Navigated = "navigated", e.Superseded = "superseded", e.Unresolved = "unresolved", e;
|
|
12
12
|
}({});
|
|
13
|
-
//#endregion
|
|
14
13
|
export { i as a, n as i, r as n, t as r, e as t };
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as e, i as t, n, r, t as i } from "./attachment-canvas-
|
|
2
|
-
import { i as a, o, t as s } from "./LazyContentBoundary-
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./attachment-canvas-BNS10ZnJ.js";
|
|
2
|
+
import { i as a, o, t as s } from "./LazyContentBoundary-Df8cBJYi.js";
|
|
3
3
|
import { AttachmentType as c, CodeBlockTheme as l, DEFAULT_MARKDOWN_CLASS_NAMES as u, FileExtension as d, MIMEType as f, MarkdownRenderer as p, buildCssVars as m, copyToClipboard as h, mergeClasses as g, restrainedSyntaxTheme as _, stripUrlQueryAndFragment as v } from "@epam/ai-dial-chat-shared";
|
|
4
4
|
import { SidebarOrientation as y, SidebarPanel as b } from "@epam/ai-dial-sidebar";
|
|
5
5
|
import { DIAL_ICON_SIZE as x, DIAL_KIT_ICON_STROKE as S, ElementSize as C, GhostIconButton as w, LinkButton as T, Spinner as E } from "@epam/ai-dial-ui-kit";
|
|
@@ -284,7 +284,7 @@ var G = {
|
|
|
284
284
|
let [{ DocxDocument: n, DocxScrollViewer: r }, { chartEx: o }, { createDocxHighlightSurface: c }] = await Promise.all([
|
|
285
285
|
import("@silurus/ooxml/docx"),
|
|
286
286
|
import("@silurus/ooxml/chart-ex"),
|
|
287
|
-
import("./ooxml-highlight-surfaces-
|
|
287
|
+
import("./ooxml-highlight-surfaces-wb4asEn3.js")
|
|
288
288
|
]), l = await n.load(t.url, { chartEx: o });
|
|
289
289
|
if (i()) throw l.destroy(), new Te();
|
|
290
290
|
let u = r.fromDocument(e, l, {
|
|
@@ -304,7 +304,7 @@ var G = {
|
|
|
304
304
|
let [{ PptxPresentation: n, PptxScrollViewer: r }, { chartEx: o }, { createPptxHighlightSurface: c }] = await Promise.all([
|
|
305
305
|
import("@silurus/ooxml/pptx"),
|
|
306
306
|
import("@silurus/ooxml/chart-ex"),
|
|
307
|
-
import("./ooxml-highlight-surfaces-
|
|
307
|
+
import("./ooxml-highlight-surfaces-wb4asEn3.js")
|
|
308
308
|
]), l = await n.load(t.url, { chartEx: o });
|
|
309
309
|
if (i()) throw l.destroy(), new Te();
|
|
310
310
|
let u = r.fromPresentation(e, l, {
|
|
@@ -324,7 +324,7 @@ var G = {
|
|
|
324
324
|
let [{ XlsxViewer: n }, { chartEx: r }, { createXlsxHighlightSurface: c }] = await Promise.all([
|
|
325
325
|
import("@silurus/ooxml/xlsx"),
|
|
326
326
|
import("@silurus/ooxml/chart-ex"),
|
|
327
|
-
import("./ooxml-highlight-surfaces-
|
|
327
|
+
import("./ooxml-highlight-surfaces-wb4asEn3.js")
|
|
328
328
|
]), l = new n(e, {
|
|
329
329
|
showZoomSlider: !0,
|
|
330
330
|
chartEx: r,
|
|
@@ -503,15 +503,11 @@ var G = {
|
|
|
503
503
|
let n = e.toLowerCase();
|
|
504
504
|
return t.find((e) => e.contentType.split(",").some((e) => e.trim().toLowerCase() === n && e.trim() !== ""));
|
|
505
505
|
}, Oe = (e, t) => {
|
|
506
|
-
if (
|
|
506
|
+
if (e != null && e !== "") return Object.prototype.hasOwnProperty.call(t, e) ? t[e] : void 0;
|
|
507
507
|
}, ke = (e) => `${e}:grouped-visualizer`, Ae = (e, t) => {
|
|
508
508
|
let n = (t.contentType ?? "").split(",").map((e) => e.trim().toLowerCase()).filter((e) => e !== ""), r = [], i = [];
|
|
509
509
|
return e.forEach((e) => {
|
|
510
|
-
|
|
511
|
-
r.push(e);
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
i.push(e);
|
|
510
|
+
e.url != null && e.url !== "" && (n.length === 0 || n.includes(e.contentType.toLowerCase())) ? r.push(e) : i.push(e);
|
|
515
511
|
}), {
|
|
516
512
|
claimed: r,
|
|
517
513
|
unclaimed: i
|
|
@@ -625,7 +621,7 @@ var G = {
|
|
|
625
621
|
jsonExpandIcon: "_jsonExpandIcon_13ogb_54",
|
|
626
622
|
jsonCollapseIcon: "_jsonCollapseIcon_13ogb_67",
|
|
627
623
|
jsonCollapsedContent: "_jsonCollapsedContent_13ogb_84"
|
|
628
|
-
}, Ne = () => j(async () => ({ default: (await import("./PdfContent-
|
|
624
|
+
}, Ne = () => j(async () => ({ default: (await import("./PdfContent-DbeinXjr.js")).PdfContent })), Pe = ({ url: e, fileName: t, loadErrorLabel: n }) => {
|
|
629
625
|
let [r, i] = R(!1);
|
|
630
626
|
return F(() => {
|
|
631
627
|
i(!1);
|
|
@@ -645,7 +641,7 @@ var G = {
|
|
|
645
641
|
className: "max-h-full max-w-full object-contain",
|
|
646
642
|
onError: () => i(!0)
|
|
647
643
|
});
|
|
648
|
-
}, Z = new Set([
|
|
644
|
+
}, Z = /* @__PURE__ */ new Set([
|
|
649
645
|
i.PlainText,
|
|
650
646
|
i.Code,
|
|
651
647
|
i.Ooxml
|
|
@@ -1045,11 +1041,11 @@ var G = {
|
|
|
1045
1041
|
onVisualizerSendMessage: Ae
|
|
1046
1042
|
})
|
|
1047
1043
|
});
|
|
1048
|
-
}), Re = new Set(["html", "htm"]), Q = {
|
|
1044
|
+
}), Re = /* @__PURE__ */ new Set(["html", "htm"]), Q = {
|
|
1049
1045
|
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
1050
1046
|
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
1051
1047
|
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
1052
|
-
}, ze = new Set(/* @__PURE__ */ "txt.md.markdown.json.jsonl.ndjson.xml.csv.tsv.yaml.yml.toml.ini.conf.cfg.css.scss.sass.less.js.jsx.ts.tsx.mjs.cjs.mts.cts.py.rb.go.rs.java.kt.swift.c.h.cpp.cs.sh.bash.zsh.fish.ps1.log.env.gitignore.dockerfile.makefile.sql".split(".")), Be = {
|
|
1048
|
+
}, ze = /* @__PURE__ */ new Set(/* @__PURE__ */ "txt.md.markdown.json.jsonl.ndjson.xml.csv.tsv.yaml.yml.toml.ini.conf.cfg.css.scss.sass.less.js.jsx.ts.tsx.mjs.cjs.mts.cts.py.rb.go.rs.java.kt.swift.c.h.cpp.cs.sh.bash.zsh.fish.ps1.log.env.gitignore.dockerfile.makefile.sql".split(".")), Be = {
|
|
1053
1049
|
docx: r.Docx,
|
|
1054
1050
|
xlsx: r.Xlsx,
|
|
1055
1051
|
pptx: r.Pptx,
|
|
@@ -1077,10 +1073,10 @@ var G = {
|
|
|
1077
1073
|
return n == null ? void 0 : He[n];
|
|
1078
1074
|
}, Ke = (e) => {
|
|
1079
1075
|
let t = e.lastIndexOf(".");
|
|
1080
|
-
return t
|
|
1076
|
+
return t !== -1 && ze.has(e.slice(t + 1).toLowerCase());
|
|
1081
1077
|
}, qe = (e) => {
|
|
1082
1078
|
let t = e.lastIndexOf(".");
|
|
1083
|
-
return t
|
|
1079
|
+
return t !== -1 && Re.has(e.slice(t + 1).toLowerCase());
|
|
1084
1080
|
}, Je = {
|
|
1085
1081
|
xml: "xml",
|
|
1086
1082
|
csv: "plaintext",
|
|
@@ -1141,7 +1137,7 @@ var G = {
|
|
|
1141
1137
|
errorType: n.Forbidden,
|
|
1142
1138
|
...e != null && { url: e }
|
|
1143
1139
|
}), Qe = (e) => {
|
|
1144
|
-
if (
|
|
1140
|
+
if (e.type === i.Image || e.type === i.Audio || e.type === i.Pdf || e.type === i.Ooxml) return e.url.startsWith("blob:") ? e.url : void 0;
|
|
1145
1141
|
}, $e = (e) => {
|
|
1146
1142
|
let t = Qe(e);
|
|
1147
1143
|
t != null && URL.revokeObjectURL(t);
|
|
@@ -1339,28 +1335,28 @@ var nt = ({ children: e }) => {
|
|
|
1339
1335
|
case d.Markdown:
|
|
1340
1336
|
case d.MarkdownAlt: {
|
|
1341
1337
|
let i = await e.resolveMarkdownContent(t);
|
|
1342
|
-
return i
|
|
1338
|
+
return i != null && r(i, t.name, n);
|
|
1343
1339
|
}
|
|
1344
1340
|
case d.JSON: {
|
|
1345
1341
|
let i = await e.resolveJsonContent(t);
|
|
1346
|
-
return i
|
|
1342
|
+
return i != null && r(i, t.name, n);
|
|
1347
1343
|
}
|
|
1348
1344
|
case d.PDF: {
|
|
1349
1345
|
let i = await e.resolvePdfContent(t);
|
|
1350
|
-
return i
|
|
1346
|
+
return i != null && r(i, t.name, n);
|
|
1351
1347
|
}
|
|
1352
1348
|
}
|
|
1353
1349
|
let g = t.name != null && qe(t.name) || t.url != null && qe(st(t.url));
|
|
1354
1350
|
if (t.name != null && !Ke(t.name) && !g) return r($(e.resolveContentUrl(t)), t.name, n);
|
|
1355
1351
|
if (g) {
|
|
1356
1352
|
let a = await e.resolveHtmlContent(t);
|
|
1357
|
-
return a == null ? e.hasTextSource(t) ? r($(e.resolveContentUrl(t)), t.name, n) : t.url
|
|
1353
|
+
return a == null ? e.hasTextSource(t) ? r($(e.resolveContentUrl(t)), t.name, n) : t.url != null && r({
|
|
1358
1354
|
type: i.Html,
|
|
1359
1355
|
url: t.url
|
|
1360
1356
|
}, t.name, n) : r(a, t.name, n);
|
|
1361
1357
|
}
|
|
1362
1358
|
let _ = await e.resolveCodeContent(t, Ye(m));
|
|
1363
|
-
return _
|
|
1359
|
+
return _ != null && r(_, t.name, n);
|
|
1364
1360
|
}, [
|
|
1365
1361
|
o,
|
|
1366
1362
|
s,
|
|
@@ -1371,11 +1367,11 @@ var nt = ({ children: e }) => {
|
|
|
1371
1367
|
switch (t.type) {
|
|
1372
1368
|
case c.Image: {
|
|
1373
1369
|
let r = e.resolveImageContent(t);
|
|
1374
|
-
return r
|
|
1370
|
+
return r != null && (l?.(), n(r, t.name, o), !0);
|
|
1375
1371
|
}
|
|
1376
1372
|
case c.Audio: {
|
|
1377
1373
|
let e = t.playUrl ?? t.url;
|
|
1378
|
-
return e
|
|
1374
|
+
return e != null && (n({
|
|
1379
1375
|
type: i.Audio,
|
|
1380
1376
|
url: e,
|
|
1381
1377
|
mimeType: t.contentType || void 0
|
|
@@ -1403,5 +1399,4 @@ var nt = ({ children: e }) => {
|
|
|
1403
1399
|
e
|
|
1404
1400
|
]) };
|
|
1405
1401
|
};
|
|
1406
|
-
//#endregion
|
|
1407
1402
|
export { Le as AttachmentCanvas, Fe as AttachmentCanvasBody, it as AttachmentCanvasContainer, nt as AttachmentCanvasProvider, i as AttachmentContentType, n as AttachmentErrorType, me as CodeContent, ot as InlineGroupedVisualizer, xe as McpAppCanvasRenderer, r as OoxmlFileType, t as OoxmlHighlightKind, Ze as createForbiddenCanvasContent, Xe as createLoadErrorCanvasContent, $ as createUnsupportedCanvasContent, a as downloadAttachmentContent, Ye as extensionToLanguage, Oe as findVisualizerForApplication, De as findVisualizerForMime, Ue as getOoxmlFileType, Ge as getOoxmlMimeType, ke as groupedVisualizerCanvasKey, o as isDownloadable, qe as isHtmlPreviewable, We as isOoxmlPreviewable, Ke as isTextPreviewable, Ae as partitionAttachmentsForApplicationVisualizer, rt as useAttachmentCanvas, ct as useOpenAttachmentCanvas };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as e, i as t } from "./attachment-canvas-
|
|
2
|
-
|
|
1
|
+
import { a as e, i as t } from "./attachment-canvas-BNS10ZnJ.js";
|
|
2
|
+
// src/utils/ooxml-highlight-geometry.ts
|
|
3
3
|
var n = 4 / 3, r = 9525, i = 2, a = 1, o = 0, s = 16, c = .25, l = () => {
|
|
4
4
|
let e = document.createElement("canvas").getContext("2d");
|
|
5
5
|
if (e != null) return (t, n) => (e.font !== t && (e.font = t), e.measureText(n).width);
|
|
@@ -32,11 +32,7 @@ var n = 4 / 3, r = 9525, i = 2, a = 1, o = 0, s = 16, c = .25, l = () => {
|
|
|
32
32
|
let t = [...e].sort((e, t) => e.top - t.top || e.left - t.left), n = [];
|
|
33
33
|
for (let e of t) {
|
|
34
34
|
let t = n.at(-1), r = t != null && Math.abs(t.top - e.top) <= i && Math.abs(t.height - e.height) <= i, o = t != null && e.left <= t.left + t.width + a;
|
|
35
|
-
|
|
36
|
-
t.width = Math.max(t.left + t.width, e.left + e.width) - t.left, t.height = Math.max(t.height, e.height);
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
n.push({ ...e });
|
|
35
|
+
r && o ? (t.width = Math.max(t.left + t.width, e.left + e.width) - t.left, t.height = Math.max(t.height, e.height)) : n.push({ ...e });
|
|
40
36
|
}
|
|
41
37
|
return n;
|
|
42
38
|
}, h = (e, t, n) => Math.min(Math.max(e, t), n), g = (e, t) => e.length === t.length && e.every((e, n) => e === t[n]), _ = (e, t, n) => {
|
|
@@ -67,11 +63,7 @@ var n = 4 / 3, r = 9525, i = 2, a = 1, o = 0, s = 16, c = .25, l = () => {
|
|
|
67
63
|
let e = h(n - t.start, 0, t.end - t.start), i = o(t, e, h(r - t.start, e, t.end - t.start));
|
|
68
64
|
if (i == null) continue;
|
|
69
65
|
let c = s.get(t.surfaceIndex);
|
|
70
|
-
|
|
71
|
-
s.set(t.surfaceIndex, [i]);
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
c.push(i);
|
|
66
|
+
c == null ? s.set(t.surfaceIndex, [i]) : c.push(i);
|
|
75
67
|
}
|
|
76
68
|
for (let [e, t] of s) s.set(e, m(t));
|
|
77
69
|
return s;
|
|
@@ -118,7 +110,7 @@ var n = 4 / 3, r = 9525, i = 2, a = 1, o = 0, s = 16, c = .25, l = () => {
|
|
|
118
110
|
});
|
|
119
111
|
}, x = (e) => e.rotation !== 0 || (e.textBodyRotation ?? 0) !== 0 || e.shapeFlipH === !0 || e.shapeFlipV === !0, S = ({ location: e, runs: t, measure: n }) => {
|
|
120
112
|
let r = [], i = "";
|
|
121
|
-
for (let n of t) n.shapeId != null && String(n.shapeId) === e.shapeId &&
|
|
113
|
+
for (let n of t) n.shapeId != null && String(n.shapeId) === e.shapeId && n.origin !== "master" && n.origin !== "layout" && (r.push({
|
|
122
114
|
run: n,
|
|
123
115
|
box: {
|
|
124
116
|
x: n.shapeX + n.inShapeX,
|
|
@@ -129,7 +121,7 @@ var n = 4 / 3, r = 9525, i = 2, a = 1, o = 0, s = 16, c = .25, l = () => {
|
|
|
129
121
|
start: i.length,
|
|
130
122
|
end: i.length + n.text.length,
|
|
131
123
|
surfaceIndex: o
|
|
132
|
-
}), i += n.text)
|
|
124
|
+
}), i += n.text);
|
|
133
125
|
return y(r, i, e.start, e.endExclusive, e.text, x, ({ run: e, box: t }, r, i) => v(e.text, t, e.font, 0, !1, r, i, n)).get(o) ?? [];
|
|
134
126
|
}, C = (e, t) => {
|
|
135
127
|
let n = t.indexOf(e);
|
|
@@ -223,7 +215,7 @@ var n = 4 / 3, r = 9525, i = 2, a = 1, o = 0, s = 16, c = .25, l = () => {
|
|
|
223
215
|
}, M = (e, n) => {
|
|
224
216
|
if (!Number.isSafeInteger(e.occurrence) || e.occurrence < 1) return [];
|
|
225
217
|
let r = /* @__PURE__ */ new Map();
|
|
226
|
-
for (let e of n) e.tableCell
|
|
218
|
+
for (let e of n) e.tableCell != null && e.shapeId != null && e.origin !== "master" && e.origin !== "layout" && O(r, JSON.stringify([
|
|
227
219
|
e.elementIndex,
|
|
228
220
|
e.shapeId,
|
|
229
221
|
e.tableCell.row
|
|
@@ -428,7 +420,7 @@ var n = 4 / 3, r = 9525, i = 2, a = 1, o = 0, s = 16, c = .25, l = () => {
|
|
|
428
420
|
for (let n of e) for (let e of n.locations) {
|
|
429
421
|
if (e.kind !== t.XlsxCellRange) continue;
|
|
430
422
|
let s = C(e.sheet, r.sheetNames);
|
|
431
|
-
if (
|
|
423
|
+
if (s != null && s === r.sheetIndex) for (let t of T({
|
|
432
424
|
location: e,
|
|
433
425
|
getCellViewportRect: (e) => {
|
|
434
426
|
let t = r.getCellViewportRect(e);
|
|
@@ -455,5 +447,4 @@ var n = 4 / 3, r = 9525, i = 2, a = 1, o = 0, s = 16, c = .25, l = () => {
|
|
|
455
447
|
return a == null ? e.Unresolved : a !== r.sheetIndex && (await r.goToSheet(a), i()) ? e.Superseded : (await r.scrollToCell(w(n.start), { align: "center" }), e.Navigated);
|
|
456
448
|
}
|
|
457
449
|
});
|
|
458
|
-
//#endregion
|
|
459
450
|
export { e as OoxmlNavigationOutcome, I as createDocxHighlightSurface, L as createPptxHighlightSurface, R as createXlsxHighlightSurface };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-attachment-canvas",
|
|
3
3
|
"description": "Canvas viewer for rendering attachment content — images, PDFs, Office documents, CSV, JSON, markdown, and plain text",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.18",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
30
30
|
"@modelcontextprotocol/ext-apps": "1.7.5",
|
|
31
31
|
"pdfjs-dist": "^5.4.149",
|
|
32
|
-
"@epam/ai-dial-sidebar": "1.1.
|
|
32
|
+
"@epam/ai-dial-sidebar": "1.1.18"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@epam/ai-dial-chat-shared": "1.1.
|
|
35
|
+
"@epam/ai-dial-chat-shared": "1.1.18",
|
|
36
36
|
"@epam/ai-dial-ui-kit": "^0.14.2",
|
|
37
37
|
"react": "^19.2.8"
|
|
38
38
|
},
|