@scrider/formatter 1.8.0 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -481,9 +481,13 @@ declare class BlockHandlerRegistry {
481
481
  }
482
482
 
483
483
  /**
484
- * Cell alignment options
484
+ * Column alignment options (GFM column-level subset).
485
485
  */
486
486
  type CellAlign = 'left' | 'center' | 'right';
487
+ /** Per-cell horizontal alignment (includes justify; not used in colAligns). */
488
+ type CellHorizontalAlign = CellAlign | 'justify';
489
+ /** Per-cell vertical alignment (schema in 1.8.2; HTML round-trip in 1.8.4). */
490
+ type CellVerticalAlign = 'top' | 'middle' | 'bottom';
487
491
  /**
488
492
  * Data for a single cell in an Extended Table.
489
493
  *
@@ -497,6 +501,10 @@ interface CellData {
497
501
  colspan?: number;
498
502
  /** Number of rows this cell spans (default: 1) */
499
503
  rowspan?: number;
504
+ /** Per-cell horizontal override (default: inherit column via colAligns). */
505
+ align?: CellHorizontalAlign;
506
+ /** Per-cell vertical alignment (HTML ingest/emit in formatter 1.8.4). */
507
+ vAlign?: CellVerticalAlign;
500
508
  }
501
509
  /**
502
510
  * Extended Table block data.
@@ -1992,11 +2000,34 @@ interface TableRegion {
1992
2000
  /** Slice of the original ops array covering the region. */
1993
2001
  ops: InsertOp[];
1994
2002
  }
2003
+ /** Coordinates carried on a simple-table cell terminator `\n`. */
2004
+ interface TableCellCoords {
2005
+ row: number;
2006
+ col: number;
2007
+ }
1995
2008
  /**
1996
2009
  * Predicate: this op is a `\n`-op that terminates a simple-table cell
1997
2010
  * (i.e. it carries a `table-row` attribute).
1998
2011
  */
1999
2012
  declare function isTableNewlineOp(op: Op | undefined): boolean;
2013
+ declare function tableCellCoordsFromAttributes(attrs: AttributeMap | undefined): TableCellCoords | null;
2014
+ declare function tableCellCoordsFromOp(op: Op): TableCellCoords | null;
2015
+ /**
2016
+ * True when `next` begins a new simple-table grid immediately after `prev`
2017
+ * with no plain paragraph `\n` between them.
2018
+ *
2019
+ * Patterns:
2020
+ * • row decreases (e.g. 1 → 0) — new grid after a multi-row table
2021
+ * • both on row 0 but col resets to 0 — two single-row tables stacked
2022
+ */
2023
+ declare function isAdjacentSimpleTableGridBoundary(prev: TableCellCoords, next: TableCellCoords): boolean;
2024
+ /**
2025
+ * Collect consecutive table lines for one simple-table grid.
2026
+ * Stops at the first non-table line or at an adjacent-grid boundary.
2027
+ */
2028
+ declare function collectAdjacentTableLines<T extends {
2029
+ attributes?: AttributeMap | undefined;
2030
+ }>(lines: readonly T[], startIndex: number): T[];
2000
2031
  /**
2001
2032
  * Find the boundaries of the simple-table region containing the given hint
2002
2033
  * op index. The hint may be:
@@ -2007,8 +2038,9 @@ declare function isTableNewlineOp(op: Op | undefined): boolean;
2007
2038
  * The function walks **forward** from the hint to find the nearest `\n`-op:
2008
2039
  * if it does not carry a `table-row` attribute, the hint is not inside a
2009
2040
  * table and `null` is returned. Otherwise the algorithm extends the region
2010
- * forward through contiguous table newlines and backward to the op just
2011
- * after the previous non-table `\n`-op (or the start of the array).
2041
+ * forward through contiguous table newlines (stopping at adjacent-grid
2042
+ * boundaries) and backward to the op just after the previous non-table
2043
+ * `\n`-op or adjacent-grid boundary (or the start of the array).
2012
2044
  *
2013
2045
  * @param ops - The full ops array (e.g. `delta.ops`).
2014
2046
  * @param hintOpIdx - Any op index known or guessed to be within a table.
@@ -2028,4 +2060,4 @@ declare function isTableNewlineOp(op: Op | undefined): boolean;
2028
2060
  */
2029
2061
  declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
2030
2062
 
