@scrider/formatter 1.4.2 → 1.4.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.d.cts CHANGED
@@ -1294,8 +1294,14 @@ declare function cloneDelta(delta: Delta): Delta;
1294
1294
 
1295
1295
  /** Per-paragraph line spacing stored on `\n` (Word paste, Settings Apply, toolbar). */
1296
1296
  declare const SCRIDER_LINE_HEIGHT_KEY = "scrider-line-height";
1297
+ /** Space after plain paragraph (`margin-bottom`) on `\n` (Settings Apply). */
1298
+ declare const SCRIDER_MARGIN_AFTER_KEY = "scrider-margin-after";
1299
+ /** Space before plain paragraph (`margin-top`) on `\n` (Settings Apply). */
1300
+ declare const SCRIDER_MARGIN_BEFORE_KEY = "scrider-margin-before";
1297
1301
  /** Block tags that receive line spacing (not headings). */
1298
1302
  declare const LINE_HEIGHT_BLOCK_TAGS: Set<string>;
1303
+ /** Block tags that receive paragraph spacing after (plain `<p>` only). */
1304
+ declare const PARAGRAPH_SPACING_BLOCK_TAGS: Set<string>;
1299
1305
  /**
1300
1306
  * Parse a line-height multiplier from Delta / inline CSS values
1301
1307
  * (`1.5`, `2`, `150%`).
@@ -1305,16 +1311,43 @@ declare function parseScriderLineHeightMultiplier(value: string): number | undef
1305
1311
  * Line-height for a block tag: `scrider-line-height` on the line → documentPresentation → none.
1306
1312
  */
1307
1313
  declare function blockLineHeightStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
1314
+ /**
1315
+ * Parse paragraph margin in em from Delta / inline CSS (`0.5em`, `0.5`).
1316
+ */
1317
+ declare function parseScriderMarginEm(value: string): number | undefined;
1318
+ /** Same parser as {@link parseScriderMarginEm} for margin-after values. */
1319
+ declare const parseScriderMarginAfterEm: typeof parseScriderMarginEm;
1320
+ /** Same parser as {@link parseScriderMarginEm} for margin-before values. */
1321
+ declare const parseScriderMarginBeforeEm: typeof parseScriderMarginEm;
1322
+ /**
1323
+ * Paragraph spacing before/after on plain `<p>`: block attrs → documentPresentation → none.
1324
+ * When only after is set, adds `margin-top:0` for Word paste compatibility.
1325
+ */
1326
+ declare function blockParagraphMarginStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
1327
+ /**
1328
+ * Paragraph spacing after: `scrider-margin-after` on the line → documentPresentation → none.
1329
+ */
1330
+ declare function blockMarginAfterStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
1331
+ /**
1332
+ * Paragraph spacing before: `scrider-margin-before` on the line → documentPresentation → none.
1333
+ */
1334
+ declare function blockMarginBeforeStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
1308
1335
 
1309
1336
  /**
1310
1337
  * Document-level HTML presentation for deltaToHtml (clipboard, export).
1311
1338
  * Mirrors editor Settings when block attrs are absent.
1312
1339
  * Per-block line spacing: {@link blockLineHeightStyleParts} (`scrider-line-height` on `\n`).
1340
+ * Per-block paragraph spacing: {@link blockParagraphMarginStyleParts}
1341
+ * (`scrider-margin-before` / `scrider-margin-after` on `\n`).
1313
1342
  */
1314
1343
 
