@pixerate/editor 0.4.3 → 0.4.5
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.cjs +19 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -1
- package/dist/index.js.map +1 -1
- package/dist/spreadsheet/index.cjs +19 -1
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +1 -0
- package/dist/spreadsheet/index.d.ts +1 -0
- package/dist/spreadsheet/index.js +19 -1
- package/dist/spreadsheet/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2497,10 +2497,28 @@ var SpreadsheetController = class {
|
|
|
2497
2497
|
setColumnWidth(colId, width) {
|
|
2498
2498
|
const col = this.document.columns.find((c) => c.id === colId);
|
|
2499
2499
|
if (col) {
|
|
2500
|
-
col.width = Math.max(
|
|
2500
|
+
col.width = Math.max(30, width);
|
|
2501
2501
|
this.notifyChange();
|
|
2502
2502
|
}
|
|
2503
2503
|
}
|
|
2504
|
+
autoFitColumnWidth(colId, customWidth) {
|
|
2505
|
+
if (customWidth !== void 0) {
|
|
2506
|
+
this.setColumnWidth(colId, customWidth);
|
|
2507
|
+
return;
|
|
2508
|
+
}
|
|
2509
|
+
const col = this.document.columns.find((c) => c.id === colId);
|
|
2510
|
+
if (!col) return;
|
|
2511
|
+
let maxLen = (col.title || "").length + (col.key ? col.key.length + 3 : 0);
|
|
2512
|
+
for (const row of this.document.rows) {
|
|
2513
|
+
const cell = this.getCell(row.id, col.id);
|
|
2514
|
+
const valStr = cell.value != null ? String(cell.value) : "";
|
|
2515
|
+
if (valStr.length > maxLen) {
|
|
2516
|
+
maxLen = valStr.length;
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
const estimatedWidth = Math.min(600, Math.max(50, Math.ceil(maxLen * 8.5 + 32)));
|
|
2520
|
+
this.setColumnWidth(colId, estimatedWidth);
|
|
2521
|
+
}
|
|
2504
2522
|
// --- Clipboard TSV/CSV ---
|
|
2505
2523
|
exportToTsv() {
|
|
2506
2524
|
return this.document.rows.map(
|