@scrider/formatter 1.10.3 → 1.10.5

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
@@ -30,6 +30,15 @@ interface TablePresentation {
30
30
  */
31
31
  defaultCellAlign?: TableCellAlign;
32
32
  }
33
+ /** Default table border (HTML / clipboard / PDF host should share). */
34
+ declare const TABLE_BORDER_COLOR = "#e7e7e7";
35
+ /** Header shade fill — matches editor light `--color-bg-hover` family. */
36
+ declare const TABLE_HEADER_BG = "#f5f5f5";
37
+ /**
38
+ * Zebra body-row fill — canon aligned with editor/demo light
39
+ * `--color-table-zebra` (`#f6f8fa`, arch-set1 #12).
40
+ */
41
+ declare const TABLE_ZEBRA_BG = "#f6f8fa";
33
42
  interface ResolvedTablePresentation {
34
43
  grid: boolean;
35
44
  line: boolean;
@@ -266,11 +275,21 @@ interface EmbedIsolationOptions {
266
275
  /** Add `allow="…; cross-origin-isolated"` on codeWidget iframes. @default false */
267
276
  crossOriginIsolated?: boolean;
268
277
  }
278
+ /**
279
+ * Host-provided share→embed URL transform for `{ codeWidget }` (arch-set1 D2).
280
+ * When omitted, the stored URL is used as-is (passthrough).
281
+ */
282
+ type CodeWidgetEmbedUrlFn = (url: string) => string;
269
283
  /**
270
284
  * Optional context passed to Format.render() during conversion.
271
285
  */
272
286
  interface FormatRenderContext {
273
287
  embed?: EmbedIsolationOptions;
288
+ /**
289
+ * Optional share→embed URL transform for codeWidget iframes.
290
+ * Integration policy lives in the host (editor/demo), not the formatter.
291
+ */
292
+ codeWidgetEmbedUrl?: CodeWidgetEmbedUrlFn;
274
293
  }
275
294
  /**
276
295
  * Result returned by Format.match() when an HTML element is recognized.
@@ -1187,9 +1206,9 @@ declare const blockFormat: Format<Record<string, unknown>>;
1187
1206
  * embeds can boot SharedArrayBuffer when the host is cross-origin-isolated.
1188
1207
  * `credentialless` keeps the frame loadable under COEP on such a host.
1189
1208
  *
1190
- * The src is run through `toCodeWidgetEmbedUrl` at render time, which is
1191
- * idempotent, so resize/float attributes and the Delta ↔ HTML round-trip stay
1192
- * stable regardless of whether the stored value is the user URL or embed URL.
1209
+ * Share→embed URL rules are **not** in the formatter (arch-set1 D2). Inject
1210
+ * `deltaToHtml({ codeWidgetEmbedUrl })` / `FormatRenderContext.codeWidgetEmbedUrl`
1211
+ * from the host; default is passthrough of the stored URL.
1193
1212
  */
1194
1213
  declare const codeWidgetFormat: Format<string>;
1195
1214
 
@@ -1709,6 +1728,12 @@ interface DeltaToHtmlOptions {
1709
1728
  * Enable when the host page is cross-origin-isolated (COOP + COEP).
1710
1729
  */
1711
1730
  embed?: EmbedIsolationOptions;
1731
+ /**
1732
+ * Share→embed URL transform for `{ codeWidget }` iframes (arch-set1 D2).
1733
+ * Default: passthrough (stored URL unchanged). Provider rules belong in the
1734
+ * host — inject e.g. `@scrider/editor-react`'s `toCodeWidgetEmbedUrl`.
1735
+ */
1736
+ codeWidgetEmbedUrl?: CodeWidgetEmbedUrlFn;
1712
1737
  }
1713
1738
  /**
1714
1739
  * Convert a Delta to an HTML string
@@ -1847,25 +1872,14 @@ declare function escapeHtml(text: string): string;
1847
1872
  */
1848
1873
  declare function unescapeHtml(text: string): string;
1849
1874
  /**
1850
- * Convert a code-playground URL to an embeddable iframe URL (Phase 8 Part 3.5).
1851
- *
1852
- * Idempotent: a URL that is already in embed form is returned unchanged, so the
1853
- * Delta HTML Delta round-trip is stable regardless of which form is stored.
1854
- *
1855
- * Provider | User URL | Embed URL
1856
- * -------------|----------------------------------|-----------------------------------
1857
- * StackBlitz | stackblitz.com/edit/{id} | …?embed=1
1858
- * | stackblitz.com/github/{u}/{r} | …?embed=1
1859
- * CodeSandbox | codesandbox.io/s/{id} | codesandbox.io/embed/{id}
1860
- * Replit | replit.com/@{u}/{repl} | …?embed=true
1861
- * CodePen | codepen.io/{u}/pen/{id} | codepen.io/{u}/embed/{id}
1862
- * JSFiddle | jsfiddle.net/{u}/{id}/ | jsfiddle.net/{u}/{id}/embedded/
1863
- * Trinket | trinket.io/{lang}/{id} | trinket.io/embed/{lang}/{id}
1864
- * OneCompiler | onecompiler.com/{lang}/{id} | onecompiler.com/embed/{lang}/{id}
1865
- *
1866
- * Unknown hosts are returned unchanged (the marker `data-code-widget` still
1867
- * makes them render as an iframe; auto-detection of bare URLs lives in the
1868
- * editor layer).
1875
+ * Resolve codeWidget iframe `src` (arch-set1 D2).
1876
+ * Uses the host-injected transform when present; otherwise passthrough.
1877
+ */
1878
+ declare function resolveCodeWidgetEmbedSrc(url: string, context?: FormatRenderContext): string;
1879
+ /**
1880
+ * @deprecated Since 1.10.4 — identity/passthrough only. Provider share→embed
1881
+ * rules live in the host (`deltaToHtml({ codeWidgetEmbedUrl })` / editor-react
1882
+ * `toCodeWidgetEmbedUrl`). Kept as a stable export name for old imports.
1869
1883
  */
1870
1884
  declare function toCodeWidgetEmbedUrl(url: string): string;
1871
1885
 
@@ -1994,6 +2008,11 @@ interface DeltaToMarkdownOptions {
1994
2008
  * `render()` is used as HTML fallback in Markdown.
1995
2009
  */
1996
2010
  registry?: Registry;
2011
+ /**
2012
+ * Share→embed URL transform for attributed `{ codeWidget }` HTML fallback
2013
+ * (arch-set1 D2). Default: passthrough.
2014
+ */
2015
+ codeWidgetEmbedUrl?: CodeWidgetEmbedUrlFn;
1997
2016
  /**
1998
2017
  * Rendering style for `{ softBreak: true }` embeds (Phase 7 Part 0).
1999
2018
  *
@@ -2256,4 +2275,4 @@ declare function collectAdjacentTableLines<T extends {
2256
2275
  */
2257
2276
  declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
2258
2277
 
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 };
2278
+ 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 CodeWidgetEmbedUrlFn, 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, TABLE_BORDER_COLOR, TABLE_HEADER_BG, TABLE_ZEBRA_BG, 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, resolveCodeWidgetEmbedSrc, 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
@@ -30,6 +30,15 @@ interface TablePresentation {
30
30
  */
31
31
  defaultCellAlign?: TableCellAlign;
32
32
  }
33
+ /** Default table border (HTML / clipboard / PDF host should share). */
34
+ declare const TABLE_BORDER_COLOR = "#e7e7e7";
35
+ /** Header shade fill — matches editor light `--color-bg-hover` family. */
36
+ declare const TABLE_HEADER_BG = "#f5f5f5";
37
+ /**
38
+ * Zebra body-row fill — canon aligned with editor/demo light
39
+ * `--color-table-zebra` (`#f6f8fa`, arch-set1 #12).
40
+ */
41
+ declare const TABLE_ZEBRA_BG = "#f6f8fa";
33
42
  interface ResolvedTablePresentation {
34
43
  grid: boolean;
35
44
  line: boolean;
@@ -266,11 +275,21 @@ interface EmbedIsolationOptions {
266
275
  /** Add `allow="…; cross-origin-isolated"` on codeWidget iframes. @default false */
267
276
  crossOriginIsolated?: boolean;
268
277
  }
278
+ /**
279
+ * Host-provided share→embed URL transform for `{ codeWidget }` (arch-set1 D2).
280
+ * When omitted, the stored URL is used as-is (passthrough).
281
+ */
282
+ type CodeWidgetEmbedUrlFn = (url: string) => string;
269
283
  /**
270
284
  * Optional context passed to Format.render() during conversion.
271
285
  */
272
286
  interface FormatRenderContext {
273
287
  embed?: EmbedIsolationOptions;
288
+ /**
289
+ * Optional share→embed URL transform for codeWidget iframes.
290
+ * Integration policy lives in the host (editor/demo), not the formatter.
291
+ */
292
+ codeWidgetEmbedUrl?: CodeWidgetEmbedUrlFn;
274
293
  }
275
294
  /**
276
295
  * Result returned by Format.match() when an HTML element is recognized.
@@ -1187,9 +1206,9 @@ declare const blockFormat: Format<Record<string, unknown>>;
1187
1206
  * embeds can boot SharedArrayBuffer when the host is cross-origin-isolated.
1188
1207
  * `credentialless` keeps the frame loadable under COEP on such a host.
1189
1208
  *
1190
- * The src is run through `toCodeWidgetEmbedUrl` at render time, which is
1191
- * idempotent, so resize/float attributes and the Delta ↔ HTML round-trip stay
1192
- * stable regardless of whether the stored value is the user URL or embed URL.
1209
+ * Share→embed URL rules are **not** in the formatter (arch-set1 D2). Inject
1210
+ * `deltaToHtml({ codeWidgetEmbedUrl })` / `FormatRenderContext.codeWidgetEmbedUrl`
1211
+ * from the host; default is passthrough of the stored URL.
1193
1212
  */
1194
1213
  declare const codeWidgetFormat: Format<string>;
1195
1214
 
@@ -1709,6 +1728,12 @@ interface DeltaToHtmlOptions {
1709
1728
  * Enable when the host page is cross-origin-isolated (COOP + COEP).
1710
1729
  */
1711
1730
  embed?: EmbedIsolationOptions;
1731
+ /**
1732
+ * Share→embed URL transform for `{ codeWidget }` iframes (arch-set1 D2).
1733
+ * Default: passthrough (stored URL unchanged). Provider rules belong in the
1734
+ * host — inject e.g. `@scrider/editor-react`'s `toCodeWidgetEmbedUrl`.
1735
+ */
1736
+ codeWidgetEmbedUrl?: CodeWidgetEmbedUrlFn;
1712
1737
  }
1713
1738
  /**
1714
1739
  * Convert a Delta to an HTML string
@@ -1847,25 +1872,14 @@ declare function escapeHtml(text: string): string;
1847
1872
  */
1848
1873
  declare function unescapeHtml(text: string): string;
1849
1874
  /**
1850
- * Convert a code-playground URL to an embeddable iframe URL (Phase 8 Part 3.5).
1851
- *
1852
- * Idempotent: a URL that is already in embed form is returned unchanged, so the
1853
- * Delta HTML Delta round-trip is stable regardless of which form is stored.
1854
- *
1855
- * Provider | User URL | Embed URL
1856
- * -------------|----------------------------------|-----------------------------------
1857
- * StackBlitz | stackblitz.com/edit/{id} | …?embed=1
1858
- * | stackblitz.com/github/{u}/{r} | …?embed=1
1859
- * CodeSandbox | codesandbox.io/s/{id} | codesandbox.io/embed/{id}
1860
- * Replit | replit.com/@{u}/{repl} | …?embed=true
1861
- * CodePen | codepen.io/{u}/pen/{id} | codepen.io/{u}/embed/{id}
1862
- * JSFiddle | jsfiddle.net/{u}/{id}/ | jsfiddle.net/{u}/{id}/embedded/
1863
- * Trinket | trinket.io/{lang}/{id} | trinket.io/embed/{lang}/{id}
1864
- * OneCompiler | onecompiler.com/{lang}/{id} | onecompiler.com/embed/{lang}/{id}
1865
- *
1866
- * Unknown hosts are returned unchanged (the marker `data-code-widget` still
1867
- * makes them render as an iframe; auto-detection of bare URLs lives in the
1868
- * editor layer).
1875
+ * Resolve codeWidget iframe `src` (arch-set1 D2).
1876
+ * Uses the host-injected transform when present; otherwise passthrough.
1877
+ */
1878
+ declare function resolveCodeWidgetEmbedSrc(url: string, context?: FormatRenderContext): string;
1879
+ /**
1880
+ * @deprecated Since 1.10.4 — identity/passthrough only. Provider share→embed
1881
+ * rules live in the host (`deltaToHtml({ codeWidgetEmbedUrl })` / editor-react
1882
+ * `toCodeWidgetEmbedUrl`). Kept as a stable export name for old imports.
1869
1883
  */
1870
1884
  declare function toCodeWidgetEmbedUrl(url: string): string;
1871
1885
 
@@ -1994,6 +2008,11 @@ interface DeltaToMarkdownOptions {
1994
2008
  * `render()` is used as HTML fallback in Markdown.
1995
2009
  */
1996
2010
  registry?: Registry;
2011
+ /**
2012
+ * Share→embed URL transform for attributed `{ codeWidget }` HTML fallback
2013
+ * (arch-set1 D2). Default: passthrough.
2014
+ */
2015
+ codeWidgetEmbedUrl?: CodeWidgetEmbedUrlFn;
1997
2016
  /**
1998
2017
  * Rendering style for `{ softBreak: true }` embeds (Phase 7 Part 0).
1999
2018
  *
@@ -2256,4 +2275,4 @@ declare function collectAdjacentTableLines<T extends {
2256
2275
  */
2257
2276
  declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
2258
2277
 
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 };
2278
+ 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 CodeWidgetEmbedUrlFn, 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, TABLE_BORDER_COLOR, TABLE_HEADER_BG, TABLE_ZEBRA_BG, 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, resolveCodeWidgetEmbedSrc, 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.js CHANGED
@@ -456,7 +456,7 @@ var EMBED_RENDERERS = {
456
456
  if (h && h !== "auto") styles.push(`height: ${/^\d+$/.test(h) ? h + "px" : h}`);
457
457
  }
458
458
  const style = styles.length > 0 ? ` style="${styles.join("; ")}"` : "";
459
- const embedSrc = toCodeWidgetEmbedUrl(src);
459
+ const embedSrc = resolveCodeWidgetEmbedSrc(src, context);
460
460
  return `<iframe data-code-widget src="${escapeHtml(embedSrc)}" frameborder="0" allowfullscreen${renderEmbedIframeIsolationAttrs(context, "codeWidget")}${float}${style}></iframe>`;
461
461
  },
462
462
  // `data-scrider-embed` marks this span as 1 Delta char for DomBridge before
@@ -556,31 +556,6 @@ function fromVideoEmbedUrl(embedUrl) {
556
556
  }
557
557
  return embedUrl;
558
558
  }
