@scrider/formatter 1.10.0 → 1.10.3

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
@@ -2,13 +2,55 @@ import { AttributeMap, Op, Delta, InsertOp } from '@scrider/delta';
2
2
  export * from '@scrider/delta';
3
3
  export { InsertOp as ContentOp } from '@scrider/delta';
4
4
 
5
+ /**
6
+ * Simple Table HTML presentation options for deltaToHtml (clipboard, export).
7
+ * Structural data stays in Delta (table-row, table-col-align); this only affects inline styles.
8
+ */
9
+ /** Column/cell horizontal alignment (GFM subset). */
10
+ type TableCellAlign = 'left' | 'center' | 'right';
11
+ /** Optional styling when serializing Simple Tables to HTML. */
12
+ interface TablePresentation {
13
+ /** Full 1px border on all cell sides. When true, `line` is ignored. */
14
+ grid?: boolean;
15
+ /** Bottom border only (DeepSeek / ChatGPT). Used when `grid` is not true. */
16
+ line?: boolean;
17
+ /** Border color as explicit hex (e.g. `#e7e7e7`). */
18
+ borderColor?: string;
19
+ /** Background on header cells (`th`). */
20
+ headerShade?: boolean;
21
+ /** Background on even table rows in the body (see `isZebraBodyRow`). */
22
+ zebraRows?: boolean;
23
+ /** `font-weight: bold` on `th`. */
24
+ headerBold?: boolean;
25
+ /** `text-align: center` on `th` (GitHub-style header). */
26
+ headerCenter?: boolean;
27
+ /**
28
+ * Alignment for cells without `table-col-align` in Delta. Never overrides GFM column align.
29
+ * @default 'left'
30
+ */
31
+ defaultCellAlign?: TableCellAlign;
32
+ }
33
+ interface ResolvedTablePresentation {
34
+ grid: boolean;
35
+ line: boolean;
36
+ borderColor: string;
37
+ headerShade: boolean;
38
+ zebraRows: boolean;
39
+ headerBold: boolean;
40
+ headerCenter: boolean;
41
+ defaultCellAlign: TableCellAlign;
42
+ }
43
+ declare function resolveTablePresentation(presentation?: TablePresentation): ResolvedTablePresentation;
44
+ /** Match CSS `tr:nth-child(even) td` when header rows precede body in `<table>`. */
45
+ declare function isZebraBodyRow(headerRowCount: number, bodyRowIndex: number): boolean;
46
+
5
47
  /**
6
48
  * Document-level metadata (Scrider format extension).
7
49
  *
8
50
  * Concrete schema for the opaque `scrider-metadata` sibling field defined in
9
51
  * `@scrider/delta` (`ScriderDocument`). It carries document-wide defaults ONCE
10
- * (line spacing, paragraph spacing, indent, heading policy, fonts) instead of
11
- * duplicating them as block attributes on every `\n`.
52
+ * (line spacing, paragraph spacing, indent, heading policy, fonts, table
53
+ * presentation) instead of duplicating them as block attributes on every `\n`.
12
54
  *
13
55
  * Layering:
14
56
  * - `@scrider/delta` treats the value as opaque `Record<string, unknown>` — it
@@ -18,11 +60,15 @@ export { InsertOp as ContentOp } from '@scrider/delta';
18
60
  * export projection).
19
61
  *
20
62
  * All fields are optional and additive: extending the interface never changes the
21
- * op-stream and is backward compatible. Presentation-relevant fields are projected
22
- * to HTML via {@link documentMetadataToPresentation}; heading/font policy is applied
23
- * by upstream layers (CSS vars, bake) and is intentionally NOT part of the inline
24
- * export projection.
63
+ * op-stream and is backward compatible.
64
+ *
65
+ * Projection:
66
+ * - Spacing / indent → {@link documentMetadataToPresentation} (paragraph CSS).
67
+ * - Heading policy → {@link resolveHeadingPolicy} / heading block styles on `h1`–`h6`.
68
+ * - `tablePresentation` → same shape as `DeltaToHtmlOptions.tablePresentation`
69
+ * (used when the explicit option is omitted).
25
70
  */