2031
- export { ALERT_TYPES, type AlertBlockData, type AlertType, type AlignType, BOX_FLOAT_VALUES, BOX_OVERFLOW_VALUES, type BlockContext, type BlockHandler, BlockHandlerRegistry, type BlockRenderOptions, type BoxBlockData, type BoxFloat, type BoxOpAttributes, type BoxOverflow, BrowserDOMAdapter, type CellAlign, type CellData, type ColumnsBlockData, type DOMAdapter, type DOMDocument, type DOMDocumentFragment, type DOMElement, type DOMNode, type DOMNodeList, type DeltaToHtmlOptions, type DeltaToMarkdownOptions, type DocumentPresentation, type EmbedIsolationOptions, type FootnotesBlockData, type Format, type FormatDefinition, type FormatMatchResult, type FormatRenderContext, type FormatScope, type HtmlToDeltaOptions, LINE_HEIGHT_BLOCK_TAGS, type ListType, type MarkdownToDeltaOptions, NODE_TYPE, NodeDOMAdapter, PARAGRAPH_SPACING_BLOCK_TAGS, Registry, type ResolvedDocumentPresentation, type ResolvedTablePresentation, SCRIDER_LINE_HEIGHT_KEY, SCRIDER_MARGIN_AFTER_KEY, SCRIDER_MARGIN_BEFORE_KEY, type SanitizeOptions, type TableBlockData, type TableCellAlign, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockMarginAfterStyleParts, blockMarginBeforeStyleParts, blockParagraphMarginStyleParts, blockPresentationStyleParts, blockquoteFormat, boldFormat, boxBlockHandler, browserAdapter, cloneDelta, codeBlockFormat, codeFormat, codeWidgetFormat, colorFormat, columnsBlockHandler, createDefaultBlockHandlers, createDefaultRegistry, defaultBlockFormats, defaultEmbedFormats, defaultFormats, defaultInlineFormats, deltaToHtml, deltaToMarkdown, dividerFormat, documentPresentationStyleParts, escapeHtml, extractBoxOpAttributes, extractTableRegion, fontFormat, footnoteRefFormat, footnotesBlockHandler, formulaFormat, getAdapter, getNamedColors, headerFormat, headerIdFormat, htmlToDelta, imageFormat, indentFormat, isAdapterAvailable, isElement, isRemarkAvailable, isTableNewlineOp, isTextNode, isValidColor, isValidHexColor, isZebraBodyRow, italicFormat, kbdFormat, linkFormat, listFormat, markFormat, markdownToDelta, markdownToDeltaSync, nodeAdapter, normalizeDelta, parseScriderLineHeightMultiplier, parseScriderMarginAfterEm, parseScriderMarginBeforeEm, parseScriderMarginEm, preloadRemark, resolveDocumentPresentation, resolveTablePresentation, sanitizeDelta, sizeFormat, slugify, slugifyWithDedup, softBreakFormat, strikeFormat, subscriptFormat, superscriptFormat, tableBlockHandler, tableColAlignFormat, tableColFormat, tableHeaderFormat, tableRowFormat, toCodeWidgetEmbedUrl, toHexColor, underlineFormat, unescapeHtml, validateDelta, videoFormat };
2063
+ export { ALERT_TYPES, type AlertBlockData, type AlertType, type AlignType, BOX_FLOAT_VALUES, BOX_OVERFLOW_VALUES, type BlockContext, type BlockHandler, BlockHandlerRegistry, type BlockRenderOptions, type BoxBlockData, type BoxFloat, type BoxOpAttributes, type BoxOverflow, BrowserDOMAdapter, type CellAlign, type CellData, type CellHorizontalAlign, type CellVerticalAlign, type ColumnsBlockData, type DOMAdapter, type DOMDocument, type DOMDocumentFragment, type DOMElement, type DOMNode, type DOMNodeList, type DeltaToHtmlOptions, type DeltaToMarkdownOptions, type DocumentPresentation, type EmbedIsolationOptions, type FootnotesBlockData, type Format, type FormatDefinition, type FormatMatchResult, type FormatRenderContext, type FormatScope, type HtmlToDeltaOptions, LINE_HEIGHT_BLOCK_TAGS, type ListType, type MarkdownToDeltaOptions, NODE_TYPE, NodeDOMAdapter, PARAGRAPH_SPACING_BLOCK_TAGS, Registry, type ResolvedDocumentPresentation, type ResolvedTablePresentation, SCRIDER_LINE_HEIGHT_KEY, SCRIDER_MARGIN_AFTER_KEY, SCRIDER_MARGIN_BEFORE_KEY, type SanitizeOptions, type TableBlockData, type TableCellAlign, type TableCellCoords, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockMarginAfterStyleParts, blockMarginBeforeStyleParts, blockParagraphMarginStyleParts, blockPresentationStyleParts, blockquoteFormat, boldFormat, boxBlockHandler, browserAdapter, cloneDelta, codeBlockFormat, codeFormat, codeWidgetFormat, collectAdjacentTableLines, colorFormat, columnsBlockHandler, createDefaultBlockHandlers, createDefaultRegistry, defaultBlockFormats, defaultEmbedFormats, defaultFormats, defaultInlineFormats, deltaToHtml, deltaToMarkdown, dividerFormat, documentPresentationStyleParts, escapeHtml, extractBoxOpAttributes, extractTableRegion, fontFormat, footnoteRefFormat, footnotesBlockHandler, formulaFormat, getAdapter, getNamedColors, headerFormat, headerIdFormat, htmlToDelta, imageFormat, indentFormat, isAdapterAvailable, isAdjacentSimpleTableGridBoundary, isElement, isRemarkAvailable, isTableNewlineOp, isTextNode, isValidColor, isValidHexColor, isZebraBodyRow, italicFormat, kbdFormat, linkFormat, listFormat, markFormat, markdownToDelta, markdownToDeltaSync, nodeAdapter, normalizeDelta, parseScriderLineHeightMultiplier, parseScriderMarginAfterEm, parseScriderMarginBeforeEm, parseScriderMarginEm, preloadRemark, resolveDocumentPresentation, resolveTablePresentation, sanitizeDelta, sizeFormat, slugify, slugifyWithDedup, softBreakFormat, strikeFormat, subscriptFormat, superscriptFormat, tableBlockHandler, tableCellCoordsFromAttributes, tableCellCoordsFromOp, tableColAlignFormat, tableColFormat, tableHeaderFormat, tableRowFormat, toCodeWidgetEmbedUrl, toHexColor, underlineFormat, unescapeHtml, validateDelta, videoFormat };
package/dist/index.d.ts CHANGED
@@ -481,9 +481,13 @@ declare class BlockHandlerRegistry {
481
481
  }
