eat-js-sdk 2.2.7 → 2.2.8
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 +43 -4
- package/package.json +1 -1
|
@@ -19142,7 +19142,7 @@ const parseSentences = (rawText, correctAnswers = []) => {
|
|
|
19142
19142
|
const chunks = decoded.split("<eat-sentence>");
|
|
19143
19143
|
for (const chunk of chunks) {
|
|
19144
19144
|
const contentfulMatch = chunk.match(
|
|
19145
|
-
/((?:<(?!\/?eat-)[^>]+>)*)<eat-contentful>(.*?)<\/eat-contentful>(
|
|
19145
|
+
/((?:<(?!\/?eat-)[^>]+>)*)<eat-contentful>(.*?)<\/eat-contentful>([\s\S]*)/
|
|
19146
19146
|
);
|
|
19147
19147
|
const outerOpen = contentfulMatch ? contentfulMatch[1] : "";
|
|
19148
19148
|
const outerClose = contentfulMatch ? contentfulMatch[3] : "";
|
|
@@ -19418,9 +19418,48 @@ function SelectableTextInteractionContent($$anchor, $$props) {
|
|
|
19418
19418
|
}
|
|
19419
19419
|
});
|
|
19420
19420
|
const splitLastWord = (text) => {
|
|
19421
|
-
const
|
|
19422
|
-
|
|
19423
|
-
|
|
19421
|
+
const tagRe = /<[^>]+>|[^<]+/g;
|
|
19422
|
+
const tokens = [];
|
|
19423
|
+
let m;
|
|
19424
|
+
while ((m = tagRe.exec(text)) !== null) {
|
|
19425
|
+
tokens.push({ isTag: m[0].startsWith("<"), value: m[0] });
|
|
19426
|
+
}
|
|
19427
|
+
let splitTi = -1;
|
|
19428
|
+
let splitPos = -1;
|
|
19429
|
+
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
19430
|
+
if (!tokens[i].isTag) {
|
|
19431
|
+
const sp = tokens[i].value.lastIndexOf(" ");
|
|
19432
|
+
if (sp !== -1) {
|
|
19433
|
+
splitTi = i;
|
|
19434
|
+
splitPos = sp;
|
|
19435
|
+
break;
|
|
19436
|
+
}
|
|
19437
|
+
}
|
|
19438
|
+
}
|
|
19439
|
+
if (splitTi === -1) return ["", text];
|
|
19440
|
+
const getTagName2 = (tag) => tag.replace(/^<\/?([^\s>/]+).*$/, "$1").toLowerCase();
|
|
19441
|
+
const openStack = [];
|
|
19442
|
+
for (let i = 0; i < splitTi; i++) {
|
|
19443
|
+
const tok = tokens[i];
|
|
19444
|
+
if (!tok.isTag) continue;
|
|
19445
|
+
if (tok.value.startsWith("</")) {
|
|
19446
|
+
const name = getTagName2(tok.value);
|
|
19447
|
+
for (let j = openStack.length - 1; j >= 0; j--) {
|
|
19448
|
+
if (getTagName2(openStack[j]) === name) {
|
|
19449
|
+
openStack.splice(j, 1);
|
|
19450
|
+
break;
|
|
19451
|
+
}
|
|
19452
|
+
}
|
|
19453
|
+
} else if (!tok.value.endsWith("/>")) {
|
|
19454
|
+
openStack.push(tok.value);
|
|
19455
|
+
}
|
|
19456
|
+
}
|
|
19457
|
+
const closeTags = [...openStack].reverse().map((t2) => `</${getTagName2(t2)}>`).join("");
|
|
19458
|
+
const reopenTags = openStack.join("");
|
|
19459
|
+
const textVal = tokens[splitTi].value;
|
|
19460
|
+
const bodyText = tokens.slice(0, splitTi).map((t2) => t2.value).join("") + textVal.slice(0, splitPos + 1) + closeTags;
|
|
19461
|
+
const lastWord = reopenTags + textVal.slice(splitPos + 1) + tokens.slice(splitTi + 1).map((t2) => t2.value).join("");
|
|
19462
|
+
return [bodyText, lastWord];
|
|
19424
19463
|
};
|
|
19425
19464
|
const focusFirstSegment = () => {
|
|
19426
19465
|
const first = get$1(passageEl)?.querySelector('[role="button"][tabindex="0"]');
|