Repository navigation
v0.14.0
- @tooee/cli@0.14.0
- @tooee/ask@0.14.0
- @tooee/choose@0.14.0
- @tooee/clipboard@0.14.0
- @tooee/commands@0.14.0
- @tooee/config@0.14.0
- @tooee/diff@0.14.0
- @tooee/fuzzy@0.14.0
- @tooee/layout@0.14.0
- @tooee/marks@0.14.0
- @tooee/overlays@0.14.0
- @tooee/panels@0.14.0
- @tooee/renderers@0.14.0
- @tooee/router@0.14.0
- @tooee/search@0.14.0
- @tooee/shell@0.14.0
- @tooee/toasts@0.14.0
- @tooee/themes@0.14.0
- @tooee/view@0.14.0
FlatBlock is a tagged union (5d0ff96)
FlatBlock from @tooee/renderers is now a union of block types. Each block has a kind field, plus the indent and source fields that every block shares:
kind |
Other fields |
|---|---|
"heading" |
token: Tokens.Heading |
"paragraph" |
token: Tokens.Paragraph |
"code" |
token: Tokens.Code |
"blockquote" |
token: Tokens.Blockquote |
"hr" |
token: Tokens.Hr |
"list-line" |
token: Tokens.Text | Tokens.Paragraph, bullet: string, optional checked |
"table-row" |
row: FlatTableRow (no token) |
"other" |
token: Token |
Check block.kind to narrow a block. TypeScript then gives you the typed Marked token, so you do not need a type assertion. For example, block.kind === "heading" ? block.token.depth : null.
To upgrade:
- Replace
block.bullet !== undefinedwithblock.kind === "list-line". Only the first line of a list item hasbulletandchecked. - Replace
block.tableRowwithblock.kind === "table-row"andblock.row. - Code that reads
block.tokenmust narrow first, because atable-rowblock has notoken.
source, indent, flattenMarkdown and getFlatBlockText do not change. Each block type is exported as its own type, such as FlatHeadingBlock and FlatTableRowBlock, and FlatBlockKind is the union of the kind values.
flattenMarkdown returns the same blocks in the same order as before. Rendering does not change.
One document row per Markdown table row (a48d5ac)
In MarkdownView and the Markdown view of @tooee/view, each table row is now its own document row. The header row and every body row get their own gutter number, cursor position, selection, mark, search hit and copy text. Before, a whole table was one row.
flattenMarkdown now returns one FlatBlock for the header row and one for each body row, in place of one block per table. This applies to tables inside list items too. Each row block has:
kind:"table-row".row: a newFlatTableRowwith the parenttable, the rowindex(0is the header, body rows start at1) and the row's Markdown line asraw. All rows of one table share the sametableobject.source: a span over that row's line only. The delimiter line (| --- |) is not part of any row.
getFlatBlockText returns the row's Markdown line, such as | Bob | ops |, so search and copy work on one row.
Code that counts blocks or stores block indices sees more blocks for each table, and every index after a table moves. Indices saved by an earlier version, such as comment anchors keyed by rendered row, point at a different block after a table. Re-anchor them by source line where possible. A table row block has no token. Use getFlatBlockText or row.raw for the row's text, and row.table for the whole table.
The table keeps its bordered grid. All rows of a table share one set of column widths. Links in table cells stay clickable and keep their OSC 8 hyperlinks. MarkdownView no longer registers OpenTUI's text-table element, because Markdown tables now draw each cell as its own text.
Document gutter uses the theme colours (872ed5f)
The Document component in @tooee/shell did not give its row document a palette. Its gutter used fixed dark colours (#0d1117 and #6e7681) in every theme. Document now uses useGutterPalette(), so the gutter takes backgroundElement and textMuted from the active theme, as MarkdownView and CodeView do. Pass palette to choose other colours.