559
- function splitUrl(url) {
560
- let rest = url;
561
- let hash = "";
562
- const hashIdx = rest.indexOf("#");
563
- if (hashIdx >= 0) {
564
- hash = rest.slice(hashIdx);
565
- rest = rest.slice(0, hashIdx);
566
- }
567
- let query = "";
568
- const qIdx = rest.indexOf("?");
569
- if (qIdx >= 0) {
570
- query = rest.slice(qIdx);
571
- rest = rest.slice(0, qIdx);
572
- }
573
- return { base: rest, query, hash };
574
- }
575
- function hasQueryParam(url, key) {
576
- const { query } = splitUrl(url);
577
- return new RegExp(`[?&]${key}=`, "i").test(query);
578
- }
579
- function appendQueryParam(url, key, value) {
580
- const { base, query, hash } = splitUrl(url);
581
- const next = query ? `${query}&${key}=${value}` : `?${key}=${value}`;
582
- return `${base}${next}${hash}`;
583
- }
584
559
  var CODE_WIDGET_IFRAME_ALLOW = "accelerometer; camera; encrypted-media; geolocation; gyroscope; microphone; midi; payment; usb; xr-spatial-tracking; cross-origin-isolated";
585
560
  function renderEmbedIframeIsolationAttrs(context, kind) {
586
561
  const opts = context?.embed;
@@ -593,38 +568,13 @@ function renderEmbedIframeIsolationAttrs(context, kind) {
593
568
  }
594
569
  return parts.length ? ` ${parts.join(" ")}` : "";
595
570
  }
