Skip to content

TableCell

Unofficial

Represents a single cell in a markdown table.

Import:

import type { TableCell } from '@obsidian-typings/obsidian-public-latest';

Signature:

export interface TableCell

Properties

PropertyTypeDescription
colnumberColumn index of the cell.
contentElHTMLElementElement containing the cell's content.
dirtybooleanWhether the cell has been modified since the last save.
elHTMLElementDOM element for the cell.
endnumberEnd offset of the cell content, relative to the start of the table.
padEndnumberNumber of trailing padding spaces in the cell.
padStartnumberNumber of leading padding spaces in the cell.
rownumberRow index of the cell.
startnumberStart offset of the cell content, relative to the start of the table.
tableTableEditorTable widget that owns this cell.
textstringText content of the cell, without padding.

Methods

MethodReturnsDescription
getAbsoluteOffsets()TableCellOffsetsGet the offsets of the cell within the whole document.
getLength()numberGet the total length of the cell content including padding.
getTextWithPadding()stringGet the cell text with its leading and trailing padding spaces.
handleMobileCaretDrag(view, pointerId)voidHandle a mobile caret drag interaction for this cell.
init(el, start, end)voidInitialize the cell with a DOM element and its offsets within the table.
lockDimensions()voidLock the cell's current dimensions to prevent layout reflow during operations.
scrollIntoView()voidScroll the cell into the visible area of the editor.
setTextDir()voidSet the text direction of the cell based on its content.
updateWidth(width)voidRecalculate the cell's padding for a target column width, honouring the column's alignment.

Links to this page: