@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.cjs +117 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -58
- package/dist/index.d.ts +110 -58
- package/dist/index.js +114 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
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.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
1510
|
-
*
|
|
1511
|
-
*
|
|
1512
|
-
*
|
|
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
|
-
*
|
|
1536
|
-
*
|
|
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
|
-
|
|
1539
|
-
type
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
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
|
|
1573
|
-
/**
|
|
1574
|
-
|
|
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,
|
|
1649
|
-
*
|
|
1650
|
-
* `
|
|
1651
|
-
*
|
|
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
|
|
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.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
1510
|
-
*
|
|
1511
|
-
*
|
|
1512
|
-
*
|
|
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
|
-
*
|
|
1536
|
-
*
|
|
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
|
-
|
|
1539
|
-
type
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
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
|
|
1573
|
-
/**
|
|
1574
|
-
|
|
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,
|
|
1649
|
-
*
|
|
1650
|
-
* `
|
|
1651
|
-
*
|
|
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 };
|