@scrider/formatter 1.4.3 → 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.cjs +71 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -4
- package/dist/index.d.ts +23 -4
- package/dist/index.js +66 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1296,6 +1296,8 @@ declare function cloneDelta(delta: Delta): Delta;
|
|
|
1296
1296
|
declare const SCRIDER_LINE_HEIGHT_KEY = "scrider-line-height";
|
|
1297
1297
|
/** Space after plain paragraph (`margin-bottom`) on `\n` (Settings Apply). */
|
|
1298
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";
|
|
1299
1301
|
/** Block tags that receive line spacing (not headings). */
|
|
1300
1302
|
declare const LINE_HEIGHT_BLOCK_TAGS: Set<string>;
|
|
1301
1303
|
/** Block tags that receive paragraph spacing after (plain `<p>` only). */
|
|
@@ -1310,19 +1312,33 @@ declare function parseScriderLineHeightMultiplier(value: string): number | undef
|
|
|
1310
1312
|
*/
|
|
1311
1313
|
declare function blockLineHeightStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
|
|
1312
1314
|
/**
|
|
1313
|
-
* Parse
|
|
1315
|
+
* Parse paragraph margin in em from Delta / inline CSS (`0.5em`, `0.5`).
|
|
1314
1316
|
*/
|
|
1315
|
-
declare function
|
|
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[];
|
|
1316
1327
|
/**
|
|
1317
1328
|
* Paragraph spacing after: `scrider-margin-after` on the line → documentPresentation → none.
|
|
1318
1329
|
*/
|
|
1319
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[];
|
|
1320
1335
|
|
|
1321
1336
|
/**
|
|
1322
1337
|
* Document-level HTML presentation for deltaToHtml (clipboard, export).
|
|
1323
1338
|
* Mirrors editor Settings when block attrs are absent.
|
|
1324
1339
|
* Per-block line spacing: {@link blockLineHeightStyleParts} (`scrider-line-height` on `\n`).
|
|
1325
|
-
* Per-block paragraph spacing: {@link
|
|
1340
|
+
* Per-block paragraph spacing: {@link blockParagraphMarginStyleParts}
|
|
1341
|
+
* (`scrider-margin-before` / `scrider-margin-after` on `\n`).
|
|
1326
1342
|
*/
|
|
1327
1343
|
|
|
1328
1344
|
interface DocumentPresentation {
|
|
@@ -1330,6 +1346,8 @@ interface DocumentPresentation {
|
|
|
1330
1346
|
lineSpacing?: number;
|
|
1331
1347
|
/** Space after plain paragraphs in em, e.g. 0.5 */
|
|
1332
1348
|
paragraphSpacingAfterEm?: number;
|
|
1349
|
+
/** Space before plain paragraphs in em, e.g. 0.5 */
|
|
1350
|
+
paragraphSpacingBeforeEm?: number;
|
|
1333
1351
|
/** First-line indent in cm on `<p>` only (lists: use listBlockIndentCm). */
|
|
1334
1352
|
textIndentCm?: number;
|
|
1335
1353
|
/** Extra left padding on top-level `<ul>`/`<ol>` — shifts marker + text as a block. */
|
|
@@ -1338,6 +1356,7 @@ interface DocumentPresentation {
|
|
|
1338
1356
|
interface ResolvedDocumentPresentation {
|
|
1339
1357
|
lineSpacing: number | undefined;
|
|
1340
1358
|
paragraphSpacingAfterEm: number | undefined;
|
|
1359
|
+
paragraphSpacingBeforeEm: number | undefined;
|
|
1341
1360
|
textIndentCm: number | undefined;
|
|
1342
1361
|
listBlockIndentCm: number | undefined;
|
|
1343
1362
|
}
|
|
@@ -1925,4 +1944,4 @@ declare function isTableNewlineOp(op: Op | undefined): boolean;
|
|
|
1925
1944
|
*/
|
|
1926
1945
|
declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
|
|
1927
1946
|
|
|
1928
|
-
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, type SanitizeOptions, type TableBlockData, type TableCellAlign, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockMarginAfterStyleParts, 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, 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
|
@@ -1296,6 +1296,8 @@ declare function cloneDelta(delta: Delta): Delta;
|
|
|
1296
1296
|
declare const SCRIDER_LINE_HEIGHT_KEY = "scrider-line-height";
|
|
1297
1297
|
/** Space after plain paragraph (`margin-bottom`) on `\n` (Settings Apply). */
|
|
1298
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";
|
|
1299
1301
|
/** Block tags that receive line spacing (not headings). */
|
|
1300
1302
|
declare const LINE_HEIGHT_BLOCK_TAGS: Set<string>;
|
|
1301
1303
|
/** Block tags that receive paragraph spacing after (plain `<p>` only). */
|
|
@@ -1310,19 +1312,33 @@ declare function parseScriderLineHeightMultiplier(value: string): number | undef
|
|
|
1310
1312
|
*/
|
|
1311
1313
|
declare function blockLineHeightStyleParts(tag: string, blockAttributes: AttributeMap | undefined, resolved: ResolvedDocumentPresentation | undefined): string[];
|
|
1312
1314
|
/**
|
|
1313
|
-
* Parse
|
|
1315
|
+
* Parse paragraph margin in em from Delta / inline CSS (`0.5em`, `0.5`).
|
|
1314
1316
|
*/
|
|
1315
|
-
declare function
|
|
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[];
|
|
1316
1327
|
/**
|
|
1317
1328
|
* Paragraph spacing after: `scrider-margin-after` on the line → documentPresentation → none.
|
|
1318
1329
|
*/
|
|
1319
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[];
|
|
1320
1335
|
|
|
1321
1336
|
/**
|
|
1322
1337
|
* Document-level HTML presentation for deltaToHtml (clipboard, export).
|
|
1323
1338
|
* Mirrors editor Settings when block attrs are absent.
|
|
1324
1339
|
* Per-block line spacing: {@link blockLineHeightStyleParts} (`scrider-line-height` on `\n`).
|
|
1325
|
-
* Per-block paragraph spacing: {@link
|
|
1340
|
+
* Per-block paragraph spacing: {@link blockParagraphMarginStyleParts}
|
|
1341
|
+
* (`scrider-margin-before` / `scrider-margin-after` on `\n`).
|
|
1326
1342
|
*/
|
|
1327
1343
|
|
|
1328
1344
|
interface DocumentPresentation {
|
|
@@ -1330,6 +1346,8 @@ interface DocumentPresentation {
|
|
|
1330
1346
|
lineSpacing?: number;
|
|
1331
1347
|
/** Space after plain paragraphs in em, e.g. 0.5 */
|
|
1332
1348
|
paragraphSpacingAfterEm?: number;
|
|
1349
|
+
/** Space before plain paragraphs in em, e.g. 0.5 */
|
|
1350
|
+
paragraphSpacingBeforeEm?: number;
|
|
1333
1351
|
/** First-line indent in cm on `<p>` only (lists: use listBlockIndentCm). */
|
|
1334
1352
|
textIndentCm?: number;
|
|
1335
1353
|
/** Extra left padding on top-level `<ul>`/`<ol>` — shifts marker + text as a block. */
|
|
@@ -1338,6 +1356,7 @@ interface DocumentPresentation {
|
|
|
1338
1356
|
interface ResolvedDocumentPresentation {
|
|
1339
1357
|
lineSpacing: number | undefined;
|
|
1340
1358
|
paragraphSpacingAfterEm: number | undefined;
|
|
1359
|
+
paragraphSpacingBeforeEm: number | undefined;
|
|
1341
1360
|
textIndentCm: number | undefined;
|
|
1342
1361
|
listBlockIndentCm: number | undefined;
|
|
1343
1362
|
}
|
|
@@ -1925,4 +1944,4 @@ declare function isTableNewlineOp(op: Op | undefined): boolean;
|
|
|
1925
1944
|
*/
|
|
1926
1945
|
declare function extractTableRegion(ops: readonly Op[], hintOpIdx: number): TableRegion | null;
|
|
1927
1946
|
|
|
1928
|
-
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, type SanitizeOptions, type TableBlockData, type TableCellAlign, type TableColAlignType, type TablePresentation, type TableRegion, alertBlockHandler, alignFormat, backgroundFormat, blockFormat, blockLineHeightStyleParts, blockMarginAfterStyleParts, 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, 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
|
@@ -2496,6 +2496,7 @@ function slugifyWithDedup(text, usedSlugs) {
|
|
|
2496
2496
|
// src/conversion/html/block-presentation.ts
|
|
2497
2497
|
var SCRIDER_LINE_HEIGHT_KEY = "scrider-line-height";
|
|
2498
2498
|
var SCRIDER_MARGIN_AFTER_KEY = "scrider-margin-after";
|
|
2499
|
+
var SCRIDER_MARGIN_BEFORE_KEY = "scrider-margin-before";
|
|
2499
2500
|
var LINE_HEIGHT_BLOCK_TAGS = /* @__PURE__ */ new Set(["p", "li", "blockquote"]);
|
|
2500
2501
|
var PARAGRAPH_SPACING_BLOCK_TAGS = /* @__PURE__ */ new Set(["p"]);
|
|
2501
2502
|
function parseScriderLineHeightMultiplier(value) {
|
|
@@ -2526,7 +2527,7 @@ function blockLineHeightStyleParts(tag, blockAttributes, resolved) {
|
|
|
2526
2527
|
}
|
|
2527
2528
|
return [];
|
|
2528
2529
|
}
|
|
2529
|
-
function
|
|
2530
|
+
function parseScriderMarginEm(value) {
|
|
2530
2531
|
const trimmed = value.trim();
|
|
2531
2532
|
if (!trimmed) return void 0;
|
|
2532
2533
|
const emMatch = trimmed.match(/^(-?\d+(?:\.\d+)?)\s*em$/i);
|
|
@@ -2539,20 +2540,59 @@ function parseScriderMarginAfterEm(value) {
|
|
|
2539
2540
|
if (Number.isFinite(n) && n >= 0) return n;
|
|
2540
2541
|
return void 0;
|
|
2541
2542
|
}
|
|
2542
|
-
|
|
2543
|
-
|
|
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;
|
|
2544
2552
|
}
|
|
2545
|
-
function
|
|
2553
|
+
function blockParagraphMarginStyleParts(tag, blockAttributes, resolved) {
|
|
2546
2554
|
if (!PARAGRAPH_SPACING_BLOCK_TAGS.has(tag)) return [];
|
|
2547
|
-
const
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
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");
|
|
2551
2571
|
}
|
|
2552
|
-
if (
|
|
2553
|
-
|
|
2572
|
+
if (marginBottom !== void 0) {
|
|
2573
|
+
parts.push(`margin-bottom:${marginBottom}em`);
|
|
2554
2574
|
}
|
|
2555
|
-
return
|
|
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`];
|
|
2556
2596
|
}
|
|
2557
2597
|
|
|
2558
2598
|
// src/conversion/html/document-presentation.ts
|
|
@@ -2562,10 +2602,17 @@ function resolveDocumentPresentation(presentation) {
|
|
|
2562
2602
|
const textIndentCm = typeof presentation.textIndentCm === "number" && presentation.textIndentCm > 0 ? presentation.textIndentCm : void 0;
|
|
2563
2603
|
const listBlockIndentCm = typeof presentation.listBlockIndentCm === "number" && presentation.listBlockIndentCm > 0 ? presentation.listBlockIndentCm : void 0;
|
|
2564
2604
|
const paragraphSpacingAfterEm = typeof presentation.paragraphSpacingAfterEm === "number" && Number.isFinite(presentation.paragraphSpacingAfterEm) && presentation.paragraphSpacingAfterEm >= 0 ? presentation.paragraphSpacingAfterEm : void 0;
|
|
2565
|
-
|
|
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) {
|
|
2566
2607
|
return void 0;
|
|
2567
2608
|
}
|
|
2568
|
-
return {
|
|
2609
|
+
return {
|
|
2610
|
+
lineSpacing,
|
|
2611
|
+
paragraphSpacingAfterEm,
|
|
2612
|
+
paragraphSpacingBeforeEm,
|
|
2613
|
+
textIndentCm,
|
|
2614
|
+
listBlockIndentCm
|
|
2615
|
+
};
|
|
2569
2616
|
}
|
|
2570
2617
|
var TEXT_INDENT_TAGS = /* @__PURE__ */ new Set(["p"]);
|
|
2571
2618
|
function documentPresentationListWrapperStyleParts(resolved) {
|
|
@@ -2583,7 +2630,7 @@ function documentPresentationStyleParts(tag, resolved) {
|
|
|
2583
2630
|
function blockPresentationStyleParts(tag, blockAttributes, resolved) {
|
|
2584
2631
|
return [
|
|
2585
2632
|
...blockLineHeightStyleParts(tag, blockAttributes, resolved),
|
|
2586
|
-
...
|
|
2633
|
+
...blockParagraphMarginStyleParts(tag, blockAttributes, resolved),
|
|
2587
2634
|
...documentPresentationStyleParts(tag, resolved)
|
|
2588
2635
|
];
|
|
2589
2636
|
}
|
|
@@ -5222,12 +5269,15 @@ export {
|
|
|
5222
5269
|
Registry,
|
|
5223
5270
|
SCRIDER_LINE_HEIGHT_KEY,
|
|
5224
5271
|
SCRIDER_MARGIN_AFTER_KEY,
|
|
5272
|
+
SCRIDER_MARGIN_BEFORE_KEY,
|
|
5225
5273
|
alertBlockHandler,
|
|
5226
5274
|
alignFormat,
|
|
5227
5275
|
backgroundFormat,
|
|
5228
5276
|
blockFormat,
|
|
5229
5277
|
blockLineHeightStyleParts,
|
|
5230
5278
|
blockMarginAfterStyleParts,
|
|
5279
|
+
blockMarginBeforeStyleParts,
|
|
5280
|
+
blockParagraphMarginStyleParts,
|
|
5231
5281
|
blockPresentationStyleParts,
|
|
5232
5282
|
blockquoteFormat,
|
|
5233
5283
|
boldFormat,
|
|
@@ -5281,6 +5331,8 @@ export {
|
|
|
5281
5331
|
normalizeDelta,
|
|
5282
5332
|
parseScriderLineHeightMultiplier,
|
|
5283
5333
|
parseScriderMarginAfterEm,
|
|
5334
|
+
parseScriderMarginBeforeEm,
|
|
5335
|
+
parseScriderMarginEm,
|
|
5284
5336
|
preloadRemark,
|
|
5285
5337
|
resolveDocumentPresentation,
|
|
5286
5338
|
resolveTablePresentation,
|