@examind/block-sdk 0.1.12 → 0.1.13
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/index.js +27 -17
- package/dist/index.mjs +27 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1730,29 +1730,39 @@ var SpanNodeHandler = class extends NodeHandler2 {
|
|
|
1730
1730
|
if (node.childNodes.length === 1 && node.childNodes[0] instanceof TextNode) {
|
|
1731
1731
|
return this.createTextNode(node.text, styleAttr);
|
|
1732
1732
|
}
|
|
1733
|
-
|
|
1733
|
+
const results = [];
|
|
1734
|
+
const textNodes = [];
|
|
1734
1735
|
for (const childNode of node.childNodes) {
|
|
1735
1736
|
for (const child of traverse2(childNode)) {
|
|
1736
|
-
if (child.type
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
childResult = {
|
|
1740
|
-
...textNode,
|
|
1741
|
-
style: this.mergeStyles(textNode.style, styleAttr)
|
|
1742
|
-
};
|
|
1737
|
+
if (child.type === "text") {
|
|
1738
|
+
const textNode = child;
|
|
1739
|
+
textNodes.push(textNode);
|
|
1743
1740
|
} else {
|
|
1744
|
-
|
|
1745
|
-
childResult.format |= textNode.format || 0;
|
|
1746
|
-
childResult.style = this.mergeStyles(
|
|
1747
|
-
childResult.style,
|
|
1748
|
-
textNode.style
|
|
1749
|
-
);
|
|
1741
|
+
results.push(child);
|
|
1750
1742
|
}
|
|
1751
1743
|
}
|
|
1752
1744
|
}
|
|
1753
|
-
if (
|
|
1754
|
-
|
|
1755
|
-
|
|
1745
|
+
if (textNodes.length > 0) {
|
|
1746
|
+
const mergedTextNode = this.mergeTextNodes(
|
|
1747
|
+
textNodes,
|
|
1748
|
+
styleAttr
|
|
1749
|
+
);
|
|
1750
|
+
results.push(mergedTextNode);
|
|
1751
|
+
} else if (node.text.trim()) {
|
|
1752
|
+
results.push(this.createTextNode(node.text, styleAttr));
|
|
1753
|
+
}
|
|
1754
|
+
return results;
|
|
1755
|
+
}
|
|
1756
|
+
mergeTextNodes(textNodes, spanStyle) {
|
|
1757
|
+
const result = { ...textNodes[0] };
|
|
1758
|
+
result.style = this.mergeStyles(result.style, spanStyle);
|
|
1759
|
+
for (let i = 1; i < textNodes.length; i++) {
|
|
1760
|
+
const node = textNodes[i];
|
|
1761
|
+
result.text += node.text;
|
|
1762
|
+
result.format |= node.format || 0;
|
|
1763
|
+
result.style = this.mergeStyles(result.style, node.style);
|
|
1764
|
+
}
|
|
1765
|
+
return result;
|
|
1756
1766
|
}
|
|
1757
1767
|
createTextNode(text, style) {
|
|
1758
1768
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -1703,29 +1703,39 @@ var SpanNodeHandler = class extends NodeHandler2 {
|
|
|
1703
1703
|
if (node.childNodes.length === 1 && node.childNodes[0] instanceof TextNode) {
|
|
1704
1704
|
return this.createTextNode(node.text, styleAttr);
|
|
1705
1705
|
}
|
|
1706
|
-
|
|
1706
|
+
const results = [];
|
|
1707
|
+
const textNodes = [];
|
|
1707
1708
|
for (const childNode of node.childNodes) {
|
|
1708
1709
|
for (const child of traverse2(childNode)) {
|
|
1709
|
-
if (child.type
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
childResult = {
|
|
1713
|
-
...textNode,
|
|
1714
|
-
style: this.mergeStyles(textNode.style, styleAttr)
|
|
1715
|
-
};
|
|
1710
|
+
if (child.type === "text") {
|
|
1711
|
+
const textNode = child;
|
|
1712
|
+
textNodes.push(textNode);
|
|
1716
1713
|
} else {
|
|
1717
|
-
|
|
1718
|
-
childResult.format |= textNode.format || 0;
|
|
1719
|
-
childResult.style = this.mergeStyles(
|
|
1720
|
-
childResult.style,
|
|
1721
|
-
textNode.style
|
|
1722
|
-
);
|
|
1714
|
+
results.push(child);
|
|
1723
1715
|
}
|
|
1724
1716
|
}
|
|
1725
1717
|
}
|
|
1726
|
-
if (
|
|
1727
|
-
|
|
1728
|
-
|
|
1718
|
+
if (textNodes.length > 0) {
|
|
1719
|
+
const mergedTextNode = this.mergeTextNodes(
|
|
1720
|
+
textNodes,
|
|
1721
|
+
styleAttr
|
|
1722
|
+
);
|
|
1723
|
+
results.push(mergedTextNode);
|
|
1724
|
+
} else if (node.text.trim()) {
|
|
1725
|
+
results.push(this.createTextNode(node.text, styleAttr));
|
|
1726
|
+
}
|
|
1727
|
+
return results;
|
|
1728
|
+
}
|
|
1729
|
+
mergeTextNodes(textNodes, spanStyle) {
|
|
1730
|
+
const result = { ...textNodes[0] };
|
|
1731
|
+
result.style = this.mergeStyles(result.style, spanStyle);
|
|
1732
|
+
for (let i = 1; i < textNodes.length; i++) {
|
|
1733
|
+
const node = textNodes[i];
|
|
1734
|
+
result.text += node.text;
|
|
1735
|
+
result.format |= node.format || 0;
|
|
1736
|
+
result.style = this.mergeStyles(result.style, node.style);
|
|
1737
|
+
}
|
|
1738
|
+
return result;
|
|
1729
1739
|
}
|
|
1730
1740
|
createTextNode(text, style) {
|
|
1731
1741
|
return {
|