1315
1344
  interface DocumentPresentation {
1316
1345
  /** Line spacing multiplier, e.g. 1.5 */
1317
1346
  lineSpacing?: number;
1347
+ /** Space after plain paragraphs in em, e.g. 0.5 */
1348
+ paragraphSpacingAfterEm?: number;
1349
+ /** Space before plain paragraphs in em, e.g. 0.5 */
1350
+ paragraphSpacingBeforeEm?: number;
1318
1351
  /** First-line indent in cm on `<p>` only (lists: use listBlockIndentCm). */
1319
1352
  textIndentCm?: number;
1320
1353
  /** Extra left padding on top-level `<ul>`/`<ol>` — shifts marker + text as a block. */
@@ -1322,6 +1355,8 @@ interface DocumentPresentation {
1322
1355
  }
1323
1356
  interface ResolvedDocumentPresentation {
1324
1357
  lineSpacing: number | undefined;
1358
+ paragraphSpacingAfterEm: number | undefined;
1359
+ paragraphSpacingBeforeEm: number | undefined;
1325
1360
  textIndentCm: number | undefined;
1326
1361
  listBlockIndentCm: number | undefined;
1327
1362
  }
@@ -1909,4 +1944,4 @@ declare function isTableNewlineOp(op: Op | undefined): boolean;
1909
1944
  */
1910
1945
  declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
1911
1946
 
1912
- 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 ColumnsBlockData, type DOMAdapter, type DOMDocument, type DOMDocumentFragment, type DOMElement, type DOMNode, type DOMNodeList, type DeltaToHtmlOptions, type DeltaToMarkdownOptions, type DocumentPresentation, type FootnotesBlockData, type Format, type FormatDefinition, type FormatMatchResult, type FormatScope, type HtmlToDeltaOptions, LINE_HEIGHT_BLOCK_TAGS, type ListType, type MarkdownToDeltaOptions, NODE_TYPE, NodeDOMAdapter, Registry, type ResolvedDocumentPresentation, type ResolvedTablePresentation, SCRIDER_LINE_HEIGHT_KEY, type SanitizeOptions, type TableBlockData, type TableCellAlign, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockPresentationStyleParts, blockquoteFormat, boldFormat, boxBlockHandler, browserAdapter, cloneDelta, codeBlockFormat, codeFormat, colorFormat, columnsBlockHandler, createDefaultBlockHandlers, createDefaultRegistry, defaultBlockFormats, defaultEmbedFormats, defaultFormats, defaultInlineFormats, deltaToHtml, deltaToMarkdown, dividerFormat, documentPresentationStyleParts, escapeHtml, extractBoxOpAttributes, extractTableRegion, fontFormat, footnoteRefFormat, footnotesBlockHandler, formulaFormat, getAdapter, getNamedColors, headerFormat, headerIdFormat, htmlToDelta, imageFormat, indentFormat, isAdapterAvailable, isElement, isRemarkAvailable, isTableNewlineOp, isTextNode, isValidColor, isValidHexColor, isZebraBodyRow, italicFormat, kbdFormat, linkFormat, listFormat, markFormat, markdownToDelta, markdownToDeltaSync, nodeAdapter, normalizeDelta, parseScriderLineHeightMultiplier, preloadRemark, resolveDocumentPresentation, resolveTablePresentation, sanitizeDelta, sizeFormat, slugify, slugifyWithDedup, softBreakFormat, strikeFormat, subscriptFormat, superscriptFormat, tableBlockHandler, tableColAlignFormat, tableColFormat, tableHeaderFormat, tableRowFormat, toHexColor, underlineFormat, unescapeHtml, validateDelta, videoFormat };
1947
+ 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 ColumnsBlockData, type DOMAdapter, type DOMDocument, type DOMDocumentFragment, type DOMElement, type DOMNode, type DOMNodeList, type DeltaToHtmlOptions, type DeltaToMarkdownOptions, type DocumentPresentation, type FootnotesBlockData, type Format, type FormatDefinition, type FormatMatchResult, 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 TableBlockData, type TableCellAlign, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockMarginAfterStyleParts, blockMarginBeforeStyleParts, blockParagraphMarginStyleParts, blockPresentationStyleParts, blockquoteFormat, boldFormat, boxBlockHandler, browserAdapter, cloneDelta, codeBlockFormat, codeFormat, colorFormat, columnsBlockHandler, createDefaultBlockHandlers, createDefaultRegistry, defaultBlockFormats, defaultEmbedFormats, defaultFormats, defaultInlineFormats, deltaToHtml, deltaToMarkdown, dividerFormat, documentPresentationStyleParts, escapeHtml, extractBoxOpAttributes, extractTableRegion, fontFormat, footnoteRefFormat, footnotesBlockHandler, formulaFormat, getAdapter, getNamedColors, headerFormat, headerIdFormat, htmlToDelta, imageFormat, indentFormat, isAdapterAvailable, 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, tableColAlignFormat, tableColFormat, tableHeaderFormat, tableRowFormat, toHexColor, underlineFormat, unescapeHtml, validateDelta, videoFormat };
package/dist/index.d.ts CHANGED
@@ -1294,8 +1294,14 @@ declare function cloneDelta(delta: Delta): Delta;
1294
1294
 
