@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 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
- let childResult = null;
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 !== "text") continue;
1737
- const textNode = child;
1738
- if (!childResult) {
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
- childResult.text += textNode.text;
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 (childResult) return childResult;
1754
- const textContent = node.text.trim();
1755
- return textContent ? this.createTextNode(node.text, styleAttr) : null;
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
- let childResult = null;
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 !== "text") continue;
1710
- const textNode = child;
1711
- if (!childResult) {
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
- childResult.text += textNode.text;
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 (childResult) return childResult;
1727
- const textContent = node.text.trim();
1728
- return textContent ? this.createTextNode(node.text, styleAttr) : null;
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@examind/block-sdk",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "@comment version": [
5
5
  "Don't specify package version here. It will be injected by publish workflow."
6
6
  ],