Skip to content

v0.2.0-alpha

Pre-release
Pre-release

Choose a tag to compare

@pedropaulovc pedropaulovc released this 23 Jan 03:28
· 25 commits to main since this release
Immutable release. Only release title and notes can be modified.

Added

  • linesInViewport() method - Query which lines are visible in viewport (no side effects), returns ViewportLineInfo with fullyVisible and partiallyVisible ranges
  • isLineRendered(n) method - Check if a line is rendered in DOM (no side effects)
  • isLineVisible(n, partial?) method - Check if a line is visible in viewport (no side effects)
  • documentLineNumber(locator) method - Get 1-based document line number for a line element
  • firstVisibleLine() method - Get first actually-visible line (skips anchor lines)
  • scrollToLine() position options - Control where line appears: 'top', 'center', 'bottom', or numeric 0-1
  • LineRange type - Range of line numbers with first and last properties
  • ViewportLineInfo type - Viewport line information with fullyVisible and partiallyVisible arrays
  • ScrollLinePosition type - Position option for scrollToLine()
  • ScrollToLineOptions type - Options for scrollToLine() including position and waitForIdle

Changed

  • Renamed lines to linesInDOM - Clarifies these are DOM elements (may include off-screen anchor lines)
  • Renamed materializedLine(n) to lineInDOMAt(n) - Clarifies it's a DOM index, not document line number
  • Renamed materializedLineContaining() to lineInDOMContaining() - Consistent naming
  • Renamed lineVisible() to scrollToLineAndLocate() - Name reveals side effect (scrolls before returning)
  • Renamed scrollLineIntoView() to scrollToLine() - Simpler name
  • Renamed toHaveVisibleLineCount() to toHaveDOMLineCount() - Consistent with linesInDOM
  • Documentation notes about virtual rendering - linesInDOM may NOT be contiguous (CodeMirror keeps anchor lines like line 1 in DOM with .cm-gap spacers)

Breaking Changes

  • lines renamed to linesInDOM
  • materializedLine(n) renamed to lineInDOMAt(n) and is now 0-indexed (was 1-indexed)
  • materializedLineContaining() renamed to lineInDOMContaining()
  • lineVisible() renamed to scrollToLineAndLocate()
  • scrollLineIntoView() renamed to scrollToLine()
  • toHaveVisibleLineCount() renamed to toHaveDOMLineCount()