1295
1295
  /** Per-paragraph line spacing stored on `\n` (Word paste, Settings Apply, toolbar). */
1296
1296
  declare const SCRIDER_LINE_HEIGHT_KEY = "scrider-line-height";
1297
+ /** Space after plain paragraph (`margin-bottom`) on `\n` (Settings Apply). */
1298
+ declare const SCRIDER_MARGIN_AFTER_KEY = "scrider-margin-after";
1299
+ /** Space before plain paragraph (`margin-top`) on `\n` (Settings Apply). */
1300
+ declare const SCRIDER_MARGIN_BEFORE_KEY = "scrider-margin-before";
1297
1301
  /** Block tags that receive line spacing (not headings). */
1298
1302
  declare const LINE_HEIGHT_BLOCK_TAGS: Set<string>;
1303
+ /** Block tags that receive paragraph spacing after (plain `<p>` only). */
1304
+ declare const PARAGRAPH_SPACING_BLOCK_TAGS: Set<string>;
1299
1305
  /**
1300
1306
  * Parse a line-height multiplier from Delta / inline CSS values
1301
1307
  * (`1.5`, `2`, `150%`).
@@ -1305,16 +1311,43 @@ declare function parseScriderLineHeightMultiplier(value: string): number | undef
1305
1311
  * Line-height for a block tag: `scrider-line-height` on the line → documentPresentation → none.
1306
1312
  */
1307
1313
  declare function blockLineHeightStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
1314
+ /**
1315
+ * Parse paragraph margin in em from Delta / inline CSS (`0.5em`, `0.5`).
1316
+ */
1317
+ declare function parseScriderMarginEm(value: string): number | undefined;
1318
+ /** Same parser as {@link parseScriderMarginEm} for margin-after values. */
1319
+ declare const parseScriderMarginAfterEm: typeof parseScriderMarginEm;
1320
+ /** Same parser as {@link parseScriderMarginEm} for margin-before values. */
1321
+ declare const parseScriderMarginBeforeEm: typeof parseScriderMarginEm;
1322
+ /**
1323
+ * Paragraph spacing before/after on plain `<p>`: block attrs → documentPresentation → none.
1324
+ * When only after is set, adds `margin-top:0` for Word paste compatibility.
1325
+ */
1326
+ declare function blockParagraphMarginStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
1327
+ /**
1328
+ * Paragraph spacing after: `scrider-margin-after` on the line → documentPresentation → none.
1329
+ */
1330
+ declare function blockMarginAfterStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
1331
+ /**
1332
+ * Paragraph spacing before: `scrider-margin-before` on the line → documentPresentation → none.
1333
+ */
1334
+ declare function blockMarginBeforeStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
1308
1335
 
1309
1336
  /**
1310
1337
  * Document-level HTML presentation for deltaToHtml (clipboard, export).
1311
1338
  * Mirrors editor Settings when block attrs are absent.
1312
1339
  * Per-block line spacing: {@link blockLineHeightStyleParts} (`scrider-line-height` on `\n`).
1340
+ * Per-block paragraph spacing: {@link blockParagraphMarginStyleParts}
1341
+ * (`scrider-margin-before` / `scrider-margin-after` on `\n`).
1313
1342
  */
1314
1343
 