482
482
 
483
483
  /**
484
- * Cell alignment options
484
+ * Column alignment options (GFM column-level subset).
485
485
  */
486
486
  type CellAlign = 'left' | 'center' | 'right';
487
+ /** Per-cell horizontal alignment (includes justify; not used in colAligns). */
488
+ type CellHorizontalAlign = CellAlign | 'justify';
489
+ /** Per-cell vertical alignment (schema in 1.8.2; HTML round-trip in 1.8.4). */
490
+ type CellVerticalAlign = 'top' | 'middle' | 'bottom';
487
491
  /**
488
492
  * Data for a single cell in an Extended Table.
489
493
  *
@@ -497,6 +501,10 @@ interface CellData {
497
501
  colspan?: number;
498
502
  /** Number of rows this cell spans (default: 1) */
499
503
  rowspan?: number;
504
+ /** Per-cell horizontal override (default: inherit column via colAligns). */
505
+ align?: CellHorizontalAlign;
506
+ /** Per-cell vertical alignment (HTML ingest/emit in formatter 1.8.4). */
507
+ vAlign?: CellVerticalAlign;
500
508
  }
501
509
  /**
502
510
  * Extended Table block data.
@@ -1992,11 +2000,34 @@ interface TableRegion {
1992
2000
  /** Slice of the original ops array covering the region. */
1993
2001
  ops: InsertOp[];
1994
2002
  }
2003
+ /** Coordinates carried on a simple-table cell terminator `\n`. */
2004
+ interface TableCellCoords {
2005
+ row: number;
2006
+ col: number;
2007
+ }
1995
2008
  /**
1996
2009
  * Predicate: this op is a `\n`-op that terminates a simple-table cell
1997
2010
  * (i.e. it carries a `table-row` attribute).
1998
2011
  */
1999
2012
  declare function isTableNewlineOp(op: Op | undefined): boolean;
