# -*- coding: utf-8 -*-importtypingasTimportdataclassesfromfunc_args.apiimportREQ,OPTfrom..type_enumimportTypeEnumfrom..mark_or_nodeimportBase,BaseNodeifT.TYPE_CHECKING:# pragma: no coverfrom.node_table_rowimportNodeTableRowfrom..marks.mark_fragmentimportMarkFragment
[docs]@dataclasses.dataclass(frozen=True)classNodeTableAttrs(Base):""" Attributes for :class:`NodeTable`. :param displayMode: Optional. Controls responsive behavior on narrow screens. "default" scales columns down up to 40%, "fixed" maintains original widths. :param isNumberColumnEnabled: Optional. If True, adds automatic row numbering. :param layout: Optional. Controls table alignment. Options include "wide", "full-width", "center", "align-end", "align-start", "default". :param localId: Optional. A unique identifier for the node. :param width: Optional. Table width in pixels. Overrides layout when specified. Recommended minimums: 48px for 1 column, 96px for 2 columns, 144px for 3+. Maximum: 1800px. """displayMode:T.Literal["default","fixed"]=OPTisNumberColumnEnabled:bool=OPTlayout:T.Literal["wide","full-width","center","align-end","align-start","default",]=OPTlocalId:str=OPTwidth:float=OPT
[docs]@dataclasses.dataclass(frozen=True)classNodeTable(BaseNode):""" A container for defining table structures. The table node is a top-level block node that contains one or more tableRow nodes. Each tableRow contains tableCell or tableHeader nodes with paragraph content. Layout options: - **center**: Center-aligned (default=760px) - **wide**: Wider center-aligned (960px) - **full-width**: Stretches edge to edge (1800px) - **align-start/align-end**: Aligned to start/end of content area Note: Tables render on web and desktop only; mobile rendering is unavailable. Reference: https://developer.atlassian.com/cloud/jira/platform/apis/document/nodes/table/ """type:str=TypeEnum.table.valueattrs:NodeTableAttrs=OPTcontent:list["NodeTableRow"]=REQmarks:list["MarkFragment"]=OPT
[docs]defto_markdown(self,ignore_error:bool=False,)->str:lines=list()forrowinself.content:try:md=row.to_markdown()lines.append(md)ifrow.content[0].is_type_of(TypeEnum.tableHeader):lines.append("| "+" | ".join(["---"]*len(row.content))+" |")exceptExceptionase:# pragma: no coverifignore_error:passelse:raiseereturn"\n".join(lines)