@deepcitation/deepcitation-js 1.1.5 → 1.1.7
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/lib/parsing/parseCitation.js +3 -5
- package/lib/react/CitationComponent.js +2 -2
- package/lib/react/CitationVariants.js +1 -1
- package/lib/react/primitives.js +3 -3
- package/lib/react/utils.js +1 -1
- package/lib/types/citation.d.ts +0 -1
- package/lib/types/search.d.ts +1 -1
- package/package.json +1 -1
|
@@ -55,7 +55,7 @@ export function getCitationStatus(verification) {
|
|
|
55
55
|
const searchState = verification?.searchState;
|
|
56
56
|
const isMiss = searchState?.status === "not_found";
|
|
57
57
|
const isFullMatchWithMissedValue = searchState?.status === "found_phrase_missed_value";
|
|
58
|
-
const isFoundValueMissedFullMatch = searchState?.status === "
|
|
58
|
+
const isFoundValueMissedFullMatch = searchState?.status === "found_key_span_only";
|
|
59
59
|
const isPartialMatch = searchState?.status === "partial_text_found" ||
|
|
60
60
|
searchState?.status === "found_on_other_page" ||
|
|
61
61
|
searchState?.status === "found_on_other_line" ||
|
|
@@ -158,11 +158,10 @@ export const parseCitation = (fragment, mdAttachmentId, citationCounterRef, isVe
|
|
|
158
158
|
pageNumber,
|
|
159
159
|
startPageKey: `page_number_${pageNumber || 1}_index_${pageIndex || 0}`,
|
|
160
160
|
fullPhrase,
|
|
161
|
-
keySpan,
|
|
161
|
+
keySpan: keySpan || value,
|
|
162
162
|
citationNumber,
|
|
163
163
|
lineIds,
|
|
164
164
|
beforeCite,
|
|
165
|
-
value,
|
|
166
165
|
timestamps,
|
|
167
166
|
reasoning,
|
|
168
167
|
};
|
|
@@ -221,9 +220,8 @@ const parseJsonCitation = (jsonCitation, citationNumber) => {
|
|
|
221
220
|
fullPhrase,
|
|
222
221
|
citationNumber,
|
|
223
222
|
lineIds,
|
|
224
|
-
keySpan,
|
|
223
|
+
keySpan: keySpan || value,
|
|
225
224
|
reasoning,
|
|
226
|
-
value,
|
|
227
225
|
};
|
|
228
226
|
return citation;
|
|
229
227
|
};
|
|
@@ -94,7 +94,7 @@ const StatusTooltipContent = ({ citation, status, verification, isExpanded, onTo
|
|
|
94
94
|
}
|
|
95
95
|
// Fallback to citation text if no phrases recorded
|
|
96
96
|
if (allPhrases.length === 0) {
|
|
97
|
-
const searchedText = citation.fullPhrase || citation.
|
|
97
|
+
const searchedText = citation.fullPhrase || citation.keySpan?.toString() || "";
|
|
98
98
|
if (searchedText) {
|
|
99
99
|
allPhrases.push(searchedText);
|
|
100
100
|
}
|
|
@@ -104,7 +104,7 @@ const StatusTooltipContent = ({ citation, status, verification, isExpanded, onTo
|
|
|
104
104
|
return (_jsxs("span", { className: "dc-status-tooltip", role: "tooltip", children: [_jsxs("span", { className: "dc-status-header dc-status-header--miss", children: [_jsx(WarningIcon, {}), _jsx("span", { children: "Not found in source" })] }), allPhrases.length > 0 && (_jsxs("span", { className: "dc-search-phrases", children: [_jsxs("span", { className: "dc-search-phrases-header", children: [hiddenCount > 0 && (_jsx("button", { type: "button", className: "dc-search-phrases-toggle", onClick: onToggleExpand, children: isExpanded ? "collapse" : `+${hiddenCount} more` })), _jsxs("span", { className: "dc-status-label", children: ["Searched ", allPhrases.length, " phrase", allPhrases.length > 1 ? "s" : ""] })] }), _jsx("span", { className: "dc-search-phrases-list", children: (isExpanded ? allPhrases : allPhrases.slice(0, 1)).map((phrase, idx) => (_jsxs("span", { className: "dc-search-phrase-item", children: ["\"", phrase.length > 80 ? phrase.slice(0, 80) + "…" : phrase, "\""] }, idx))) })] }))] }));
|
|
105
105
|
}
|
|
106
106
|
if (isPartialMatch) {
|
|
107
|
-
const expectedText = citation.fullPhrase || citation.
|
|
107
|
+
const expectedText = citation.fullPhrase || citation.keySpan?.toString() || "";
|
|
108
108
|
const actualText = verification?.matchSnippet || "";
|
|
109
109
|
const truncatedExpected = expectedText.length > 100
|
|
110
110
|
? expectedText.slice(0, 100) + "…"
|
|
@@ -68,7 +68,7 @@ export const ChipCitation = forwardRef(({ citation, children, className, display
|
|
|
68
68
|
? "citation-chip--pending"
|
|
69
69
|
: "";
|
|
70
70
|
return (_jsxs(_Fragment, { children: [children, _jsxs("span", { ref: ref, "data-citation-id": citationKey, "data-citation-instance": citationInstanceId, "data-variant": "chip", className: classNames("citation-chip", sizeClasses[size], statusClass, className), onMouseEnter: preventTooltips ? undefined : handleMouseEnter, onMouseLeave: preventTooltips ? undefined : handleMouseLeave, onMouseDown: handleClick, onClick: (e) => e.stopPropagation(), "aria-label": displayText ? `Citation: ${displayText}` : undefined, children: [showIcon &&
|
|
71
|
-
(icon || _jsx("span", { className: "citation-chip__icon", children: "\uD83D\uDCC4" })),
|
|
71
|
+
(icon || _jsx("span", { className: "citation-chip__icon", children: "\uD83D\uDCC4" })), _jsx("span", { className: "citation-chip__text", children: displayText }), isPartialMatch && renderPartialIndicator(status), isVerified && !isPartialMatch && renderVerifiedIndicator(status), isPending && (_jsx("span", { className: "citation-chip__pending", children: pendingContent }))] })] }));
|
|
72
72
|
});
|
|
73
73
|
ChipCitation.displayName = "ChipCitation";
|
|
74
74
|
/**
|
package/lib/react/primitives.js
CHANGED
|
@@ -101,7 +101,7 @@ export const CitationNumber = forwardRef(({ className, number, ...props }, ref)
|
|
|
101
101
|
if (number !== undefined)
|
|
102
102
|
return String(number);
|
|
103
103
|
if (config.displayKeySpan) {
|
|
104
|
-
return (citation.
|
|
104
|
+
return (citation.keySpan?.toString() ||
|
|
105
105
|
citation.citationNumber?.toString() ||
|
|
106
106
|
config.fallbackDisplay ||
|
|
107
107
|
"");
|
|
@@ -120,9 +120,9 @@ export const CitationValue = forwardRef(({ className, value, separator = " ", ..
|
|
|
120
120
|
const displayValue = useMemo(() => {
|
|
121
121
|
if (value !== undefined)
|
|
122
122
|
return value;
|
|
123
|
-
if (config.displayKeySpan)
|
|
123
|
+
if (!config.displayKeySpan)
|
|
124
124
|
return "";
|
|
125
|
-
return citation.
|
|
125
|
+
return citation.keySpan?.toString() || "";
|
|
126
126
|
}, [value, citation, config]);
|
|
127
127
|
if (!displayValue)
|
|
128
128
|
return null;
|
package/lib/react/utils.js
CHANGED
|
@@ -20,7 +20,7 @@ export function generateCitationKey(citation) {
|
|
|
20
20
|
* Combines the citation key with a random suffix for uniqueness.
|
|
21
21
|
*/
|
|
22
22
|
export function generateCitationInstanceId(citationKey) {
|
|
23
|
-
const randomSuffix = Math.random().toString(36).
|
|
23
|
+
const randomSuffix = Math.random().toString(36).slice(2, 11);
|
|
24
24
|
return `${citationKey}-${randomSuffix}`;
|
|
25
25
|
}
|
|
26
26
|
/**
|
package/lib/types/citation.d.ts
CHANGED
package/lib/types/search.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SearchStatus = "loading" | "pending" | "not_found" | "partial_text_found" | "found" | "
|
|
1
|
+
export type SearchStatus = "loading" | "pending" | "not_found" | "partial_text_found" | "found" | "found_key_span_only" | "found_phrase_missed_value" | "found_on_other_page" | "found_on_other_line" | "first_word_found" | "timestamp_wip";
|
|
2
2
|
export type SearchMethod = "exact_line_match" | "line_with_buffer" | "current_page" | "keyspan_fallback" | "adjacent_pages" | "expanded_window" | "regex_search" | "bm25_search" | "fuzzy_regex" | "first_word_fallback";
|
|
3
3
|
export interface SearchAttempt {
|
|
4
4
|
method: SearchMethod;
|