@epam/ai-dial-quotations 1.2.0-dev.133 → 1.2.0-dev.139
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.
|
@@ -42,8 +42,14 @@ export interface UseCitationMarkdownComponentsCallbacks {
|
|
|
42
42
|
* `isCompactTypography` drops the paragraph class one type-scale step, matching
|
|
43
43
|
* `COMPACT_MARKDOWN_CLASS_NAMES` so cited and uncited paragraphs stay the same
|
|
44
44
|
* size.
|
|
45
|
+
*
|
|
46
|
+
* `fallbackGroups` is an optional pool of groups that do not belong to this
|
|
47
|
+
* message, consulted only to resolve a `<cit data-id="…">` element the
|
|
48
|
+
* message's own `groups` do not cover. It never affects sentinel injection or
|
|
49
|
+
* `processedContent`, so a foreign group cannot shift a marker position in
|
|
50
|
+
* this message's text; a colliding id is always resolved from `groups`.
|
|
45
51
|
*/
|
|
46
|
-
export declare const useCitationMarkdownComponents: (content: string, groups: AnnotationGroup[], callbacks: UseCitationMarkdownComponentsCallbacks, isStreaming?: boolean, isCompactTypography?: boolean) => {
|
|
52
|
+
export declare const useCitationMarkdownComponents: (content: string, groups: AnnotationGroup[], callbacks: UseCitationMarkdownComponentsCallbacks, isStreaming?: boolean, isCompactTypography?: boolean, fallbackGroups?: AnnotationGroup[]) => {
|
|
47
53
|
processedContent: string;
|
|
48
54
|
markdownComponents: Components;
|
|
49
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCitationMarkdownComponents.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCitationMarkdownComponents/useCitationMarkdownComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EAEhB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAErF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAO3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE/E,6FAA6F;AAC7F,MAAM,WAAW,sCAAsC;IACrD,4GAA4G;IAC5G,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IAChE,gFAAgF;IAChF,aAAa,CAAC,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC;IAChD,yEAAyE;IACzE,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9C,4FAA4F;IAC5F,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG;QACnC,UAAU,EAAE,kBAAkB,CAAC;QAC/B,YAAY,EAAE,oBAAoB,CAAC;KACpC,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"useCitationMarkdownComponents.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCitationMarkdownComponents/useCitationMarkdownComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EAEhB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAErF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAO3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE/E,6FAA6F;AAC7F,MAAM,WAAW,sCAAsC;IACrD,4GAA4G;IAC5G,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IAChE,gFAAgF;IAChF,aAAa,CAAC,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC;IAChD,yEAAyE;IACzE,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9C,4FAA4F;IAC5F,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG;QACnC,UAAU,EAAE,kBAAkB,CAAC;QAC/B,YAAY,EAAE,oBAAoB,CAAC;KACpC,CAAC;CACH;AAwCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,6BAA6B,GACxC,SAAS,MAAM,EACf,QAAQ,eAAe,EAAE,EACzB,WAAW,sCAAsC,EACjD,qBAAmB,EACnB,6BAA2B,EAC3B,iBAAgB,eAAe,EAA0B,KACxD;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,UAAU,CAAA;CAyG5D,CAAC"}
|
package/index.js
CHANGED
|
@@ -398,46 +398,50 @@ var T = {
|
|
|
398
398
|
let n = K(e, t);
|
|
399
399
|
return Array.isArray(n) ? n : [n];
|
|
400
400
|
}) : e;
|
|
401
|
-
}, be = {}, xe = (e) => {
|
|
401
|
+
}, be = {}, xe = [], q = (e) => {
|
|
402
402
|
let t = e.primaryAnnotation.target?.selector;
|
|
403
403
|
return t?.type === "html_tag" ? t.id : void 0;
|
|
404
404
|
}, Se = (e, t) => /* @__PURE__ */ v(g, { children: [
|
|
405
405
|
e == null ? "<cit>" : `<cit data-id="${e}">`,
|
|
406
406
|
t,
|
|
407
407
|
"</cit>"
|
|
408
|
-
] }), Ce = (e, t, n, r = !1, a = !1) => {
|
|
409
|
-
let { onPreview:
|
|
408
|
+
] }), Ce = (e, t, n, r = !1, a = !1, o = xe) => {
|
|
409
|
+
let { onPreview: s, isPreviewable: c, onOpenInBrowser: l, buildLabels: u } = n, d = C(() => r ? G(e) : W(t.length > 0 ? he(e, t) : e), [
|
|
410
410
|
e,
|
|
411
411
|
t,
|
|
412
412
|
r
|
|
413
|
-
]),
|
|
413
|
+
]), f = d.includes("<cit");
|
|
414
414
|
return {
|
|
415
|
-
processedContent:
|
|
415
|
+
processedContent: d,
|
|
416
416
|
markdownComponents: C(() => {
|
|
417
417
|
let e = /* @__PURE__ */ new Map();
|
|
418
|
+
for (let t of o) {
|
|
419
|
+
let n = q(t);
|
|
420
|
+
n != null && e.set(n, t);
|
|
421
|
+
}
|
|
418
422
|
for (let n of t) {
|
|
419
|
-
let t =
|
|
423
|
+
let t = q(n);
|
|
420
424
|
t != null && e.set(t, n);
|
|
421
425
|
}
|
|
422
426
|
let n = (e) => {
|
|
423
|
-
let { cardLabels: t, markerLabels: n } =
|
|
427
|
+
let { cardLabels: t, markerLabels: n } = u(e);
|
|
424
428
|
return /* @__PURE__ */ _(N, {
|
|
425
429
|
group: e,
|
|
426
|
-
onPreview: (t) =>
|
|
427
|
-
isPreviewable:
|
|
428
|
-
onOpenInBrowser:
|
|
430
|
+
onPreview: (t) => s(t, e),
|
|
431
|
+
isPreviewable: c,
|
|
432
|
+
onOpenInBrowser: l,
|
|
429
433
|
cardLabels: t,
|
|
430
434
|
markerLabels: n
|
|
431
435
|
}, `citation-${e.groupKey}`);
|
|
432
436
|
}, r = (e) => {
|
|
433
437
|
let r = t[e];
|
|
434
438
|
return r ? n(r) : null;
|
|
435
|
-
},
|
|
439
|
+
}, d = { cit: (t) => {
|
|
436
440
|
let r = t["data-id"] == null ? void 0 : e.get(t["data-id"]);
|
|
437
441
|
return r ? n(r) : Se(t["data-id"], t.children);
|
|
438
442
|
} };
|
|
439
|
-
return t.length === 0 ?
|
|
440
|
-
...
|
|
443
|
+
return t.length === 0 && o.length === 0 ? f ? d : be : {
|
|
444
|
+
...d,
|
|
441
445
|
p: ({ children: e, ...t }) => /* @__PURE__ */ _("p", {
|
|
442
446
|
...t,
|
|
443
447
|
className: i(a ? "dial-small-paragraph-text" : "dial-body-paragraph-text", "mb-3 [overflow-wrap:anywhere] [text-wrap:pretty] last:mb-0"),
|
|
@@ -455,11 +459,12 @@ var T = {
|
|
|
455
459
|
s,
|
|
456
460
|
c,
|
|
457
461
|
l,
|
|
462
|
+
u,
|
|
458
463
|
a,
|
|
459
|
-
|
|
464
|
+
f
|
|
460
465
|
])
|
|
461
466
|
};
|
|
462
|
-
},
|
|
467
|
+
}, J = (e) => {
|
|
463
468
|
try {
|
|
464
469
|
return decodeURIComponent(e);
|
|
465
470
|
} catch {
|
|
@@ -468,14 +473,14 @@ var T = {
|
|
|
468
473
|
}, we = (e) => {
|
|
469
474
|
try {
|
|
470
475
|
let t = new URL(e);
|
|
471
|
-
return t.pathname.split("/").map((e) =>
|
|
476
|
+
return t.pathname.split("/").map((e) => J(e)).filter(Boolean).at(-1) ?? t.hostname;
|
|
472
477
|
} catch {
|
|
473
|
-
return e.split("/").map((e) =>
|
|
478
|
+
return e.split("/").map((e) => J(e)).filter(Boolean).at(-1) ?? e;
|
|
474
479
|
}
|
|
475
|
-
},
|
|
480
|
+
}, Y = (e, t) => e.body?.source?.attachment?.title ?? we(t), X = (e) => {
|
|
476
481
|
let t = e.target?.selector;
|
|
477
482
|
return t?.type === "html_tag" ? t : void 0;
|
|
478
|
-
}, Te = (e) =>
|
|
483
|
+
}, Te = (e) => X(e) != null, Z = (e) => {
|
|
479
484
|
let t = /* @__PURE__ */ new Map();
|
|
480
485
|
for (let n of e) {
|
|
481
486
|
if (Te(n)) continue;
|
|
@@ -485,16 +490,16 @@ var T = {
|
|
|
485
490
|
r ? r.annotations.push(n) : t.set(e, {
|
|
486
491
|
groupKey: e,
|
|
487
492
|
sourceUrl: e,
|
|
488
|
-
sourceName:
|
|
493
|
+
sourceName: Y(n, e),
|
|
489
494
|
annotations: [n],
|
|
490
495
|
primaryAnnotation: n
|
|
491
496
|
});
|
|
492
497
|
}
|
|
493
498
|
return Array.from(t.values());
|
|
494
|
-
},
|
|
499
|
+
}, Q = (e) => {
|
|
495
500
|
let t = /* @__PURE__ */ new Map();
|
|
496
501
|
for (let n of e) {
|
|
497
|
-
let e =
|
|
502
|
+
let e = X(n)?.id;
|
|
498
503
|
if (e == null) continue;
|
|
499
504
|
let r = n.body?.source?.attachment?.url;
|
|
500
505
|
if (r == null) continue;
|
|
@@ -502,22 +507,22 @@ var T = {
|
|
|
502
507
|
i ? i.annotations.push(n) : t.set(e, {
|
|
503
508
|
groupKey: `cit:${e}`,
|
|
504
509
|
sourceUrl: r,
|
|
505
|
-
sourceName:
|
|
510
|
+
sourceName: Y(n, r),
|
|
506
511
|
annotations: [n],
|
|
507
512
|
primaryAnnotation: n
|
|
508
513
|
});
|
|
509
514
|
}
|
|
510
515
|
return Array.from(t.values());
|
|
511
|
-
}, Ee = (e) => [...
|
|
516
|
+
}, Ee = (e) => [...Q(e), ...Z(e)], De = (e, t) => {
|
|
512
517
|
let n = e.body?.source?.attachment?.url;
|
|
513
518
|
return n == null || !t.includes(e) ? [e] : t.filter((e) => e.body?.source?.attachment?.url === n);
|
|
514
|
-
},
|
|
515
|
-
let t =
|
|
519
|
+
}, Oe = (e) => e.url == null && e.reference_url != null, ke = /^(.*\.pdf)(?:#page=(\d+))?$/i, $ = (e) => {
|
|
520
|
+
let t = ke.exec(e);
|
|
516
521
|
return t ? {
|
|
517
522
|
baseUrl: t[1],
|
|
518
523
|
page: t[2] == null ? null : Number(t[2])
|
|
519
524
|
} : null;
|
|
520
|
-
},
|
|
525
|
+
}, Ae = (t) => Z((t ?? []).filter(Oe).map((t) => {
|
|
521
526
|
let n = t.reference_url, r = $(n) != null;
|
|
522
527
|
return { body: {
|
|
523
528
|
quote: t.data,
|
|
@@ -532,4 +537,4 @@ var T = {
|
|
|
532
537
|
} };
|
|
533
538
|
}));
|
|
534
539
|
//#endregion
|
|
535
|
-
export { D as CitationCard, A as CitationCardProvider, N as CitationDropdown, O as CitationMarker, T as QUOTATIONS_CLASS, L as annotationHighlightId, U as annotationToOfficeHighlightLocations, oe as annotationsToPdfHighlights, De as gatherSameSourceAnnotations, se as getAnnotationPdfPage,
|
|
540
|
+
export { D as CitationCard, A as CitationCardProvider, N as CitationDropdown, O as CitationMarker, T as QUOTATIONS_CLASS, L as annotationHighlightId, U as annotationToOfficeHighlightLocations, oe as annotationsToPdfHighlights, De as gatherSameSourceAnnotations, se as getAnnotationPdfPage, Ae as getReferenceAttachmentGroups, Ee as groupAnnotations, Q as groupAnnotationsByCitId, Z as groupAnnotationsBySource, he as injectCitationSentinels, z as isDocxRangeSelector, H as isExcelRcRangeSelector, B as isPptxRangeSelector, Oe as isReferenceOnlyAttachment, $ as parsePdfPageReference, K as replaceSentinelsInChildren, R as resolveMessageAnnotations, G as stripCitTagsWhileStreaming, de as useAnnotations, pe as useCitationCard, j as useCitationCardContext, Ce as useCitationMarkdownComponents };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-quotations",
|
|
3
3
|
"description": "Citation and annotation components, hooks, and utilities for AI DIAL conversations",
|
|
4
|
-
"version": "1.2.0-dev.
|
|
4
|
+
"version": "1.2.0-dev.139",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"react": "^19.2.8",
|
|
26
|
-
"@epam/ai-dial-chat-shared": "1.2.0-dev.
|
|
26
|
+
"@epam/ai-dial-chat-shared": "1.2.0-dev.139",
|
|
27
27
|
"@epam/ai-dial-ui-kit": "^0.15.0-dev.18"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|