@deepcitation/deepcitation-js 1.1.4 → 1.1.6
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 +2 -4
- package/lib/react/CitationComponent.js +8 -10
- package/lib/react/CitationVariants.js +17 -17
- package/lib/react/index.d.ts +2 -2
- package/lib/react/index.js +2 -2
- package/lib/react/primitives.d.ts +2 -2
- package/lib/react/primitives.js +7 -7
- package/lib/react/types.d.ts +1 -1
- package/lib/react/utils.d.ts +4 -4
- package/lib/react/utils.js +9 -9
- package/lib/types/citation.d.ts +0 -1
- package/lib/types/verification.d.ts +1 -3
- package/lib/types/verification.js +1 -3
- package/package.json +1 -1
|
@@ -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) + "…"
|
|
@@ -182,7 +182,7 @@ const DefaultPopoverContent = ({ verification, status, onImageClick, }) => {
|
|
|
182
182
|
* This means partial matches have blue text (because they were found) but
|
|
183
183
|
* an orange indicator (because they didn't match exactly).
|
|
184
184
|
*/
|
|
185
|
-
export const CitationComponent = forwardRef(({ citation, children, className,
|
|
185
|
+
export const CitationComponent = forwardRef(({ citation, children, className, displayKeySpan = false, fallbackDisplay, verification, variant = "brackets", eventHandlers, isMobile = false, renderIndicator, renderContent, popoverPosition = "top", renderPopoverContent, }, ref) => {
|
|
186
186
|
const containerRef = useRef(null);
|
|
187
187
|
const wrapperRef = useRef(null);
|
|
188
188
|
const [expandedImageSrc, setExpandedImageSrc] = useState(null);
|
|
@@ -274,13 +274,13 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
274
274
|
}
|
|
275
275
|
// For text/minimal/brackets, show the value or fullPhrase
|
|
276
276
|
return getCitationDisplayText(citation, {
|
|
277
|
-
|
|
277
|
+
displayKeySpan: variant === "text" ||
|
|
278
278
|
variant === "minimal" ||
|
|
279
279
|
variant === "brackets" ||
|
|
280
|
-
|
|
280
|
+
displayKeySpan,
|
|
281
281
|
fallbackDisplay,
|
|
282
282
|
});
|
|
283
|
-
}, [citation, variant,
|
|
283
|
+
}, [citation, variant, displayKeySpan, fallbackDisplay]);
|
|
284
284
|
// Found status class for text styling (blue for found, gray for miss)
|
|
285
285
|
const foundStatusClass = useMemo(() => getFoundStatusClass(status), [status]);
|
|
286
286
|
// Event handlers
|
|
@@ -300,7 +300,7 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
300
300
|
// Early return for miss with fallback display
|
|
301
301
|
if (fallbackDisplay !== null &&
|
|
302
302
|
fallbackDisplay !== undefined &&
|
|
303
|
-
|
|
303
|
+
displayKeySpan &&
|
|
304
304
|
isMiss) {
|
|
305
305
|
return (_jsx("span", { className: classNames("dc-citation-fallback", className), children: fallbackDisplay }));
|
|
306
306
|
}
|
|
@@ -332,9 +332,7 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
332
332
|
status,
|
|
333
333
|
citationKey,
|
|
334
334
|
displayText,
|
|
335
|
-
isMergedDisplay: variant === "text" ||
|
|
336
|
-
variant === "brackets" ||
|
|
337
|
-
displayCitationValue,
|
|
335
|
+
isMergedDisplay: variant === "text" || variant === "brackets" || displayKeySpan,
|
|
338
336
|
});
|
|
339
337
|
}
|
|
340
338
|
// Indicator-only variant - just the checkmark/warning
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { memo, useMemo, useCallback, forwardRef, } from "react";
|
|
3
3
|
import { getCitationStatus } from "../parsing/parseCitation.js";
|
|
4
|
-
import { generateCitationKey, generateCitationInstanceId, getCitationDisplayText,
|
|
4
|
+
import { generateCitationKey, generateCitationInstanceId, getCitationDisplayText, getCitationKeySpanText, classNames, } from "./utils.js";
|
|
5
5
|
const TWO_DOTS_THINKING_CONTENT = "..";
|
|
6
6
|
/**
|
|
7
7
|
* Hook to get common citation data.
|
|
@@ -31,16 +31,16 @@ const DefaultPartialIndicator = () => (_jsx("span", { className: "citation-parti
|
|
|
31
31
|
* <ChipCitation citation={citation} verification={found} size="md" />
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
export const ChipCitation = forwardRef(({ citation, children, className,
|
|
34
|
+
export const ChipCitation = forwardRef(({ citation, children, className, displayKeySpan = false, fallbackDisplay, verification, eventHandlers, isMobile = false, preventTooltips = false, pendingContent = TWO_DOTS_THINKING_CONTENT, renderVerifiedIndicator = () => _jsx(DefaultVerifiedIndicator, {}), renderPartialIndicator = () => _jsx(DefaultPartialIndicator, {}), size = "md", showIcon = false, icon, }, ref) => {
|
|
35
35
|
const { citationKey, citationInstanceId, status } = useCitationData(citation, verification);
|
|
36
36
|
const { isVerified, isMiss, isPartialMatch, isPending } = status;
|
|
37
37
|
const displayText = useMemo(() => getCitationDisplayText(citation, {
|
|
38
|
-
|
|
38
|
+
displayKeySpan,
|
|
39
39
|
fallbackDisplay,
|
|
40
|
-
}), [citation,
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
}), [citation,
|
|
40
|
+
}), [citation, displayKeySpan, fallbackDisplay]);
|
|
41
|
+
const keySpanText = useMemo(() => getCitationKeySpanText(citation, {
|
|
42
|
+
displayKeySpan,
|
|
43
|
+
}), [citation, displayKeySpan]);
|
|
44
44
|
const handleClick = useCallback((e) => {
|
|
45
45
|
e.preventDefault();
|
|
46
46
|
e.stopPropagation();
|
|
@@ -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
|
/**
|
|
@@ -81,13 +81,13 @@ ChipCitation.displayName = "ChipCitation";
|
|
|
81
81
|
* // Renders: Text content¹
|
|
82
82
|
* ```
|
|
83
83
|
*/
|
|
84
|
-
export const SuperscriptCitation = forwardRef(({ citation, children, className,
|
|
84
|
+
export const SuperscriptCitation = forwardRef(({ citation, children, className, displayKeySpan = false, fallbackDisplay, verification, eventHandlers, isMobile = false, preventTooltips = false, pendingContent = TWO_DOTS_THINKING_CONTENT, renderVerifiedIndicator = () => _jsx(DefaultVerifiedIndicator, {}), renderPartialIndicator = () => _jsx(DefaultPartialIndicator, {}), showBrackets = false, }, ref) => {
|
|
85
85
|
const { citationKey, citationInstanceId, status } = useCitationData(citation, verification);
|
|
86
86
|
const { isVerified, isMiss, isPartialMatch, isPending } = status;
|
|
87
87
|
const displayText = useMemo(() => getCitationDisplayText(citation, {
|
|
88
|
-
|
|
88
|
+
displayKeySpan,
|
|
89
89
|
fallbackDisplay,
|
|
90
|
-
}), [citation,
|
|
90
|
+
}), [citation, displayKeySpan, fallbackDisplay]);
|
|
91
91
|
const handleClick = useCallback((e) => {
|
|
92
92
|
e.preventDefault();
|
|
93
93
|
e.stopPropagation();
|
|
@@ -173,14 +173,14 @@ FootnoteCitation.displayName = "FootnoteCitation";
|
|
|
173
173
|
* // Renders: "quoted text" with subtle underline
|
|
174
174
|
* ```
|
|
175
175
|
*/
|
|
176
|
-
export const InlineCitation = forwardRef(({ citation, children, className,
|
|
176
|
+
export const InlineCitation = forwardRef(({ citation, children, className, displayKeySpan = true, // Default to merged for inline
|
|
177
177
|
fallbackDisplay, verification, eventHandlers, preventTooltips = false, pendingContent = TWO_DOTS_THINKING_CONTENT, renderVerifiedIndicator = () => _jsx(DefaultVerifiedIndicator, {}), renderPartialIndicator = () => _jsx(DefaultPartialIndicator, {}), underlineStyle = "dotted", }, ref) => {
|
|
178
178
|
const { citationKey, citationInstanceId, status } = useCitationData(citation, verification);
|
|
179
179
|
const { isVerified, isMiss, isPartialMatch, isPending } = status;
|
|
180
180
|
const displayText = useMemo(() => getCitationDisplayText(citation, {
|
|
181
|
-
|
|
181
|
+
displayKeySpan,
|
|
182
182
|
fallbackDisplay,
|
|
183
|
-
}), [citation,
|
|
183
|
+
}), [citation, displayKeySpan, fallbackDisplay]);
|
|
184
184
|
const handleClick = useCallback((e) => {
|
|
185
185
|
e.preventDefault();
|
|
186
186
|
e.stopPropagation();
|
|
@@ -216,13 +216,13 @@ InlineCitation.displayName = "InlineCitation";
|
|
|
216
216
|
* // Renders: 1
|
|
217
217
|
* ```
|
|
218
218
|
*/
|
|
219
|
-
export const MinimalCitation = forwardRef(({ citation, children, className,
|
|
219
|
+
export const MinimalCitation = forwardRef(({ citation, children, className, displayKeySpan = false, fallbackDisplay, verification, eventHandlers, preventTooltips = false, pendingContent = TWO_DOTS_THINKING_CONTENT, renderVerifiedIndicator = () => _jsx(DefaultVerifiedIndicator, {}), renderPartialIndicator = () => _jsx(DefaultPartialIndicator, {}), showStatusIndicator = true, }, ref) => {
|
|
220
220
|
const { citationKey, citationInstanceId, status } = useCitationData(citation, verification);
|
|
221
221
|
const { isVerified, isMiss, isPartialMatch, isPending } = status;
|
|
222
222
|
const displayText = useMemo(() => getCitationDisplayText(citation, {
|
|
223
|
-
|
|
223
|
+
displayKeySpan,
|
|
224
224
|
fallbackDisplay,
|
|
225
|
-
}), [citation,
|
|
225
|
+
}), [citation, displayKeySpan, fallbackDisplay]);
|
|
226
226
|
const handleClick = useCallback((e) => {
|
|
227
227
|
e.preventDefault();
|
|
228
228
|
e.stopPropagation();
|
package/lib/react/index.d.ts
CHANGED
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
* @packageDocumentation
|
|
12
12
|
*/
|
|
13
13
|
export type { CitationContentProps, CitationRenderProps, CitationTooltipProps, CitationStyles, CitationStateClasses, CitationCursorClasses, CitationEventHandlers, CitationVariant as CitationVariantType, UrlFetchStatus, UrlCitationMeta, UrlCitationProps, } from "./types.js";
|
|
14
|
-
export { extractDomain, isBlockedStatus, isErrorStatus, isVerifiedStatus } from "./UrlCitationComponent.js";
|
|
15
|
-
export { generateCitationKey, generateCitationInstanceId, getCitationDisplayText,
|
|
14
|
+
export { extractDomain, isBlockedStatus, isErrorStatus, isVerifiedStatus, } from "./UrlCitationComponent.js";
|
|
15
|
+
export { generateCitationKey, generateCitationInstanceId, getCitationDisplayText, getCitationKeySpanText, classNames, CITATION_X_PADDING, CITATION_Y_PADDING, } from "./utils.js";
|
|
16
16
|
export { CitationComponent, MemoizedCitationComponent, type CitationVariant, type CitationComponentProps, } from "./CitationComponent.js";
|
package/lib/react/index.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* @packageDocumentation
|
|
12
12
|
*/
|
|
13
13
|
// URL Utilities - For handling URL citation metadata
|
|
14
|
-
export { extractDomain, isBlockedStatus, isErrorStatus, isVerifiedStatus } from "./UrlCitationComponent.js";
|
|
14
|
+
export { extractDomain, isBlockedStatus, isErrorStatus, isVerifiedStatus, } from "./UrlCitationComponent.js";
|
|
15
15
|
// Utilities - For generating citation keys and display text
|
|
16
|
-
export { generateCitationKey, generateCitationInstanceId, getCitationDisplayText,
|
|
16
|
+
export { generateCitationKey, generateCitationInstanceId, getCitationDisplayText, getCitationKeySpanText, classNames, CITATION_X_PADDING, CITATION_Y_PADDING, } from "./utils.js";
|
|
17
17
|
// Components
|
|
18
18
|
export { CitationComponent, MemoizedCitationComponent, } from "./CitationComponent.js";
|
|
@@ -14,7 +14,7 @@ interface CitationContextValue {
|
|
|
14
14
|
verification: Verification | null;
|
|
15
15
|
searchState: SearchState | null;
|
|
16
16
|
config: {
|
|
17
|
-
|
|
17
|
+
displayKeySpan: boolean;
|
|
18
18
|
fallbackDisplay: string | null;
|
|
19
19
|
pendingContent: ReactNode;
|
|
20
20
|
};
|
|
@@ -28,7 +28,7 @@ export interface CitationRootProps {
|
|
|
28
28
|
verification?: Verification | null;
|
|
29
29
|
searchState?: SearchState | null;
|
|
30
30
|
children: ReactNode;
|
|
31
|
-
|
|
31
|
+
displayKeySpan?: boolean;
|
|
32
32
|
fallbackDisplay?: string | null;
|
|
33
33
|
pendingContent?: ReactNode;
|
|
34
34
|
}
|
package/lib/react/primitives.js
CHANGED
|
@@ -20,7 +20,7 @@ export function useCitationContextSafe() {
|
|
|
20
20
|
return useContext(CitationContext);
|
|
21
21
|
}
|
|
22
22
|
/** Root component that provides citation context to all child primitives. */
|
|
23
|
-
export const CitationRoot = forwardRef(({ citation, verification = null, searchState = null, children,
|
|
23
|
+
export const CitationRoot = forwardRef(({ citation, verification = null, searchState = null, children, displayKeySpan = false, fallbackDisplay = null, pendingContent = "..", className, ...props }, ref) => {
|
|
24
24
|
const citationKey = useMemo(() => generateCitationKey(citation), [citation]);
|
|
25
25
|
const citationInstanceId = useMemo(() => generateCitationInstanceId(citationKey), [citationKey]);
|
|
26
26
|
const status = getCitationStatus(verification);
|
|
@@ -32,7 +32,7 @@ export const CitationRoot = forwardRef(({ citation, verification = null, searchS
|
|
|
32
32
|
verification,
|
|
33
33
|
searchState,
|
|
34
34
|
config: {
|
|
35
|
-
|
|
35
|
+
displayKeySpan,
|
|
36
36
|
fallbackDisplay,
|
|
37
37
|
pendingContent,
|
|
38
38
|
},
|
|
@@ -43,7 +43,7 @@ export const CitationRoot = forwardRef(({ citation, verification = null, searchS
|
|
|
43
43
|
status,
|
|
44
44
|
verification,
|
|
45
45
|
searchState,
|
|
46
|
-
|
|
46
|
+
displayKeySpan,
|
|
47
47
|
fallbackDisplay,
|
|
48
48
|
pendingContent,
|
|
49
49
|
]);
|
|
@@ -100,8 +100,8 @@ export const CitationNumber = forwardRef(({ className, number, ...props }, ref)
|
|
|
100
100
|
const displayNumber = useMemo(() => {
|
|
101
101
|
if (number !== undefined)
|
|
102
102
|
return String(number);
|
|
103
|
-
if (config.
|
|
104
|
-
return (citation.
|
|
103
|
+
if (config.displayKeySpan) {
|
|
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.
|
|
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/types.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ export interface BaseCitationProps {
|
|
|
90
90
|
/** Class name for controlling inner content width */
|
|
91
91
|
innerWidthClassName?: string;
|
|
92
92
|
/** When true, displays value/citationNumber merged in the bracket */
|
|
93
|
-
|
|
93
|
+
displayKeySpan?: boolean;
|
|
94
94
|
/** Fallback display text when citation value is empty */
|
|
95
95
|
fallbackDisplay?: string | null;
|
|
96
96
|
/** Display variant for the citation */
|
package/lib/react/utils.d.ts
CHANGED
|
@@ -13,14 +13,14 @@ export declare function generateCitationInstanceId(citationKey: string): string;
|
|
|
13
13
|
* Gets the display text for a citation based on configuration.
|
|
14
14
|
*/
|
|
15
15
|
export declare function getCitationDisplayText(citation: Citation, options?: {
|
|
16
|
-
|
|
16
|
+
displayKeySpan?: boolean;
|
|
17
17
|
fallbackDisplay?: string | null;
|
|
18
18
|
}): string;
|
|
19
19
|
/**
|
|
20
|
-
* Gets the
|
|
20
|
+
* Gets the keySpan text to display before the citation bracket.
|
|
21
21
|
*/
|
|
22
|
-
export declare function
|
|
23
|
-
|
|
22
|
+
export declare function getCitationKeySpanText(citation: Citation, options?: {
|
|
23
|
+
displayKeySpan?: boolean;
|
|
24
24
|
}): string;
|
|
25
25
|
/**
|
|
26
26
|
* Joins class names, filtering out falsy values.
|
package/lib/react/utils.js
CHANGED
|
@@ -20,16 +20,16 @@ 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
|
/**
|
|
27
27
|
* Gets the display text for a citation based on configuration.
|
|
28
28
|
*/
|
|
29
29
|
export function getCitationDisplayText(citation, options = {}) {
|
|
30
|
-
const {
|
|
31
|
-
if (
|
|
32
|
-
return (citation.
|
|
30
|
+
const { displayKeySpan = false, fallbackDisplay } = options;
|
|
31
|
+
if (displayKeySpan) {
|
|
32
|
+
return (citation.keySpan?.toString() ||
|
|
33
33
|
citation.citationNumber?.toString() ||
|
|
34
34
|
fallbackDisplay ||
|
|
35
35
|
"");
|
|
@@ -37,14 +37,14 @@ export function getCitationDisplayText(citation, options = {}) {
|
|
|
37
37
|
return citation.citationNumber?.toString() || "";
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Gets the
|
|
40
|
+
* Gets the keySpan text to display before the citation bracket.
|
|
41
41
|
*/
|
|
42
|
-
export function
|
|
43
|
-
const {
|
|
44
|
-
if (
|
|
42
|
+
export function getCitationKeySpanText(citation, options = {}) {
|
|
43
|
+
const { displayKeySpan = false } = options;
|
|
44
|
+
if (displayKeySpan) {
|
|
45
45
|
return "";
|
|
46
46
|
}
|
|
47
|
-
return citation.
|
|
47
|
+
return citation.keySpan?.toString() || "";
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Joins class names, filtering out falsy values.
|
package/lib/types/citation.d.ts
CHANGED
|
@@ -5,10 +5,8 @@ export declare const NOT_FOUND_VERIFICATION_INDEX = -1;
|
|
|
5
5
|
export declare const PENDING_VERIFICATION_INDEX = -2;
|
|
6
6
|
export declare const BLANK_VERIFICATION: Verification;
|
|
7
7
|
export interface Verification {
|
|
8
|
-
|
|
9
|
-
lowerCaseSearchTerm: string | null;
|
|
8
|
+
fileId?: string | null;
|
|
10
9
|
label?: string | null;
|
|
11
|
-
attachmentId?: string | null;
|
|
12
10
|
pageNumber?: number | null;
|
|
13
11
|
timestamp?: number | null;
|
|
14
12
|
citation?: Citation;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
export const NOT_FOUND_VERIFICATION_INDEX = -1;
|
|
2
2
|
export const PENDING_VERIFICATION_INDEX = -2;
|
|
3
3
|
export const BLANK_VERIFICATION = {
|
|
4
|
+
fileId: null,
|
|
4
5
|
pageNumber: NOT_FOUND_VERIFICATION_INDEX,
|
|
5
|
-
regex: null,
|
|
6
|
-
lowerCaseSearchTerm: null,
|
|
7
|
-
attachmentId: null,
|
|
8
6
|
matchSnippet: null,
|
|
9
7
|
source: null,
|
|
10
8
|
citation: {
|