@coveo/quantic 3.29.0-pre.69831eeed4 → 3.29.0-pre.6b29972016
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/README.md +1 -1
- package/force-app/main/default/lwc/quanticCitation/quanticCitation.html +1 -0
- package/force-app/main/default/lwc/quanticCitation/quanticCitation.js +33 -7
- package/force-app/main/default/lwc/quanticFeedbackModal/quanticFeedbackModal.js +1 -1
- package/force-app/main/default/lwc/quanticFeedbackModalQna/quanticFeedbackModalQna.js +1 -1
- package/force-app/main/default/lwc/quanticGeneratedAnswer/quanticGeneratedAnswer.js +21 -6
- package/force-app/main/default/lwc/quanticGeneratedAnswer/templates/generatedAnswer.html +1 -0
- package/force-app/main/default/lwc/quanticSourceCitations/quanticSourceCitations.html +1 -0
- package/force-app/main/default/lwc/quanticSourceCitations/quanticSourceCitations.js +7 -0
- package/force-app/main/default/lwc/quanticUtils/citationAnchoringUtils.js +43 -0
- package/force-app/main/default/lwc/quanticUtils/quanticUtils.js +1 -0
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/case-assist-engine/case-assist-engine.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/breadcrumb-manager/headless-breadcrumb-manager.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/case-field/headless-case-field.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/case-input/headless-case-input.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/product-listing/headless-product-listing.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recommendations/headless-recommendations.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/search/headless-search.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/context/headless-core-context.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/did-you-mean/headless-core-did-you-mean.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/facet-manager/headless-core-facet-manager.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/facets/category-facet/headless-core-category-facet.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/facets/facet/headless-core-facet.d.ts +3 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/facets/range-facet/date-facet/headless-core-date-facet.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/facets/range-facet/date-facet/headless-core-date-filter.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-facet.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-filter.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/folded-result-list/headless-core-folded-result-list.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/pager/headless-core-pager.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/query-error/headless-core-query-error.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/result-list/headless-core-result-list.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/results-per-page/headless-core-results-per-page.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/sort/headless-core-sort.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/status/headless-core-status.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/tab/headless-core-tab.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/triggers/headless-core-notify-trigger.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/triggers/headless-core-query-trigger.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/triggers/headless-core-redirection-trigger.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/dictionary-field-context/headless-dictionary-field-context.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/document-suggestion-list/case-assist-headless-interactive-result.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/document-suggestion-list/headless-document-suggestion-list.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/field-suggestions/category-facet/headless-category-field-suggestions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/field-suggestions/facet/headless-field-suggestions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/history-manager/headless-history-manager.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/instant-results/instant-results.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/query-summary/headless-query-summary.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/quickview/case-assist-headless-quickview.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/quickview/headless-quickview.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/recent-queries-list/headless-recent-queries-list.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/recent-results-list/headless-recent-results-list.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/recommendation/headless-recommendation.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/relevance-inspector/headless-relevance-inspector.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/result-list/headless-interactive-result.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/standalone-search-box/headless-standalone-search-box.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/static-filter/headless-static-filter.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/triggers/headless-execute-trigger.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/url-manager/headless-url-manager.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/build.d.ts +8 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/controller-inference.d.ts +4 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/engine.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/types/engine.d.ts +4 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/types/from-build-result.d.ts +8 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce-next.index.d.ts +2 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/engine/commerce-engine.ssr.d.ts +13 -5
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/hydrated-state-factory.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/static-state-factory.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/build.d.ts +5 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/controller-inference.d.ts +0 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/engine.d.ts +6 -17
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/fetch-static-state.d.ts +7 -11
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/hydrate-static-state.d.ts +6 -10
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/controller-utils.d.ts +0 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/build.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/engine.d.ts +3 -9
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/fetch-static-state.d.ts +7 -12
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/hydrate-static-state.d.ts +6 -10
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/engine/search-engine.ssr.d.ts +8 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next.index.d.ts +1 -2
- package/force-app/main/default/staticresources/coveoheadless/headless.js +2 -2
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +2 -2
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +2 -2
- package/package.json +3 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/from-build-result.d.ts +0 -19
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/from-build-result.d.ts +0 -8
package/README.md
CHANGED
|
@@ -125,7 +125,7 @@ npm run deploy:examples --target-org MyCustomOrg
|
|
|
125
125
|
|
|
126
126
|
**Note** Before attempting to run [Playwright](https://playwright.dev/) tests, make sure the `Quantic Examples` community is deployed as described in the previous section in both orgs, the one where LWS is enabled and the one where it is disabled.
|
|
127
127
|
|
|
128
|
-
**Note** For more information on how to add tests, please refer to our [Quantic Testing Strategy](https://github.com/coveo/ui-kit/blob/
|
|
128
|
+
**Note** For more information on how to add tests, please refer to our [Quantic Testing Strategy](https://github.com/coveo/ui-kit/blob/main/packages/quantic/decisions/0001-testing-strategy.md), which provides detailed guidelines on testing Quantic components.
|
|
129
129
|
|
|
130
130
|
To run Playwright tests, run:
|
|
131
131
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {LinkUtils} from 'c/quanticUtils';
|
|
1
|
+
import {LinkUtils, generateTextFragmentUrl} from 'c/quanticUtils';
|
|
2
2
|
import {NavigationMixin} from 'lightning/navigation';
|
|
3
3
|
import {LightningElement, api} from 'lwc';
|
|
4
4
|
|
|
@@ -7,6 +7,8 @@ import {LightningElement, api} from 'lwc';
|
|
|
7
7
|
const minimumTooltipDisplayDurationMs = 1000;
|
|
8
8
|
const debounceDurationBeforeHoverMs = 200;
|
|
9
9
|
|
|
10
|
+
const supportedFileTypesForTextFragment = ['html', 'SalesforceItem'];
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* The `QuanticCitation` component renders an individual citation.
|
|
12
14
|
* @fires CustomEvent#quantic__citationhover
|
|
@@ -18,7 +20,7 @@ export default class QuanticCitation extends NavigationMixin(LightningElement) {
|
|
|
18
20
|
/**
|
|
19
21
|
* The citation item information.
|
|
20
22
|
* @api
|
|
21
|
-
* @type {{title: string, index: number, text: string, clickUri: string, fields: object}}
|
|
23
|
+
* @type {{title: string, index: number, text: string, uri: string, clickUri: string, fields: object}}
|
|
22
24
|
*/
|
|
23
25
|
@api citation;
|
|
24
26
|
/**
|
|
@@ -27,6 +29,13 @@ export default class QuanticCitation extends NavigationMixin(LightningElement) {
|
|
|
27
29
|
* @type {InteractiveCitation}
|
|
28
30
|
*/
|
|
29
31
|
@api interactiveCitation;
|
|
32
|
+
/**
|
|
33
|
+
* Whether to disable citation anchoring.
|
|
34
|
+
* @api
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
@api disableCitationAnchoring = false;
|
|
30
39
|
|
|
31
40
|
/** @type {Object} */
|
|
32
41
|
timeout;
|
|
@@ -42,6 +51,16 @@ export default class QuanticCitation extends NavigationMixin(LightningElement) {
|
|
|
42
51
|
isInitialRender = true;
|
|
43
52
|
/** @type {string} */
|
|
44
53
|
salesforceRecordUrl;
|
|
54
|
+
/** @type {boolean} */
|
|
55
|
+
isHrefWithTextFragment = false;
|
|
56
|
+
|
|
57
|
+
connectedCallback() {
|
|
58
|
+
const fileType = this.citation?.fields?.filetype;
|
|
59
|
+
this.isHrefWithTextFragment =
|
|
60
|
+
!this.disableCitationAnchoring &&
|
|
61
|
+
supportedFileTypesForTextFragment.includes(fileType) &&
|
|
62
|
+
!!this.text;
|
|
63
|
+
}
|
|
45
64
|
|
|
46
65
|
renderedCallback() {
|
|
47
66
|
if (this.isInitialRender) {
|
|
@@ -111,7 +130,9 @@ export default class QuanticCitation extends NavigationMixin(LightningElement) {
|
|
|
111
130
|
}
|
|
112
131
|
|
|
113
132
|
handleClick(event) {
|
|
114
|
-
|
|
133
|
+
// Only apply the Salesforce navigation using the mixin for Salesforce documents and when citation anchoring is disabled.
|
|
134
|
+
// Otherwise we rely on the default behavior of the browser with a `hrefValue`.
|
|
135
|
+
if (this.isSalesforceLink && !this.isHrefWithTextFragment) {
|
|
115
136
|
event.preventDefault();
|
|
116
137
|
this.navigateToSalesforceRecord(event);
|
|
117
138
|
}
|
|
@@ -145,10 +166,9 @@ export default class QuanticCitation extends NavigationMixin(LightningElement) {
|
|
|
145
166
|
}
|
|
146
167
|
|
|
147
168
|
get hrefValue() {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return this.clickUri;
|
|
169
|
+
return this.isHrefWithTextFragment
|
|
170
|
+
? generateTextFragmentUrl(this.sourceUri, this.text)
|
|
171
|
+
: this.sourceUri;
|
|
152
172
|
}
|
|
153
173
|
|
|
154
174
|
/**
|
|
@@ -180,4 +200,10 @@ export default class QuanticCitation extends NavigationMixin(LightningElement) {
|
|
|
180
200
|
get index() {
|
|
181
201
|
return this.citation?.index;
|
|
182
202
|
}
|
|
203
|
+
|
|
204
|
+
get sourceUri() {
|
|
205
|
+
return this.isSalesforceLink
|
|
206
|
+
? this.salesforceRecordUrl
|
|
207
|
+
: (this.clickUri ?? this.citation?.uri);
|
|
208
|
+
}
|
|
183
209
|
}
|
|
@@ -20,7 +20,7 @@ import successTemplate from './success.html';
|
|
|
20
20
|
* The `QuanticFeedbackModal` component overlays a message modal on top of the current app window, the modal contains a form that allows the user to give feedback.
|
|
21
21
|
*
|
|
22
22
|
* Under the hood, the component relies on a [`lightningModal`](https://developer.salesforce.com/docs/component-library/bundle/lightning-modal/documentation) component.
|
|
23
|
-
* For an example of how to use the `QuanticFeedbackModal` component, see the [`quanticSmartSnippet`](https://github.com/coveo/ui-kit/blob/
|
|
23
|
+
* For an example of how to use the `QuanticFeedbackModal` component, see the [`quanticSmartSnippet`](https://github.com/coveo/ui-kit/blob/main/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/quanticSmartSnippet.js) implementation.
|
|
24
24
|
*
|
|
25
25
|
* @category Search
|
|
26
26
|
* @category Insight Panel
|
|
@@ -32,7 +32,7 @@ import successTemplate from './templates/success.html';
|
|
|
32
32
|
* The `QuanticFeedbackModalQna` component overlays a message modal on top of the current app window, the modal contains a form that allows the user to give feedback on a CRGA response.
|
|
33
33
|
*
|
|
34
34
|
* Under the hood, the component relies on a [`lightningModal`](https://developer.salesforce.com/docs/component-library/bundle/lightning-modal/documentation) component.
|
|
35
|
-
* For an example of how to use the `QuanticFeedbackModalQna` component, see the [`quanticGeneratedAnswer`](https://github.com/coveo/ui-kit/blob/
|
|
35
|
+
* For an example of how to use the `QuanticFeedbackModalQna` component, see the [`quanticGeneratedAnswer`](https://github.com/coveo/ui-kit/blob/main/packages/quantic/force-app/main/default/lwc/quanticGeneratedAnswer/quanticGeneratedAnswer.js) implementation.
|
|
36
36
|
*
|
|
37
37
|
* @category Search
|
|
38
38
|
* @category Insight Panel
|
|
@@ -49,6 +49,7 @@ const MAX_VALID_COLLAPSED_HEIGHT = 500;
|
|
|
49
49
|
const MIN_VALID_COLLAPSED_HEIGHT = 150;
|
|
50
50
|
|
|
51
51
|
const GENERATED_ANSWER_DATA_KEY = 'coveo-generated-answer-data';
|
|
52
|
+
const DEFAULT_CITATION_FIELDS = ['sfid', 'sfkbid', 'sfkavid', 'filetype'];
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
55
|
* The `QuanticGeneratedAnswer` component automatically generates an answer using Coveo machine learning models to answer the query executed by the user.
|
|
@@ -71,9 +72,9 @@ export default class QuanticGeneratedAnswer extends LightningElement {
|
|
|
71
72
|
* A list of fields to fetch with the citations used to generate the answer.
|
|
72
73
|
* @api
|
|
73
74
|
* @type {string}
|
|
74
|
-
* @defaultValue `'sfid,sfkbid,sfkavid'`
|
|
75
|
+
* @defaultValue `'sfid,sfkbid,sfkavid,filetype'`
|
|
75
76
|
*/
|
|
76
|
-
@api fieldsToIncludeInCitations = 'sfid,sfkbid,sfkavid';
|
|
77
|
+
@api fieldsToIncludeInCitations = 'sfid,sfkbid,sfkavid,filetype';
|
|
77
78
|
/**
|
|
78
79
|
* Whether the generated answer should be collapsible when it exceeds the maximum height of 250px.
|
|
79
80
|
* @api
|
|
@@ -118,6 +119,13 @@ export default class QuanticGeneratedAnswer extends LightningElement {
|
|
|
118
119
|
this._maxCollapsedHeight = DEFAULT_COLLAPSED_HEIGHT;
|
|
119
120
|
}
|
|
120
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Whether to disable citation anchoring.
|
|
124
|
+
* @api
|
|
125
|
+
* @type {boolean}
|
|
126
|
+
* @default false
|
|
127
|
+
*/
|
|
128
|
+
@api disableCitationAnchoring = false;
|
|
121
129
|
|
|
122
130
|
labels = {
|
|
123
131
|
generatedAnswerForYou,
|
|
@@ -530,10 +538,17 @@ export default class QuanticGeneratedAnswer extends LightningElement {
|
|
|
530
538
|
}
|
|
531
539
|
|
|
532
540
|
get citationFields() {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
541
|
+
const userCitationFields =
|
|
542
|
+
this.fieldsToIncludeInCitations
|
|
543
|
+
?.split(',')
|
|
544
|
+
.map((field) => field.trim())
|
|
545
|
+
.filter((field) => field.length > 0) || [];
|
|
546
|
+
|
|
547
|
+
const combinedCitationFields = [
|
|
548
|
+
...DEFAULT_CITATION_FIELDS,
|
|
549
|
+
...userCitationFields,
|
|
550
|
+
];
|
|
551
|
+
return [...new Set(combinedCitationFields)];
|
|
537
552
|
}
|
|
538
553
|
|
|
539
554
|
get shouldShowDisclaimer() {
|
|
@@ -37,6 +37,13 @@ export default class QuanticSourceCitations extends LightningElement {
|
|
|
37
37
|
* @type {function}
|
|
38
38
|
*/
|
|
39
39
|
@api citationHoverHandler;
|
|
40
|
+
/**
|
|
41
|
+
* Whether to disable citation anchoring.
|
|
42
|
+
* @api
|
|
43
|
+
* @type {boolean}
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
@api disableCitationAnchoring = false;
|
|
40
47
|
|
|
41
48
|
/** @type {AnyHeadless} */
|
|
42
49
|
headless;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts a text to highlight from a given text.
|
|
3
|
+
* It tries to extract the first sentence, and if it fails, it returns the first few words.
|
|
4
|
+
* @param {string} text The text from which to extract the text to highlight.
|
|
5
|
+
* @returns {string} The extracted text to highlight.
|
|
6
|
+
*/
|
|
7
|
+
export function extractTextToHighlight(text) {
|
|
8
|
+
const fallbackWordCount = 5;
|
|
9
|
+
|
|
10
|
+
const trimmedText = text.trim();
|
|
11
|
+
if (!trimmedText || typeof trimmedText !== 'string') {
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const sentenceRegex =
|
|
16
|
+
/(?<=^|\p{P}\s)\p{P}?\p{Lu}.*?[.!?]+(?=\s+(?:\p{Lu}|\d)|$)/gu;
|
|
17
|
+
const sentences = trimmedText.match(sentenceRegex);
|
|
18
|
+
|
|
19
|
+
if (Array.isArray(sentences) && sentences?.length > 0) {
|
|
20
|
+
return sentences[0].trim();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return trimmedText.split(/\s+/).slice(0, fallbackWordCount).join(' ');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Generates an encoded text fragment URL for the citation.
|
|
28
|
+
* This URL will highlight the text in the citation if it is an HTML file.
|
|
29
|
+
* @param {string} uri
|
|
30
|
+
* @param {string} text
|
|
31
|
+
* @returns {string}
|
|
32
|
+
* @example
|
|
33
|
+
* generateTextFragmentUrl('https://example.com', 'This is a sample text.');
|
|
34
|
+
* // Returns: 'https://example.com#:~:text=This%20is%20a%20sample%20text.'
|
|
35
|
+
*/
|
|
36
|
+
export function generateTextFragmentUrl(uri, text) {
|
|
37
|
+
const highlight = extractTextToHighlight(text);
|
|
38
|
+
const encodedTextFragment = encodeURIComponent(highlight).replace(
|
|
39
|
+
/-/g,
|
|
40
|
+
'%2D'
|
|
41
|
+
);
|
|
42
|
+
return `${uri}#:~:text=${encodedTextFragment}`;
|
|
43
|
+
}
|
|
@@ -35,6 +35,7 @@ import pastYear_plural from '@salesforce/label/c.quantic_PastYear_plural';
|
|
|
35
35
|
export * from './recentQueriesUtils';
|
|
36
36
|
export * from './markdownUtils';
|
|
37
37
|
export * from './facetDependenciesUtils';
|
|
38
|
+
export * from './citationAnchoringUtils';
|
|
38
39
|
|
|
39
40
|
export class Debouncer {
|
|
40
41
|
_timeout;
|