596
- function toCodeWidgetEmbedUrl(url) {
571
+ function resolveCodeWidgetEmbedSrc(url, context) {
597
572
  const u = typeof url === "string" ? url.trim() : "";
598
573
  if (!u) return "";
599
- if (/(?:\/\/|^)(?:[\w-]+\.)*stackblitz\.com\//i.test(u)) {
600
- return hasQueryParam(u, "embed") ? u : appendQueryParam(u, "embed", "1");
601
- }
602
- if (/(?:\/\/|^)(?:[\w-]+\.)*codesandbox\.io\//i.test(u)) {
603
- if (/codesandbox\.io\/embed\//i.test(u)) return u;
604
- return u.replace(/codesandbox\.io\/s\//i, "codesandbox.io/embed/");
605
- }
606
- if (/(?:\/\/|^)(?:[\w-]+\.)*replit\.com\//i.test(u)) {
607
- return hasQueryParam(u, "embed") ? u : appendQueryParam(u, "embed", "true");
608
- }
609
- if (/(?:\/\/|^)(?:[\w-]+\.)*codepen\.io\//i.test(u)) {
610
- if (/codepen\.io\/[^/]+\/embed\//i.test(u)) return u;
611
- return u.replace(/(codepen\.io\/[^/]+)\/pen\//i, "$1/embed/");
612
- }
613
- if (/(?:\/\/|^)(?:[\w-]+\.)*jsfiddle\.net\//i.test(u)) {
614
- const { base, query, hash } = splitUrl(u);
615
- if (/\/embedded(?:\/|$)/i.test(base)) return u;
616
- const trimmed = base.replace(/\/+$/, "");
617
- return `${trimmed}/embedded/${query}${hash}`;
618
- }
619
- if (/(?:\/\/|^)(?:[\w-]+\.)*trinket\.io\//i.test(u)) {
620
- if (/trinket\.io\/embed\//i.test(u)) return u;
621
- return u.replace(/trinket\.io\//i, "trinket.io/embed/");
622
- }
623
- if (/(?:\/\/|^)(?:[\w-]+\.)*onecompiler\.com\//i.test(u)) {
624
- if (/onecompiler\.com\/embed\//i.test(u)) return u;
625
- return u.replace(/onecompiler\.com\//i, "onecompiler.com/embed/");
626
- }
627
- return u;
574
+ return context?.codeWidgetEmbedUrl ? context.codeWidgetEmbedUrl(u) : u;
575
+ }
576
+ function toCodeWidgetEmbedUrl(url) {
577
+ return typeof url === "string" ? url.trim() : "";
628
578
  }
629
579
 
630
580
  // src/schema/blocks/table.ts
@@ -2467,7 +2417,7 @@ var codeWidgetFormat = {
2467
2417
  if (h && h !== "auto") styles.push(`height: ${/^\d+$/.test(h) ? h + "px" : h}`);
2468
2418
  }
2469
2419
  const style = styles.length > 0 ? ` style="${styles.join("; ")}"` : "";
2470
- const embedSrc = toCodeWidgetEmbedUrl(src);
2420
+ const embedSrc = resolveCodeWidgetEmbedSrc(src, context);
2471
2421
  return `<iframe data-code-widget src="${escapeHtml(embedSrc)}" frameborder="0" allowfullscreen${renderEmbedIframeIsolationAttrs(context, "codeWidget")}${float}${style}></iframe>`;
2472
2422
  },
2473
2423
  match(element) {
@@ -3263,9 +3213,12 @@ function headingPolicyStyleParts(tag, blockAttributes, policy) {
3263
3213
  }
3264
3214
 
3265
3215
  // src/conversion/html/table-presentation.ts
3266
- var DEFAULT_BORDER_COLOR = "#e7e7e7";
3267
- var DEFAULT_HEADER_BG = "#f5f5f5";
3268
- var DEFAULT_ZEBRA_BG = "#fafafa";
3216
+ var TABLE_BORDER_COLOR = "#e7e7e7";
3217
+ var TABLE_HEADER_BG = "#f5f5f5";
3218
+ var TABLE_ZEBRA_BG = "#f6f8fa";
3219
+ var DEFAULT_BORDER_COLOR = TABLE_BORDER_COLOR;
3220
+ var DEFAULT_HEADER_BG = TABLE_HEADER_BG;
3221
+ var DEFAULT_ZEBRA_BG = TABLE_ZEBRA_BG;
3269
3222
  var CELL_PADDING = "6px 13px";
3270
3223
  function resolveTablePresentation(presentation) {
3271
3224
  return {
@@ -3964,7 +3917,10 @@ function renderEmbed(value, attributes, renderers, blockHandlers, options) {
3964
3917
  return "";
3965
3918
  }
3966
3919
  const embedValue = value[embedType];
3967
- const embedContext = options?.embed != null ? { embed: options.embed } : {};
3920
+ const embedContext = {
3921
+ ...options?.embed != null ? { embed: options.embed } : {},
3922
+ ...options?.codeWidgetEmbedUrl != null ? { codeWidgetEmbedUrl: options.codeWidgetEmbedUrl } : {}
3923
+ };
3968
3924
  const registry = options?.registry;
3969
3925
  if (registry) {
3970
3926
  const format = registry.get(embedType);
@@ -4798,7 +4754,8 @@ function deltaToMarkdown(delta, options = {}) {
4798
4754
  prettyHtml = false,
4799
4755
  registry,
4800
4756
  softBreakStyle = "spaces",
4801
- trimTrailingNewlines = false
4757
+ trimTrailingNewlines = false,
4758
+ codeWidgetEmbedUrl
4802
4759
  } = options;
4803
4760
  const useLatexDelimiters = mathSyntax === "latex";
4804
4761
  const lines = splitIntoLines2(delta.ops);
@@ -4840,7 +4797,9 @@ function deltaToMarkdown(delta, options = {}) {
4840
4797
  blockHandlers,
4841
4798
  false,
4842
4799
  registry,
4843
- softBreakStyle
4800
+ softBreakStyle,
4801
+ false,
4802
+ codeWidgetEmbedUrl
4844
4803
  )
4845
4804
  ).join("\n");
4846
4805
  if (language === "math") {
@@ -4892,7 +4851,9 @@ ${code}
4892
4851
  blockHandlers,
4893
4852
  prettyHtml,
4894
4853
  registry,
4895
- softBreakStyle
4854
+ softBreakStyle,
4855
+ false,
4856
+ codeWidgetEmbedUrl
4896
4857
  );
4897
4858
  if (!content && !hasBlockFormat(attrs)) {
4898
4859
  result.push(preserveEmptyLines ? "<br>" : "");
@@ -5116,7 +5077,7 @@ function getCodeBlockId2(attributes) {
5116
5077
  const id = attributes["code-block-id"];
5117
5078
  return typeof id === "string" ? id : void 0;
5118
5079
  }
5119
- function renderLineContent2(ops, embedRenderers, inCodeBlock, useLatexDelimiters = false, blockHandlers, prettyHtml = false, registry, softBreakStyle = "spaces", inTableCell = false) {
5080
+ function renderLineContent2(ops, embedRenderers, inCodeBlock, useLatexDelimiters = false, blockHandlers, prettyHtml = false, registry, softBreakStyle = "spaces", inTableCell = false, codeWidgetEmbedUrl) {
5120
5081
  let result = "";
5121
5082
  for (const op of ops) {
5122
5083
  const attrs = op.attributes;
@@ -5138,7 +5099,8 @@ function renderLineContent2(ops, embedRenderers, inCodeBlock, useLatexDelimiters
5138
5099
  prettyHtml,
5139
5100
  registry,
5140
5101
  softBreakStyle,
5141
- inTableCell
5102
+ inTableCell,
5103
+ codeWidgetEmbedUrl
5142
5104
  );
5143
5105
  }
5144
5106
  }
@@ -5172,7 +5134,7 @@ function renderInlineText2(text, attributes) {
5172
5134
  }
5173
5135
  return result;
5174
5136
  }
5175
- function renderEmbed2(embed, attributes, customRenderers, useLatexDelimiters = false, blockHandlers, prettyHtml = false, registry, softBreakStyle = "spaces", inTableCell = false) {
5137
+ function renderEmbed2(embed, attributes, customRenderers, useLatexDelimiters = false, blockHandlers, prettyHtml = false, registry, softBreakStyle = "spaces", inTableCell = false, codeWidgetEmbedUrl) {
5176
5138
  const entries = Object.entries(embed);
5177
5139
  if (entries.length === 0) return "";
5178
5140
  const firstEntry = entries[0];
@@ -5221,7 +5183,11 @@ function renderEmbed2(embed, attributes, customRenderers, useLatexDelimiters = f
5221
5183
  if (md !== null) return md;
5222
5184
  }
5223
5185
  if (format.render) {
5224
- return format.render(embedValue, attributes);
5186
+ return format.render(
5187
+ embedValue,
5188
+ attributes,
5189
+ codeWidgetEmbedUrl != null ? { codeWidgetEmbedUrl } : void 0
5190
+ );
5225
5191
  }
5226
5192
  }
5227
5193
  }
@@ -5282,7 +5248,7 @@ function renderEmbed2(embed, attributes, customRenderers, useLatexDelimiters = f
5282
5248
  if (h && h !== "auto") styles.push(`height: ${/^\d+$/.test(h) ? h + "px" : h}`);
5283
5249
  }
5284
5250
  const styleAttr = styles.length > 0 ? ` style="${styles.join("; ")}"` : "";
5285
- const embedSrc = toCodeWidgetEmbedUrl(src);
5251
+ const embedSrc = codeWidgetEmbedUrl ? codeWidgetEmbedUrl(src) : src;
5286
5252
  return `<iframe data-code-widget src="${escapeHtml(embedSrc)}" frameborder="0" allowfullscreen${floatAttr}${styleAttr}></iframe>`;
5287
5253
  }
5288
5254
  return `![Widget](${src})`;
@@ -6202,6 +6168,9 @@ export {
6202
6168
  SCRIDER_MARGIN_AFTER_KEY,
6203
6169
  SCRIDER_MARGIN_BEFORE_KEY,
6204
6170
  SCRIDER_TEXT_INDENT_KEY,
6171
+ TABLE_BORDER_COLOR,
6172
+ TABLE_HEADER_BG,
6173
+ TABLE_ZEBRA_BG,
6205
6174
  TEXT_INDENT_BLOCK_TAGS,
6206
6175
  alertBlockHandler,
6207
6176
  alignFormat,
@@ -6275,6 +6244,7 @@ export {
6275
6244
  parseScriderMarginEm,
6276
6245
  preloadRemark,
6277
6246
  renderDelta,
6247
+ resolveCodeWidgetEmbedSrc,
6278
6248
  resolveDocumentPresentation,
6279
6249
  resolveHeadingPolicy,
6280
6250
  resolveTablePresentation,