71
+
26
72
  interface ScriderDocumentMetadata {
27
73
  /** Line spacing multiplier, e.g. `1.5`. */
28
74
  lineSpacing?: number;
@@ -34,16 +80,35 @@ interface ScriderDocumentMetadata {
34
80
  textIndentCm?: number;
35
81
  /** Extra left indent in cm on top-level `<ul>`/`<ol>` (shifts marker + text). */
36
82
  listBlockIndentCm?: number;
37
- /** Document heading horizontal alignment policy. */
83
+ /** Document heading horizontal alignment policy. Presence = policy on. */
38
84
  headingAlign?: 'left' | 'center' | 'right';
39
- /** Document heading bold policy. */
85
+ /** Document heading bold policy. `true` = force bold on `h1`–`h6`. */
40
86
  headingBold?: boolean;
41
- /** Named heading size-grid preset id (schema defined upstream). */
87
+ /**
88
+ * Named heading size-grid preset id (`scrider` | `google` | `word` | `browser` | `githubEm`).
89
+ * Ignored when {@link headingAuto} is true.
90
+ */
42
91
  headingSizeGridPreset?: string;
92
+ /**
93
+ * When true, headings use browser/CSS natural size (no size-grid projection).
94
+ * Mutually exclusive with {@link headingSizeGridPreset} in Settings UI.
95
+ */
96
+ headingAuto?: boolean;
97
+ /**
98
+ * Heading decoration preset (`none` | `scrider` | `github`).
99
+ * Editor: `data-scrider-heading-decoration`. Export: PDF/HTML vertical rhythm + rules.
100
+ */
101
+ headingDecoration?: 'none' | 'scrider' | 'github';
43
102
  /** Default document font family (bare family name, e.g. `Georgia`). */
44
103
  defaultFont?: string;
45
104
  /** Default document font size as a CSS length, e.g. `12pt`. */
46
105
  defaultFontSize?: string;
106
+ /**
107
+ * Simple / view table chrome (borders, header shade, zebra). Same shape as
108
+ * `DeltaToHtmlOptions.tablePresentation`. Persisted with the document so export
109
+ * matches Settings without a separate channel.
110
+ */
111
+ tablePresentation?: TablePresentation;
47
112
  }
48
113
 
49
114
  /**
@@ -1504,13 +1569,12 @@ interface ResolvedDocumentPresentation {
1504
1569
  declare function resolveDocumentPresentation(presentation?: DocumentPresentation): ResolvedDocumentPresentation | undefined;
1505
1570
  /**
1506
1571
  * Project {@link ScriderDocumentMetadata} onto an HTML {@link DocumentPresentation}
1507
- * (export / clipboard inline CSS).
1572
+ * (export / clipboard inline CSS for paragraphs/lists).
1508
1573
  *
1509
- * Only presentation-relevant fields are mapped (line/paragraph spacing, indent).
1510
- * Heading policy (align/bold/size grid) and fonts are applied by upstream layers
1511
- * (CSS vars in the editor, bake into block/inline attrs) and are deliberately not
1512
- * part of the inline projection. Returns `undefined` when nothing maps, so callers
1513
- * can fall back cleanly.
1574
+ * Maps line/paragraph spacing and indent only. Heading policy is projected
1575
+ * separately via {@link resolveHeadingPolicy} / {@link headingPolicyStyleParts}
1576
+ * onto `h1`–`h6`. `tablePresentation` is read from metadata in `deltaToHtml`
1577
+ * when the explicit option is omitted. Returns `undefined` when nothing maps.
1514
1578
  */
1515
1579
  declare function documentMetadataToPresentation(metadata: ScriderDocumentMetadata | undefined): DocumentPresentation | undefined;
1516
1580
  /**
@@ -1532,46 +1596,32 @@ declare function documentPresentationStyleParts(tag: string, resolved: ResolvedD
1532
1596
  declare function blockPresentationStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
1533
1597
 
1534
1598
  /**
1535
- * Simple Table HTML presentation options for deltaToHtml (clipboard, export).
1536
- * Structural data stays in Delta (table-row, table-col-align); this only affects inline styles.
1599
+ * Document-level heading policy projected to export HTML (`h1`–`h6` inline CSS).
1600
+ *
1601
+ * Editor applies the same policy via CSS vars (`--scrider-heading-*`, `--scrider-hN-size`).
1602
+ * Size maps mirror `editor-core` `HEADER_SIZE_PRESETS` — keep in sync.
1537
1603
  */
1538
- /** Column/cell horizontal alignment (GFM subset). */
1539
- type TableCellAlign = 'left' | 'center' | 'right';
1540
- /** Optional styling when serializing Simple Tables to HTML. */
1541
- interface TablePresentation {
1542
- /** Full 1px border on all cell sides. When true, `line` is ignored. */
1543
- grid?: boolean;
1544
- /** Bottom border only (DeepSeek / ChatGPT). Used when `grid` is not true. */
1545
- line?: boolean;
1546
- /** Border color as explicit hex (e.g. `#e7e7e7`). */
1547
- borderColor?: string;
1548
- /** Background on header cells (`th`). */
1549
- headerShade?: boolean;
1550
- /** Background on even table rows in the body (see `isZebraBodyRow`). */
1551
- zebraRows?: boolean;
1552
- /** `font-weight: bold` on `th`. */
1553
- headerBold?: boolean;
1554
- /** `text-align: center` on `th` (GitHub-style header). */
1555
- headerCenter?: boolean;
1556
- /**
1557
- * Alignment for cells without `table-col-align` in Delta. Never overrides GFM column align.
1558
- * @default 'left'
1559
- */
1560
- defaultCellAlign?: TableCellAlign;
1561
- }
1562
- interface ResolvedTablePresentation {
1563
- grid: boolean;
1564
- line: boolean;
1565
- borderColor: string;
1566
- headerShade: boolean;
1567
- zebraRows: boolean;
1568
- headerBold: boolean;
1569
- headerCenter: boolean;
1570
- defaultCellAlign: TableCellAlign;
1604
+
1605
+ type HeaderLevel = 1 | 2 | 3 | 4 | 5 | 6;
1606
+ type HeaderSizeMap = Readonly<Record<HeaderLevel, string>>;
1607
+ type HeaderSizePresetName = 'scrider' | 'google' | 'word' | 'browser' | 'githubEm';
1608
+ /** Keep in sync with `@scrider/editor-core` `HEADER_SIZE_PRESETS`. */
1609
+ declare const HEADER_SIZE_PRESETS: Readonly<Record<HeaderSizePresetName, HeaderSizeMap>>;
1610
+ interface ResolvedHeadingPolicy {
1611
+ align: 'left' | 'center' | 'right' | undefined;
1612
+ bold: boolean;
1613
+ /** When set and `auto` is false, emit font-size on `hN` when Delta has no inline size. */
1614
+ sizePreset: HeaderSizePresetName | undefined;
1615
+ auto: boolean;
1571
1616
  }
1572
- declare function resolveTablePresentation(presentation?: TablePresentation): ResolvedTablePresentation;
1573
- /** Match CSS `tr:nth-child(even) td` when header rows precede body in `<table>`. */
1574
- declare function isZebraBodyRow(headerRowCount: number, bodyRowIndex: number): boolean;
1617
+ declare function resolveHeadingPolicy(metadata: ScriderDocumentMetadata | undefined): ResolvedHeadingPolicy | undefined;
1618
+ /**
1619
+ * Inline styles for a heading block from document metadata.
1620
+ * Baked Delta attrs win: `align` on `\n` skips metadata align; presence of any
1621
+ * text with explicit `size` is not detectable at block level — size from preset
1622
+ * is always emitted when policy is on (matches editor CSS vars on `hN`).
1623
+ */
1624
+ declare function headingPolicyStyleParts(tag: string, blockAttributes: AttributeMap | undefined, policy: ResolvedHeadingPolicy | undefined): string[];
1575
1625
 
1576
1626
  /**
1577
1627
  * Delta → HTML Conversion
@@ -1645,10 +1695,12 @@ interface DeltaToHtmlOptions {
1645
1695
  /**
1646
1696
  * Document-level metadata (Scrider format extension, `scrider-metadata`).
1647
1697
  *
1648
- * When {@link documentPresentation} is not provided, the presentation-relevant
1649
- * fields of this metadata are projected to inline CSS via
1650
- * `documentMetadataToPresentation` (export/clipboard). An explicit
1651
- * `documentPresentation` always takes precedence. Does not change Delta.
1698
+ * When {@link documentPresentation} is not provided, spacing/indent fields are
1699
+ * projected via `documentMetadataToPresentation`. Heading policy
1700
+ * (`headingAlign` / `headingBold` / `headingSizeGridPreset` / `headingAuto`)
1701
+ * is projected onto `h1`–`h6`. When {@link tablePresentation} is omitted,
1702
+ * `metadata.tablePresentation` is used. An explicit `documentPresentation` /
1703
+ * `tablePresentation` always takes precedence. Does not change Delta.
1652
1704
  */
1653
1705
  documentMetadata?: ScriderDocumentMetadata;
1654
1706
  /**
@@ -2204,4 +2256,4 @@ declare function collectAdjacentTableLines<T extends {
2204
2256
  */
2205
2257
  declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
2206
2258
 
2207
- 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 RenderProfile, type ResolvedDocumentPresentation, type ResolvedTablePresentation, SCRIDER_LINE_HEIGHT_KEY, SCRIDER_MARGIN_AFTER_KEY, SCRIDER_MARGIN_BEFORE_KEY, SCRIDER_TEXT_INDENT_KEY, type SanitizeOptions, type ScriderDocumentMetadata, TEXT_INDENT_BLOCK_TAGS, type TableBlockData, type TableBlockFloat, type TableCellAlign, type TableCellCoords, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockMarginAfterStyleParts, blockMarginBeforeStyleParts, blockParagraphMarginStyleParts, blockPresentationStyleParts, blockTextIndentStyleParts, blockquoteFormat, boldFormat, boxBlockHandler, browserAdapter, cloneDelta, codeBlockFormat, codeFormat, codeWidgetFormat, collectAdjacentTableLines, colorFormat, columnsBlockHandler, createDefaultBlockHandlers, createDefaultRegistry, defaultBlockFormats, defaultEmbedFormats, defaultFormats, defaultInlineFormats, deltaToDom, deltaToHtml, deltaToMarkdown, dividerFormat, documentMetadataToPresentation, 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, renderDelta, resolveDocumentPresentation, resolveTablePresentation, sanitizeDelta, sizeFormat, slugify, slugifyWithDedup, softBreakFormat, strikeFormat, subscriptFormat, superscriptFormat, tableBlockHandler, tableCellCoordsFromAttributes, tableCellCoordsFromOp, tableColAlignFormat, tableColFormat, tableHeaderFormat, tableRowFormat, toCodeWidgetEmbedUrl, toHexColor, underlineFormat, unescapeHtml, validateDelta, videoFormat };
2259
+ 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, HEADER_SIZE_PRESETS, type HtmlToDeltaOptions, LINE_HEIGHT_BLOCK_TAGS, type ListType, type MarkdownToDeltaOptions, NODE_TYPE, NodeDOMAdapter, PARAGRAPH_SPACING_BLOCK_TAGS, Registry, type RenderProfile, type ResolvedDocumentPresentation, type ResolvedTablePresentation, SCRIDER_LINE_HEIGHT_KEY, SCRIDER_MARGIN_AFTER_KEY, SCRIDER_MARGIN_BEFORE_KEY, SCRIDER_TEXT_INDENT_KEY, type SanitizeOptions, type ScriderDocumentMetadata, TEXT_INDENT_BLOCK_TAGS, type TableBlockData, type TableBlockFloat, type TableCellAlign, type TableCellCoords, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockMarginAfterStyleParts, blockMarginBeforeStyleParts, blockParagraphMarginStyleParts, blockPresentationStyleParts, blockTextIndentStyleParts, blockquoteFormat, boldFormat, boxBlockHandler, browserAdapter, cloneDelta, codeBlockFormat, codeFormat, codeWidgetFormat, collectAdjacentTableLines, colorFormat, columnsBlockHandler, createDefaultBlockHandlers, createDefaultRegistry, defaultBlockFormats, defaultEmbedFormats, defaultFormats, defaultInlineFormats, deltaToDom, deltaToHtml, deltaToMarkdown, dividerFormat, documentMetadataToPresentation, documentPresentationStyleParts, escapeHtml, extractBoxOpAttributes, extractTableRegion, fontFormat, footnoteRefFormat, footnotesBlockHandler, formulaFormat, getAdapter, getNamedColors, headerFormat, headerIdFormat, headingPolicyStyleParts, 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, renderDelta, resolveDocumentPresentation, resolveHeadingPolicy, 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
@@ -2,13 +2,55 @@ import { AttributeMap, Op, Delta, InsertOp } from '@scrider/delta';
2
2
  export * from '@scrider/delta';
3
3
  export { InsertOp as ContentOp } from '@scrider/delta';
4
4
 
5
+ /**
6
+ * Simple Table HTML presentation options for deltaToHtml (clipboard, export).
7
+ * Structural data stays in Delta (table-row, table-col-align); this only affects inline styles.
8
+ */
9
+ /** Column/cell horizontal alignment (GFM subset). */
10
+ type TableCellAlign = 'left' | 'center' | 'right';
11
+ /** Optional styling when serializing Simple Tables to HTML. */
12
+ interface TablePresentation {
13
+ /** Full 1px border on all cell sides. When true, `line` is ignored. */
14
+ grid?: boolean;
15
+ /** Bottom border only (DeepSeek / ChatGPT). Used when `grid` is not true. */
16
+ line?: boolean;
17
+ /** Border color as explicit hex (e.g. `#e7e7e7`). */
18
+ borderColor?: string;
19
+ /** Background on header cells (`th`). */
20
+ headerShade?: boolean;
21
+ /** Background on even table rows in the body (see `isZebraBodyRow`). */
22
+ zebraRows?: boolean;
23
+ /** `font-weight: bold` on `th`. */
24
+ headerBold?: boolean;
25
+ /** `text-align: center` on `th` (GitHub-style header). */
26
+ headerCenter?: boolean;
27
+ /**
28
+ * Alignment for cells without `table-col-align` in Delta. Never overrides GFM column align.
29
+ * @default 'left'
30
+ */
31
+ defaultCellAlign?: TableCellAlign;
32
+ }
33
+ interface ResolvedTablePresentation {
34
+ grid: boolean;
35
+ line: boolean;
36
+ borderColor: string;
37
+ headerShade: boolean;
38
+ zebraRows: boolean;
39
+ headerBold: boolean;
40
+ headerCenter: boolean;
41
+ defaultCellAlign: TableCellAlign;
42
+ }
43
+ declare function resolveTablePresentation(presentation?: TablePresentation): ResolvedTablePresentation;
44
+ /** Match CSS `tr:nth-child(even) td` when header rows precede body in `<table>`. */
45
+ declare function isZebraBodyRow(headerRowCount: number, bodyRowIndex: number): boolean;
46
+
5
47
  /**
6
48
  * Document-level metadata (Scrider format extension).
7
49
  *
8
50
  * Concrete schema for the opaque `scrider-metadata` sibling field defined in
9
51
  * `@scrider/delta` (`ScriderDocument`). It carries document-wide defaults ONCE
10
- * (line spacing, paragraph spacing, indent, heading policy, fonts) instead of
11
- * duplicating them as block attributes on every `\n`.
52
+ * (line spacing, paragraph spacing, indent, heading policy, fonts, table
53
+ * presentation) instead of duplicating them as block attributes on every `\n`.
12
54
  *
13
55
  * Layering:
14
56
  * - `@scrider/delta` treats the value as opaque `Record<string, unknown>` — it
@@ -18,11 +60,15 @@ export { InsertOp as ContentOp } from '@scrider/delta';
18
60
  * export projection).
19
61
  *
20
62
  * All fields are optional and additive: extending the interface never changes the
21
- * op-stream and is backward compatible. Presentation-relevant fields are projected
22
- * to HTML via {@link documentMetadataToPresentation}; heading/font policy is applied
23
- * by upstream layers (CSS vars, bake) and is intentionally NOT part of the inline
24
- * export projection.
63
+ * op-stream and is backward compatible.
64
+ *
65
+ * Projection:
66
+ * - Spacing / indent → {@link documentMetadataToPresentation} (paragraph CSS).
67
+ * - Heading policy → {@link resolveHeadingPolicy} / heading block styles on `h1`–`h6`.
68
+ * - `tablePresentation` → same shape as `DeltaToHtmlOptions.tablePresentation`
69
+ * (used when the explicit option is omitted).
25
70
  */
71
+
26
72
  interface ScriderDocumentMetadata {
27
73
  /** Line spacing multiplier, e.g. `1.5`. */
28
74
  lineSpacing?: number;
@@ -34,16 +80,35 @@ interface ScriderDocumentMetadata {
34
80
  textIndentCm?: number;
35
81
  /** Extra left indent in cm on top-level `<ul>`/`<ol>` (shifts marker + text). */
36
82
  listBlockIndentCm?: number;
37
- /** Document heading horizontal alignment policy. */
83
+ /** Document heading horizontal alignment policy. Presence = policy on. */
38
84
  headingAlign?: 'left' | 'center' | 'right';
39
- /** Document heading bold policy. */
85
+ /** Document heading bold policy. `true` = force bold on `h1`–`h6`. */
40
86
  headingBold?: boolean;
41
- /** Named heading size-grid preset id (schema defined upstream). */
87
+ /**
88
+ * Named heading size-grid preset id (`scrider` | `google` | `word` | `browser` | `githubEm`).
89
+ * Ignored when {@link headingAuto} is true.
90
+ */
42
91
  headingSizeGridPreset?: string;
92
+ /**
93
+ * When true, headings use browser/CSS natural size (no size-grid projection).
94
+ * Mutually exclusive with {@link headingSizeGridPreset} in Settings UI.
95
+ */
96
+ headingAuto?: boolean;
97
+ /**
98
+ * Heading decoration preset (`none` | `scrider` | `github`).
99
+ * Editor: `data-scrider-heading-decoration`. Export: PDF/HTML vertical rhythm + rules.
100
+ */
101
+ headingDecoration?: 'none' | 'scrider' | 'github';
43
102
  /** Default document font family (bare family name, e.g. `Georgia`). */
44
103
  defaultFont?: string;
45
104
  /** Default document font size as a CSS length, e.g. `12pt`. */
46
105
  defaultFontSize?: string;
106
+ /**
107
+ * Simple / view table chrome (borders, header shade, zebra). Same shape as
108
+ * `DeltaToHtmlOptions.tablePresentation`. Persisted with the document so export
109
+ * matches Settings without a separate channel.
110
+ */
111
+ tablePresentation?: TablePresentation;
47
112
  }
48
113
 
49
114
  /**
@@ -1504,13 +1569,12 @@ interface ResolvedDocumentPresentation {
1504
1569
  declare function resolveDocumentPresentation(presentation?: DocumentPresentation): ResolvedDocumentPresentation | undefined;
1505
1570
  /**
1506
1571
  * Project {@link ScriderDocumentMetadata} onto an HTML {@link DocumentPresentation}
1507
- * (export / clipboard inline CSS).
1572
+ * (export / clipboard inline CSS for paragraphs/lists).
1508
1573
  *
1509
- * Only presentation-relevant fields are mapped (line/paragraph spacing, indent).
1510
- * Heading policy (align/bold/size grid) and fonts are applied by upstream layers
1511
- * (CSS vars in the editor, bake into block/inline attrs) and are deliberately not
1512
- * part of the inline projection. Returns `undefined` when nothing maps, so callers
1513
- * can fall back cleanly.
1574
+ * Maps line/paragraph spacing and indent only. Heading policy is projected
1575
+ * separately via {@link resolveHeadingPolicy} / {@link headingPolicyStyleParts}
1576
+ * onto `h1`–`h6`. `tablePresentation` is read from metadata in `deltaToHtml`
1577
+ * when the explicit option is omitted. Returns `undefined` when nothing maps.
1514
1578
  */
1515
1579
  declare function documentMetadataToPresentation(metadata: ScriderDocumentMetadata | undefined): DocumentPresentation | undefined;
1516
1580
  /**
@@ -1532,46 +1596,32 @@ declare function documentPresentationStyleParts(tag: string, resolved: ResolvedD
1532
1596
  declare function blockPresentationStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
1533
1597
 
1534
1598
  /**
1535
- * Simple Table HTML presentation options for deltaToHtml (clipboard, export).
1536
- * Structural data stays in Delta (table-row, table-col-align); this only affects inline styles.
1599
+ * Document-level heading policy projected to export HTML (`h1`–`h6` inline CSS).
1600
+ *
1601
+ * Editor applies the same policy via CSS vars (`--scrider-heading-*`, `--scrider-hN-size`).
1602
+ * Size maps mirror `editor-core` `HEADER_SIZE_PRESETS` — keep in sync.
1537
1603
  */
1538
- /** Column/cell horizontal alignment (GFM subset). */
1539
- type TableCellAlign = 'left' | 'center' | 'right';
1540
- /** Optional styling when serializing Simple Tables to HTML. */
1541
- interface TablePresentation {
1542
- /** Full 1px border on all cell sides. When true, `line` is ignored. */
1543
- grid?: boolean;
1544
- /** Bottom border only (DeepSeek / ChatGPT). Used when `grid` is not true. */
1545
- line?: boolean;
1546
- /** Border color as explicit hex (e.g. `#e7e7e7`). */
1547
- borderColor?: string;
1548
- /** Background on header cells (`th`). */
1549
- headerShade?: boolean;
1550
- /** Background on even table rows in the body (see `isZebraBodyRow`). */
1551
- zebraRows?: boolean;
1552
- /** `font-weight: bold` on `th`. */
1553
- headerBold?: boolean;
1554
- /** `text-align: center` on `th` (GitHub-style header). */
1555
- headerCenter?: boolean;
1556
- /**
1557
- * Alignment for cells without `table-col-align` in Delta. Never overrides GFM column align.
1558
- * @default 'left'
1559
- */
1560
- defaultCellAlign?: TableCellAlign;
1561
- }
1562
- interface ResolvedTablePresentation {
1563
- grid: boolean;
1564
- line: boolean;
1565
- borderColor: string;
1566
- headerShade: boolean;
1567
- zebraRows: boolean;
1568
- headerBold: boolean;
1569
- headerCenter: boolean;
1570
- defaultCellAlign: TableCellAlign;
1604
+
1605
+ type HeaderLevel = 1 | 2 | 3 | 4 | 5 | 6;
1606
+ type HeaderSizeMap = Readonly<Record<HeaderLevel, string>>;
1607
+ type HeaderSizePresetName = 'scrider' | 'google' | 'word' | 'browser' | 'githubEm';
1608
+ /** Keep in sync with `@scrider/editor-core` `HEADER_SIZE_PRESETS`. */
1609
+ declare const HEADER_SIZE_PRESETS: Readonly<Record<HeaderSizePresetName, HeaderSizeMap>>;
1610
+ interface ResolvedHeadingPolicy {
1611
+ align: 'left' | 'center' | 'right' | undefined;
1612
+ bold: boolean;
1613
+ /** When set and `auto` is false, emit font-size on `hN` when Delta has no inline size. */
1614
+ sizePreset: HeaderSizePresetName | undefined;
1615
+ auto: boolean;
1571
1616
  }
1572
- declare function resolveTablePresentation(presentation?: TablePresentation): ResolvedTablePresentation;
1573
- /** Match CSS `tr:nth-child(even) td` when header rows precede body in `<table>`. */
1574
- declare function isZebraBodyRow(headerRowCount: number, bodyRowIndex: number): boolean;
1617
+ declare function resolveHeadingPolicy(metadata: ScriderDocumentMetadata | undefined): ResolvedHeadingPolicy | undefined;
1618
+ /**
1619
+ * Inline styles for a heading block from document metadata.
1620
+ * Baked Delta attrs win: `align` on `\n` skips metadata align; presence of any
1621
+ * text with explicit `size` is not detectable at block level — size from preset
1622
+ * is always emitted when policy is on (matches editor CSS vars on `hN`).
1623
+ */
1624
+ declare function headingPolicyStyleParts(tag: string, blockAttributes: AttributeMap | undefined, policy: ResolvedHeadingPolicy | undefined): string[];
1575
1625
 
1576
1626
  /**
1577
1627
  * Delta → HTML Conversion
@@ -1645,10 +1695,12 @@ interface DeltaToHtmlOptions {
1645
1695
  /**
1646
1696
  * Document-level metadata (Scrider format extension, `scrider-metadata`).
1647
1697
  *
1648
- * When {@link documentPresentation} is not provided, the presentation-relevant
1649
- * fields of this metadata are projected to inline CSS via
1650
- * `documentMetadataToPresentation` (export/clipboard). An explicit
1651
- * `documentPresentation` always takes precedence. Does not change Delta.
1698
+ * When {@link documentPresentation} is not provided, spacing/indent fields are
1699
+ * projected via `documentMetadataToPresentation`. Heading policy
1700
+ * (`headingAlign` / `headingBold` / `headingSizeGridPreset` / `headingAuto`)
1701
+ * is projected onto `h1`–`h6`. When {@link tablePresentation} is omitted,
1702
+ * `metadata.tablePresentation` is used. An explicit `documentPresentation` /
1703
+ * `tablePresentation` always takes precedence. Does not change Delta.
1652
1704
  */
1653
1705
  documentMetadata?: ScriderDocumentMetadata;
1654
1706
  /**
@@ -2204,4 +2256,4 @@ declare function collectAdjacentTableLines<T extends {
2204
2256
  */
2205
2257
  declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
2206
2258
 
2207
- 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 RenderProfile, type ResolvedDocumentPresentation, type ResolvedTablePresentation, SCRIDER_LINE_HEIGHT_KEY, SCRIDER_MARGIN_AFTER_KEY, SCRIDER_MARGIN_BEFORE_KEY, SCRIDER_TEXT_INDENT_KEY, type SanitizeOptions, type ScriderDocumentMetadata, TEXT_INDENT_BLOCK_TAGS, type TableBlockData, type TableBlockFloat, type TableCellAlign, type TableCellCoords, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockMarginAfterStyleParts, blockMarginBeforeStyleParts, blockParagraphMarginStyleParts, blockPresentationStyleParts, blockTextIndentStyleParts, blockquoteFormat, boldFormat, boxBlockHandler, browserAdapter, cloneDelta, codeBlockFormat, codeFormat, codeWidgetFormat, collectAdjacentTableLines, colorFormat, columnsBlockHandler, createDefaultBlockHandlers, createDefaultRegistry, defaultBlockFormats, defaultEmbedFormats, defaultFormats, defaultInlineFormats, deltaToDom, deltaToHtml, deltaToMarkdown, dividerFormat, documentMetadataToPresentation, 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, renderDelta, resolveDocumentPresentation, resolveTablePresentation, sanitizeDelta, sizeFormat, slugify, slugifyWithDedup, softBreakFormat, strikeFormat, subscriptFormat, superscriptFormat, tableBlockHandler, tableCellCoordsFromAttributes, tableCellCoordsFromOp, tableColAlignFormat, tableColFormat, tableHeaderFormat, tableRowFormat, toCodeWidgetEmbedUrl, toHexColor, underlineFormat, unescapeHtml, validateDelta, videoFormat };
2259
+ 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, HEADER_SIZE_PRESETS, type HtmlToDeltaOptions, LINE_HEIGHT_BLOCK_TAGS, type ListType, type MarkdownToDeltaOptions, NODE_TYPE, NodeDOMAdapter, PARAGRAPH_SPACING_BLOCK_TAGS, Registry, type RenderProfile, type ResolvedDocumentPresentation, type ResolvedTablePresentation, SCRIDER_LINE_HEIGHT_KEY, SCRIDER_MARGIN_AFTER_KEY, SCRIDER_MARGIN_BEFORE_KEY, SCRIDER_TEXT_INDENT_KEY, type SanitizeOptions, type ScriderDocumentMetadata, TEXT_INDENT_BLOCK_TAGS, type TableBlockData, type TableBlockFloat, type TableCellAlign, type TableCellCoords, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockMarginAfterStyleParts, blockMarginBeforeStyleParts, blockParagraphMarginStyleParts, blockPresentationStyleParts, blockTextIndentStyleParts, blockquoteFormat, boldFormat, boxBlockHandler, browserAdapter, cloneDelta, codeBlockFormat, codeFormat, codeWidgetFormat, collectAdjacentTableLines, colorFormat, columnsBlockHandler, createDefaultBlockHandlers, createDefaultRegistry, defaultBlockFormats, defaultEmbedFormats, defaultFormats, defaultInlineFormats, deltaToDom, deltaToHtml, deltaToMarkdown, dividerFormat, documentMetadataToPresentation, documentPresentationStyleParts, escapeHtml, extractBoxOpAttributes, extractTableRegion, fontFormat, footnoteRefFormat, footnotesBlockHandler, formulaFormat, getAdapter, getNamedColors, headerFormat, headerIdFormat, headingPolicyStyleParts, 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, renderDelta, resolveDocumentPresentation, resolveHeadingPolicy, resolveTablePresentation, sanitizeDelta, sizeFormat, slugify, slugifyWithDedup, softBreakFormat, strikeFormat, subscriptFormat, superscriptFormat, tableBlockHandler, tableCellCoordsFromAttributes, tableCellCoordsFromOp, tableColAlignFormat, tableColFormat, tableHeaderFormat, tableRowFormat, toCodeWidgetEmbedUrl, toHexColor, underlineFormat, unescapeHtml, validateDelta, videoFormat };