2013
+ declare function tableCellCoordsFromAttributes(attrs: AttributeMap | undefined): TableCellCoords | null;
2014
+ declare function tableCellCoordsFromOp(op: Op): TableCellCoords | null;
2015
+ /**
2016
+ * True when `next` begins a new simple-table grid immediately after `prev`
2017
+ * with no plain paragraph `\n` between them.
2018
+ *
2019
+ * Patterns:
2020
+ * • row decreases (e.g. 1 → 0) — new grid after a multi-row table
2021
+ * • both on row 0 but col resets to 0 — two single-row tables stacked
2022
+ */
2023
+ declare function isAdjacentSimpleTableGridBoundary(prev: TableCellCoords, next: TableCellCoords): boolean;
2024
+ /**
2025
+ * Collect consecutive table lines for one simple-table grid.
2026
+ * Stops at the first non-table line or at an adjacent-grid boundary.
2027
+ */
2028
+ declare function collectAdjacentTableLines<T extends {
2029
+ attributes?: AttributeMap | undefined;
2030
+ }>(lines: readonly T[], startIndex: number): T[];
2000
2031
  /**
2001
2032
  * Find the boundaries of the simple-table region containing the given hint
2002
2033
  * op index. The hint may be:
@@ -2007,8 +2038,9 @@ declare function isTableNewlineOp(op: Op | undefined): boolean;
2007
2038
  * The function walks **forward** from the hint to find the nearest `\n`-op:
2008
2039
  * if it does not carry a `table-row` attribute, the hint is not inside a
2009
2040
  * table and `null` is returned. Otherwise the algorithm extends the region
2010
- * forward through contiguous table newlines and backward to the op just
2011
- * after the previous non-table `\n`-op (or the start of the array).
2041
+ * forward through contiguous table newlines (stopping at adjacent-grid
2042
+ * boundaries) and backward to the op just after the previous non-table
2043
+ * `\n`-op or adjacent-grid boundary (or the start of the array).
2012
2044
  *
2013
2045
  * @param ops - The full ops array (e.g. `delta.ops`).
2014
2046
  * @param hintOpIdx - Any op index known or guessed to be within a table.
@@ -2028,4 +2060,4 @@ declare function isTableNewlineOp(op: Op | undefined): boolean;
2028
2060
  */
2029
2061
  declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
2030
2062
 
