accessify-widget 0.3.5 → 0.3.6
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/accessify.min.js +1 -1
- package/dist/accessify.min.js.map +1 -1
- package/dist/accessify.mjs +1 -1
- package/dist/{index-BTkeEVoS.js → index-DDv0soH8.js} +57 -23
- package/dist/{index-BTkeEVoS.js.map → index-DDv0soH8.js.map} +1 -1
- package/dist/{keyboard-nav-BZ4ei-Lt.js → keyboard-nav-DYBrrE4b.js} +2 -2
- package/dist/{keyboard-nav-BZ4ei-Lt.js.map → keyboard-nav-DYBrrE4b.js.map} +1 -1
- package/dist/{page-structure-JY54Sj14.js → page-structure-BTemvR2X.js} +2 -2
- package/dist/{page-structure-JY54Sj14.js.map → page-structure-BTemvR2X.js.map} +1 -1
- package/dist/widget.js +1 -1
- package/dist/widget.js.map +1 -1
- package/package.json +1 -1
package/dist/accessify.mjs
CHANGED
|
@@ -6433,14 +6433,14 @@ function FeatureGrid($$anchor, $$props) {
|
|
|
6433
6433
|
const FEATURE_LOADERS = {
|
|
6434
6434
|
contrast: () => import("./contrast-CqsICAkU.js"),
|
|
6435
6435
|
"text-size": () => import("./text-size-C6OFhCGi.js"),
|
|
6436
|
-
"keyboard-nav": () => import("./keyboard-nav-
|
|
6436
|
+
"keyboard-nav": () => import("./keyboard-nav-DYBrrE4b.js"),
|
|
6437
6437
|
"link-highlight": () => import("./link-highlight-DBGm067Y.js"),
|
|
6438
6438
|
"reading-guide": () => import("./reading-guide-VT8NciIL.js"),
|
|
6439
6439
|
"reading-mask": () => import("./reading-mask-BABChuCz.js"),
|
|
6440
6440
|
"animation-stop": () => import("./animation-stop-C0MwseK0.js"),
|
|
6441
6441
|
"hide-images": () => import("./hide-images-B_LeCBcd.js"),
|
|
6442
6442
|
"big-cursor": () => import("./big-cursor-B2UKu9dQ.js"),
|
|
6443
|
-
"page-structure": () => import("./page-structure-
|
|
6443
|
+
"page-structure": () => import("./page-structure-BTemvR2X.js"),
|
|
6444
6444
|
tts: () => import("./tts-CjszLRnb.js"),
|
|
6445
6445
|
"text-simplify": () => import("./text-simplify-Cvhpio7g.js"),
|
|
6446
6446
|
"alt-text": () => Promise.resolve().then(() => altText)
|
|
@@ -6877,19 +6877,55 @@ function groupTextNodes(textNodes) {
|
|
|
6877
6877
|
const siblings = textNodes.filter((n) => !assigned.has(n) && findBlockAncestor(n) === block2);
|
|
6878
6878
|
if (siblings.length > 1) {
|
|
6879
6879
|
for (const s of siblings) assigned.add(s);
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
});
|
|
6880
|
+
const fullText = (block2.textContent?.trim() || "").replace(/\s+/g, " ");
|
|
6881
|
+
const shortNodes = siblings.filter((n) => n.data.trim().length <= 2).length;
|
|
6882
|
+
const charPerNode = shortNodes > siblings.length * 0.5;
|
|
6883
|
+
groups.push({ nodes: siblings, fullText, singleNode: false, charPerNode });
|
|
6885
6884
|
continue;
|
|
6886
6885
|
}
|
|
6887
6886
|
}
|
|
6888
6887
|
assigned.add(node);
|
|
6889
|
-
groups.push({ nodes: [node], fullText: node.data.trim(), singleNode: true });
|
|
6888
|
+
groups.push({ nodes: [node], fullText: node.data.trim(), singleNode: true, charPerNode: false });
|
|
6890
6889
|
}
|
|
6891
6890
|
return groups;
|
|
6892
6891
|
}
|
|
6892
|
+
function distributeCharsToNodes(nodes, translated) {
|
|
6893
|
+
const origLengths = nodes.map((n) => n.data.trim().length);
|
|
6894
|
+
const origWhitespace = nodes.map((n) => ({
|
|
6895
|
+
leading: n.data.match(/^\s*/)?.[0] || "",
|
|
6896
|
+
trailing: n.data.match(/\s*$/)?.[0] || ""
|
|
6897
|
+
}));
|
|
6898
|
+
let charIdx = 0;
|
|
6899
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
6900
|
+
const origLen = origLengths[i];
|
|
6901
|
+
if (origLen === 0) {
|
|
6902
|
+
continue;
|
|
6903
|
+
}
|
|
6904
|
+
const chunk = translated.slice(charIdx, charIdx + origLen);
|
|
6905
|
+
charIdx += origLen;
|
|
6906
|
+
nodes[i].data = origWhitespace[i].leading + chunk + origWhitespace[i].trailing;
|
|
6907
|
+
}
|
|
6908
|
+
if (charIdx < translated.length) {
|
|
6909
|
+
const overflow = translated.slice(charIdx);
|
|
6910
|
+
for (let i = nodes.length - 1; i >= 0; i--) {
|
|
6911
|
+
if (origLengths[i] > 0) {
|
|
6912
|
+
nodes[i].data = nodes[i].data.trimEnd() + overflow + origWhitespace[i].trailing;
|
|
6913
|
+
break;
|
|
6914
|
+
}
|
|
6915
|
+
}
|
|
6916
|
+
}
|
|
6917
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
6918
|
+
if (origLengths[i] > 0) {
|
|
6919
|
+
const assigned = translated.slice(
|
|
6920
|
+
origLengths.slice(0, i).reduce((a, b) => a + b, 0),
|
|
6921
|
+
origLengths.slice(0, i + 1).reduce((a, b) => a + b, 0)
|
|
6922
|
+
);
|
|
6923
|
+
if (!assigned) {
|
|
6924
|
+
nodes[i].data = origWhitespace[i].leading + origWhitespace[i].trailing;
|
|
6925
|
+
}
|
|
6926
|
+
}
|
|
6927
|
+
}
|
|
6928
|
+
}
|
|
6893
6929
|
function findBlockAncestor(node) {
|
|
6894
6930
|
let el = node.parentElement;
|
|
6895
6931
|
while (el && el !== document.body) {
|
|
@@ -6931,23 +6967,21 @@ async function translatePage(targetLang) {
|
|
|
6931
6967
|
});
|
|
6932
6968
|
observerPaused = true;
|
|
6933
6969
|
for (const group of nodeGroups) {
|
|
6970
|
+
const replacement = lookup.get(group.fullText);
|
|
6971
|
+
if (!replacement) continue;
|
|
6934
6972
|
if (group.singleNode) {
|
|
6935
6973
|
const node = group.nodes[0];
|
|
6936
|
-
const
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
}
|
|
6974
|
+
const leading = node.data.match(/^\s*/)?.[0] || "";
|
|
6975
|
+
const trailing = node.data.match(/\s*$/)?.[0] || "";
|
|
6976
|
+
node.data = leading + replacement + trailing;
|
|
6977
|
+
} else if (group.charPerNode) {
|
|
6978
|
+
distributeCharsToNodes(group.nodes, replacement);
|
|
6942
6979
|
} else {
|
|
6943
|
-
const
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
for (let i = 1; i < group.nodes.length; i++) {
|
|
6949
|
-
group.nodes[i].data = "";
|
|
6950
|
-
}
|
|
6980
|
+
const firstNode = group.nodes[0];
|
|
6981
|
+
const leading = firstNode.data.match(/^\s*/)?.[0] || "";
|
|
6982
|
+
firstNode.data = leading + replacement;
|
|
6983
|
+
for (let i = 1; i < group.nodes.length; i++) {
|
|
6984
|
+
group.nodes[i].data = "";
|
|
6951
6985
|
}
|
|
6952
6986
|
}
|
|
6953
6987
|
}
|
|
@@ -8536,4 +8570,4 @@ export {
|
|
|
8536
8570
|
init as i,
|
|
8537
8571
|
t
|
|
8538
8572
|
};
|
|
8539
|
-
//# sourceMappingURL=index-
|
|
8573
|
+
//# sourceMappingURL=index-DDv0soH8.js.map
|