Skip to content

Commit 52566d2

Browse files
committed
refactor: linting
1 parent 124f584 commit 52566d2

File tree

1 file changed

+21
-7
lines changed
  • packages/core/src/api/blockManipulation/commands/updateBlock

1 file changed

+21
-7
lines changed

packages/core/src/api/blockManipulation/commands/updateBlock/updateBlock.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,9 @@ type CellAnchor = { row: number; col: number; offset: number };
350350
*/
351351
export function captureCellAnchor(tr: Transaction): CellAnchor | null {
352352
const sel = tr.selection;
353-
if (!(sel instanceof TextSelection)) return null;
353+
if (!(sel instanceof TextSelection)) {
354+
return null;
355+
}
354356

355357
const $head = tr.doc.resolve(sel.head);
356358
// Find enclosing cell and table
@@ -366,19 +368,25 @@ export function captureCellAnchor(tr: Transaction): CellAnchor | null {
366368
break;
367369
}
368370
}
369-
if (cellDepth < 0 || tableDepth < 0) return null;
371+
if (cellDepth < 0 || tableDepth < 0) {
372+
return null;
373+
}
370374

371375
// Absolute positions (before the cell)
372376
const cellPos = $head.before(cellDepth);
373377
const tablePos = $head.before(tableDepth);
374378
const table = tr.doc.nodeAt(tablePos);
375-
if (!table || table.type.name !== "table") return null;
379+
if (!table || table.type.name !== "table") {
380+
return null;
381+
}
376382

377383
// Visual grid position via TableMap (handles spans)
378384
const map = TableMap.get(table);
379385
const rel = cellPos - (tablePos + 1); // relative to inside table
380386
const idx = map.map.indexOf(rel);
381-
if (idx < 0) return null;
387+
if (idx < 0) {
388+
return null;
389+
}
382390

383391
const row = Math.floor(idx / map.width);
384392
const col = idx % map.width;
@@ -396,7 +404,9 @@ function restoreCellAnchor(
396404
blockInfo: BlockInfo,
397405
a: CellAnchor,
398406
): boolean {
399-
if (blockInfo.blockNoteType !== "table") return false;
407+
if (blockInfo.blockNoteType !== "table") {
408+
return false;
409+
}
400410

401411
// 1) Resolve the table node in the current document
402412
let tablePos = -1;
@@ -418,7 +428,9 @@ function restoreCellAnchor(
418428
}
419429

420430
const table = tablePos >= 0 ? tr.doc.nodeAt(tablePos) : null;
421-
if (!table || table.type.name !== "table") return false;
431+
if (!table || table.type.name !== "table") {
432+
return false;
433+
}
422434

423435
// 2) Clamp row/col to the table’s current grid
424436
const map = TableMap.get(table);
@@ -428,7 +440,9 @@ function restoreCellAnchor(
428440
// 3) Compute the absolute position of the target cell (pos BEFORE the cell)
429441
const cellIndex = row * map.width + col;
430442
const relCellPos = map.map[cellIndex]; // relative to (tablePos + 1)
431-
if (relCellPos == null) return false;
443+
if (relCellPos == null) {
444+
return false;
445+
}
432446
const cellPos = tablePos + 1 + relCellPos;
433447

434448
// 4) Place the caret inside the cell, clamping the text offset

0 commit comments

Comments
 (0)