eat-js-sdk 2.3.6 → 2.3.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/dist/interaction-builder.mjs +17 -10
- package/package.json +1 -1
|
@@ -19420,9 +19420,10 @@ const parseWords = (rawText) => {
|
|
|
19420
19420
|
const segments = [];
|
|
19421
19421
|
let globalIndex = 0;
|
|
19422
19422
|
const tokenRegex = /((?:<(?!\/?eat-)[^>]+>)*)<eat-contentful>(.*?)<\/eat-contentful>((?:<\/[^>]+>)*)|((?:<(?!\/?eat-)[^>]*>|[^<>])+)/g;
|
|
19423
|
-
const
|
|
19424
|
-
const
|
|
19425
|
-
const
|
|
19423
|
+
const trailingPunctuationPattern = /([.,!?;:)\]}"'\u201D\u2019»…\u2014\u2013]+)$/;
|
|
19424
|
+
const leadingPunctuationPattern = /^([([{'""\u201C\u2018]+)/;
|
|
19425
|
+
const openingCharsAtWordEndPattern = /([(\[{\u201C\u2018]+)$/;
|
|
19426
|
+
const wordContainsOnlyPunctuationPattern = /^[^\w\u00C0-\u024F]+$/;
|
|
19426
19427
|
for (let pIdx = 0; pIdx < paragraphs.length; pIdx++) {
|
|
19427
19428
|
const para = paragraphs[pIdx];
|
|
19428
19429
|
const decoded = para.replace(/<eat-contentful>/g, "<eat-contentful>").replace(/<\/eat-contentful>/g, "</eat-contentful>");
|
|
@@ -19430,7 +19431,7 @@ const parseWords = (rawText) => {
|
|
|
19430
19431
|
let match;
|
|
19431
19432
|
let pendingLeadingPunct = "";
|
|
19432
19433
|
const flushLeadingPunct = (text) => {
|
|
19433
|
-
const m = text.match(
|
|
19434
|
+
const m = text.match(leadingPunctuationPattern);
|
|
19434
19435
|
const extractedLeading = m ? m[1] : "";
|
|
19435
19436
|
const lp = pendingLeadingPunct + extractedLeading;
|
|
19436
19437
|
const leadingPunctuation = lp.length ? lp : void 0;
|
|
@@ -19447,7 +19448,7 @@ const parseWords = (rawText) => {
|
|
|
19447
19448
|
const { leadingPunctuation, extractedLeading } = flushLeadingPunct(displayText);
|
|
19448
19449
|
const textAfterLeading = extractedLeading ? displayText.slice(extractedLeading.length) : displayText;
|
|
19449
19450
|
const rawAfterLeading = extractedLeading ? rawContent.slice(extractedLeading.length) : rawContent;
|
|
19450
|
-
const punctMatch = textAfterLeading.match(
|
|
19451
|
+
const punctMatch = textAfterLeading.match(trailingPunctuationPattern);
|
|
19451
19452
|
const rawText2 = punctMatch ? rawAfterLeading.slice(0, -punctMatch[1].length) : rawAfterLeading;
|
|
19452
19453
|
const trailingPunctuation = punctMatch ? punctMatch[1] : void 0;
|
|
19453
19454
|
const innerText = punctMatch ? textAfterLeading.slice(0, -punctMatch[1].length) : textAfterLeading;
|
|
@@ -19461,8 +19462,8 @@ const parseWords = (rawText) => {
|
|
|
19461
19462
|
const words = hasHtmlTags(rawChunk) ? extractHtmlWords(rawChunk) : rawChunk.split(/\s+/).filter(Boolean);
|
|
19462
19463
|
for (const word of words) {
|
|
19463
19464
|
const visibleWord = hasHtmlTags(word) ? stripTags(word) : decodeHtmlEntities(word);
|
|
19464
|
-
if (
|
|
19465
|
-
if (
|
|
19465
|
+
if (wordContainsOnlyPunctuationPattern.test(visibleWord)) {
|
|
19466
|
+
if (leadingPunctuationPattern.test(visibleWord)) {
|
|
19466
19467
|
pendingLeadingPunct += visibleWord;
|
|
19467
19468
|
} else {
|
|
19468
19469
|
const prev = segments[segments.length - 1];
|
|
@@ -19482,7 +19483,7 @@ const parseWords = (rawText) => {
|
|
|
19482
19483
|
wordForTrailing = word.replace(new RegExp("^((?:<[^>]+>)*)" + escapeRegExp(extractedLeading)), "$1");
|
|
19483
19484
|
}
|
|
19484
19485
|
const visibleAfterLeading = extractedLeading ? innerVisible.slice(extractedLeading.length) : innerVisible;
|
|
19485
|
-
const punctMatch = visibleAfterLeading.match(
|
|
19486
|
+
const punctMatch = visibleAfterLeading.match(trailingPunctuationPattern);
|
|
19486
19487
|
if (punctMatch) {
|
|
19487
19488
|
const punc = punctMatch[1];
|
|
19488
19489
|
const rebuilt = wordForTrailing.replace(new RegExp(escapeRegExp(punc) + "(</)"), "$1");
|
|
@@ -19497,8 +19498,14 @@ const parseWords = (rawText) => {
|
|
|
19497
19498
|
}
|
|
19498
19499
|
} else {
|
|
19499
19500
|
const { leadingPunctuation, extractedLeading } = flushLeadingPunct(visibleWord);
|
|
19500
|
-
|
|
19501
|
-
const
|
|
19501
|
+
let wordAfterLeading = extractedLeading ? visibleWord.slice(extractedLeading.length) : visibleWord;
|
|
19502
|
+
const openingCharsAtEnd = wordAfterLeading.match(openingCharsAtWordEndPattern);
|
|
19503
|
+
if (openingCharsAtEnd) {
|
|
19504
|
+
pendingLeadingPunct += openingCharsAtEnd[1];
|
|
19505
|
+
wordAfterLeading = wordAfterLeading.slice(0, -openingCharsAtEnd[1].length);
|
|
19506
|
+
}
|
|
19507
|
+
if (!wordAfterLeading.length) continue;
|
|
19508
|
+
const punctMatch = wordAfterLeading.match(trailingPunctuationPattern);
|
|
19502
19509
|
const text = decodeNbsp(punctMatch ? wordAfterLeading.slice(0, -punctMatch[1].length) : wordAfterLeading);
|
|
19503
19510
|
const trailingPunctuation = punctMatch ? punctMatch[1] : void 0;
|
|
19504
19511
|
segments.push({ id: `${globalIndex}`, text, leadingPunctuation, trailingPunctuation });
|