@examind/block-sdk 0.1.5 → 0.1.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/index.js +46 -8
- package/dist/index.mjs +46 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -629,9 +629,10 @@ var TableCellNodeHandler = class extends NodeHandler {
|
|
|
629
629
|
}
|
|
630
630
|
}
|
|
631
631
|
}
|
|
632
|
-
|
|
632
|
+
const hasColspan = tableCellNode.colSpan && tableCellNode.colSpan > 1;
|
|
633
|
+
if (!hasColspan && metadata?.colWidthPixels && cellIndex >= 0 && cellIndex < metadata.colWidthPixels.length) {
|
|
633
634
|
styles.push(`width: ${metadata.colWidthPixels[cellIndex]}px;`);
|
|
634
|
-
} else if (tableCellNode.width) {
|
|
635
|
+
} else if (!hasColspan && tableCellNode.width) {
|
|
635
636
|
styles.push(`width: ${tableCellNode.width}px;`);
|
|
636
637
|
}
|
|
637
638
|
if (tableCellNode.backgroundColor) {
|
|
@@ -644,7 +645,8 @@ var TableCellNodeHandler = class extends NodeHandler {
|
|
|
644
645
|
}
|
|
645
646
|
const styleAttr = styles.length > 0 ? ` style="${styles.join(" ")}"` : "";
|
|
646
647
|
const tag = tableCellNode.headerState > 0 ? "th" : "td";
|
|
647
|
-
|
|
648
|
+
const colspanAttr = tableCellNode.colSpan && tableCellNode.colSpan > 1 ? ` colspan="${tableCellNode.colSpan}"` : "";
|
|
649
|
+
return `<${tag}${styleAttr}${colspanAttr}>${createHtmlFromNestedNodes(tableCellNode.children, { parentNode: tableCellNode })}</${tag}>`;
|
|
648
650
|
}
|
|
649
651
|
};
|
|
650
652
|
|
|
@@ -1823,6 +1825,13 @@ var TableCellNodeHandler2 = class extends NodeHandler2 {
|
|
|
1823
1825
|
const isHeader = node.tagName === "TH";
|
|
1824
1826
|
const cellNode = createEmptyTableCellNode(isHeader);
|
|
1825
1827
|
cellNode.headerState = node.tagName === "TH" ? 1 : 0;
|
|
1828
|
+
const colspan = node.getAttribute("colspan");
|
|
1829
|
+
if (colspan) {
|
|
1830
|
+
const colSpanValue = parseInt(colspan, 10);
|
|
1831
|
+
if (!isNaN(colSpanValue) && colSpanValue > 1) {
|
|
1832
|
+
cellNode.colSpan = colSpanValue;
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1826
1835
|
const styleAttr = node.getAttribute("style") || "";
|
|
1827
1836
|
const width = extractStyleValue(styleAttr, "width", true, "%");
|
|
1828
1837
|
if (width !== null) {
|
|
@@ -1907,8 +1916,20 @@ var TableNodeHandler2 = class extends NodeHandler2 {
|
|
|
1907
1916
|
tableNode.children.push(...processedRows);
|
|
1908
1917
|
});
|
|
1909
1918
|
}
|
|
1919
|
+
hasColspan(row) {
|
|
1920
|
+
const cells = row.querySelectorAll("th, td");
|
|
1921
|
+
return Array.from(cells).some((cell) => {
|
|
1922
|
+
const colspan = cell.getAttribute("colspan");
|
|
1923
|
+
return colspan && parseInt(colspan, 10) > 1;
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1910
1926
|
findTargetRowForWidths(node) {
|
|
1911
|
-
|
|
1927
|
+
const rows = node.querySelectorAll("tr");
|
|
1928
|
+
if (rows.length === 0) return null;
|
|
1929
|
+
for (const row of rows) {
|
|
1930
|
+
if (!this.hasColspan(row)) return row;
|
|
1931
|
+
}
|
|
1932
|
+
return rows[0];
|
|
1912
1933
|
}
|
|
1913
1934
|
extractColumnWidths(targetRow, effectiveReferenceWidth) {
|
|
1914
1935
|
const cells = targetRow.querySelectorAll("th, td");
|
|
@@ -1921,11 +1942,28 @@ var TableNodeHandler2 = class extends NodeHandler2 {
|
|
|
1921
1942
|
cell,
|
|
1922
1943
|
effectiveReferenceWidth
|
|
1923
1944
|
);
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1945
|
+
const colspan = parseInt(
|
|
1946
|
+
cell.getAttribute("colspan") || "1",
|
|
1947
|
+
10
|
|
1948
|
+
);
|
|
1949
|
+
if (colspan > 1) {
|
|
1950
|
+
const widthPerColumn = result.width / colspan;
|
|
1951
|
+
const percentPerColumn = result.percentEquivalent / colspan;
|
|
1952
|
+
for (let i = 0; i < colspan; i++) {
|
|
1953
|
+
colWidths.push(Math.round(widthPerColumn));
|
|
1954
|
+
if (result.width > 0) {
|
|
1955
|
+
totalSpecifiedPercent += percentPerColumn;
|
|
1956
|
+
} else {
|
|
1957
|
+
unspecifiedColumns++;
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1927
1960
|
} else {
|
|
1928
|
-
|
|
1961
|
+
colWidths.push(result.width);
|
|
1962
|
+
if (result.width > 0) {
|
|
1963
|
+
totalSpecifiedPercent += result.percentEquivalent;
|
|
1964
|
+
} else {
|
|
1965
|
+
unspecifiedColumns++;
|
|
1966
|
+
}
|
|
1929
1967
|
}
|
|
1930
1968
|
});
|
|
1931
1969
|
if (unspecifiedColumns > 0 && totalSpecifiedPercent < 100) {
|
package/dist/index.mjs
CHANGED
|
@@ -602,9 +602,10 @@ var TableCellNodeHandler = class extends NodeHandler {
|
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
|
-
|
|
605
|
+
const hasColspan = tableCellNode.colSpan && tableCellNode.colSpan > 1;
|
|
606
|
+
if (!hasColspan && metadata?.colWidthPixels && cellIndex >= 0 && cellIndex < metadata.colWidthPixels.length) {
|
|
606
607
|
styles.push(`width: ${metadata.colWidthPixels[cellIndex]}px;`);
|
|
607
|
-
} else if (tableCellNode.width) {
|
|
608
|
+
} else if (!hasColspan && tableCellNode.width) {
|
|
608
609
|
styles.push(`width: ${tableCellNode.width}px;`);
|
|
609
610
|
}
|
|
610
611
|
if (tableCellNode.backgroundColor) {
|
|
@@ -617,7 +618,8 @@ var TableCellNodeHandler = class extends NodeHandler {
|
|
|
617
618
|
}
|
|
618
619
|
const styleAttr = styles.length > 0 ? ` style="${styles.join(" ")}"` : "";
|
|
619
620
|
const tag = tableCellNode.headerState > 0 ? "th" : "td";
|
|
620
|
-
|
|
621
|
+
const colspanAttr = tableCellNode.colSpan && tableCellNode.colSpan > 1 ? ` colspan="${tableCellNode.colSpan}"` : "";
|
|
622
|
+
return `<${tag}${styleAttr}${colspanAttr}>${createHtmlFromNestedNodes(tableCellNode.children, { parentNode: tableCellNode })}</${tag}>`;
|
|
621
623
|
}
|
|
622
624
|
};
|
|
623
625
|
|
|
@@ -1796,6 +1798,13 @@ var TableCellNodeHandler2 = class extends NodeHandler2 {
|
|
|
1796
1798
|
const isHeader = node.tagName === "TH";
|
|
1797
1799
|
const cellNode = createEmptyTableCellNode(isHeader);
|
|
1798
1800
|
cellNode.headerState = node.tagName === "TH" ? 1 : 0;
|
|
1801
|
+
const colspan = node.getAttribute("colspan");
|
|
1802
|
+
if (colspan) {
|
|
1803
|
+
const colSpanValue = parseInt(colspan, 10);
|
|
1804
|
+
if (!isNaN(colSpanValue) && colSpanValue > 1) {
|
|
1805
|
+
cellNode.colSpan = colSpanValue;
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1799
1808
|
const styleAttr = node.getAttribute("style") || "";
|
|
1800
1809
|
const width = extractStyleValue(styleAttr, "width", true, "%");
|
|
1801
1810
|
if (width !== null) {
|
|
@@ -1880,8 +1889,20 @@ var TableNodeHandler2 = class extends NodeHandler2 {
|
|
|
1880
1889
|
tableNode.children.push(...processedRows);
|
|
1881
1890
|
});
|
|
1882
1891
|
}
|
|
1892
|
+
hasColspan(row) {
|
|
1893
|
+
const cells = row.querySelectorAll("th, td");
|
|
1894
|
+
return Array.from(cells).some((cell) => {
|
|
1895
|
+
const colspan = cell.getAttribute("colspan");
|
|
1896
|
+
return colspan && parseInt(colspan, 10) > 1;
|
|
1897
|
+
});
|
|
1898
|
+
}
|
|
1883
1899
|
findTargetRowForWidths(node) {
|
|
1884
|
-
|
|
1900
|
+
const rows = node.querySelectorAll("tr");
|
|
1901
|
+
if (rows.length === 0) return null;
|
|
1902
|
+
for (const row of rows) {
|
|
1903
|
+
if (!this.hasColspan(row)) return row;
|
|
1904
|
+
}
|
|
1905
|
+
return rows[0];
|
|
1885
1906
|
}
|
|
1886
1907
|
extractColumnWidths(targetRow, effectiveReferenceWidth) {
|
|
1887
1908
|
const cells = targetRow.querySelectorAll("th, td");
|
|
@@ -1894,11 +1915,28 @@ var TableNodeHandler2 = class extends NodeHandler2 {
|
|
|
1894
1915
|
cell,
|
|
1895
1916
|
effectiveReferenceWidth
|
|
1896
1917
|
);
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1918
|
+
const colspan = parseInt(
|
|
1919
|
+
cell.getAttribute("colspan") || "1",
|
|
1920
|
+
10
|
|
1921
|
+
);
|
|
1922
|
+
if (colspan > 1) {
|
|
1923
|
+
const widthPerColumn = result.width / colspan;
|
|
1924
|
+
const percentPerColumn = result.percentEquivalent / colspan;
|
|
1925
|
+
for (let i = 0; i < colspan; i++) {
|
|
1926
|
+
colWidths.push(Math.round(widthPerColumn));
|
|
1927
|
+
if (result.width > 0) {
|
|
1928
|
+
totalSpecifiedPercent += percentPerColumn;
|
|
1929
|
+
} else {
|
|
1930
|
+
unspecifiedColumns++;
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1900
1933
|
} else {
|
|
1901
|
-
|
|
1934
|
+
colWidths.push(result.width);
|
|
1935
|
+
if (result.width > 0) {
|
|
1936
|
+
totalSpecifiedPercent += result.percentEquivalent;
|
|
1937
|
+
} else {
|
|
1938
|
+
unspecifiedColumns++;
|
|
1939
|
+
}
|
|
1902
1940
|
}
|
|
1903
1941
|
});
|
|
1904
1942
|
if (unspecifiedColumns > 0 && totalSpecifiedPercent < 100) {
|