@openworkbook/core 0.1.0 → 0.1.1

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 CHANGED
@@ -74990,6 +74990,24 @@ function paintErrorIndicators(ctx, wb, s3, rb, cb) {
74990
74990
  ctx.restore();
74991
74991
  }
74992
74992
 
74993
+ // src/view/frame.ts
74994
+ function nextFrame(fn, ms = 150) {
74995
+ let done = false;
74996
+ const stop = () => {
74997
+ done = true;
74998
+ if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(raf);
74999
+ clearTimeout(timer);
75000
+ };
75001
+ const run3 = () => {
75002
+ if (done) return;
75003
+ stop();
75004
+ if (typeof window !== "undefined") fn();
75005
+ };
75006
+ const raf = requestAnimationFrame(run3), timer = setTimeout(run3, ms);
75007
+ timer.unref?.();
75008
+ return stop;
75009
+ }
75010
+
74993
75011
  // src/view/pivotOverwriteMarks.ts
74994
75012
  var PIVOT_OVERWRITE_MARK_COLOR = "#d97706";
74995
75013
  function pivotOverwrittenCells(s3) {
@@ -83833,13 +83851,15 @@ var _GridView = class _GridView extends Emitter {
83833
83851
  this.wb = wb;
83834
83852
  this.popup = null;
83835
83853
  this.ro = null;
83836
- this.raf = 0;
83854
+ this.raf = null;
83837
83855
  this.unsub = [];
83838
83856
  this.state = /* @__PURE__ */ new Map();
83839
83857
  /** [window] The sheet this view is pinned to (null: follows `wb.active`) and its last known index. */
83840
83858
  this.pin = null;
83841
83859
  this.pinAt = 0;
83842
83860
  this.drag = null;
83861
+ /** [resize double click] The last column / row resize drag that ended (index, size before it, time): a double click on a resize edge acts on it. */
83862
+ this.lastResize = null;
83843
83863
  this.fillTarget = null;
83844
83864
  /** [table resize] The range a table being resized with its handle would get. */
83845
83865
  this.tableDraft = null;
@@ -84085,6 +84105,7 @@ var _GridView = class _GridView extends Emitter {
84085
84105
  /** Show every note of the sheet as a callout next to its cell (view state, not saved). Set it with `setShowAllNotes`. */
84086
84106
  this.showAllNotes = false;
84087
84107
  this.cmCard = null;
84108
+ this.adopting = false;
84088
84109
  /** Commit the edit. Returns false when validation rejected the value. */
84089
84110
  /** [formula entry] See `ViewOptions.refuseInvalidFormulas`. */
84090
84111
  this.refuseInvalidFormulas = false;
@@ -84285,7 +84306,7 @@ var _GridView = class _GridView extends Emitter {
84285
84306
  if (opts.sheetAreaOffset) this.setSheetAreaOffset(opts.sheetAreaOffset);
84286
84307
  on(this.editor, "keydown", (e) => this.onKeyDown(e));
84287
84308
  on(this.editor, "input", () => {
84288
- if (this.editing) {
84309
+ if (this.editing || this.adoptTyped(false)) {
84289
84310
  this.refSpan = null;
84290
84311
  this.sizeEditor();
84291
84312
  this.emit("edittext", this.editor.value);
@@ -84298,9 +84319,13 @@ var _GridView = class _GridView extends Emitter {
84298
84319
  on(this.editor, "paste", (e) => this.onPaste(e));
84299
84320
  on(this.editor, "beforeinput", (e) => this.maskBeforeInput(e));
84300
84321
  on(this.editor, "compositionstart", () => {
84322
+ if (!this.editing) this.adoptTyped(true);
84301
84323
  if (this.mask) this.mask.before = { text: this.editor.value, at: this.editor.selectionStart ?? 0 };
84302
84324
  });
84303
- on(this.editor, "compositionend", (e) => this.maskComposed(e.data || ""));
84325
+ on(this.editor, "compositionend", (e) => {
84326
+ if (this.editing) this.maskComposed(e.data || "");
84327
+ else this.focusGrid();
84328
+ });
84304
84329
  this.richListen(on);
84305
84330
  this.assistInit(opts);
84306
84331
  this.unsub.push(wb.on("change", () => this.onModelChange()));
@@ -84330,6 +84355,13 @@ var _GridView = class _GridView extends Emitter {
84330
84355
  emitAnnounce: (text6, assertive) => this.emit("announce", { text: text6, assertive })
84331
84356
  }, typeof opts.accessibility === "object" ? opts.accessibility : {});
84332
84357
  }
84358
+ {
84359
+ const m0 = this.sheet.getMerge(0, 0);
84360
+ if (m0) {
84361
+ this.selections = [{ r1: m0.r1, c1: m0.c1, r2: m0.r2, c2: m0.c2 }];
84362
+ this.focus = { row: m0.r2, col: m0.c2 };
84363
+ }
84364
+ }
84333
84365
  this.resize();
84334
84366
  }
84335
84367
  /** [shared clipboard] The page's internal clipboard (see `sharedClip`); setting it tells the other views (`clipboard` event). */
@@ -84371,7 +84403,7 @@ var _GridView = class _GridView extends Emitter {
84371
84403
  this.destroyed = true;
84372
84404
  sharedClip.views.delete(this);
84373
84405
  if (sharedClip.owner === this) this.clip = null;
84374
- cancelAnimationFrame(this.raf);
84406
+ this.raf?.();
84375
84407
  this.ro?.disconnect();
84376
84408
  this.unsub.forEach((f) => f());
84377
84409
  this.controls.destroy();
@@ -84564,8 +84596,8 @@ var _GridView = class _GridView extends Emitter {
84564
84596
  }
84565
84597
  invalidate() {
84566
84598
  if (this.raf || this.destroyed) return;
84567
- this.raf = requestAnimationFrame(() => {
84568
- this.raf = 0;
84599
+ this.raf = nextFrame(() => {
84600
+ this.raf = null;
84569
84601
  this.draw();
84570
84602
  });
84571
84603
  }
@@ -84575,10 +84607,11 @@ var _GridView = class _GridView extends Emitter {
84575
84607
  this.state.set(this.lastSheet, { sel: this.selections, active: this.active, anchor: this.anchor, focus: this.focus, sx: this.scroller.scrollLeft, sy: this.scroller.scrollTop });
84576
84608
  this.lastSheet = s3;
84577
84609
  const st = this.state.get(s3);
84578
- this.selections = st?.sel || [{ r1: 0, c1: 0, r2: 0, c2: 0 }];
84610
+ const m0 = s3.getMerge(0, 0);
84611
+ this.selections = st?.sel || [m0 ? { r1: m0.r1, c1: m0.c1, r2: m0.r2, c2: m0.c2 } : { r1: 0, c1: 0, r2: 0, c2: 0 }];
84579
84612
  this.active = st?.active || { row: 0, col: 0 };
84580
84613
  this.anchor = st?.anchor || { row: 0, col: 0 };
84581
- this.focus = st?.focus || { row: 0, col: 0 };
84614
+ this.focus = st?.focus || (m0 ? { row: m0.r2, col: m0.c2 } : { row: 0, col: 0 });
84582
84615
  this.updateSpacer();
84583
84616
  this.scroller.scrollLeft = st?.sx || 0;
84584
84617
  this.scroller.scrollTop = st?.sy || 0;
@@ -84706,10 +84739,13 @@ var _GridView = class _GridView extends Emitter {
84706
84739
  let need = 0;
84707
84740
  for (let c = 0; c <= s3.maxCol; c++) {
84708
84741
  const cell = s3.getCell(r3, c);
84709
- if (!cell || cell.v === void 0 && cell.f === void 0 || s3.getMerge(r3, c)) continue;
84742
+ if (!cell || cell.v === void 0 && cell.f === void 0) continue;
84743
+ const m = s3.getMerge(r3, c);
84744
+ if (m && (m.r1 !== m.r2 || m.c1 !== c)) continue;
84745
+ const width = m ? s3.cols.offset(m.c2 + 1) - s3.cols.offset(m.c1) : s3.cols.size(c);
84710
84746
  const st = s3.getStyle(r3, c);
84711
84747
  if (cell.rich) {
84712
- if (!st.rotation) need = Math.max(need, this.richHeight(listRuns(cell.rich, st.textList), st, s3.cols.size(c)));
84748
+ if (!st.rotation) need = Math.max(need, this.richHeight(listRuns(cell.rich, st.textList), st, width));
84713
84749
  continue;
84714
84750
  }
84715
84751
  const big2 = (st.fontSize || this.theme.fontSize) > this.theme.fontSize;
@@ -84720,7 +84756,7 @@ var _GridView = class _GridView extends Emitter {
84720
84756
  if (!text6) continue;
84721
84757
  this.ctx.font = this.font(st);
84722
84758
  const pad = cellPadding(st);
84723
- const lines2 = st.wrap ? this.wrapLines(text6, Math.max(8, s3.cols.size(c) - pad.left - pad.right - (st.indent || 0) * 9)).length : 1;
84759
+ const lines2 = st.wrap ? this.wrapLines(text6, Math.max(8, width - pad.left - pad.right - (st.indent || 0) * 9)).length : 1;
84724
84760
  need = Math.max(need, fittedRowPx(st.fontSize || this.theme.fontSize, lines2, pad.top + pad.bottom, acc, st.fontFamily));
84725
84761
  }
84726
84762
  const cur2 = s3.rows.auto.get(r3);
@@ -84803,6 +84839,22 @@ var _GridView = class _GridView extends Emitter {
84803
84839
  ctx.fillRect(x, y, w2 - 1, h - 1);
84804
84840
  if (bgImg && !bgOver) paintBackgroundTiles(ctx, bgImg, cb.o, rb.o, { x, y, w: w2 - 1, h: h - 1 }, s3.rightToLeft, bgOpt);
84805
84841
  this.paintCell(m.r1, m.c1, x, y, w2, h, borders, true);
84842
+ const edge = (r3, c, cx2, cy, cw, ch, below) => {
84843
+ if (!cw || !ch || s3.getMerge(r3, c) || (s3.autoMerges.length || s3._dataRanges) && s3.getAutoMerge(r3, c)) return;
84844
+ const cond = s3.getCond(r3, c), base = s3.getDisplayStyle(r3, c);
84845
+ const st0 = this.extras.style(r3, c, cond?.style ? { ...base, ...cond.style } : base);
84846
+ const st = this.forcedColors ? forcedCellStyle(st0, t) : st0;
84847
+ if (!st.fill && !st.fillPattern && !st.fillGradient) return;
84848
+ ctx.save();
84849
+ ctx.beginPath();
84850
+ if (below) ctx.rect(cx2 - 1, cy - 1, cw + 1, 1);
84851
+ else ctx.rect(cx2 - 1, cy - 1, 1, ch + 1);
84852
+ ctx.clip();
84853
+ paintCellFill(ctx, st, cx2 - 1, cy - 1, cw + 1, ch + 1, { originX: cx2 - s3.cols.offset(c), originY: cy - s3.rows.offset(r3) });
84854
+ ctx.restore();
84855
+ };
84856
+ if (m.r2 + 1 <= rb.b) for (let c = Math.max(m.c1, cb.a); c <= Math.min(m.c2, cb.b); c++) edge(m.r2 + 1, c, cb.o + s3.cols.offset(c), y + h, s3.cols.size(c), s3.rows.size(m.r2 + 1), true);
84857
+ if (m.c2 + 1 <= cb.b) for (let r3 = Math.max(m.r1, rb.a); r3 <= Math.min(m.r2, rb.b); r3++) edge(r3, m.c2 + 1, x + w2, rb.o + s3.rows.offset(r3), s3.cols.size(m.c2 + 1), s3.rows.size(r3), false);
84806
84858
  }
84807
84859
  if (this.lateText.length) {
84808
84860
  const late = this.lateText;
@@ -87268,6 +87320,10 @@ var _GridView = class _GridView extends Emitter {
87268
87320
  if (!d) return;
87269
87321
  this.drag = null;
87270
87322
  this.showDragTip("", null);
87323
+ if ((d.mode === "colresize" || d.mode === "rowresize") && !d.unhide) {
87324
+ const lr = this.lastResize, now3 = Date.now();
87325
+ this.lastResize = { mode: d.mode, index: d.index, size: lr && lr.mode === d.mode && lr.index === d.index && now3 - lr.at < 700 ? lr.size : d.size, at: now3 };
87326
+ }
87271
87327
  const s3 = this.sheet;
87272
87328
  if (d.mode === "tableresize") {
87273
87329
  const draft = this.tableDraft, tb = s3.tables.find((x) => x.id === d.id);
@@ -87623,6 +87679,12 @@ var _GridView = class _GridView extends Emitter {
87623
87679
  // [cell drag] END
87624
87680
  onDblClick(e) {
87625
87681
  const p = this.point(e), h = this.hit(p.x, p.y), s3 = this.sheet;
87682
+ const lr = this.lastResize;
87683
+ this.lastResize = null;
87684
+ if (lr && Date.now() - lr.at < 700 && !this.zeroSized(lr.mode === "colresize" ? s3.cols : s3.rows, lr.index)) {
87685
+ this.autoFitEdge(lr.mode === "colresize" ? "col" : "row", lr.index, lr.size);
87686
+ return;
87687
+ }
87626
87688
  const he = this.headerEvent(h, e);
87627
87689
  if (he) {
87628
87690
  this.emit("headerdblclick", he);
@@ -87669,8 +87731,8 @@ var _GridView = class _GridView extends Emitter {
87669
87731
  s3.autoFitCol(i, this.measure);
87670
87732
  } else s3.setRowHeight(i, s3.rows.def);
87671
87733
  });
87672
- } else if (h.area === "colresize") s3.autoFitCol(h.col, this.measure);
87673
- else if (h.area === "rowresize") s3.setRowHeight(h.row, s3.rows.def);
87734
+ } else if (h.area === "colresize") this.autoFitEdge("col", h.col);
87735
+ else if (h.area === "rowresize") this.autoFitEdge("row", h.row);
87674
87736
  else if (h.area === "cell" && s3.getValidation(this.active.row, this.active.col)?.type !== "checkbox" && !this.controls.swallowDblClick(this.active.row, this.active.col, p)) this.startEdit();
87675
87737
  }
87676
87738
  onHover(e) {
@@ -88023,18 +88085,39 @@ var _GridView = class _GridView extends Emitter {
88023
88085
  this.editPos = { row, col };
88024
88086
  this.refSpan = null;
88025
88087
  this.lastMode = quick ? "enter" : "edit";
88026
- this.editor.value = text6 ?? this.inputText(this.sheet, row, col);
88088
+ const adopt = this.adopting;
88089
+ if (!adopt) this.editor.value = text6 ?? this.inputText(this.sheet, row, col);
88027
88090
  this.richBegin(text6 === void 0);
88028
88091
  this.placeEditor();
88029
88092
  if (focus) this.editor.focus({ preventScroll: true });
88030
88093
  const n4 = this.editor.value.length;
88031
- this.editor.setSelectionRange(this.selectAllOnEdit && text6 === void 0 ? 0 : n4, n4);
88094
+ if (!adopt) this.editor.setSelectionRange(this.selectAllOnEdit && text6 === void 0 ? 0 : n4, n4);
88032
88095
  this.editorInputBegin(row, col, text6);
88033
88096
  this.emit("editing", true);
88034
88097
  this.emit("edittext", this.editor.value);
88035
88098
  this.invalidate();
88036
88099
  return true;
88037
88100
  }
88101
+ /**
88102
+ * Text reached the focused grid without a key press that starts an edit: an input method (the key is `Process`),
88103
+ * dictation, an on-screen keyboard, automation that inserts text. The cell goes into Enter mode with that text,
88104
+ * as when it is typed. `composing`: a composition starts, its text is still to come. Returns false when no edit
88105
+ * started (an object is selected, the cell may not be edited): the text is dropped.
88106
+ */
88107
+ adoptTyped(composing2) {
88108
+ const text6 = composing2 ? "" : this.editor.value.replace(/^[\r\n]+$/, "");
88109
+ let ok = false;
88110
+ if ((composing2 || text6) && !this.selectedObject && !this.selSet.length) {
88111
+ this.adopting = true;
88112
+ try {
88113
+ ok = this.startEdit(text6, true);
88114
+ } finally {
88115
+ this.adopting = false;
88116
+ }
88117
+ }
88118
+ if (!ok && !composing2) this.focusGrid();
88119
+ return ok;
88120
+ }
88038
88121
  get editText() {
88039
88122
  return this.editor.value;
88040
88123
  }
@@ -89108,10 +89191,13 @@ var _GridView = class _GridView extends Emitter {
89108
89191
  this.extendTo(this.focus.row, 0);
89109
89192
  this.scrollIntoView(this.active.row, 0);
89110
89193
  return true;
89111
- case "sheetStart":
89112
- this.jumpTo(0, 0);
89194
+ case "sheetStart": {
89195
+ const r3 = s3.frozenRows < s3.rows.count ? s3.frozenRows : 0, c = s3.frozenCols < s3.cols.count ? s3.frozenCols : 0;
89196
+ this.jumpTo(r3, c);
89197
+ this.scrollTo({ x: 0, y: 0 });
89113
89198
  this.scrollIntoView(this.active.row, this.active.col);
89114
89199
  return true;
89200
+ }
89115
89201
  case "rowEnd":
89116
89202
  this.jumpTo(this.active.row, s3.maxCol);
89117
89203
  return true;
@@ -89195,7 +89281,10 @@ var _GridView = class _GridView extends Emitter {
89195
89281
  if (this.extendTo(this.focus.row, s3.maxCol)) this.scrollIntoView(this.focus.row, s3.maxCol);
89196
89282
  return true;
89197
89283
  case "extendSheetStart":
89198
- if (this.extendTo(0, 0)) this.scrollIntoView(0, 0);
89284
+ if (this.extendTo(0, 0)) {
89285
+ this.scrollTo({ x: 0, y: 0 });
89286
+ this.scrollIntoView(0, 0);
89287
+ }
89199
89288
  return true;
89200
89289
  case "extendSheetEnd":
89201
89290
  if (this.extendTo(s3.maxRow, s3.maxCol)) this.scrollIntoView(s3.maxRow, s3.maxCol);
@@ -90420,6 +90509,29 @@ var _GridView = class _GridView extends Emitter {
90420
90509
  }
90421
90510
  this.selectCell(Math.min(g.r1, s3.rows.count - 1), Math.min(g.c1, s3.cols.count - 1));
90422
90511
  }
90512
+ /**
90513
+ * [resize double click] Double click on the edge of a column / row header: fit the column to its content, or the row
90514
+ * to its (wrapped) content, as Excel does; when the column / row is part of a selection of whole columns / rows, all
90515
+ * of them are fitted. `before` is the size the drag of the double click started from: it is put back first, so a
90516
+ * column without content keeps its width. One undo step.
90517
+ */
90518
+ autoFitEdge(axis, index, before2) {
90519
+ const s3 = this.sheet, col = axis === "col", ax = col ? s3.cols : s3.rows;
90520
+ if (ax.resizeLocked.has(index)) return;
90521
+ const whole2 = this.selections.filter((g) => col ? g.r1 === 0 && g.r2 >= s3.rows.count - 1 && index >= g.c1 && index <= g.c2 : g.c1 === 0 && g.c2 >= s3.cols.count - 1 && index >= g.r1 && index <= g.r2);
90522
+ const spans = whole2.length ? whole2.map((g) => col ? [g.c1, Math.min(g.c2, s3.maxCol)] : [g.r1, Math.min(g.r2, s3.maxRow)]) : [[index, index]];
90523
+ this.wb.transact(() => {
90524
+ if (before2 !== void 0 && ax.size(index) !== before2) {
90525
+ if (col) s3.setColWidth(index, before2);
90526
+ else s3.setRowHeight(index, before2);
90527
+ }
90528
+ for (const [a, b3] of spans) {
90529
+ if (col) {
90530
+ for (let c = a; c <= b3; c++) if (!ax.resizeLocked.has(c) && ax.size(c)) s3.autoFitCol(c, this.measure);
90531
+ } else this.autoFitRows({ r1: a, r2: b3, c1: 0, c2: 0 });
90532
+ }
90533
+ });
90534
+ }
90423
90535
  /** Fit row heights to their (wrapped) content for the rows of the selection. */
90424
90536
  autoFitRows(range2 = this.selection) {
90425
90537
  const s3 = this.sheet;
@@ -90427,17 +90539,19 @@ var _GridView = class _GridView extends Emitter {
90427
90539
  for (let r3 = range2.r1; r3 <= Math.min(range2.r2, s3.maxRow); r3++) {
90428
90540
  let need = s3.rows.def;
90429
90541
  s3.eachCell({ r1: r3, r2: r3, c1: 0, c2: s3.maxCol }, (rr, c) => {
90430
- if (s3.getMerge(rr, c)) return;
90542
+ const m = s3.getMerge(rr, c);
90543
+ if (m && (m.r1 !== m.r2 || m.r1 !== rr || m.c1 !== c)) return;
90544
+ const width = m ? s3.cols.offset(m.c2 + 1) - s3.cols.offset(m.c1) : s3.cols.size(c);
90431
90545
  const st = s3.getStyle(rr, c), text6 = s3.getText(rr, c);
90432
90546
  if (!text6) return;
90433
90547
  const rich = s3.getCell(rr, c)?.rich;
90434
90548
  if (rich && !st.rotation) {
90435
- need = Math.max(need, this.richHeight(rich, st, s3.cols.size(c)));
90549
+ need = Math.max(need, this.richHeight(rich, st, width));
90436
90550
  return;
90437
90551
  }
90438
90552
  this.ctx.font = this.font(st);
90439
90553
  const lineH = Math.round((st.fontSize || this.theme.fontSize) * PT2 * 1.25);
90440
- const lines2 = st.wrap ? this.wrapLines(text6, s3.cols.size(c) - 8).length : 1;
90554
+ const lines2 = st.wrap ? this.wrapLines(text6, width - 8).length : 1;
90441
90555
  need = Math.max(need, lines2 * lineH + 4);
90442
90556
  });
90443
90557
  s3.setRowHeight(r3, need);
package/dist/index.d.cts CHANGED
@@ -12358,7 +12358,7 @@ declare function fillSeries(sheet: Worksheet, range: Range, options?: SeriesOpti
12358
12358
  * | `clear` | Clear the contents of the selection (delete the selected floating object). |
12359
12359
  * | `lineBreak` | Insert a line break in the cell editor (only while editing). |
12360
12360
  * | `rowStart` `extendRowStart` `rowEnd` | First cell of the row / extend to it / last used column of the row. |
12361
- * | `sheetStart` `sheetEnd` | Cell A1 / the last used cell. |
12361
+ * | `sheetStart` `sheetEnd` | Cell A1 (with frozen rows or columns: the first cell of the scrolling pane), scrolled to the start / the last used cell. |
12362
12362
  * | `pageDown` `pageUp` `extendPageDown` `extendPageUp` | One screen down / up (extending the selection). |
12363
12363
  * | `toggleCheckbox` | Toggle a checkbox cell; on any other cell the key types as usual. |
12364
12364
  * | `undo` `redo` `selectAll` | Undo, redo, select all cells. |
@@ -15064,6 +15064,8 @@ declare class GridView extends Emitter<ViewEvents> {
15064
15064
  private pin;
15065
15065
  private pinAt;
15066
15066
  private drag;
15067
+ /** [resize double click] The last column / row resize drag that ended (index, size before it, time): a double click on a resize edge acts on it. */
15068
+ private lastResize;
15067
15069
  private fillTarget;
15068
15070
  /** [table resize] The range a table being resized with its handle would get. */
15069
15071
  private tableDraft;
@@ -15682,6 +15684,14 @@ declare class GridView extends Emitter<ViewEvents> {
15682
15684
  private paintHighlight;
15683
15685
  /** Begin editing the active cell. Pass `text` to replace its content. */
15684
15686
  startEdit(text?: string, quick?: boolean, focus?: boolean): boolean;
15687
+ private adopting;
15688
+ /**
15689
+ * Text reached the focused grid without a key press that starts an edit: an input method (the key is `Process`),
15690
+ * dictation, an on-screen keyboard, automation that inserts text. The cell goes into Enter mode with that text,
15691
+ * as when it is typed. `composing`: a composition starts, its text is still to come. Returns false when no edit
15692
+ * started (an object is selected, the cell may not be edited): the text is dropped.
15693
+ */
15694
+ private adoptTyped;
15685
15695
  get editText(): string;
15686
15696
  /** Update the editor text from an external input such as a formula bar. */
15687
15697
  setEditText(text: string): void;
@@ -16161,6 +16171,13 @@ declare class GridView extends Emitter<ViewEvents> {
16161
16171
  toggleFilter(): void;
16162
16172
  insert(axis: 'row' | 'col', after?: boolean): void;
16163
16173
  remove(axis: 'row' | 'col'): void;
16174
+ /**
16175
+ * [resize double click] Double click on the edge of a column / row header: fit the column to its content, or the row
16176
+ * to its (wrapped) content, as Excel does; when the column / row is part of a selection of whole columns / rows, all
16177
+ * of them are fitted. `before` is the size the drag of the double click started from: it is put back first, so a
16178
+ * column without content keeps its width. One undo step.
16179
+ */
16180
+ private autoFitEdge;
16164
16181
  /** Fit row heights to their (wrapped) content for the rows of the selection. */
16165
16182
  autoFitRows(range?: Range): void;
16166
16183
  /** Zoom so the current selection fills the viewport. */
package/dist/index.d.ts CHANGED
@@ -12358,7 +12358,7 @@ declare function fillSeries(sheet: Worksheet, range: Range, options?: SeriesOpti
12358
12358
  * | `clear` | Clear the contents of the selection (delete the selected floating object). |
12359
12359
  * | `lineBreak` | Insert a line break in the cell editor (only while editing). |
12360
12360
  * | `rowStart` `extendRowStart` `rowEnd` | First cell of the row / extend to it / last used column of the row. |
12361
- * | `sheetStart` `sheetEnd` | Cell A1 / the last used cell. |
12361
+ * | `sheetStart` `sheetEnd` | Cell A1 (with frozen rows or columns: the first cell of the scrolling pane), scrolled to the start / the last used cell. |
12362
12362
  * | `pageDown` `pageUp` `extendPageDown` `extendPageUp` | One screen down / up (extending the selection). |
12363
12363
  * | `toggleCheckbox` | Toggle a checkbox cell; on any other cell the key types as usual. |
12364
12364
  * | `undo` `redo` `selectAll` | Undo, redo, select all cells. |
@@ -15064,6 +15064,8 @@ declare class GridView extends Emitter<ViewEvents> {
15064
15064
  private pin;
15065
15065
  private pinAt;
15066
15066
  private drag;
15067
+ /** [resize double click] The last column / row resize drag that ended (index, size before it, time): a double click on a resize edge acts on it. */
15068
+ private lastResize;
15067
15069
  private fillTarget;
15068
15070
  /** [table resize] The range a table being resized with its handle would get. */
15069
15071
  private tableDraft;
@@ -15682,6 +15684,14 @@ declare class GridView extends Emitter<ViewEvents> {
15682
15684
  private paintHighlight;
15683
15685
  /** Begin editing the active cell. Pass `text` to replace its content. */
15684
15686
  startEdit(text?: string, quick?: boolean, focus?: boolean): boolean;
15687
+ private adopting;
15688
+ /**
15689
+ * Text reached the focused grid without a key press that starts an edit: an input method (the key is `Process`),
15690
+ * dictation, an on-screen keyboard, automation that inserts text. The cell goes into Enter mode with that text,
15691
+ * as when it is typed. `composing`: a composition starts, its text is still to come. Returns false when no edit
15692
+ * started (an object is selected, the cell may not be edited): the text is dropped.
15693
+ */
15694
+ private adoptTyped;
15685
15695
  get editText(): string;
15686
15696
  /** Update the editor text from an external input such as a formula bar. */
15687
15697
  setEditText(text: string): void;
@@ -16161,6 +16171,13 @@ declare class GridView extends Emitter<ViewEvents> {
16161
16171
  toggleFilter(): void;
16162
16172
  insert(axis: 'row' | 'col', after?: boolean): void;
16163
16173
  remove(axis: 'row' | 'col'): void;
16174
+ /**
16175
+ * [resize double click] Double click on the edge of a column / row header: fit the column to its content, or the row
16176
+ * to its (wrapped) content, as Excel does; when the column / row is part of a selection of whole columns / rows, all
16177
+ * of them are fitted. `before` is the size the drag of the double click started from: it is put back first, so a
16178
+ * column without content keeps its width. One undo step.
16179
+ */
16180
+ private autoFitEdge;
16164
16181
  /** Fit row heights to their (wrapped) content for the rows of the selection. */
16165
16182
  autoFitRows(range?: Range): void;
16166
16183
  /** Zoom so the current selection fills the viewport. */
package/dist/index.js CHANGED
@@ -73032,6 +73032,24 @@ function paintErrorIndicators(ctx, wb, s3, rb, cb) {
73032
73032
  ctx.restore();
73033
73033
  }
73034
73034
 
73035
+ // src/view/frame.ts
73036
+ function nextFrame(fn, ms = 150) {
73037
+ let done = false;
73038
+ const stop = () => {
73039
+ done = true;
73040
+ if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(raf);
73041
+ clearTimeout(timer);
73042
+ };
73043
+ const run3 = () => {
73044
+ if (done) return;
73045
+ stop();
73046
+ if (typeof window !== "undefined") fn();
73047
+ };
73048
+ const raf = requestAnimationFrame(run3), timer = setTimeout(run3, ms);
73049
+ timer.unref?.();
73050
+ return stop;
73051
+ }
73052
+
73035
73053
  // src/view/pivotOverwriteMarks.ts
73036
73054
  var PIVOT_OVERWRITE_MARK_COLOR = "#d97706";
73037
73055
  function pivotOverwrittenCells(s3) {
@@ -81875,13 +81893,15 @@ var _GridView = class _GridView extends Emitter {
81875
81893
  this.wb = wb;
81876
81894
  this.popup = null;
81877
81895
  this.ro = null;
81878
- this.raf = 0;
81896
+ this.raf = null;
81879
81897
  this.unsub = [];
81880
81898
  this.state = /* @__PURE__ */ new Map();
81881
81899
  /** [window] The sheet this view is pinned to (null: follows `wb.active`) and its last known index. */
81882
81900
  this.pin = null;
81883
81901
  this.pinAt = 0;
81884
81902
  this.drag = null;
81903
+ /** [resize double click] The last column / row resize drag that ended (index, size before it, time): a double click on a resize edge acts on it. */
81904
+ this.lastResize = null;
81885
81905
  this.fillTarget = null;
81886
81906
  /** [table resize] The range a table being resized with its handle would get. */
81887
81907
  this.tableDraft = null;
@@ -82127,6 +82147,7 @@ var _GridView = class _GridView extends Emitter {
82127
82147
  /** Show every note of the sheet as a callout next to its cell (view state, not saved). Set it with `setShowAllNotes`. */
82128
82148
  this.showAllNotes = false;
82129
82149
  this.cmCard = null;
82150
+ this.adopting = false;
82130
82151
  /** Commit the edit. Returns false when validation rejected the value. */
82131
82152
  /** [formula entry] See `ViewOptions.refuseInvalidFormulas`. */
82132
82153
  this.refuseInvalidFormulas = false;
@@ -82327,7 +82348,7 @@ var _GridView = class _GridView extends Emitter {
82327
82348
  if (opts.sheetAreaOffset) this.setSheetAreaOffset(opts.sheetAreaOffset);
82328
82349
  on(this.editor, "keydown", (e) => this.onKeyDown(e));
82329
82350
  on(this.editor, "input", () => {
82330
- if (this.editing) {
82351
+ if (this.editing || this.adoptTyped(false)) {
82331
82352
  this.refSpan = null;
82332
82353
  this.sizeEditor();
82333
82354
  this.emit("edittext", this.editor.value);
@@ -82340,9 +82361,13 @@ var _GridView = class _GridView extends Emitter {
82340
82361
  on(this.editor, "paste", (e) => this.onPaste(e));
82341
82362
  on(this.editor, "beforeinput", (e) => this.maskBeforeInput(e));
82342
82363
  on(this.editor, "compositionstart", () => {
82364
+ if (!this.editing) this.adoptTyped(true);
82343
82365
  if (this.mask) this.mask.before = { text: this.editor.value, at: this.editor.selectionStart ?? 0 };
82344
82366
  });
82345
- on(this.editor, "compositionend", (e) => this.maskComposed(e.data || ""));
82367
+ on(this.editor, "compositionend", (e) => {
82368
+ if (this.editing) this.maskComposed(e.data || "");
82369
+ else this.focusGrid();
82370
+ });
82346
82371
  this.richListen(on);
82347
82372
  this.assistInit(opts);
82348
82373
  this.unsub.push(wb.on("change", () => this.onModelChange()));
@@ -82372,6 +82397,13 @@ var _GridView = class _GridView extends Emitter {
82372
82397
  emitAnnounce: (text6, assertive) => this.emit("announce", { text: text6, assertive })
82373
82398
  }, typeof opts.accessibility === "object" ? opts.accessibility : {});
82374
82399
  }
82400
+ {
82401
+ const m0 = this.sheet.getMerge(0, 0);
82402
+ if (m0) {
82403
+ this.selections = [{ r1: m0.r1, c1: m0.c1, r2: m0.r2, c2: m0.c2 }];
82404
+ this.focus = { row: m0.r2, col: m0.c2 };
82405
+ }
82406
+ }
82375
82407
  this.resize();
82376
82408
  }
82377
82409
  /** [shared clipboard] The page's internal clipboard (see `sharedClip`); setting it tells the other views (`clipboard` event). */
@@ -82413,7 +82445,7 @@ var _GridView = class _GridView extends Emitter {
82413
82445
  this.destroyed = true;
82414
82446
  sharedClip.views.delete(this);
82415
82447
  if (sharedClip.owner === this) this.clip = null;
82416
- cancelAnimationFrame(this.raf);
82448
+ this.raf?.();
82417
82449
  this.ro?.disconnect();
82418
82450
  this.unsub.forEach((f) => f());
82419
82451
  this.controls.destroy();
@@ -82606,8 +82638,8 @@ var _GridView = class _GridView extends Emitter {
82606
82638
  }
82607
82639
  invalidate() {
82608
82640
  if (this.raf || this.destroyed) return;
82609
- this.raf = requestAnimationFrame(() => {
82610
- this.raf = 0;
82641
+ this.raf = nextFrame(() => {
82642
+ this.raf = null;
82611
82643
  this.draw();
82612
82644
  });
82613
82645
  }
@@ -82617,10 +82649,11 @@ var _GridView = class _GridView extends Emitter {
82617
82649
  this.state.set(this.lastSheet, { sel: this.selections, active: this.active, anchor: this.anchor, focus: this.focus, sx: this.scroller.scrollLeft, sy: this.scroller.scrollTop });
82618
82650
  this.lastSheet = s3;
82619
82651
  const st = this.state.get(s3);
82620
- this.selections = st?.sel || [{ r1: 0, c1: 0, r2: 0, c2: 0 }];
82652
+ const m0 = s3.getMerge(0, 0);
82653
+ this.selections = st?.sel || [m0 ? { r1: m0.r1, c1: m0.c1, r2: m0.r2, c2: m0.c2 } : { r1: 0, c1: 0, r2: 0, c2: 0 }];
82621
82654
  this.active = st?.active || { row: 0, col: 0 };
82622
82655
  this.anchor = st?.anchor || { row: 0, col: 0 };
82623
- this.focus = st?.focus || { row: 0, col: 0 };
82656
+ this.focus = st?.focus || (m0 ? { row: m0.r2, col: m0.c2 } : { row: 0, col: 0 });
82624
82657
  this.updateSpacer();
82625
82658
  this.scroller.scrollLeft = st?.sx || 0;
82626
82659
  this.scroller.scrollTop = st?.sy || 0;
@@ -82748,10 +82781,13 @@ var _GridView = class _GridView extends Emitter {
82748
82781
  let need = 0;
82749
82782
  for (let c = 0; c <= s3.maxCol; c++) {
82750
82783
  const cell = s3.getCell(r3, c);
82751
- if (!cell || cell.v === void 0 && cell.f === void 0 || s3.getMerge(r3, c)) continue;
82784
+ if (!cell || cell.v === void 0 && cell.f === void 0) continue;
82785
+ const m = s3.getMerge(r3, c);
82786
+ if (m && (m.r1 !== m.r2 || m.c1 !== c)) continue;
82787
+ const width = m ? s3.cols.offset(m.c2 + 1) - s3.cols.offset(m.c1) : s3.cols.size(c);
82752
82788
  const st = s3.getStyle(r3, c);
82753
82789
  if (cell.rich) {
82754
- if (!st.rotation) need = Math.max(need, this.richHeight(listRuns(cell.rich, st.textList), st, s3.cols.size(c)));
82790
+ if (!st.rotation) need = Math.max(need, this.richHeight(listRuns(cell.rich, st.textList), st, width));
82755
82791
  continue;
82756
82792
  }
82757
82793
  const big2 = (st.fontSize || this.theme.fontSize) > this.theme.fontSize;
@@ -82762,7 +82798,7 @@ var _GridView = class _GridView extends Emitter {
82762
82798
  if (!text6) continue;
82763
82799
  this.ctx.font = this.font(st);
82764
82800
  const pad = cellPadding(st);
82765
- const lines2 = st.wrap ? this.wrapLines(text6, Math.max(8, s3.cols.size(c) - pad.left - pad.right - (st.indent || 0) * 9)).length : 1;
82801
+ const lines2 = st.wrap ? this.wrapLines(text6, Math.max(8, width - pad.left - pad.right - (st.indent || 0) * 9)).length : 1;
82766
82802
  need = Math.max(need, fittedRowPx(st.fontSize || this.theme.fontSize, lines2, pad.top + pad.bottom, acc, st.fontFamily));
82767
82803
  }
82768
82804
  const cur2 = s3.rows.auto.get(r3);
@@ -82845,6 +82881,22 @@ var _GridView = class _GridView extends Emitter {
82845
82881
  ctx.fillRect(x, y, w2 - 1, h - 1);
82846
82882
  if (bgImg && !bgOver) paintBackgroundTiles(ctx, bgImg, cb.o, rb.o, { x, y, w: w2 - 1, h: h - 1 }, s3.rightToLeft, bgOpt);
82847
82883
  this.paintCell(m.r1, m.c1, x, y, w2, h, borders, true);
82884
+ const edge = (r3, c, cx2, cy, cw, ch, below) => {
82885
+ if (!cw || !ch || s3.getMerge(r3, c) || (s3.autoMerges.length || s3._dataRanges) && s3.getAutoMerge(r3, c)) return;
82886
+ const cond = s3.getCond(r3, c), base = s3.getDisplayStyle(r3, c);
82887
+ const st0 = this.extras.style(r3, c, cond?.style ? { ...base, ...cond.style } : base);
82888
+ const st = this.forcedColors ? forcedCellStyle(st0, t) : st0;
82889
+ if (!st.fill && !st.fillPattern && !st.fillGradient) return;
82890
+ ctx.save();
82891
+ ctx.beginPath();
82892
+ if (below) ctx.rect(cx2 - 1, cy - 1, cw + 1, 1);
82893
+ else ctx.rect(cx2 - 1, cy - 1, 1, ch + 1);
82894
+ ctx.clip();
82895
+ paintCellFill(ctx, st, cx2 - 1, cy - 1, cw + 1, ch + 1, { originX: cx2 - s3.cols.offset(c), originY: cy - s3.rows.offset(r3) });
82896
+ ctx.restore();
82897
+ };
82898
+ if (m.r2 + 1 <= rb.b) for (let c = Math.max(m.c1, cb.a); c <= Math.min(m.c2, cb.b); c++) edge(m.r2 + 1, c, cb.o + s3.cols.offset(c), y + h, s3.cols.size(c), s3.rows.size(m.r2 + 1), true);
82899
+ if (m.c2 + 1 <= cb.b) for (let r3 = Math.max(m.r1, rb.a); r3 <= Math.min(m.r2, rb.b); r3++) edge(r3, m.c2 + 1, x + w2, rb.o + s3.rows.offset(r3), s3.cols.size(m.c2 + 1), s3.rows.size(r3), false);
82848
82900
  }
82849
82901
  if (this.lateText.length) {
82850
82902
  const late = this.lateText;
@@ -85310,6 +85362,10 @@ var _GridView = class _GridView extends Emitter {
85310
85362
  if (!d) return;
85311
85363
  this.drag = null;
85312
85364
  this.showDragTip("", null);
85365
+ if ((d.mode === "colresize" || d.mode === "rowresize") && !d.unhide) {
85366
+ const lr = this.lastResize, now3 = Date.now();
85367
+ this.lastResize = { mode: d.mode, index: d.index, size: lr && lr.mode === d.mode && lr.index === d.index && now3 - lr.at < 700 ? lr.size : d.size, at: now3 };
85368
+ }
85313
85369
  const s3 = this.sheet;
85314
85370
  if (d.mode === "tableresize") {
85315
85371
  const draft = this.tableDraft, tb = s3.tables.find((x) => x.id === d.id);
@@ -85665,6 +85721,12 @@ var _GridView = class _GridView extends Emitter {
85665
85721
  // [cell drag] END
85666
85722
  onDblClick(e) {
85667
85723
  const p = this.point(e), h = this.hit(p.x, p.y), s3 = this.sheet;
85724
+ const lr = this.lastResize;
85725
+ this.lastResize = null;
85726
+ if (lr && Date.now() - lr.at < 700 && !this.zeroSized(lr.mode === "colresize" ? s3.cols : s3.rows, lr.index)) {
85727
+ this.autoFitEdge(lr.mode === "colresize" ? "col" : "row", lr.index, lr.size);
85728
+ return;
85729
+ }
85668
85730
  const he = this.headerEvent(h, e);
85669
85731
  if (he) {
85670
85732
  this.emit("headerdblclick", he);
@@ -85711,8 +85773,8 @@ var _GridView = class _GridView extends Emitter {
85711
85773
  s3.autoFitCol(i, this.measure);
85712
85774
  } else s3.setRowHeight(i, s3.rows.def);
85713
85775
  });
85714
- } else if (h.area === "colresize") s3.autoFitCol(h.col, this.measure);
85715
- else if (h.area === "rowresize") s3.setRowHeight(h.row, s3.rows.def);
85776
+ } else if (h.area === "colresize") this.autoFitEdge("col", h.col);
85777
+ else if (h.area === "rowresize") this.autoFitEdge("row", h.row);
85716
85778
  else if (h.area === "cell" && s3.getValidation(this.active.row, this.active.col)?.type !== "checkbox" && !this.controls.swallowDblClick(this.active.row, this.active.col, p)) this.startEdit();
85717
85779
  }
85718
85780
  onHover(e) {
@@ -86065,18 +86127,39 @@ var _GridView = class _GridView extends Emitter {
86065
86127
  this.editPos = { row, col };
86066
86128
  this.refSpan = null;
86067
86129
  this.lastMode = quick ? "enter" : "edit";
86068
- this.editor.value = text6 ?? this.inputText(this.sheet, row, col);
86130
+ const adopt = this.adopting;
86131
+ if (!adopt) this.editor.value = text6 ?? this.inputText(this.sheet, row, col);
86069
86132
  this.richBegin(text6 === void 0);
86070
86133
  this.placeEditor();
86071
86134
  if (focus) this.editor.focus({ preventScroll: true });
86072
86135
  const n4 = this.editor.value.length;
86073
- this.editor.setSelectionRange(this.selectAllOnEdit && text6 === void 0 ? 0 : n4, n4);
86136
+ if (!adopt) this.editor.setSelectionRange(this.selectAllOnEdit && text6 === void 0 ? 0 : n4, n4);
86074
86137
  this.editorInputBegin(row, col, text6);
86075
86138
  this.emit("editing", true);
86076
86139
  this.emit("edittext", this.editor.value);
86077
86140
  this.invalidate();
86078
86141
  return true;
86079
86142
  }
86143
+ /**
86144
+ * Text reached the focused grid without a key press that starts an edit: an input method (the key is `Process`),
86145
+ * dictation, an on-screen keyboard, automation that inserts text. The cell goes into Enter mode with that text,
86146
+ * as when it is typed. `composing`: a composition starts, its text is still to come. Returns false when no edit
86147
+ * started (an object is selected, the cell may not be edited): the text is dropped.
86148
+ */
86149
+ adoptTyped(composing2) {
86150
+ const text6 = composing2 ? "" : this.editor.value.replace(/^[\r\n]+$/, "");
86151
+ let ok = false;
86152
+ if ((composing2 || text6) && !this.selectedObject && !this.selSet.length) {
86153
+ this.adopting = true;
86154
+ try {
86155
+ ok = this.startEdit(text6, true);
86156
+ } finally {
86157
+ this.adopting = false;
86158
+ }
86159
+ }
86160
+ if (!ok && !composing2) this.focusGrid();
86161
+ return ok;
86162
+ }
86080
86163
  get editText() {
86081
86164
  return this.editor.value;
86082
86165
  }
@@ -87150,10 +87233,13 @@ var _GridView = class _GridView extends Emitter {
87150
87233
  this.extendTo(this.focus.row, 0);
87151
87234
  this.scrollIntoView(this.active.row, 0);
87152
87235
  return true;
87153
- case "sheetStart":
87154
- this.jumpTo(0, 0);
87236
+ case "sheetStart": {
87237
+ const r3 = s3.frozenRows < s3.rows.count ? s3.frozenRows : 0, c = s3.frozenCols < s3.cols.count ? s3.frozenCols : 0;
87238
+ this.jumpTo(r3, c);
87239
+ this.scrollTo({ x: 0, y: 0 });
87155
87240
  this.scrollIntoView(this.active.row, this.active.col);
87156
87241
  return true;
87242
+ }
87157
87243
  case "rowEnd":
87158
87244
  this.jumpTo(this.active.row, s3.maxCol);
87159
87245
  return true;
@@ -87237,7 +87323,10 @@ var _GridView = class _GridView extends Emitter {
87237
87323
  if (this.extendTo(this.focus.row, s3.maxCol)) this.scrollIntoView(this.focus.row, s3.maxCol);
87238
87324
  return true;
87239
87325
  case "extendSheetStart":
87240
- if (this.extendTo(0, 0)) this.scrollIntoView(0, 0);
87326
+ if (this.extendTo(0, 0)) {
87327
+ this.scrollTo({ x: 0, y: 0 });
87328
+ this.scrollIntoView(0, 0);
87329
+ }
87241
87330
  return true;
87242
87331
  case "extendSheetEnd":
87243
87332
  if (this.extendTo(s3.maxRow, s3.maxCol)) this.scrollIntoView(s3.maxRow, s3.maxCol);
@@ -88462,6 +88551,29 @@ var _GridView = class _GridView extends Emitter {
88462
88551
  }
88463
88552
  this.selectCell(Math.min(g.r1, s3.rows.count - 1), Math.min(g.c1, s3.cols.count - 1));
88464
88553
  }
88554
+ /**
88555
+ * [resize double click] Double click on the edge of a column / row header: fit the column to its content, or the row
88556
+ * to its (wrapped) content, as Excel does; when the column / row is part of a selection of whole columns / rows, all
88557
+ * of them are fitted. `before` is the size the drag of the double click started from: it is put back first, so a
88558
+ * column without content keeps its width. One undo step.
88559
+ */
88560
+ autoFitEdge(axis, index, before2) {
88561
+ const s3 = this.sheet, col = axis === "col", ax = col ? s3.cols : s3.rows;
88562
+ if (ax.resizeLocked.has(index)) return;
88563
+ const whole2 = this.selections.filter((g) => col ? g.r1 === 0 && g.r2 >= s3.rows.count - 1 && index >= g.c1 && index <= g.c2 : g.c1 === 0 && g.c2 >= s3.cols.count - 1 && index >= g.r1 && index <= g.r2);
88564
+ const spans = whole2.length ? whole2.map((g) => col ? [g.c1, Math.min(g.c2, s3.maxCol)] : [g.r1, Math.min(g.r2, s3.maxRow)]) : [[index, index]];
88565
+ this.wb.transact(() => {
88566
+ if (before2 !== void 0 && ax.size(index) !== before2) {
88567
+ if (col) s3.setColWidth(index, before2);
88568
+ else s3.setRowHeight(index, before2);
88569
+ }
88570
+ for (const [a, b3] of spans) {
88571
+ if (col) {
88572
+ for (let c = a; c <= b3; c++) if (!ax.resizeLocked.has(c) && ax.size(c)) s3.autoFitCol(c, this.measure);
88573
+ } else this.autoFitRows({ r1: a, r2: b3, c1: 0, c2: 0 });
88574
+ }
88575
+ });
88576
+ }
88465
88577
  /** Fit row heights to their (wrapped) content for the rows of the selection. */
88466
88578
  autoFitRows(range2 = this.selection) {
88467
88579
  const s3 = this.sheet;
@@ -88469,17 +88581,19 @@ var _GridView = class _GridView extends Emitter {
88469
88581
  for (let r3 = range2.r1; r3 <= Math.min(range2.r2, s3.maxRow); r3++) {
88470
88582
  let need = s3.rows.def;
88471
88583
  s3.eachCell({ r1: r3, r2: r3, c1: 0, c2: s3.maxCol }, (rr, c) => {
88472
- if (s3.getMerge(rr, c)) return;
88584
+ const m = s3.getMerge(rr, c);
88585
+ if (m && (m.r1 !== m.r2 || m.r1 !== rr || m.c1 !== c)) return;
88586
+ const width = m ? s3.cols.offset(m.c2 + 1) - s3.cols.offset(m.c1) : s3.cols.size(c);
88473
88587
  const st = s3.getStyle(rr, c), text6 = s3.getText(rr, c);
88474
88588
  if (!text6) return;
88475
88589
  const rich = s3.getCell(rr, c)?.rich;
88476
88590
  if (rich && !st.rotation) {
88477
- need = Math.max(need, this.richHeight(rich, st, s3.cols.size(c)));
88591
+ need = Math.max(need, this.richHeight(rich, st, width));
88478
88592
  return;
88479
88593
  }
88480
88594
  this.ctx.font = this.font(st);
88481
88595
  const lineH = Math.round((st.fontSize || this.theme.fontSize) * PT2 * 1.25);
88482
- const lines2 = st.wrap ? this.wrapLines(text6, s3.cols.size(c) - 8).length : 1;
88596
+ const lines2 = st.wrap ? this.wrapLines(text6, width - 8).length : 1;
88483
88597
  need = Math.max(need, lines2 * lineH + 4);
88484
88598
  });
88485
88599
  s3.setRowHeight(r3, need);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openworkbook/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Open source spreadsheet engine: data model, formula engine, canvas renderer",
5
5
  "license": "MIT",
6
6
  "engines": {