@scrider/formatter 1.10.3 → 1.10.4
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 +31 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -23
- package/dist/index.d.ts +33 -23
- package/dist/index.js +30 -66
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -266,11 +266,21 @@ interface EmbedIsolationOptions {
|
|
|
266
266
|
/** Add `allow="…; cross-origin-isolated"` on codeWidget iframes. @default false */
|
|
267
267
|
crossOriginIsolated?: boolean;
|
|
268
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Host-provided share→embed URL transform for `{ codeWidget }` (arch-set1 D2).
|
|
271
|
+
* When omitted, the stored URL is used as-is (passthrough).
|
|
272
|
+
*/
|
|
273
|
+
type CodeWidgetEmbedUrlFn = (url: string) => string;
|
|
269
274
|
/**
|
|
270
275
|
* Optional context passed to Format.render() during conversion.
|
|
271
276
|
*/
|
|
272
277
|
interface FormatRenderContext {
|
|
273
278
|
embed?: EmbedIsolationOptions;
|
|
279
|
+
/**
|
|
280
|
+
* Optional share→embed URL transform for codeWidget iframes.
|
|
281
|
+
* Integration policy lives in the host (editor/demo), not the formatter.
|
|
282
|
+
*/
|
|
283
|
+
codeWidgetEmbedUrl?: CodeWidgetEmbedUrlFn;
|
|
274
284
|
}
|
|
275
285
|
/**
|
|
276
286
|
* Result returned by Format.match() when an HTML element is recognized.
|
|
@@ -1187,9 +1197,9 @@ declare const blockFormat: Format<Record<string, unknown>>;
|
|
|
1187
1197
|
* embeds can boot SharedArrayBuffer when the host is cross-origin-isolated.
|
|
1188
1198
|
* `credentialless` keeps the frame loadable under COEP on such a host.
|
|
1189
1199
|
*
|
|
1190
|
-
*
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1200
|
+
* Share→embed URL rules are **not** in the formatter (arch-set1 D2). Inject
|
|
1201
|
+
* `deltaToHtml({ codeWidgetEmbedUrl })` / `FormatRenderContext.codeWidgetEmbedUrl`
|
|
1202
|
+
* from the host; default is passthrough of the stored URL.
|
|
1193
1203
|
*/
|
|
1194
1204
|
declare const codeWidgetFormat: Format<string>;
|
|
1195
1205
|
|
|
@@ -1709,6 +1719,12 @@ interface DeltaToHtmlOptions {
|
|
|
1709
1719
|
* Enable when the host page is cross-origin-isolated (COOP + COEP).
|
|
1710
1720
|
*/
|
|
1711
1721
|
embed?: EmbedIsolationOptions;
|
|
1722
|
+
/**
|
|
1723
|
+
* Share→embed URL transform for `{ codeWidget }` iframes (arch-set1 D2).
|
|
1724
|
+
* Default: passthrough (stored URL unchanged). Provider rules belong in the
|
|
1725
|
+
* host — inject e.g. `@scrider/editor-react`'s `toCodeWidgetEmbedUrl`.
|
|
1726
|
+
*/
|
|
1727
|
+
codeWidgetEmbedUrl?: CodeWidgetEmbedUrlFn;
|
|
1712
1728
|
}
|
|
1713
1729
|
/**
|
|
1714
1730
|
* Convert a Delta to an HTML string
|
|
@@ -1847,25 +1863,14 @@ declare function escapeHtml(text: string): string;
|
|
|
1847
1863
|
*/
|
|
1848
1864
|
declare function unescapeHtml(text: string): string;
|
|
1849
1865
|
/**
|
|
1850
|
-
*
|
|
1851
|
-
*
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
*
|
|
1856
|
-
*
|
|
1857
|
-
*
|
|
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).
|
|
1866
|
+
* Resolve codeWidget iframe `src` (arch-set1 D2).
|
|
1867
|
+
* Uses the host-injected transform when present; otherwise passthrough.
|
|
1868
|
+
*/
|
|
1869
|
+
declare function resolveCodeWidgetEmbedSrc(url: string, context?: FormatRenderContext): string;
|
|
1870
|
+
/**
|
|
1871
|
+
* @deprecated Since 1.10.4 — identity/passthrough only. Provider share→embed
|
|
1872
|
+
* rules live in the host (`deltaToHtml({ codeWidgetEmbedUrl })` / editor-react
|
|
1873
|
+
* `toCodeWidgetEmbedUrl`). Kept as a stable export name for old imports.
|
|
1869
1874
|
*/
|
|
1870
1875
|
declare function toCodeWidgetEmbedUrl(url: string): string;
|
|
1871
1876
|
|
|
@@ -1994,6 +1999,11 @@ interface DeltaToMarkdownOptions {
|
|
|
1994
1999
|
* `render()` is used as HTML fallback in Markdown.
|
|
1995
2000
|
*/
|
|
1996
2001
|
registry?: Registry;
|
|
2002
|
+
/**
|
|
2003
|
+
* Share→embed URL transform for attributed `{ codeWidget }` HTML fallback
|
|
2004
|
+
* (arch-set1 D2). Default: passthrough.
|
|
2005
|
+
*/
|
|
2006
|
+
codeWidgetEmbedUrl?: CodeWidgetEmbedUrlFn;
|
|
1997
2007
|
/**
|
|
1998
2008
|
* Rendering style for `{ softBreak: true }` embeds (Phase 7 Part 0).
|
|
1999
2009
|
*
|
|
@@ -2256,4 +2266,4 @@ declare function collectAdjacentTableLines<T extends {
|
|
|
2256
2266
|
*/
|
|
2257
2267
|
declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
|
|
2258
2268
|
|
|
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 };
|
|
2269
|
+
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, 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
|
@@ -266,11 +266,21 @@ interface EmbedIsolationOptions {
|
|
|
266
266
|
/** Add `allow="…; cross-origin-isolated"` on codeWidget iframes. @default false */
|
|
267
267
|
crossOriginIsolated?: boolean;
|
|
268
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Host-provided share→embed URL transform for `{ codeWidget }` (arch-set1 D2).
|
|
271
|
+
* When omitted, the stored URL is used as-is (passthrough).
|
|
272
|
+
*/
|
|
273
|
+
type CodeWidgetEmbedUrlFn = (url: string) => string;
|
|
269
274
|
/**
|
|
270
275
|
* Optional context passed to Format.render() during conversion.
|
|
271
276
|
*/
|
|
272
277
|
interface FormatRenderContext {
|
|
273
278
|
embed?: EmbedIsolationOptions;
|
|
279
|
+
/**
|
|
280
|
+
* Optional share→embed URL transform for codeWidget iframes.
|
|
281
|
+
* Integration policy lives in the host (editor/demo), not the formatter.
|
|
282
|
+
*/
|
|
283
|
+
codeWidgetEmbedUrl?: CodeWidgetEmbedUrlFn;
|
|
274
284
|
}
|
|
275
285
|
/**
|
|
276
286
|
* Result returned by Format.match() when an HTML element is recognized.
|
|
@@ -1187,9 +1197,9 @@ declare const blockFormat: Format<Record<string, unknown>>;
|
|
|
1187
1197
|
* embeds can boot SharedArrayBuffer when the host is cross-origin-isolated.
|
|
1188
1198
|
* `credentialless` keeps the frame loadable under COEP on such a host.
|
|
1189
1199
|
*
|
|
1190
|
-
*
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1200
|
+
* Share→embed URL rules are **not** in the formatter (arch-set1 D2). Inject
|
|
1201
|
+
* `deltaToHtml({ codeWidgetEmbedUrl })` / `FormatRenderContext.codeWidgetEmbedUrl`
|
|
1202
|
+
* from the host; default is passthrough of the stored URL.
|
|
1193
1203
|
*/
|
|
1194
1204
|
declare const codeWidgetFormat: Format<string>;
|
|
1195
1205
|
|
|
@@ -1709,6 +1719,12 @@ interface DeltaToHtmlOptions {
|
|
|
1709
1719
|
* Enable when the host page is cross-origin-isolated (COOP + COEP).
|
|
1710
1720
|
*/
|
|
1711
1721
|
embed?: EmbedIsolationOptions;
|
|
1722
|
+
/**
|
|
1723
|
+
* Share→embed URL transform for `{ codeWidget }` iframes (arch-set1 D2).
|
|
1724
|
+
* Default: passthrough (stored URL unchanged). Provider rules belong in the
|
|
1725
|
+
* host — inject e.g. `@scrider/editor-react`'s `toCodeWidgetEmbedUrl`.
|
|
1726
|
+
*/
|
|
1727
|
+
codeWidgetEmbedUrl?: CodeWidgetEmbedUrlFn;
|
|
1712
1728
|
}
|
|
1713
1729
|
/**
|
|
1714
1730
|
* Convert a Delta to an HTML string
|
|
@@ -1847,25 +1863,14 @@ declare function escapeHtml(text: string): string;
|
|
|
1847
1863
|
*/
|
|
1848
1864
|
declare function unescapeHtml(text: string): string;
|
|
1849
1865
|
/**
|
|
1850
|
-
*
|
|
1851
|
-
*
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
*
|
|
1856
|
-
*
|
|
1857
|
-
*
|
|
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).
|
|
1866
|
+
* Resolve codeWidget iframe `src` (arch-set1 D2).
|
|
1867
|
+
* Uses the host-injected transform when present; otherwise passthrough.
|
|
1868
|
+
*/
|
|
1869
|
+
declare function resolveCodeWidgetEmbedSrc(url: string, context?: FormatRenderContext): string;
|
|
1870
|
+
/**
|
|
1871
|
+
* @deprecated Since 1.10.4 — identity/passthrough only. Provider share→embed
|
|
1872
|
+
* rules live in the host (`deltaToHtml({ codeWidgetEmbedUrl })` / editor-react
|
|
1873
|
+
* `toCodeWidgetEmbedUrl`). Kept as a stable export name for old imports.
|
|
1869
1874
|
*/
|
|
1870
1875
|
declare function toCodeWidgetEmbedUrl(url: string): string;
|
|
1871
1876
|
|
|
@@ -1994,6 +1999,11 @@ interface DeltaToMarkdownOptions {
|
|
|
1994
1999
|
* `render()` is used as HTML fallback in Markdown.
|
|
1995
2000
|
*/
|
|
1996
2001
|
registry?: Registry;
|
|
2002
|
+
/**
|
|
2003
|
+
* Share→embed URL transform for attributed `{ codeWidget }` HTML fallback
|
|
2004
|
+
* (arch-set1 D2). Default: passthrough.
|
|
2005
|
+
*/
|
|
2006
|
+
codeWidgetEmbedUrl?: CodeWidgetEmbedUrlFn;
|
|
1997
2007
|
/**
|
|
1998
2008
|
* Rendering style for `{ softBreak: true }` embeds (Phase 7 Part 0).
|
|
1999
2009
|
*
|
|
@@ -2256,4 +2266,4 @@ declare function collectAdjacentTableLines<T extends {
|
|
|
2256
2266
|
*/
|
|
2257
2267
|
declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
|
|
2258
2268
|
|
|
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 };
|
|
2269
|
+
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, 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 =
|
|
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
|
|
571
|
+
function resolveCodeWidgetEmbedSrc(url, context) {
|
|
597
572
|
const u = typeof url === "string" ? url.trim() : "";
|
|
598
573
|
if (!u) return "";
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
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 =
|
|
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) {
|
|
@@ -3964,7 +3914,10 @@ function renderEmbed(value, attributes, renderers, blockHandlers, options) {
|
|
|
3964
3914
|
return "";
|
|
3965
3915
|
}
|
|
3966
3916
|
const embedValue = value[embedType];
|
|
3967
|
-
const embedContext =
|
|
3917
|
+
const embedContext = {
|
|
3918
|
+
...options?.embed != null ? { embed: options.embed } : {},
|
|
3919
|
+
...options?.codeWidgetEmbedUrl != null ? { codeWidgetEmbedUrl: options.codeWidgetEmbedUrl } : {}
|
|
3920
|
+
};
|
|
3968
3921
|
const registry = options?.registry;
|
|
3969
3922
|
if (registry) {
|
|
3970
3923
|
const format = registry.get(embedType);
|
|
@@ -4798,7 +4751,8 @@ function deltaToMarkdown(delta, options = {}) {
|
|
|
4798
4751
|
prettyHtml = false,
|
|
4799
4752
|
registry,
|
|
4800
4753
|
softBreakStyle = "spaces",
|
|
4801
|
-
trimTrailingNewlines = false
|
|
4754
|
+
trimTrailingNewlines = false,
|
|
4755
|
+
codeWidgetEmbedUrl
|
|
4802
4756
|
} = options;
|
|
4803
4757
|
const useLatexDelimiters = mathSyntax === "latex";
|
|
4804
4758
|
const lines = splitIntoLines2(delta.ops);
|
|
@@ -4840,7 +4794,9 @@ function deltaToMarkdown(delta, options = {}) {
|
|
|
4840
4794
|
blockHandlers,
|
|
4841
4795
|
false,
|
|
4842
4796
|
registry,
|
|
4843
|
-
softBreakStyle
|
|
4797
|
+
softBreakStyle,
|
|
4798
|
+
false,
|
|
4799
|
+
codeWidgetEmbedUrl
|
|
4844
4800
|
)
|
|
4845
4801
|
).join("\n");
|
|
4846
4802
|
if (language === "math") {
|
|
@@ -4892,7 +4848,9 @@ ${code}
|
|
|
4892
4848
|
blockHandlers,
|
|
4893
4849
|
prettyHtml,
|
|
4894
4850
|
registry,
|
|
4895
|
-
softBreakStyle
|
|
4851
|
+
softBreakStyle,
|
|
4852
|
+
false,
|
|
4853
|
+
codeWidgetEmbedUrl
|
|
4896
4854
|
);
|
|
4897
4855
|
if (!content && !hasBlockFormat(attrs)) {
|
|
4898
4856
|
result.push(preserveEmptyLines ? "<br>" : "");
|
|
@@ -5116,7 +5074,7 @@ function getCodeBlockId2(attributes) {
|
|
|
5116
5074
|
const id = attributes["code-block-id"];
|
|
5117
5075
|
return typeof id === "string" ? id : void 0;
|
|
5118
5076
|
}
|
|
5119
|
-
function renderLineContent2(ops, embedRenderers, inCodeBlock, useLatexDelimiters = false, blockHandlers, prettyHtml = false, registry, softBreakStyle = "spaces", inTableCell = false) {
|
|
5077
|
+
function renderLineContent2(ops, embedRenderers, inCodeBlock, useLatexDelimiters = false, blockHandlers, prettyHtml = false, registry, softBreakStyle = "spaces", inTableCell = false, codeWidgetEmbedUrl) {
|
|
5120
5078
|
let result = "";
|
|
5121
5079
|
for (const op of ops) {
|
|
5122
5080
|
const attrs = op.attributes;
|
|
@@ -5138,7 +5096,8 @@ function renderLineContent2(ops, embedRenderers, inCodeBlock, useLatexDelimiters
|
|
|
5138
5096
|
prettyHtml,
|
|
5139
5097
|
registry,
|
|
5140
5098
|
softBreakStyle,
|
|
5141
|
-
inTableCell
|
|
5099
|
+
inTableCell,
|
|
5100
|
+
codeWidgetEmbedUrl
|
|
5142
5101
|
);
|
|
5143
5102
|
}
|
|
5144
5103
|
}
|
|
@@ -5172,7 +5131,7 @@ function renderInlineText2(text, attributes) {
|
|
|
5172
5131
|
}
|
|
5173
5132
|
return result;
|
|
5174
5133
|
}
|
|
5175
|
-
function renderEmbed2(embed, attributes, customRenderers, useLatexDelimiters = false, blockHandlers, prettyHtml = false, registry, softBreakStyle = "spaces", inTableCell = false) {
|
|
5134
|
+
function renderEmbed2(embed, attributes, customRenderers, useLatexDelimiters = false, blockHandlers, prettyHtml = false, registry, softBreakStyle = "spaces", inTableCell = false, codeWidgetEmbedUrl) {
|
|
5176
5135
|
const entries = Object.entries(embed);
|
|
5177
5136
|
if (entries.length === 0) return "";
|
|
5178
5137
|
const firstEntry = entries[0];
|
|
@@ -5221,7 +5180,11 @@ function renderEmbed2(embed, attributes, customRenderers, useLatexDelimiters = f
|
|
|
5221
5180
|
if (md !== null) return md;
|
|
5222
5181
|
}
|
|
5223
5182
|
if (format.render) {
|
|
5224
|
-
return format.render(
|
|
5183
|
+
return format.render(
|
|
5184
|
+
embedValue,
|
|
5185
|
+
attributes,
|
|
5186
|
+
codeWidgetEmbedUrl != null ? { codeWidgetEmbedUrl } : void 0
|
|
5187
|
+
);
|
|
5225
5188
|
}
|
|
5226
5189
|
}
|
|
5227
5190
|
}
|
|
@@ -5282,7 +5245,7 @@ function renderEmbed2(embed, attributes, customRenderers, useLatexDelimiters = f
|
|
|
5282
5245
|
if (h && h !== "auto") styles.push(`height: ${/^\d+$/.test(h) ? h + "px" : h}`);
|
|
5283
5246
|
}
|
|
5284
5247
|
const styleAttr = styles.length > 0 ? ` style="${styles.join("; ")}"` : "";
|
|
5285
|
-
const embedSrc =
|
|
5248
|
+
const embedSrc = codeWidgetEmbedUrl ? codeWidgetEmbedUrl(src) : src;
|
|
5286
5249
|
return `<iframe data-code-widget src="${escapeHtml(embedSrc)}" frameborder="0" allowfullscreen${floatAttr}${styleAttr}></iframe>`;
|
|
5287
5250
|
}
|
|
5288
5251
|
return ``;
|
|
@@ -6275,6 +6238,7 @@ export {
|
|
|
6275
6238
|
parseScriderMarginEm,
|
|
6276
6239
|
preloadRemark,
|
|
6277
6240
|
renderDelta,
|
|
6241
|
+
resolveCodeWidgetEmbedSrc,
|
|
6278
6242
|
resolveDocumentPresentation,
|
|
6279
6243
|
resolveHeadingPolicy,
|
|
6280
6244
|
resolveTablePresentation,
|