@deepcitation/deepcitation-js 1.1.15 → 1.1.16
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/react/CitationComponent.d.ts +8 -8
- package/lib/react/CitationComponent.js +18 -13
- package/lib/react/CitationVariants.d.ts +2 -2
- package/lib/react/CitationVariants.js +15 -15
- package/lib/react/primitives.d.ts +2 -2
- package/lib/react/primitives.js +5 -5
- package/lib/react/types.d.ts +5 -5
- package/lib/react/utils.d.ts +2 -2
- package/lib/react/utils.js +4 -4
- package/package.json +1 -1
|
@@ -16,22 +16,22 @@ export type { CitationVariant } from "./types.js";
|
|
|
16
16
|
* // Renders: [Revenue grew by 25%✓] with blue text
|
|
17
17
|
* ```
|
|
18
18
|
*
|
|
19
|
-
* @example Numeric only - use
|
|
19
|
+
* @example Numeric only - use hideKeySpan=true with brackets variant
|
|
20
20
|
* ```tsx
|
|
21
21
|
* <CitationComponent
|
|
22
22
|
* citation={{ citationNumber: 1, keySpan: "25% growth" }}
|
|
23
23
|
* verification={verificationResult}
|
|
24
|
-
*
|
|
24
|
+
* hideKeySpan={true}
|
|
25
25
|
* />
|
|
26
26
|
* // Renders: [1✓]
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
|
-
* @example Without brackets - use
|
|
29
|
+
* @example Without brackets - use hideBrackets=true
|
|
30
30
|
* ```tsx
|
|
31
31
|
* <CitationComponent
|
|
32
32
|
* citation={{ citationNumber: 1, keySpan: "25% growth" }}
|
|
33
33
|
* verification={verificationResult}
|
|
34
|
-
*
|
|
34
|
+
* hideBrackets={true}
|
|
35
35
|
* />
|
|
36
36
|
* // Renders: 25% growth✓ (no brackets)
|
|
37
37
|
* ```
|
|
@@ -114,11 +114,11 @@ export interface CitationComponentProps extends BaseCitationProps {
|
|
|
114
114
|
*/
|
|
115
115
|
variant?: CitationVariant;
|
|
116
116
|
/**
|
|
117
|
-
* Whether to
|
|
117
|
+
* Whether to hide square brackets around the citation.
|
|
118
118
|
* Only applies to the `brackets` variant.
|
|
119
|
-
* @default
|
|
119
|
+
* @default false
|
|
120
120
|
*/
|
|
121
|
-
|
|
121
|
+
hideBrackets?: boolean;
|
|
122
122
|
/**
|
|
123
123
|
* Event handlers for citation interactions.
|
|
124
124
|
* These are always called regardless of behaviorConfig settings.
|
|
@@ -149,7 +149,7 @@ export interface CitationComponentProps extends BaseCitationProps {
|
|
|
149
149
|
renderIndicator?: (status: CitationStatus) => ReactNode;
|
|
150
150
|
/**
|
|
151
151
|
* Custom render function for the entire citation content.
|
|
152
|
-
* When provided, takes full control of rendering
|
|
152
|
+
* When provided, takes full control of rendering.
|
|
153
153
|
*/
|
|
154
154
|
renderContent?: (props: CitationRenderProps) => ReactNode;
|
|
155
155
|
/**
|
|
@@ -198,7 +198,7 @@ const DefaultPopoverContent = ({ citation, verification, status, onImageClick, }
|
|
|
198
198
|
* This means partial matches have blue text (because they were found) but
|
|
199
199
|
* an orange indicator (because they didn't match exactly).
|
|
200
200
|
*/
|
|
201
|
-
export const CitationComponent = forwardRef(({ citation, children, className,
|
|
201
|
+
export const CitationComponent = forwardRef(({ citation, children, className, hideKeySpan = false, hideBrackets = false, fallbackDisplay, verification, variant = "brackets", eventHandlers, behaviorConfig, isMobile = false, renderIndicator, renderContent, popoverPosition = "top", renderPopoverContent, }, ref) => {
|
|
202
202
|
const containerRef = useRef(null);
|
|
203
203
|
const wrapperRef = useRef(null);
|
|
204
204
|
const [expandedImageSrc, setExpandedImageSrc] = useState(null);
|
|
@@ -280,7 +280,7 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
280
280
|
e.preventDefault();
|
|
281
281
|
e.stopPropagation();
|
|
282
282
|
const context = getBehaviorContext();
|
|
283
|
-
// If custom onClick handler is provided, it REPLACES default behavior
|
|
283
|
+
// If custom onClick handler is provided via behaviorConfig, it REPLACES default behavior
|
|
284
284
|
if (behaviorConfig?.onClick) {
|
|
285
285
|
const result = behaviorConfig.onClick(context, e);
|
|
286
286
|
// If custom handler returns actions, apply them
|
|
@@ -292,7 +292,13 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
292
292
|
eventHandlers?.onClick?.(citation, citationKey, e);
|
|
293
293
|
return;
|
|
294
294
|
}
|
|
295
|
-
//
|
|
295
|
+
// If eventHandlers.onClick is provided, disable default click behavior
|
|
296
|
+
// (no popover pinning, no image expansion) - just call the handler
|
|
297
|
+
if (eventHandlers?.onClick) {
|
|
298
|
+
eventHandlers.onClick(citation, citationKey, e);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
// Default click behavior (only runs when no click handlers are provided)
|
|
296
302
|
if (verification?.verificationImageBase64) {
|
|
297
303
|
if (expandedImageSrc) {
|
|
298
304
|
// Image is open - close it and unpin
|
|
@@ -313,7 +319,6 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
313
319
|
setIsTooltipExpanded((prev) => !prev);
|
|
314
320
|
setIsPhrasesExpanded((prev) => !prev);
|
|
315
321
|
}
|
|
316
|
-
eventHandlers?.onClick?.(citation, citationKey, e);
|
|
317
322
|
}, [
|
|
318
323
|
eventHandlers,
|
|
319
324
|
behaviorConfig,
|
|
@@ -329,15 +334,15 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
329
334
|
// const { isVerified, isPending } = status;
|
|
330
335
|
const { isMiss, isPartialMatch, isVerified, isPending } = status;
|
|
331
336
|
const displayText = useMemo(() => {
|
|
332
|
-
// For text/minimal variants, always show keySpan
|
|
333
|
-
// For brackets variant, show keySpan based on
|
|
337
|
+
// For text/minimal variants, always show keySpan (hideKeySpan is ignored)
|
|
338
|
+
// For brackets variant, show keySpan based on hideKeySpan prop
|
|
334
339
|
return getCitationDisplayText(citation, {
|
|
335
|
-
|
|
336
|
-
variant
|
|
337
|
-
|
|
340
|
+
hideKeySpan: variant !== "text" &&
|
|
341
|
+
variant !== "minimal" &&
|
|
342
|
+
hideKeySpan,
|
|
338
343
|
fallbackDisplay,
|
|
339
344
|
});
|
|
340
|
-
}, [citation, variant,
|
|
345
|
+
}, [citation, variant, hideKeySpan, fallbackDisplay]);
|
|
341
346
|
// Found status class for text styling (blue for found, gray for miss)
|
|
342
347
|
const foundStatusClass = useMemo(() => getFoundStatusClass(status), [status]);
|
|
343
348
|
// Event handlers
|
|
@@ -365,7 +370,7 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
365
370
|
// Early return for miss with fallback display
|
|
366
371
|
if (fallbackDisplay !== null &&
|
|
367
372
|
fallbackDisplay !== undefined &&
|
|
368
|
-
|
|
373
|
+
!hideKeySpan &&
|
|
369
374
|
isMiss) {
|
|
370
375
|
return (_jsx("span", { className: classNames("dc-citation-fallback", className), children: fallbackDisplay }));
|
|
371
376
|
}
|
|
@@ -398,7 +403,7 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
398
403
|
status,
|
|
399
404
|
citationKey,
|
|
400
405
|
displayText,
|
|
401
|
-
isMergedDisplay: variant === "text" || variant === "brackets" ||
|
|
406
|
+
isMergedDisplay: variant === "text" || variant === "brackets" || !hideKeySpan,
|
|
402
407
|
});
|
|
403
408
|
}
|
|
404
409
|
// Indicator-only variant - just the checkmark/warning
|
|
@@ -414,7 +419,7 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
414
419
|
return (_jsxs("span", { className: "dc-citation-text", children: [displayText, renderStatusIndicator()] }));
|
|
415
420
|
}
|
|
416
421
|
// Brackets variant (default) - keySpan/number in brackets with styling
|
|
417
|
-
return (_jsxs("span", { className: "dc-citation-bracket", "aria-hidden": "true", role: "presentation", children: [
|
|
422
|
+
return (_jsxs("span", { className: "dc-citation-bracket", "aria-hidden": "true", role: "presentation", children: [!hideBrackets && "[", _jsxs("span", { className: "dc-citation-text", children: [displayText, renderStatusIndicator()] }), !hideBrackets && "]"] }));
|
|
418
423
|
};
|
|
419
424
|
// Determine if popover should be shown
|
|
420
425
|
const isPopoverHidden = popoverPosition === "hidden";
|
|
@@ -43,8 +43,8 @@ export interface ChipCitationProps extends CitationVariantProps {
|
|
|
43
43
|
*/
|
|
44
44
|
export declare const ChipCitation: React.ForwardRefExoticComponent<ChipCitationProps & React.RefAttributes<HTMLSpanElement>>;
|
|
45
45
|
export interface SuperscriptCitationProps extends CitationVariantProps {
|
|
46
|
-
/** Whether to
|
|
47
|
-
|
|
46
|
+
/** Whether to hide brackets around the superscript */
|
|
47
|
+
hideBrackets?: boolean;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Superscript style citation component.
|
|
@@ -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, hideKeySpan = 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
|
+
hideKeySpan,
|
|
39
39
|
fallbackDisplay,
|
|
40
|
-
}), [citation,
|
|
40
|
+
}), [citation, hideKeySpan, fallbackDisplay]);
|
|
41
41
|
const keySpanText = useMemo(() => getCitationKeySpanText(citation, {
|
|
42
|
-
|
|
43
|
-
}), [citation,
|
|
42
|
+
hideKeySpan,
|
|
43
|
+
}), [citation, hideKeySpan]);
|
|
44
44
|
const handleClick = useCallback((e) => {
|
|
45
45
|
e.preventDefault();
|
|
46
46
|
e.stopPropagation();
|
|
@@ -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, hideKeySpan = false, fallbackDisplay, verification, eventHandlers, isMobile = false, preventTooltips = false, pendingContent = TWO_DOTS_THINKING_CONTENT, renderVerifiedIndicator = () => _jsx(DefaultVerifiedIndicator, {}), renderPartialIndicator = () => _jsx(DefaultPartialIndicator, {}), hideBrackets = 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
|
+
hideKeySpan,
|
|
89
89
|
fallbackDisplay,
|
|
90
|
-
}), [citation,
|
|
90
|
+
}), [citation, hideKeySpan, fallbackDisplay]);
|
|
91
91
|
const handleClick = useCallback((e) => {
|
|
92
92
|
e.preventDefault();
|
|
93
93
|
e.stopPropagation();
|
|
@@ -109,7 +109,7 @@ export const SuperscriptCitation = forwardRef(({ citation, children, className,
|
|
|
109
109
|
: isPending
|
|
110
110
|
? "citation-superscript--pending"
|
|
111
111
|
: "";
|
|
112
|
-
return (_jsxs(_Fragment, { children: [children, _jsxs("sup", { ref: ref, "data-citation-id": citationKey, "data-citation-instance": citationInstanceId, "data-variant": "superscript", className: classNames("citation-superscript", statusClass, className), onMouseEnter: preventTooltips ? undefined : handleMouseEnter, onMouseLeave: preventTooltips ? undefined : handleMouseLeave, onMouseDown: handleClick, onClick: (e) => e.stopPropagation(), "aria-label": `Citation ${displayText}`, children: [
|
|
112
|
+
return (_jsxs(_Fragment, { children: [children, _jsxs("sup", { ref: ref, "data-citation-id": citationKey, "data-citation-instance": citationInstanceId, "data-variant": "superscript", className: classNames("citation-superscript", statusClass, className), onMouseEnter: preventTooltips ? undefined : handleMouseEnter, onMouseLeave: preventTooltips ? undefined : handleMouseLeave, onMouseDown: handleClick, onClick: (e) => e.stopPropagation(), "aria-label": `Citation ${displayText}`, children: [!hideBrackets && "[", displayText, isPartialMatch && renderPartialIndicator(status), isVerified && !isPartialMatch && renderVerifiedIndicator(status), isPending && pendingContent, !hideBrackets && "]"] })] }));
|
|
113
113
|
});
|
|
114
114
|
SuperscriptCitation.displayName = "SuperscriptCitation";
|
|
115
115
|
const FOOTNOTE_SYMBOLS = ["*", "†", "‡", "§", "‖", "¶"];
|
|
@@ -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, hideKeySpan = false, // Default to showing keySpan 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
|
+
hideKeySpan,
|
|
182
182
|
fallbackDisplay,
|
|
183
|
-
}), [citation,
|
|
183
|
+
}), [citation, hideKeySpan, 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, hideKeySpan = 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
|
+
hideKeySpan,
|
|
224
224
|
fallbackDisplay,
|
|
225
|
-
}), [citation,
|
|
225
|
+
}), [citation, hideKeySpan, fallbackDisplay]);
|
|
226
226
|
const handleClick = useCallback((e) => {
|
|
227
227
|
e.preventDefault();
|
|
228
228
|
e.stopPropagation();
|
|
@@ -14,7 +14,7 @@ interface CitationContextValue {
|
|
|
14
14
|
verification: Verification | null;
|
|
15
15
|
searchState: SearchState | null;
|
|
16
16
|
config: {
|
|
17
|
-
|
|
17
|
+
hideKeySpan: 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
|
+
hideKeySpan?: 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, hideKeySpan = 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
|
+
hideKeySpan,
|
|
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
|
+
hideKeySpan,
|
|
47
47
|
fallbackDisplay,
|
|
48
48
|
pendingContent,
|
|
49
49
|
]);
|
|
@@ -100,7 +100,7 @@ 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.
|
|
103
|
+
if (!config.hideKeySpan) {
|
|
104
104
|
return (citation.keySpan?.toString() ||
|
|
105
105
|
citation.citationNumber?.toString() ||
|
|
106
106
|
config.fallbackDisplay ||
|
|
@@ -120,7 +120,7 @@ export const CitationKeySpan = forwardRef(({ className, keySpan, separator = " "
|
|
|
120
120
|
const displayKeySpan = useMemo(() => {
|
|
121
121
|
if (keySpan !== undefined)
|
|
122
122
|
return keySpan;
|
|
123
|
-
if (
|
|
123
|
+
if (config.hideKeySpan)
|
|
124
124
|
return "";
|
|
125
125
|
return citation.keySpan?.toString() || "";
|
|
126
126
|
}, [keySpan, citation, config]);
|
package/lib/react/types.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import type { SearchState } from "../types/search.js";
|
|
|
5
5
|
* Available citation display variants.
|
|
6
6
|
*
|
|
7
7
|
* - `brackets`: Shows keySpan/number in brackets with blue text styling (default).
|
|
8
|
-
* Use
|
|
9
|
-
* Use
|
|
8
|
+
* Use hideKeySpan=true for numeric-only display.
|
|
9
|
+
* Use hideBrackets=true to hide the square brackets.
|
|
10
10
|
* - `text`: Shows the keySpan, inherits parent text styling, no truncation, shows indicator
|
|
11
11
|
* - `minimal`: No brackets, just display text with indicator
|
|
12
12
|
* - `indicator`: Only the status indicator (checkmark/warning), no text
|
|
@@ -91,10 +91,10 @@ export interface BaseCitationProps {
|
|
|
91
91
|
/** Class name for controlling inner content width */
|
|
92
92
|
innerWidthClassName?: string;
|
|
93
93
|
/**
|
|
94
|
-
* When true,
|
|
95
|
-
* @default
|
|
94
|
+
* When true, hides keySpan and displays citation number only. When false, displays keySpan text.
|
|
95
|
+
* @default false
|
|
96
96
|
*/
|
|
97
|
-
|
|
97
|
+
hideKeySpan?: boolean;
|
|
98
98
|
/** Fallback display text when citation keySpan is empty */
|
|
99
99
|
fallbackDisplay?: string | null;
|
|
100
100
|
/** 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
|
+
hideKeySpan?: boolean;
|
|
17
17
|
fallbackDisplay?: string | null;
|
|
18
18
|
}): string;
|
|
19
19
|
/**
|
|
20
20
|
* Gets the keySpan text to display before the citation bracket.
|
|
21
21
|
*/
|
|
22
22
|
export declare function getCitationKeySpanText(citation: Citation, options?: {
|
|
23
|
-
|
|
23
|
+
hideKeySpan?: boolean;
|
|
24
24
|
}): string;
|
|
25
25
|
/**
|
|
26
26
|
* Joins class names, filtering out falsy values.
|
package/lib/react/utils.js
CHANGED
|
@@ -29,8 +29,8 @@ export function generateCitationInstanceId(citationKey) {
|
|
|
29
29
|
* Gets the display text for a citation based on configuration.
|
|
30
30
|
*/
|
|
31
31
|
export function getCitationDisplayText(citation, options = {}) {
|
|
32
|
-
const {
|
|
33
|
-
if (
|
|
32
|
+
const { hideKeySpan = false, fallbackDisplay } = options;
|
|
33
|
+
if (!hideKeySpan) {
|
|
34
34
|
return (citation.keySpan?.toString() ||
|
|
35
35
|
citation.citationNumber?.toString() ||
|
|
36
36
|
fallbackDisplay ||
|
|
@@ -42,8 +42,8 @@ export function getCitationDisplayText(citation, options = {}) {
|
|
|
42
42
|
* Gets the keySpan text to display before the citation bracket.
|
|
43
43
|
*/
|
|
44
44
|
export function getCitationKeySpanText(citation, options = {}) {
|
|
45
|
-
const {
|
|
46
|
-
if (
|
|
45
|
+
const { hideKeySpan = false } = options;
|
|
46
|
+
if (!hideKeySpan) {
|
|
47
47
|
return "";
|
|
48
48
|
}
|
|
49
49
|
return citation.keySpan?.toString() || "";
|