1315
1344
  interface DocumentPresentation {
1316
1345
  /** Line spacing multiplier, e.g. 1.5 */
1317
1346
  lineSpacing?: number;
1347
+ /** Space after plain paragraphs in em, e.g. 0.5 */
1348
+ paragraphSpacingAfterEm?: number;
1349
+ /** Space before plain paragraphs in em, e.g. 0.5 */
1350
+ paragraphSpacingBeforeEm?: number;
1318
1351
  /** First-line indent in cm on `<p>` only (lists: use listBlockIndentCm). */
1319
1352
  textIndentCm?: number;
1320
1353
  /** Extra left padding on top-level `<ul>`/`<ol>` — shifts marker + text as a block. */
@@ -1322,6 +1355,8 @@ interface DocumentPresentation {
1322
1355
  }
1323
1356
  interface ResolvedDocumentPresentation {
1324
1357
  lineSpacing: number | undefined;
1358
+ paragraphSpacingAfterEm: number | undefined;
1359
+ paragraphSpacingBeforeEm: number | undefined;
1325
1360
  textIndentCm: number | undefined;
1326
1361
  listBlockIndentCm: number | undefined;
1327
1362
  }
@@ -1909,4 +1944,4 @@ declare function isTableNewlineOp(op: Op | undefined): boolean;
1909
1944
  */
1910
1945
  declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
1911
1946
 
1912
- 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 ColumnsBlockData, type DOMAdapter, type DOMDocument, type DOMDocumentFragment, type DOMElement, type DOMNode, type DOMNodeList, type DeltaToHtmlOptions, type DeltaToMarkdownOptions, type DocumentPresentation, type FootnotesBlockData, type Format, type FormatDefinition, type FormatMatchResult, type FormatScope, type HtmlToDeltaOptions, LINE_HEIGHT_BLOCK_TAGS, type ListType, type MarkdownToDeltaOptions, NODE_TYPE, NodeDOMAdapter, Registry, type ResolvedDocumentPresentation, type ResolvedTablePresentation, SCRIDER_LINE_HEIGHT_KEY, type SanitizeOptions, type TableBlockData, type TableCellAlign, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockPresentationStyleParts, blockquoteFormat, boldFormat, boxBlockHandler, browserAdapter, cloneDelta, codeBlockFormat, codeFormat, colorFormat, columnsBlockHandler, createDefaultBlockHandlers, createDefaultRegistry, defaultBlockFormats, defaultEmbedFormats, defaultFormats, defaultInlineFormats, deltaToHtml, deltaToMarkdown, dividerFormat, documentPresentationStyleParts, escapeHtml, extractBoxOpAttributes, extractTableRegion, fontFormat, footnoteRefFormat, footnotesBlockHandler, formulaFormat, getAdapter, getNamedColors, headerFormat, headerIdFormat, htmlToDelta, imageFormat, indentFormat, isAdapterAvailable, isElement, isRemarkAvailable, isTableNewlineOp, isTextNode, isValidColor, isValidHexColor, isZebraBodyRow, italicFormat, kbdFormat, linkFormat, listFormat, markFormat, markdownToDelta, markdownToDeltaSync, nodeAdapter, normalizeDelta, parseScriderLineHeightMultiplier, preloadRemark, resolveDocumentPresentation, resolveTablePresentation, sanitizeDelta, sizeFormat, slugify, slugifyWithDedup, softBreakFormat, strikeFormat, subscriptFormat, superscriptFormat, tableBlockHandler, tableColAlignFormat, tableColFormat, tableHeaderFormat, tableRowFormat, toHexColor, underlineFormat, unescapeHtml, validateDelta, videoFormat };
1947
+ 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 ColumnsBlockData, type DOMAdapter, type DOMDocument, type DOMDocumentFragment, type DOMElement, type DOMNode, type DOMNodeList, type DeltaToHtmlOptions, type DeltaToMarkdownOptions, type DocumentPresentation, type FootnotesBlockData, type Format, type FormatDefinition, type FormatMatchResult, 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 TableBlockData, type TableCellAlign, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockMarginAfterStyleParts, blockMarginBeforeStyleParts, blockParagraphMarginStyleParts, blockPresentationStyleParts, blockquoteFormat, boldFormat, boxBlockHandler, browserAdapter, cloneDelta, codeBlockFormat, codeFormat, colorFormat, columnsBlockHandler, createDefaultBlockHandlers, createDefaultRegistry, defaultBlockFormats, defaultEmbedFormats, defaultFormats, defaultInlineFormats, deltaToHtml, deltaToMarkdown, dividerFormat, documentPresentationStyleParts, escapeHtml, extractBoxOpAttributes, extractTableRegion, fontFormat, footnoteRefFormat, footnotesBlockHandler, formulaFormat, getAdapter, getNamedColors, headerFormat, headerIdFormat, htmlToDelta, imageFormat, indentFormat, isAdapterAvailable, 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, tableColAlignFormat, tableColFormat, tableHeaderFormat, tableRowFormat, toHexColor, underlineFormat, unescapeHtml, validateDelta, videoFormat };
package/dist/index.js CHANGED
@@ -2495,7 +2495,10 @@ function slugifyWithDedup(text, usedSlugs) {
2495
2495
 
2496
2496
  // src/conversion/html/block-presentation.ts
2497
2497
  var SCRIDER_LINE_HEIGHT_KEY = "scrider-line-height";
2498
+ var SCRIDER_MARGIN_AFTER_KEY = "scrider-margin-after";
2499
+ var SCRIDER_MARGIN_BEFORE_KEY = "scrider-margin-before";
2498
2500
  var LINE_HEIGHT_BLOCK_TAGS = /* @__PURE__ */ new Set(["p", "li", "blockquote"]);
2501
+ var PARAGRAPH_SPACING_BLOCK_TAGS = /* @__PURE__ */ new Set(["p"]);
2499
2502
  function parseScriderLineHeightMultiplier(value) {
2500
2503
  const trimmed = value.trim();
2501
2504
  if (!trimmed) return void 0;
@@ -2524,6 +2527,73 @@ function blockLineHeightStyleParts(tag, blockAttributes, resolved) {
2524
2527
  }
2525
2528
  return [];
2526
2529
  }
2530
+ function parseScriderMarginEm(value) {
2531
+ const trimmed = value.trim();
2532
+ if (!trimmed) return void 0;
2533
+ const emMatch = trimmed.match(/^(-?\d+(?:\.\d+)?)\s*em$/i);
2534
+ if (emMatch) {
2535
+ const n2 = Number.parseFloat(emMatch[1]);
2536
+ if (Number.isFinite(n2) && n2 >= 0) return n2;
2537
+ return void 0;
2538
+ }
2539
+ const n = Number.parseFloat(trimmed);
2540
+ if (Number.isFinite(n) && n >= 0) return n;
2541
+ return void 0;
2542
+ }
2543
+ var parseScriderMarginAfterEm = parseScriderMarginEm;
2544
+ var parseScriderMarginBeforeEm = parseScriderMarginEm;
2545
+ function resolveParagraphMarginEm(blockAttributes, blockKey, documentEm) {
2546
+ const raw = blockAttributes?.[blockKey];
2547
+ if (typeof raw === "string") {
2548
+ const fromBlock = parseScriderMarginEm(raw);
2549
+ if (fromBlock !== void 0) return fromBlock;
2550
+ }
2551
+ return documentEm;
2552
+ }
2553
+ function blockParagraphMarginStyleParts(tag, blockAttributes, resolved) {
2554
+ if (!PARAGRAPH_SPACING_BLOCK_TAGS.has(tag)) return [];
2555
+ const marginTop = resolveParagraphMarginEm(
2556
+ blockAttributes,
2557
+ SCRIDER_MARGIN_BEFORE_KEY,
2558
+ resolved?.paragraphSpacingBeforeEm
2559
+ );
2560
+ const marginBottom = resolveParagraphMarginEm(
2561
+ blockAttributes,
2562
+ SCRIDER_MARGIN_AFTER_KEY,
2563
+ resolved?.paragraphSpacingAfterEm
2564
+ );
2565
+ if (marginTop === void 0 && marginBottom === void 0) return [];
2566
+ const parts = [];
2567
+ if (marginTop !== void 0) {
2568
+ parts.push(`margin-top:${marginTop}em`);
2569
+ } else if (marginBottom !== void 0) {
2570
+ parts.push("margin-top:0");
2571
+ }
2572
+ if (marginBottom !== void 0) {
2573
+ parts.push(`margin-bottom:${marginBottom}em`);
2574
+ }
2575
+ return parts;
2576
+ }
2577
+ function blockMarginAfterStyleParts(tag, blockAttributes, resolved) {
2578
+ if (!PARAGRAPH_SPACING_BLOCK_TAGS.has(tag)) return [];
2579
+ const marginBottom = resolveParagraphMarginEm(
2580
+ blockAttributes,
2581
+ SCRIDER_MARGIN_AFTER_KEY,
2582
+ resolved?.paragraphSpacingAfterEm
2583
+ );
2584
+ if (marginBottom === void 0) return [];
2585
+ return ["margin-top:0", `margin-bottom:${marginBottom}em`];
2586
+ }
2587
+ function blockMarginBeforeStyleParts(tag, blockAttributes, resolved) {
2588
+ if (!PARAGRAPH_SPACING_BLOCK_TAGS.has(tag)) return [];
2589
+ const marginTop = resolveParagraphMarginEm(
2590
+ blockAttributes,
2591
+ SCRIDER_MARGIN_BEFORE_KEY,
2592
+ resolved?.paragraphSpacingBeforeEm
2593
+ );
2594
+ if (marginTop === void 0) return [];
2595
+ return [`margin-top:${marginTop}em`];
2596
+ }
2527
2597
 
2528
2598
  // src/conversion/html/document-presentation.ts
2529
2599
  function resolveDocumentPresentation(presentation) {
@@ -2531,10 +2601,18 @@ function resolveDocumentPresentation(presentation) {
2531
2601
  const lineSpacing = typeof presentation.lineSpacing === "number" && presentation.lineSpacing > 0 ? presentation.lineSpacing : void 0;
2532
2602
  const textIndentCm = typeof presentation.textIndentCm === "number" && presentation.textIndentCm > 0 ? presentation.textIndentCm : void 0;
2533
2603
  const listBlockIndentCm = typeof presentation.listBlockIndentCm === "number" && presentation.listBlockIndentCm > 0 ? presentation.listBlockIndentCm : void 0;
2534
- if (lineSpacing === void 0 && textIndentCm === void 0 && listBlockIndentCm === void 0) {
2604
+ const paragraphSpacingAfterEm = typeof presentation.paragraphSpacingAfterEm === "number" && Number.isFinite(presentation.paragraphSpacingAfterEm) && presentation.paragraphSpacingAfterEm >= 0 ? presentation.paragraphSpacingAfterEm : void 0;
2605
+ const paragraphSpacingBeforeEm = typeof presentation.paragraphSpacingBeforeEm === "number" && Number.isFinite(presentation.paragraphSpacingBeforeEm) && presentation.paragraphSpacingBeforeEm >= 0 ? presentation.paragraphSpacingBeforeEm : void 0;
2606
+ if (lineSpacing === void 0 && paragraphSpacingAfterEm === void 0 && paragraphSpacingBeforeEm === void 0 && textIndentCm === void 0 && listBlockIndentCm === void 0) {
2535
2607
  return void 0;
2536
2608
  }
2537
- return { lineSpacing, textIndentCm, listBlockIndentCm };
2609
+ return {
2610
+ lineSpacing,
2611
+ paragraphSpacingAfterEm,
2612
+ paragraphSpacingBeforeEm,
2613
+ textIndentCm,
2614
+ listBlockIndentCm
2615
+ };
2538
2616
  }
2539
2617
  var TEXT_INDENT_TAGS = /* @__PURE__ */ new Set(["p"]);
2540
2618
  function documentPresentationListWrapperStyleParts(resolved) {
@@ -2552,6 +2630,7 @@ function documentPresentationStyleParts(tag, resolved) {
2552
2630
  function blockPresentationStyleParts(tag, blockAttributes, resolved) {
2553
2631
  return [
2554
2632
  ...blockLineHeightStyleParts(tag, blockAttributes, resolved),
2633
+ ...blockParagraphMarginStyleParts(tag, blockAttributes, resolved),
2555
2634
  ...documentPresentationStyleParts(tag, resolved)
2556
2635
  ];
2557
2636
  }
@@ -5186,13 +5265,19 @@ export {
5186
5265
  LINE_HEIGHT_BLOCK_TAGS,
5187
5266
  NODE_TYPE,
5188
5267
  NodeDOMAdapter,
5268
+ PARAGRAPH_SPACING_BLOCK_TAGS,
5189
5269
  Registry,
5190
5270
  SCRIDER_LINE_HEIGHT_KEY,
5271
+ SCRIDER_MARGIN_AFTER_KEY,
5272
+ SCRIDER_MARGIN_BEFORE_KEY,
5191
5273
  alertBlockHandler,
5192
5274
  alignFormat,
5193
5275
  backgroundFormat,
5194
5276
  blockFormat,
5195
5277
  blockLineHeightStyleParts,
5278
+ blockMarginAfterStyleParts,
5279
+ blockMarginBeforeStyleParts,
5280
+ blockParagraphMarginStyleParts,
5196
5281
  blockPresentationStyleParts,
5197
5282
  blockquoteFormat,
5198
5283
  boldFormat,
@@ -5245,6 +5330,9 @@ export {
5245
5330
  nodeAdapter,
5246
5331
  normalizeDelta,
5247
5332
  parseScriderLineHeightMultiplier,
5333
+ parseScriderMarginAfterEm,
5334
+ parseScriderMarginBeforeEm,
5335
+ parseScriderMarginEm,
5248
5336
  preloadRemark,
5249
5337
  resolveDocumentPresentation,
5250
5338
  resolveTablePresentation,