2031
- export { ALERT_TYPES, type AlertBlockData, type AlertType, type AlignType, BOX_FLOAT_VALUES, BOX_OVERFLOW_VALUES, type BlockContext, type BlockHandler, BlockHandlerRegistry, type BlockRenderOptions, type BoxBlockData, type BoxFloat, type BoxOpAttributes, type BoxOverflow, BrowserDOMAdapter, type CellAlign, type CellData, type ColumnsBlockData, type DOMAdapter, type DOMDocument, type DOMDocumentFragment, type DOMElement, type DOMNode, type DOMNodeList, type DeltaToHtmlOptions, type DeltaToMarkdownOptions, type DocumentPresentation, type EmbedIsolationOptions, type FootnotesBlockData, type Format, type FormatDefinition, type FormatMatchResult, type FormatRenderContext, type FormatScope, type HtmlToDeltaOptions, LINE_HEIGHT_BLOCK_TAGS, type ListType, type MarkdownToDeltaOptions, NODE_TYPE, NodeDOMAdapter, PARAGRAPH_SPACING_BLOCK_TAGS, Registry, type ResolvedDocumentPresentation, type ResolvedTablePresentation, SCRIDER_LINE_HEIGHT_KEY, SCRIDER_MARGIN_AFTER_KEY, SCRIDER_MARGIN_BEFORE_KEY, type SanitizeOptions, type TableBlockData, type TableCellAlign, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockMarginAfterStyleParts, blockMarginBeforeStyleParts, blockParagraphMarginStyleParts, blockPresentationStyleParts, blockquoteFormat, boldFormat, boxBlockHandler, browserAdapter, cloneDelta, codeBlockFormat, codeFormat, codeWidgetFormat, colorFormat, columnsBlockHandler, createDefaultBlockHandlers, createDefaultRegistry, defaultBlockFormats, defaultEmbedFormats, defaultFormats, defaultInlineFormats, deltaToHtml, deltaToMarkdown, dividerFormat, documentPresentationStyleParts, escapeHtml, extractBoxOpAttributes, extractTableRegion, fontFormat, footnoteRefFormat, footnotesBlockHandler, formulaFormat, getAdapter, getNamedColors, headerFormat, headerIdFormat, htmlToDelta, imageFormat, indentFormat, isAdapterAvailable, isElement, isRemarkAvailable, isTableNewlineOp, isTextNode, isValidColor, isValidHexColor, isZebraBodyRow, italicFormat, kbdFormat, linkFormat, listFormat, markFormat, markdownToDelta, markdownToDeltaSync, nodeAdapter, normalizeDelta, parseScriderLineHeightMultiplier, parseScriderMarginAfterEm, parseScriderMarginBeforeEm, parseScriderMarginEm, preloadRemark, resolveDocumentPresentation, resolveTablePresentation, sanitizeDelta, sizeFormat, slugify, slugifyWithDedup, softBreakFormat, strikeFormat, subscriptFormat, superscriptFormat, tableBlockHandler, tableColAlignFormat, tableColFormat, tableHeaderFormat, tableRowFormat, toCodeWidgetEmbedUrl, toHexColor, underlineFormat, unescapeHtml, validateDelta, videoFormat };
2063
+ export { ALERT_TYPES, type AlertBlockData, type AlertType, type AlignType, BOX_FLOAT_VALUES, BOX_OVERFLOW_VALUES, type BlockContext, type BlockHandler, BlockHandlerRegistry, type BlockRenderOptions, type BoxBlockData, type BoxFloat, type BoxOpAttributes, type BoxOverflow, BrowserDOMAdapter, type CellAlign, type CellData, type CellHorizontalAlign, type CellVerticalAlign, type ColumnsBlockData, type DOMAdapter, type DOMDocument, type DOMDocumentFragment, type DOMElement, type DOMNode, type DOMNodeList, type DeltaToHtmlOptions, type DeltaToMarkdownOptions, type DocumentPresentation, type EmbedIsolationOptions, type FootnotesBlockData, type Format, type FormatDefinition, type FormatMatchResult, type FormatRenderContext, type FormatScope, type HtmlToDeltaOptions, LINE_HEIGHT_BLOCK_TAGS, type ListType, type MarkdownToDeltaOptions, NODE_TYPE, NodeDOMAdapter, PARAGRAPH_SPACING_BLOCK_TAGS, Registry, type ResolvedDocumentPresentation, type ResolvedTablePresentation, SCRIDER_LINE_HEIGHT_KEY, SCRIDER_MARGIN_AFTER_KEY, SCRIDER_MARGIN_BEFORE_KEY, type SanitizeOptions, type TableBlockData, type TableCellAlign, type TableCellCoords, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockMarginAfterStyleParts, blockMarginBeforeStyleParts, blockParagraphMarginStyleParts, blockPresentationStyleParts, blockquoteFormat, boldFormat, boxBlockHandler, browserAdapter, cloneDelta, codeBlockFormat, codeFormat, codeWidgetFormat, collectAdjacentTableLines, colorFormat, columnsBlockHandler, createDefaultBlockHandlers, createDefaultRegistry, defaultBlockFormats, defaultEmbedFormats, defaultFormats, defaultInlineFormats, deltaToHtml, deltaToMarkdown, dividerFormat, documentPresentationStyleParts, escapeHtml, extractBoxOpAttributes, extractTableRegion, fontFormat, footnoteRefFormat, footnotesBlockHandler, formulaFormat, getAdapter, getNamedColors, headerFormat, headerIdFormat, htmlToDelta, imageFormat, indentFormat, isAdapterAvailable, isAdjacentSimpleTableGridBoundary, isElement, isRemarkAvailable, isTableNewlineOp, isTextNode, isValidColor, isValidHexColor, isZebraBodyRow, italicFormat, kbdFormat, linkFormat, listFormat, markFormat, markdownToDelta, markdownToDeltaSync, nodeAdapter, normalizeDelta, parseScriderLineHeightMultiplier, parseScriderMarginAfterEm, parseScriderMarginBeforeEm, parseScriderMarginEm, preloadRemark, resolveDocumentPresentation, resolveTablePresentation, sanitizeDelta, sizeFormat, slugify, slugifyWithDedup, softBreakFormat, strikeFormat, subscriptFormat, superscriptFormat, tableBlockHandler, tableCellCoordsFromAttributes, tableCellCoordsFromOp, tableColAlignFormat, tableColFormat, tableHeaderFormat, tableRowFormat, toCodeWidgetEmbedUrl, toHexColor, underlineFormat, unescapeHtml, validateDelta, videoFormat };