@scrider/formatter 1.9.1 → 1.10.1
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 +44 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -2
- package/dist/index.d.ts +55 -2
- package/dist/index.js +39 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1427,8 +1427,12 @@ declare const SCRIDER_LINE_HEIGHT_KEY = "scrider-line-height";
|
|
|
1427
1427
|
declare const SCRIDER_MARGIN_AFTER_KEY = "scrider-margin-after";
|
|
1428
1428
|
/** Space before plain paragraph (`margin-top`) on `\n` (Settings Apply). */
|
|
1429
1429
|
declare const SCRIDER_MARGIN_BEFORE_KEY = "scrider-margin-before";
|
|
1430
|
+
/** Per-paragraph first-line indent stored on `\n` (Word paste, Settings Apply). */
|
|
1431
|
+
declare const SCRIDER_TEXT_INDENT_KEY = "scrider-text-indent";
|
|
1430
1432
|
/** Block tags that receive line spacing (not headings). */
|
|
1431
1433
|
declare const LINE_HEIGHT_BLOCK_TAGS: Set<string>;
|
|
1434
|
+
/** Block tags that receive first-line indent (plain `<p>` only). */
|
|
1435
|
+
declare const TEXT_INDENT_BLOCK_TAGS: Set<string>;
|
|
1432
1436
|
/** Block tags that receive paragraph spacing after (plain `<p>` only). */
|
|
1433
1437
|
declare const PARAGRAPH_SPACING_BLOCK_TAGS: Set<string>;
|
|
1434
1438
|
/**
|
|
@@ -1440,6 +1444,14 @@ declare function parseScriderLineHeightMultiplier(value: string): number | undef
|
|
|
1440
1444
|
* Line-height for a block tag: `scrider-line-height` on the line → documentPresentation → none.
|
|
1441
1445
|
*/
|
|
1442
1446
|
declare function blockLineHeightStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
|
|
1447
|
+
/**
|
|
1448
|
+
* First-line indent for a plain `<p>`: `scrider-text-indent` on the line (baked,
|
|
1449
|
+
* e.g. Word paste) → documentPresentation `textIndentCm` → none.
|
|
1450
|
+
*
|
|
1451
|
+
* The block attr wins over the document default (mirrors line-height / margin
|
|
1452
|
+
* resolution). The raw block value is a CSS length string (e.g. `1.25cm`).
|
|
1453
|
+
*/
|
|
1454
|
+
declare function blockTextIndentStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
|
|
1443
1455
|
/**
|
|
1444
1456
|
* Parse paragraph margin in em from Delta / inline CSS (`0.5em`, `0.5`).
|
|
1445
1457
|
*/
|
|
@@ -1501,10 +1513,21 @@ declare function resolveDocumentPresentation(presentation?: DocumentPresentation
|
|
|
1501
1513
|
* can fall back cleanly.
|
|
1502
1514
|
*/
|
|
1503
1515
|
declare function documentMetadataToPresentation(metadata: ScriderDocumentMetadata | undefined): DocumentPresentation | undefined;
|
|
1504
|
-
/**
|
|
1516
|
+
/**
|
|
1517
|
+
* Document-level first-line indent only (no per-block attr).
|
|
1518
|
+
*
|
|
1519
|
+
* @deprecated Superseded by {@link blockTextIndentStyleParts}, which resolves the
|
|
1520
|
+
* per-block `scrider-text-indent` attr with the document default as fallback and
|
|
1521
|
+
* is what {@link blockPresentationStyleParts} now uses. Kept exported for
|
|
1522
|
+
* backward compatibility; output is unchanged for document-only callers.
|
|
1523
|
+
*/
|
|
1505
1524
|
declare function documentPresentationStyleParts(tag: string, resolved: ResolvedDocumentPresentation | undefined): string[];
|
|
1506
1525
|
/**
|
|
1507
1526
|
* All block presentation styles for deltaToHtml: Delta attrs, then document defaults.
|
|
1527
|
+
*
|
|
1528
|
+
* First-line indent now resolves per-block: baked `scrider-text-indent` wins over
|
|
1529
|
+
* the document `textIndentCm` default (previously the per-block attr was dropped
|
|
1530
|
+
* on export). Output for document-only paragraphs is unchanged.
|
|
1508
1531
|
*/
|
|
1509
1532
|
declare function blockPresentationStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
|
|
1510
1533
|
|
|
@@ -1654,6 +1677,36 @@ interface DeltaToHtmlOptions {
|
|
|
1654
1677
|
* ```
|
|
1655
1678
|
*/
|
|
1656
1679
|
declare function deltaToHtml(delta: Delta, options?: DeltaToHtmlOptions): string;
|
|
1680
|
+
/**
|
|
1681
|
+
* Rendering profile: how a Delta is turned into markup.
|
|
1682
|
+
*
|
|
1683
|
+
* - `export`: full fidelity for clipboard / Office / HTML export. Document-level
|
|
1684
|
+
* presentation (line/paragraph spacing, first-line/list indent) and table
|
|
1685
|
+
* presentation are projected to inline CSS so the markup is self-contained.
|
|
1686
|
+
* - `editor`: markup for the editor's contenteditable surface. Document-level
|
|
1687
|
+
* presentation and table presentation are intentionally dropped — the editor
|
|
1688
|
+
* applies them live via CSS custom properties on the container, so inline
|
|
1689
|
+
* copies would double-apply and fight the Settings panel. Per-block baked
|
|
1690
|
+
* attributes (`scrider-line-height`, `scrider-margin-*`, `scrider-text-indent`)
|
|
1691
|
+
* still render, since they are part of the document content.
|
|
1692
|
+
*/
|
|
1693
|
+
type RenderProfile = 'export' | 'editor';
|
|
1694
|
+
/**
|
|
1695
|
+
* Render a Delta with an explicit {@link RenderProfile}.
|
|
1696
|
+
*
|
|
1697
|
+
* Thin dispatcher over {@link deltaToHtml} (the export core). See
|
|
1698
|
+
* {@link RenderProfile} for how the profiles differ.
|
|
1699
|
+
*/
|
|
1700
|
+
declare function renderDelta(delta: Delta, profile: RenderProfile, options?: DeltaToHtmlOptions): string;
|
|
1701
|
+
/**
|
|
1702
|
+
* Render a Delta for the editor's contenteditable surface (`editor` profile).
|
|
1703
|
+
*
|
|
1704
|
+
* Equivalent to `renderDelta(delta, 'editor', options)`. Document-level and table
|
|
1705
|
+
* presentation are dropped (applied live via CSS vars); the built-in `softBreak`
|
|
1706
|
+
* renderer already emits `<br data-scrider-embed>`, so the editor needs no
|
|
1707
|
+
* embed-renderer override.
|
|
1708
|
+
*/
|
|
1709
|
+
declare function deltaToDom(delta: Delta, options?: DeltaToHtmlOptions): string;
|
|
1657
1710
|
|
|
1658
1711
|
/**
|
|
1659
1712
|
* HTML → Delta Conversion
|
|
@@ -2151,4 +2204,4 @@ declare function collectAdjacentTableLines<T extends {
|
|
|
2151
2204
|
*/
|
|
2152
2205
|
declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
|
|
2153
2206
|
|
|
2154
|
-
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 ScriderDocumentMetadata, type TableBlockData, type TableBlockFloat, 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, 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, resolveDocumentPresentation, resolveTablePresentation, sanitizeDelta, sizeFormat, slugify, slugifyWithDedup, softBreakFormat, strikeFormat, subscriptFormat, superscriptFormat, tableBlockHandler, tableCellCoordsFromAttributes, tableCellCoordsFromOp, tableColAlignFormat, tableColFormat, tableHeaderFormat, tableRowFormat, toCodeWidgetEmbedUrl, toHexColor, underlineFormat, unescapeHtml, validateDelta, videoFormat };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1427,8 +1427,12 @@ declare const SCRIDER_LINE_HEIGHT_KEY = "scrider-line-height";
|
|
|
1427
1427
|
declare const SCRIDER_MARGIN_AFTER_KEY = "scrider-margin-after";
|
|
1428
1428
|
/** Space before plain paragraph (`margin-top`) on `\n` (Settings Apply). */
|
|
1429
1429
|
declare const SCRIDER_MARGIN_BEFORE_KEY = "scrider-margin-before";
|
|
1430
|
+
/** Per-paragraph first-line indent stored on `\n` (Word paste, Settings Apply). */
|
|
1431
|
+
declare const SCRIDER_TEXT_INDENT_KEY = "scrider-text-indent";
|
|
1430
1432
|
/** Block tags that receive line spacing (not headings). */
|
|
1431
1433
|
declare const LINE_HEIGHT_BLOCK_TAGS: Set<string>;
|
|
1434
|
+
/** Block tags that receive first-line indent (plain `<p>` only). */
|
|
1435
|
+
declare const TEXT_INDENT_BLOCK_TAGS: Set<string>;
|
|
1432
1436
|
/** Block tags that receive paragraph spacing after (plain `<p>` only). */
|
|
1433
1437
|
declare const PARAGRAPH_SPACING_BLOCK_TAGS: Set<string>;
|
|
1434
1438
|
/**
|
|
@@ -1440,6 +1444,14 @@ declare function parseScriderLineHeightMultiplier(value: string): number | undef
|
|
|
1440
1444
|
* Line-height for a block tag: `scrider-line-height` on the line → documentPresentation → none.
|
|
1441
1445
|
*/
|
|
1442
1446
|
declare function blockLineHeightStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
|
|
1447
|
+
/**
|
|
1448
|
+
* First-line indent for a plain `<p>`: `scrider-text-indent` on the line (baked,
|
|
1449
|
+
* e.g. Word paste) → documentPresentation `textIndentCm` → none.
|
|
1450
|
+
*
|
|
1451
|
+
* The block attr wins over the document default (mirrors line-height / margin
|
|
1452
|
+
* resolution). The raw block value is a CSS length string (e.g. `1.25cm`).
|
|
1453
|
+
*/
|
|
1454
|
+
declare function blockTextIndentStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
|
|
1443
1455
|
/**
|
|
1444
1456
|
* Parse paragraph margin in em from Delta / inline CSS (`0.5em`, `0.5`).
|
|
1445
1457
|
*/
|
|
@@ -1501,10 +1513,21 @@ declare function resolveDocumentPresentation(presentation?: DocumentPresentation
|
|
|
1501
1513
|
* can fall back cleanly.
|
|
1502
1514
|
*/
|
|
1503
1515
|
declare function documentMetadataToPresentation(metadata: ScriderDocumentMetadata | undefined): DocumentPresentation | undefined;
|
|
1504
|
-
/**
|
|
1516
|
+
/**
|
|
1517
|
+
* Document-level first-line indent only (no per-block attr).
|
|
1518
|
+
*
|
|
1519
|
+
* @deprecated Superseded by {@link blockTextIndentStyleParts}, which resolves the
|
|
1520
|
+
* per-block `scrider-text-indent` attr with the document default as fallback and
|
|
1521
|
+
* is what {@link blockPresentationStyleParts} now uses. Kept exported for
|
|
1522
|
+
* backward compatibility; output is unchanged for document-only callers.
|
|
1523
|
+
*/
|
|
1505
1524
|
declare function documentPresentationStyleParts(tag: string, resolved: ResolvedDocumentPresentation | undefined): string[];
|
|
1506
1525
|
/**
|
|
1507
1526
|
* All block presentation styles for deltaToHtml: Delta attrs, then document defaults.
|
|
1527
|
+
*
|
|
1528
|
+
* First-line indent now resolves per-block: baked `scrider-text-indent` wins over
|
|
1529
|
+
* the document `textIndentCm` default (previously the per-block attr was dropped
|
|
1530
|
+
* on export). Output for document-only paragraphs is unchanged.
|
|
1508
1531
|
*/
|
|
1509
1532
|
declare function blockPresentationStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
|
|
1510
1533
|
|
|
@@ -1654,6 +1677,36 @@ interface DeltaToHtmlOptions {
|
|
|
1654
1677
|
* ```
|
|
1655
1678
|
*/
|
|
1656
1679
|
declare function deltaToHtml(delta: Delta, options?: DeltaToHtmlOptions): string;
|
|
1680
|
+
/**
|
|
1681
|
+
* Rendering profile: how a Delta is turned into markup.
|
|
1682
|
+
*
|
|
1683
|
+
* - `export`: full fidelity for clipboard / Office / HTML export. Document-level
|
|
1684
|
+
* presentation (line/paragraph spacing, first-line/list indent) and table
|
|
1685
|
+
* presentation are projected to inline CSS so the markup is self-contained.
|
|
1686
|
+
* - `editor`: markup for the editor's contenteditable surface. Document-level
|
|
1687
|
+
* presentation and table presentation are intentionally dropped — the editor
|
|
1688
|
+
* applies them live via CSS custom properties on the container, so inline
|
|
1689
|
+
* copies would double-apply and fight the Settings panel. Per-block baked
|
|
1690
|
+
* attributes (`scrider-line-height`, `scrider-margin-*`, `scrider-text-indent`)
|
|
1691
|
+
* still render, since they are part of the document content.
|
|
1692
|
+
*/
|
|
1693
|
+
type RenderProfile = 'export' | 'editor';
|
|
1694
|
+
/**
|
|
1695
|
+
* Render a Delta with an explicit {@link RenderProfile}.
|
|
1696
|
+
*
|
|
1697
|
+
* Thin dispatcher over {@link deltaToHtml} (the export core). See
|
|
1698
|
+
* {@link RenderProfile} for how the profiles differ.
|
|
1699
|
+
*/
|
|
1700
|
+
declare function renderDelta(delta: Delta, profile: RenderProfile, options?: DeltaToHtmlOptions): string;
|
|
1701
|
+
/**
|
|
1702
|
+
* Render a Delta for the editor's contenteditable surface (`editor` profile).
|
|
1703
|
+
*
|
|
1704
|
+
* Equivalent to `renderDelta(delta, 'editor', options)`. Document-level and table
|
|
1705
|
+
* presentation are dropped (applied live via CSS vars); the built-in `softBreak`
|
|
1706
|
+
* renderer already emits `<br data-scrider-embed>`, so the editor needs no
|
|
1707
|
+
* embed-renderer override.
|
|
1708
|
+
*/
|
|
1709
|
+
declare function deltaToDom(delta: Delta, options?: DeltaToHtmlOptions): string;
|
|
1657
1710
|
|
|
1658
1711
|
/**
|
|
1659
1712
|
* HTML → Delta Conversion
|
|
@@ -2151,4 +2204,4 @@ declare function collectAdjacentTableLines<T extends {
|
|
|
2151
2204
|
*/
|
|
2152
2205
|
declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
|
|
2153
2206
|
|
|
2154
|
-
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 ScriderDocumentMetadata, type TableBlockData, type TableBlockFloat, 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, 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, resolveDocumentPresentation, resolveTablePresentation, sanitizeDelta, sizeFormat, slugify, slugifyWithDedup, softBreakFormat, strikeFormat, subscriptFormat, superscriptFormat, tableBlockHandler, tableCellCoordsFromAttributes, tableCellCoordsFromOp, tableColAlignFormat, tableColFormat, tableHeaderFormat, tableRowFormat, toCodeWidgetEmbedUrl, toHexColor, underlineFormat, unescapeHtml, validateDelta, videoFormat };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -459,9 +459,13 @@ var EMBED_RENDERERS = {
|
|
|
459
459
|
const embedSrc = toCodeWidgetEmbedUrl(src);
|
|
460
460
|
return `<iframe data-code-widget src="${escapeHtml(embedSrc)}" frameborder="0" allowfullscreen${renderEmbedIframeIsolationAttrs(context, "codeWidget")}${float}${style}></iframe>`;
|
|
461
461
|
},
|
|
462
|
+
// `data-scrider-embed` marks this span as 1 Delta char for DomBridge before
|
|
463
|
+
// KaTeX post-render replaces the text body with a `.katex` subtree. Without
|
|
464
|
+
// the marker, DomBridge counts the raw LaTeX length and drifts indices for
|
|
465
|
+
// everything after the formula (e.g. Simple Table chrome probe fails).
|
|
462
466
|
formula: (value) => {
|
|
463
467
|
const latex = typeof value === "string" ? value : "";
|
|
464
|
-
return `<span class="formula" data-formula="${escapeHtml(latex)}">${escapeHtml(latex)}</span>`;
|
|
468
|
+
return `<span class="formula" data-formula="${escapeHtml(latex)}" data-scrider-embed>${escapeHtml(latex)}</span>`;
|
|
465
469
|
},
|
|
466
470
|
diagram: (value) => {
|
|
467
471
|
const source = typeof value === "string" ? value : "";
|
|
@@ -2587,7 +2591,7 @@ var formulaFormat = {
|
|
|
2587
2591
|
},
|
|
2588
2592
|
render(value) {
|
|
2589
2593
|
const latex = typeof value === "string" ? value : "";
|
|
2590
|
-
return `<span class="formula" data-formula="${escapeHtml(latex)}">${escapeHtml(latex)}</span>`;
|
|
2594
|
+
return `<span class="formula" data-formula="${escapeHtml(latex)}" data-scrider-embed>${escapeHtml(latex)}</span>`;
|
|
2591
2595
|
},
|
|
2592
2596
|
match(element) {
|
|
2593
2597
|
if (element.tagName.toLowerCase() !== "span") return null;
|
|
@@ -2999,7 +3003,9 @@ function slugifyWithDedup(text, usedSlugs) {
|
|
|
2999
3003
|
var SCRIDER_LINE_HEIGHT_KEY = "scrider-line-height";
|
|
3000
3004
|
var SCRIDER_MARGIN_AFTER_KEY = "scrider-margin-after";
|
|
3001
3005
|
var SCRIDER_MARGIN_BEFORE_KEY = "scrider-margin-before";
|
|
3006
|
+
var SCRIDER_TEXT_INDENT_KEY = "scrider-text-indent";
|
|
3002
3007
|
var LINE_HEIGHT_BLOCK_TAGS = /* @__PURE__ */ new Set(["p", "li", "blockquote"]);
|
|
3008
|
+
var TEXT_INDENT_BLOCK_TAGS = /* @__PURE__ */ new Set(["p"]);
|
|
3003
3009
|
var PARAGRAPH_SPACING_BLOCK_TAGS = /* @__PURE__ */ new Set(["p"]);
|
|
3004
3010
|
function parseScriderLineHeightMultiplier(value) {
|
|
3005
3011
|
const trimmed = value.trim();
|
|
@@ -3029,6 +3035,18 @@ function blockLineHeightStyleParts(tag, blockAttributes, resolved) {
|
|
|
3029
3035
|
}
|
|
3030
3036
|
return [];
|
|
3031
3037
|
}
|
|
3038
|
+
function blockTextIndentStyleParts(tag, blockAttributes, resolved) {
|
|
3039
|
+
if (!TEXT_INDENT_BLOCK_TAGS.has(tag)) return [];
|
|
3040
|
+
const raw = blockAttributes?.[SCRIDER_TEXT_INDENT_KEY];
|
|
3041
|
+
if (typeof raw === "string") {
|
|
3042
|
+
const trimmed = raw.trim();
|
|
3043
|
+
if (trimmed) return [`text-indent:${trimmed}`];
|
|
3044
|
+
}
|
|
3045
|
+
if (resolved?.textIndentCm !== void 0) {
|
|
3046
|
+
return [`text-indent:${resolved.textIndentCm}cm`];
|
|
3047
|
+
}
|
|
3048
|
+
return [];
|
|
3049
|
+
}
|
|
3032
3050
|
function parseScriderMarginEm(value) {
|
|
3033
3051
|
const trimmed = value.trim();
|
|
3034
3052
|
if (!trimmed) return void 0;
|
|
@@ -3153,7 +3171,7 @@ function blockPresentationStyleParts(tag, blockAttributes, resolved) {
|
|
|
3153
3171
|
return [
|
|
3154
3172
|
...blockLineHeightStyleParts(tag, blockAttributes, resolved),
|
|
3155
3173
|
...blockParagraphMarginStyleParts(tag, blockAttributes, resolved),
|
|
3156
|
-
...
|
|
3174
|
+
...blockTextIndentStyleParts(tag, blockAttributes, resolved)
|
|
3157
3175
|
];
|
|
3158
3176
|
}
|
|
3159
3177
|
function joinStyleParts(parts) {
|
|
@@ -3437,6 +3455,19 @@ function deltaToHtml(delta, options = {}) {
|
|
|
3437
3455
|
}
|
|
3438
3456
|
return html;
|
|
3439
3457
|
}
|
|
3458
|
+
function stripPresentationForEditor(options) {
|
|
3459
|
+
const rest = { ...options };
|
|
3460
|
+
delete rest.documentPresentation;
|
|
3461
|
+
delete rest.documentMetadata;
|
|
3462
|
+
delete rest.tablePresentation;
|
|
3463
|
+
return rest;
|
|
3464
|
+
}
|
|
3465
|
+
function renderDelta(delta, profile, options = {}) {
|
|
3466
|
+
return profile === "editor" ? deltaToHtml(delta, stripPresentationForEditor(options)) : deltaToHtml(delta, options);
|
|
3467
|
+
}
|
|
3468
|
+
function deltaToDom(delta, options = {}) {
|
|
3469
|
+
return renderDelta(delta, "editor", options);
|
|
3470
|
+
}
|
|
3440
3471
|
function getIndent(level) {
|
|
3441
3472
|
return " ".repeat(level);
|
|
3442
3473
|
}
|
|
@@ -6074,6 +6105,8 @@ export {
|
|
|
6074
6105
|
SCRIDER_LINE_HEIGHT_KEY,
|
|
6075
6106
|
SCRIDER_MARGIN_AFTER_KEY,
|
|
6076
6107
|
SCRIDER_MARGIN_BEFORE_KEY,
|
|
6108
|
+
SCRIDER_TEXT_INDENT_KEY,
|
|
6109
|
+
TEXT_INDENT_BLOCK_TAGS,
|
|
6077
6110
|
alertBlockHandler,
|
|
6078
6111
|
alignFormat,
|
|
6079
6112
|
backgroundFormat,
|
|
@@ -6083,6 +6116,7 @@ export {
|
|
|
6083
6116
|
blockMarginBeforeStyleParts,
|
|
6084
6117
|
blockParagraphMarginStyleParts,
|
|
6085
6118
|
blockPresentationStyleParts,
|
|
6119
|
+
blockTextIndentStyleParts,
|
|
6086
6120
|
blockquoteFormat,
|
|
6087
6121
|
boldFormat,
|
|
6088
6122
|
boxBlockHandler,
|
|
@@ -6100,6 +6134,7 @@ export {
|
|
|
6100
6134
|
defaultEmbedFormats,
|
|
6101
6135
|
defaultFormats,
|
|
6102
6136
|
defaultInlineFormats,
|
|
6137
|
+
deltaToDom,
|
|
6103
6138
|
deltaToHtml,
|
|
6104
6139
|
deltaToMarkdown,
|
|
6105
6140
|
dividerFormat,
|
|
@@ -6142,6 +6177,7 @@ export {
|
|
|
6142
6177
|
parseScriderMarginBeforeEm,
|
|
6143
6178
|
parseScriderMarginEm,
|
|
6144
6179
|
preloadRemark,
|
|
6180
|
+
renderDelta,
|
|
6145
6181
|
resolveDocumentPresentation,
|
|
6146
6182
|
resolveTablePresentation,
|
|
6147
6183
|
sanitizeDelta,
|