@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.js
CHANGED
|
@@ -2418,10 +2418,28 @@ var SpreadsheetController = class {
|
|
|
2418
2418
|
setColumnWidth(colId, width) {
|
|
2419
2419
|
const col = this.document.columns.find((c) => c.id === colId);
|
|
2420
2420
|
if (col) {
|
|
2421
|
-
col.width = Math.max(
|
|
2421
|
+
col.width = Math.max(30, width);
|
|
2422
2422
|
this.notifyChange();
|
|
2423
2423
|
}
|
|
2424
2424
|
}
|
|
2425
|
+
autoFitColumnWidth(colId, customWidth) {
|
|
2426
|
+
if (customWidth !== void 0) {
|
|
2427
|
+
this.setColumnWidth(colId, customWidth);
|
|
2428
|
+
return;
|
|
2429
|
+
}
|
|
2430
|
+
const col = this.document.columns.find((c) => c.id === colId);
|
|
2431
|
+
if (!col) return;
|
|
2432
|
+
let maxLen = (col.title || "").length + (col.key ? col.key.length + 3 : 0);
|
|
2433
|
+
for (const row of this.document.rows) {
|
|
2434
|
+
const cell = this.getCell(row.id, col.id);
|
|
2435
|
+
const valStr = cell.value != null ? String(cell.value) : "";
|
|
2436
|
+
if (valStr.length > maxLen) {
|
|
2437
|
+
maxLen = valStr.length;
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
const estimatedWidth = Math.min(600, Math.max(50, Math.ceil(maxLen * 8.5 + 32)));
|
|
2441
|
+
this.setColumnWidth(colId, estimatedWidth);
|
|
2442
|
+
}
|
|
2425
2443
|
// --- Clipboard TSV/CSV ---
|
|
2426
2444
|
exportToTsv() {
|
|
2427
2445
|
return this.document.rows.map(
|