Skip to content

v2.0.0

Choose a tag to compare

@shbernal shbernal released this 05 Aug 10:44
· 979 commits to main since this release

A tables release, and the first breaking one: custom table styles are gone,
because PowerPoint never rendered them. Everything else here is the table
surface growing to cover what that API was reaching for.

npm install @shbernal/ts-pptx

Removed

  • BREAKING: Presentation.defineTableStyle() and TableProps.styleDrivenCells
    are gone
    , along with the TableStyleProps / TableStyleRegionProps types.
    PowerPoint resolves <a:tableStyleId> against its own table-style gallery
    and never reads a style definition out of the package — measured by rendering
    in PowerPoint desktop 16.0, not inferred from the schema. The API emitted
    well-formed, schema-valid XML that can never paint.

    Migration — style tables with direct formatting, which is what carried them
    all along:

    // before
    const brand = pptx.defineTableStyle({
      name: 'Brand',
      wholeTbl: { border: { type: 'solid', color: 'D9D9D9', width: 0.5 } },
      firstRow: { fill: '1A2B3C', color: 'FFFFFF', bold: true },
    })
    slide.addTable(rows, { tableStyle: brand, hasHeader: true, styleDrivenCells: true })
    
    // after
    slide.addTable(rows, {
      hasHeader: true,
      border: { type: 'solid', color: 'D9D9D9', width: 0.5 },
      headerRow: { fill: { color: '1A2B3C' }, color: 'FFFFFF', bold: true },
    })

    TableProps.tableStyle still exists and still works — it is now typed as
    TableStyle alone, since only a built-in GUID renders. The read side is
    unaffected:
    Table.resolvedStyle, TableCell.resolvedFill and
    importSlideMasters({ tableStyles }) still resolve style graphs out of
    imported decks, because PowerPoint honours its own definitions.

Added

  • Table editing on @shbernal/ts-pptx/read — cell properties, rows, columns
    and merges, where the read proxies were previously read-plus-text-edit only.
  • TableProps.tableFill — the table's own background, as a real a:tblPr
    fill.
  • TableProps.outerBorder — a border for the table's perimeter only, as
    distinct from TableProps.border, which is a per-cell default.
  • BorderProps.dashType — the exact a:prstDash preset, instead of
    collapsing every dashed border onto sysDash. ShapeLineProps.dashType now
    spans the whole ST_PresetLineDashVal set.
  • TableCellProps.diagonal, .anchorCtr, .cell3D, .horzOverflow — cell
    corner-to-corner rules, horizontal block centring, a 3-D bevel, and clip vs.
    overflow behaviour.
  • TableCell.gradientFill / .patternFill / .hasOwnFill / .id /
    .headerIds
    (read) — non-solid cell fills and cell/header association.
  • border/unknown-key — a new diagnostic reporting an unrecognized
    BorderProps key instead of silently dropping it.
  • docs/tables.md
    — the table guide, which did not exist. Tables were the most-used object after
    text and the only major one with no prose doc.

Fixed

  • tableToSlides cell padding is now converted from px to inches. A computed
    CSS padding: 4px was assigned straight to TableCellProps.margin, which is
    inches — emitting a 4 inch text inset. Padding now resolves at 96px/in.
    This changes emitted bytes for any padded HTML table; cells will look
    substantially tighter, because they are now inset by what was asked for.
  • fitColumns: 'shrink' measured against the wrong slide margin — it
    subtracted the left margin where the right one bounds the space. Invisible with
    the default symmetric margins, wrong for any asymmetric master.
  • A styled table cell's own fill is no longer dropped by pptx-to-script.
  • A theme-indexed picture background reported the wrong part — a p:bgRef
    a:blipFill comes out of the theme part, so its r:embed is scoped to the
    theme's relationships, not the owning slide/layout/master's.
  • A table-level border side with width: 0 is now emitted as the hairline it
    asks for
    , matching what per-cell borders already did.

Documentation: https://shbernal.github.io/ts-pptx/

Full changelog: https://github.com/shbernal/ts-pptx/blob/v2.0.0/CHANGELOG.md