@coveo/quantic 3.30.3-pre.b407bdfc38 → 3.30.3-pre.c0341d0ed7
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/force-app/main/default/lwc/quanticUtils/markdownUtils.js +18 -3
- package/force-app/main/default/lwc/quanticUtils/quanticUtils.js +108 -17
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +3 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/navigator-context-provider.d.ts +0 -6
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/knowledge/generated-answer/headless-answerapi-generated-answer-mocks.d.ts +7737 -704
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/generated-answer/generated-answer-request.d.ts +20 -1961
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce-next.index.d.ts +2 -7
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/engine/commerce-engine.ssr.d.ts +3 -9
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/build-factory.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/recommendation-static-state-factory.d.ts +0 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/build.d.ts +5 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/engine.d.ts +8 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/utils/engine-wiring.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/engine/search-engine.ssr.d.ts +4 -10
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/types/build.d.ts +0 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/types/engine.d.ts +8 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/types/fetch-static-state.d.ts +1 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/types/hydrate-static-state.d.ts +1 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next.index.d.ts +5 -6
- package/force-app/main/default/staticresources/coveoheadless/headless.js +3 -3
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +3 -3
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +3 -3
- package/package.json +3 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/test/mock-context.d.ts +0 -2
|
@@ -7,6 +7,9 @@ import {loadScript} from 'lightning/platformResourceLoader';
|
|
|
7
7
|
* Transforms a single line of text that may contain HTML to plain text.
|
|
8
8
|
* @param {string} textWithHtml A single line of text that may contain HTML
|
|
9
9
|
* @returns {string} The value as plain text
|
|
10
|
+
* @example
|
|
11
|
+
* toInlinePlainText('<p>Hello <strong>World</strong></p>');
|
|
12
|
+
* // Returns: 'Hello World'
|
|
10
13
|
*/
|
|
11
14
|
const toInlinePlainText = (textWithHtml) => {
|
|
12
15
|
const withoutHtmlTags = textWithHtml.replace(/<[^>]*>/g, ' ');
|
|
@@ -21,7 +24,7 @@ const unclosedElement = /(\*{1,3}|`)($|\w[\w\s]*$)/;
|
|
|
21
24
|
/**
|
|
22
25
|
* Complete unclosed elements such as bold, italic, and code.
|
|
23
26
|
* @param {string} text
|
|
24
|
-
* @returns {string}
|
|
27
|
+
* @returns {string} The corrected text content.
|
|
25
28
|
*/
|
|
26
29
|
const completeUnclosedElement = (text) => {
|
|
27
30
|
const match = unclosedElement.exec(text);
|
|
@@ -41,6 +44,11 @@ const completeUnclosedElement = (text) => {
|
|
|
41
44
|
return text;
|
|
42
45
|
};
|
|
43
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Escape HTML special characters in a string.
|
|
49
|
+
* @param {*} text
|
|
50
|
+
* @returns {string} The escaped HTML string.
|
|
51
|
+
*/
|
|
44
52
|
const escapeHtml = (text) => {
|
|
45
53
|
return text
|
|
46
54
|
.replace(/&/g, '&')
|
|
@@ -50,6 +58,12 @@ const escapeHtml = (text) => {
|
|
|
50
58
|
.replace(/'/g, ''');
|
|
51
59
|
};
|
|
52
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Custom Marked renderer to override the default rendering of certain elements.
|
|
63
|
+
* @type {object}
|
|
64
|
+
* @property {Function} code
|
|
65
|
+
* @returns {string} The code block element to render.
|
|
66
|
+
*/
|
|
53
67
|
const customRenderer = {
|
|
54
68
|
code(code) {
|
|
55
69
|
return `<pre><code>${escapeHtml(code)}</code></pre>`;
|
|
@@ -59,6 +73,7 @@ const customRenderer = {
|
|
|
59
73
|
* Custom Marked renderer to replace heading elements with div elements.
|
|
60
74
|
* @param {string} text
|
|
61
75
|
* @param {string} level
|
|
76
|
+
* @return {string} The heading element to render.
|
|
62
77
|
*/
|
|
63
78
|
heading(text, level) {
|
|
64
79
|
const plainText = toInlinePlainText(text);
|
|
@@ -69,7 +84,7 @@ const customRenderer = {
|
|
|
69
84
|
/**
|
|
70
85
|
* Returns escaped HTML.
|
|
71
86
|
* @param {string} text
|
|
72
|
-
* @returns
|
|
87
|
+
* @returns {string} The escaped HTML string.
|
|
73
88
|
*/
|
|
74
89
|
html(text) {
|
|
75
90
|
return escapeHtml(text);
|
|
@@ -119,7 +134,7 @@ const transformMarkdownToHtml = (text, marked) => {
|
|
|
119
134
|
|
|
120
135
|
/**
|
|
121
136
|
* Load the libraries Marked and DOMPurify.
|
|
122
|
-
* @param
|
|
137
|
+
* @param element
|
|
123
138
|
* @returns {Promise<any>}
|
|
124
139
|
*/
|
|
125
140
|
const loadMarkdownDependencies = (element) => {
|
|
@@ -37,6 +37,9 @@ export * from './markdownUtils';
|
|
|
37
37
|
export * from './facetDependenciesUtils';
|
|
38
38
|
export * from './citationAnchoringUtils';
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Utility class for debouncing function calls.
|
|
42
|
+
*/
|
|
40
43
|
export class Debouncer {
|
|
41
44
|
_timeout;
|
|
42
45
|
|
|
@@ -90,14 +93,18 @@ export class Deferred {
|
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Utility class for working with search results and binding analytics events.
|
|
98
|
+
*/
|
|
93
99
|
export class ResultUtils {
|
|
94
100
|
/**
|
|
95
|
-
* Binds
|
|
96
|
-
* @returns An unbind function for the events
|
|
101
|
+
* Binds analytics logging events to result elements.
|
|
97
102
|
* @param {import("coveo").SearchEngine} engine An instance of an Headless Engine
|
|
98
103
|
* @param {import("coveo").Result} result The result object
|
|
99
104
|
* @param {import("lwc").ShadowRootTheGoodPart} resultElement Parent result element
|
|
105
|
+
* @param {Function} controllerBuilder Function to build the interactive result controller.
|
|
100
106
|
* @param {string} selector Optional. Css selector that selects all links to the document. Default: "a" tags with the clickUri as "href" parameter.
|
|
107
|
+
* @returns An unbind function for the events
|
|
101
108
|
*/
|
|
102
109
|
static bindClickEventsOnResult(
|
|
103
110
|
engine,
|
|
@@ -137,12 +144,15 @@ export class ResultUtils {
|
|
|
137
144
|
}
|
|
138
145
|
}
|
|
139
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Utility class for link operations and analytics binding.
|
|
149
|
+
*/
|
|
140
150
|
export class LinkUtils {
|
|
141
151
|
/**
|
|
142
152
|
* Binds the logging of a link
|
|
143
|
-
* @returns An unbind function for the events
|
|
144
153
|
* @param {HTMLAnchorElement} link the link element
|
|
145
154
|
* @param {{select:function, beginDelayedSelect: function, cancelPendingSelect: function }} actions
|
|
155
|
+
* @returns An unbind function for the events
|
|
146
156
|
*/
|
|
147
157
|
static bindAnalyticsToLink(link, actions) {
|
|
148
158
|
const eventsMap = {
|
|
@@ -165,6 +175,9 @@ export class LinkUtils {
|
|
|
165
175
|
}
|
|
166
176
|
}
|
|
167
177
|
|
|
178
|
+
/**
|
|
179
|
+
* Utility class for internationalization and localization.
|
|
180
|
+
*/
|
|
168
181
|
export class I18nUtils {
|
|
169
182
|
static getTextWithDecorator(text, startTag, endTag) {
|
|
170
183
|
return `${startTag}${text}${endTag}`;
|
|
@@ -178,6 +191,13 @@ export class I18nUtils {
|
|
|
178
191
|
return new Intl.PluralRules(LOCALE).select(count) === 'one';
|
|
179
192
|
}
|
|
180
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Gets the label name with count.
|
|
196
|
+
* @param {string} labelName
|
|
197
|
+
* @param {string|number} count
|
|
198
|
+
* @returns {string} The label name with count.
|
|
199
|
+
* @example `labelName_zero`, `labelName_plural` or `labelName`
|
|
200
|
+
*/
|
|
181
201
|
static getLabelNameWithCount(labelName, count) {
|
|
182
202
|
if (count === 0) {
|
|
183
203
|
return `${labelName}_zero`;
|
|
@@ -187,6 +207,16 @@ export class I18nUtils {
|
|
|
187
207
|
return labelName;
|
|
188
208
|
}
|
|
189
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Formats a string with the given arguments.
|
|
212
|
+
* @param {*} stringToFormat
|
|
213
|
+
* @param {...any} formattingArguments
|
|
214
|
+
* @returns {string} The formatted string.
|
|
215
|
+
* @throws {Error} If string format is not a string.
|
|
216
|
+
* @example
|
|
217
|
+
* I18nUtils.format('Hello {{0}}, you have {{1}} new messages', 'John', 5);
|
|
218
|
+
* returns 'Hello John, you have 5 new messages'
|
|
219
|
+
*/
|
|
190
220
|
static format(stringToFormat, ...formattingArguments) {
|
|
191
221
|
if (typeof stringToFormat !== 'string')
|
|
192
222
|
throw new Error("'stringToFormat' must be a String");
|
|
@@ -197,6 +227,11 @@ export class I18nUtils {
|
|
|
197
227
|
);
|
|
198
228
|
}
|
|
199
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Gets the short date pattern for the current locale.
|
|
232
|
+
* @returns {string} The short date pattern.
|
|
233
|
+
* @example `M/d/yyyy` for `en-US`, `d/M/yyyy` for `fr-FR`, etc.
|
|
234
|
+
*/
|
|
200
235
|
static getShortDatePattern() {
|
|
201
236
|
const date = new Date(2000, 2, 4); // month is zero-based
|
|
202
237
|
const dateAsString = I18nUtils.formatDate(date);
|
|
@@ -215,11 +250,13 @@ export class I18nUtils {
|
|
|
215
250
|
}
|
|
216
251
|
|
|
217
252
|
/**
|
|
253
|
+
* Formats the date in the current locale.
|
|
218
254
|
* @param {Date} date
|
|
255
|
+
* @returns {string} The formatted date.
|
|
219
256
|
*/
|
|
220
257
|
static formatDate(date) {
|
|
221
|
-
const
|
|
222
|
-
return
|
|
258
|
+
const formattedDate = new Intl.DateTimeFormat(LOCALE).format(date);
|
|
259
|
+
return formattedDate;
|
|
223
260
|
}
|
|
224
261
|
|
|
225
262
|
/**
|
|
@@ -227,15 +264,24 @@ export class I18nUtils {
|
|
|
227
264
|
* @returns {string}
|
|
228
265
|
*/
|
|
229
266
|
static escapeHTML(html) {
|
|
230
|
-
|
|
267
|
+
const escape = document.createElement('textarea');
|
|
231
268
|
escape.textContent = html;
|
|
232
269
|
// eslint-disable-next-line @lwc/lwc/no-inner-html
|
|
233
270
|
return escape.innerHTML;
|
|
234
271
|
}
|
|
235
272
|
}
|
|
236
273
|
|
|
274
|
+
/**
|
|
275
|
+
* Storage key for standalone search box configuration.
|
|
276
|
+
* @constant {string}
|
|
277
|
+
*/
|
|
237
278
|
export const STANDALONE_SEARCH_BOX_STORAGE_KEY = 'coveo-standalone-search-box';
|
|
238
279
|
|
|
280
|
+
/**
|
|
281
|
+
* Key codes for common keyboard interactions.
|
|
282
|
+
* @readonly
|
|
283
|
+
* @enum {string}
|
|
284
|
+
*/
|
|
239
285
|
export const keys = {
|
|
240
286
|
ESC: 'Escape',
|
|
241
287
|
TAB: 'Tab',
|
|
@@ -259,15 +305,24 @@ export function setItemInLocalStorage(key, item) {
|
|
|
259
305
|
/**
|
|
260
306
|
* Replace char found in pattern with \\$&
|
|
261
307
|
* @param {string} value
|
|
308
|
+
* @return {string}
|
|
262
309
|
*/
|
|
263
310
|
export function regexEncode(value) {
|
|
264
311
|
return value.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
|
|
265
312
|
}
|
|
266
|
-
|
|
313
|
+
/**
|
|
314
|
+
* Parses an XML string into a DOM Document.
|
|
315
|
+
* @param {string} string
|
|
316
|
+
* @returns {Document}
|
|
317
|
+
*/
|
|
267
318
|
export function parseXML(string) {
|
|
268
319
|
return new window.DOMParser().parseFromString(string, 'text/xml');
|
|
269
320
|
}
|
|
270
321
|
|
|
322
|
+
/**
|
|
323
|
+
* Utility class for time-based calculations and formatting.
|
|
324
|
+
* Provides methods to convert between different time units and format durations.
|
|
325
|
+
*/
|
|
271
326
|
export class TimeSpan {
|
|
272
327
|
constructor(time, isMilliseconds = true) {
|
|
273
328
|
if (isMilliseconds) {
|
|
@@ -344,6 +399,10 @@ export class TimeSpan {
|
|
|
344
399
|
}
|
|
345
400
|
}
|
|
346
401
|
|
|
402
|
+
/**
|
|
403
|
+
* Utility class for date operations and formatting.
|
|
404
|
+
* Handles conversion between different date formats and provides parsing utilities.
|
|
405
|
+
*/
|
|
347
406
|
export class DateUtils {
|
|
348
407
|
/**
|
|
349
408
|
* Converts a date string from the Coveo Search API format to the ISO-8601 format.
|
|
@@ -391,6 +450,7 @@ export class DateUtils {
|
|
|
391
450
|
* @param {number} hours The local hours to set on the date.
|
|
392
451
|
* @param {number} minutes The local minutes to set on the date.
|
|
393
452
|
* @param {number} seconds The local seconds to set on the date.
|
|
453
|
+
* @throws {Error} If specified time is invalid.
|
|
394
454
|
* @returns {Date} The parsed date.
|
|
395
455
|
*/
|
|
396
456
|
static fromLocalIsoDate(dateString, hours, minutes, seconds) {
|
|
@@ -418,6 +478,11 @@ export class DateUtils {
|
|
|
418
478
|
return new Date(`${withoutTime}T${time}`);
|
|
419
479
|
}
|
|
420
480
|
|
|
481
|
+
/**
|
|
482
|
+
* Trims the time portion from an ISO 8601 date string.
|
|
483
|
+
* @param {string} dateString
|
|
484
|
+
* @returns {string}
|
|
485
|
+
*/
|
|
421
486
|
static trimIsoTime(dateString) {
|
|
422
487
|
const timeIdx = dateString.indexOf('T');
|
|
423
488
|
return timeIdx !== -1 ? dateString.substring(0, timeIdx) : dateString;
|
|
@@ -425,6 +490,7 @@ export class DateUtils {
|
|
|
425
490
|
|
|
426
491
|
/**
|
|
427
492
|
* @param {number} timestamp
|
|
493
|
+
* @returns {boolean}
|
|
428
494
|
*/
|
|
429
495
|
static isValidTimestamp(timestamp) {
|
|
430
496
|
let isValid = true;
|
|
@@ -439,8 +505,6 @@ export class DateUtils {
|
|
|
439
505
|
|
|
440
506
|
/**
|
|
441
507
|
* Parses a given timestamp into detailed date components.
|
|
442
|
-
*
|
|
443
|
-
* @function
|
|
444
508
|
* @param {number} timestamp - The timestamp in milliseconds since January 1, 1970 (epoch time).
|
|
445
509
|
* @returns {Object} An object containing the following date details:
|
|
446
510
|
* - {number} year - The four-digit year (e.g., 2024).
|
|
@@ -497,6 +561,10 @@ export function fromSearchApiDate(dateString) {
|
|
|
497
561
|
return DateUtils.fromSearchApiDate(dateString);
|
|
498
562
|
}
|
|
499
563
|
|
|
564
|
+
/**
|
|
565
|
+
* Formats relative date ranges into human-readable strings.
|
|
566
|
+
* Supports past and future date ranges with proper pluralization.
|
|
567
|
+
*/
|
|
500
568
|
export class RelativeDateFormatter {
|
|
501
569
|
constructor() {
|
|
502
570
|
this.singularIndex = 0;
|
|
@@ -519,10 +587,15 @@ export class RelativeDateFormatter {
|
|
|
519
587
|
}
|
|
520
588
|
|
|
521
589
|
/**
|
|
522
|
-
*
|
|
523
|
-
* @param {RelativeDate} begin
|
|
524
|
-
* @param {RelativeDate} end
|
|
525
|
-
* @returns {string}
|
|
590
|
+
* Formats a relative date range into a human-readable string.
|
|
591
|
+
* @param {RelativeDate} begin The beginning of the relative date range.
|
|
592
|
+
* @param {RelativeDate} end The end of the relative date range.
|
|
593
|
+
* @returns {string} The formatted human-readable date range.
|
|
594
|
+
* @throws {Error} If the provided relative date range is invalid.
|
|
595
|
+
* @example
|
|
596
|
+
* begin = { period: 'past', unit: 'day', amount: 2 };
|
|
597
|
+
* end = { period: 'now', unit: 'day', amount: 1 };
|
|
598
|
+
* Output: "2 days ago - 1 day ago"
|
|
526
599
|
*/
|
|
527
600
|
formatRange(begin, end) {
|
|
528
601
|
const isPastRange = begin.period === 'past' && end.period === 'now';
|
|
@@ -546,6 +619,10 @@ export class RelativeDateFormatter {
|
|
|
546
619
|
}
|
|
547
620
|
}
|
|
548
621
|
|
|
622
|
+
/**
|
|
623
|
+
* Utility class for managing a simple in-memory store.
|
|
624
|
+
* Supports registering and retrieving facet and sort option data.
|
|
625
|
+
*/
|
|
549
626
|
export class Store {
|
|
550
627
|
static facetTypes = {
|
|
551
628
|
FACETS: 'facets',
|
|
@@ -565,9 +642,11 @@ export class Store {
|
|
|
565
642
|
};
|
|
566
643
|
}
|
|
567
644
|
/**
|
|
645
|
+
* Registers a facet to the store if it does not already exist.
|
|
568
646
|
* @param {Record<String, unknown>} store
|
|
569
647
|
* @param {string} facetType
|
|
570
648
|
* @param {{ label?: string; facetId: any; format?: Function;}} data
|
|
649
|
+
* @return {void}
|
|
571
650
|
*/
|
|
572
651
|
static registerFacetToStore(store, facetType, data) {
|
|
573
652
|
if (store?.state[facetType][data.facetId]) {
|
|
@@ -577,23 +656,29 @@ export class Store {
|
|
|
577
656
|
}
|
|
578
657
|
|
|
579
658
|
/**
|
|
659
|
+
* Registers sort option data to the store.
|
|
580
660
|
* @param {Record<String, any>} store
|
|
581
661
|
* @param {Array<{label: string; value: string; criterion: SortCriterion;}>} data
|
|
662
|
+
* @return {void}
|
|
582
663
|
*/
|
|
583
664
|
static registerSortOptionDataToStore(store, data) {
|
|
584
665
|
store.state.sort = data;
|
|
585
666
|
}
|
|
586
667
|
|
|
587
668
|
/**
|
|
669
|
+
* Gets facet data from the store.
|
|
588
670
|
* @param {Record<String, unknown>} store
|
|
589
671
|
* @param {string} facetType
|
|
672
|
+
* @return {Object} The facet data.
|
|
590
673
|
*/
|
|
591
674
|
static getFromStore(store, facetType) {
|
|
592
675
|
return store.state[facetType];
|
|
593
676
|
}
|
|
594
677
|
|
|
595
678
|
/**
|
|
679
|
+
* Gets sort options from the store.
|
|
596
680
|
* @param {Record<String, Object>} store
|
|
681
|
+
* @return {Array} The sort options.
|
|
597
682
|
*/
|
|
598
683
|
static getSortOptionsFromStore(store) {
|
|
599
684
|
return store.state.sort;
|
|
@@ -612,7 +697,7 @@ export class Store {
|
|
|
612
697
|
* @param {string} regionName
|
|
613
698
|
* @param {Object} elem
|
|
614
699
|
* @param {boolean} assertive
|
|
615
|
-
* @returns {AriaLiveUtils}
|
|
700
|
+
* @returns {AriaLiveUtils} Object with methods to dispatch messages and register the region.
|
|
616
701
|
*/
|
|
617
702
|
export function AriaLiveRegion(regionName, elem, assertive = false) {
|
|
618
703
|
function dispatchMessage(message) {
|
|
@@ -763,6 +848,7 @@ export function isCustomElement(element) {
|
|
|
763
848
|
/**
|
|
764
849
|
* Returns the last focusable element in an HTML slot.
|
|
765
850
|
* @param {HTMLElement & {assignedElements?: () => Array<HTMLElement> | null}} slotElement
|
|
851
|
+
* @returns {HTMLElement | null}
|
|
766
852
|
*/
|
|
767
853
|
function getLastFocusableElementFromSlot(slotElement) {
|
|
768
854
|
if (!slotElement && slotElement.assignedElements) {
|
|
@@ -782,6 +868,7 @@ function getLastFocusableElementFromSlot(slotElement) {
|
|
|
782
868
|
/**
|
|
783
869
|
* Returns the first focusable element in an HTML slot.
|
|
784
870
|
* @param {HTMLElement & {assignedElements?: () => Array<HTMLElement> | null}} slotElement
|
|
871
|
+
* @return {HTMLElement | null}
|
|
785
872
|
*/
|
|
786
873
|
function getFirstFocusableElementFromSlot(slotElement) {
|
|
787
874
|
if (!slotElement && slotElement.assignedElements) {
|
|
@@ -802,6 +889,7 @@ function getFirstFocusableElementFromSlot(slotElement) {
|
|
|
802
889
|
* Checks whether an element is indeed the targetElement or one of its parents.
|
|
803
890
|
* @param {HTMLElement} element
|
|
804
891
|
* @param {string} targetElement
|
|
892
|
+
* @returns {boolean}
|
|
805
893
|
*/
|
|
806
894
|
export function isParentOf(element, targetElement) {
|
|
807
895
|
if (!element || element.nodeType === Node.TEXT_NODE) {
|
|
@@ -827,6 +915,7 @@ export function isParentOf(element, targetElement) {
|
|
|
827
915
|
* Copies text to clipboard using the Clipboard API.
|
|
828
916
|
* https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
|
|
829
917
|
* @param {string} text
|
|
918
|
+
* @return {Promise<void>}
|
|
830
919
|
*/
|
|
831
920
|
export async function copyToClipboard(text) {
|
|
832
921
|
try {
|
|
@@ -839,6 +928,7 @@ export async function copyToClipboard(text) {
|
|
|
839
928
|
/**
|
|
840
929
|
* Copies text to clipboard using the DOM.
|
|
841
930
|
* @param {string} text
|
|
931
|
+
* @return {void}
|
|
842
932
|
*/
|
|
843
933
|
export function copyToClipboardFallback(text) {
|
|
844
934
|
const el = document.createElement('textarea');
|
|
@@ -853,6 +943,7 @@ export function copyToClipboardFallback(text) {
|
|
|
853
943
|
* Read the value of a given key from an object.
|
|
854
944
|
* @param {object} object
|
|
855
945
|
* @param {string} key
|
|
946
|
+
* @return {object | undefined} The value of the key.
|
|
856
947
|
*/
|
|
857
948
|
export function readFromObject(object, key) {
|
|
858
949
|
const firstPeriodIndex = key.indexOf('.');
|
|
@@ -898,9 +989,9 @@ export function getElementPadding(element) {
|
|
|
898
989
|
}
|
|
899
990
|
|
|
900
991
|
/**
|
|
901
|
-
* Returns the absolute
|
|
992
|
+
* Returns the absolute height of an element.
|
|
902
993
|
* @param {Element} element
|
|
903
|
-
* @returns {number}
|
|
994
|
+
* @returns {number} The absolute height of the element including padding.
|
|
904
995
|
*/
|
|
905
996
|
export function getAbsoluteHeight(element) {
|
|
906
997
|
if (!element) {
|
|
@@ -916,7 +1007,7 @@ export function getAbsoluteHeight(element) {
|
|
|
916
1007
|
/**
|
|
917
1008
|
* Returns the absolute width of an element.
|
|
918
1009
|
* @param {Element} element
|
|
919
|
-
* @returns {number}
|
|
1010
|
+
* @returns {number} The absolute width of the element including padding.
|
|
920
1011
|
*/
|
|
921
1012
|
export function getAbsoluteWidth(element) {
|
|
922
1013
|
if (!element) {
|