@scrider/formatter 1.3.5 → 1.3.7

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.js CHANGED
@@ -2502,6 +2502,11 @@ function resolveDocumentPresentation(presentation) {
2502
2502
  return { lineSpacing, textIndentCm };
2503
2503
  }
2504
2504
  var LINE_HEIGHT_TAGS = /* @__PURE__ */ new Set(["p", "li", "blockquote"]);
2505
+ var TEXT_INDENT_TAGS = /* @__PURE__ */ new Set(["p"]);
2506
+ function documentPresentationListWrapperStyleParts(resolved) {
2507
+ if (!resolved?.textIndentCm) return [];
2508
+ return [`padding-left:calc(1.5em + ${resolved.textIndentCm}cm)`];
2509
+ }
2505
2510
  function documentPresentationStyleParts(tag, resolved) {
2506
2511
  if (!resolved) return [];
2507
2512
  const parts = [];
@@ -2510,7 +2515,7 @@ function documentPresentationStyleParts(tag, resolved) {
2510
2515
  parts.push(`line-height:${resolved.lineSpacing}`);
2511
2516
  parts.push(`mso-line-height-alt:${pct}%`);
2512
2517
  }
2513
- if (resolved.textIndentCm !== void 0 && tag === "p") {
2518
+ if (resolved.textIndentCm !== void 0 && TEXT_INDENT_TAGS.has(tag)) {
2514
2519
  parts.push(`text-indent:${resolved.textIndentCm}cm`);
2515
2520
  }
2516
2521
  return parts;
@@ -2626,7 +2631,13 @@ function deltaToHtml(delta, options = {}) {
2626
2631
  continue;
2627
2632
  }
2628
2633
  if (isList) {
2629
- html += handleListOpen(listStack, listType, indent, pretty);
2634
+ html += handleListOpen(
2635
+ listStack,
2636
+ listType,
2637
+ indent,
2638
+ pretty,
2639
+ resolvedDocumentPresentation
2640
+ );
2630
2641
  if (hierarchicalNumbers && listType === "ordered") {
2631
2642
  if (counters.length > indent + 1) {
2632
2643
  counters = counters.slice(0, indent + 1);
@@ -2905,9 +2916,13 @@ function renderCodeBlock(codeLines, language, embedRenderers, pretty, blockHandl
2905
2916
  </code></pre>`;
2906
2917
  return pretty ? html + "\n" : html;
2907
2918
  }
2908
- function handleListOpen(stack, listType, indent, pretty) {
2919
+ function handleListOpen(stack, listType, indent, pretty, resolvedDocumentPresentation) {
2909
2920
  let html = "";
2910
2921
  const wrapperTag = LIST_WRAPPER_TAGS[listType] || "ul";
2922
+ const openWrapperTag = () => {
2923
+ const styleAttr = stack.length === 0 ? joinStyleParts(documentPresentationListWrapperStyleParts(resolvedDocumentPresentation)) : "";
2924
+ return `<${wrapperTag}${styleAttr}>`;
2925
+ };
2911
2926
  while (stack.length > 0) {
2912
2927
  const last = stack[stack.length - 1];
2913
2928
  if (!last || last.indent <= indent) break;
@@ -2934,7 +2949,7 @@ function handleListOpen(stack, listType, indent, pretty) {
2934
2949
  const currentIndent = last ? last.indent + 1 : 0;
2935
2950
  if (currentIndent > indent) break;
2936
2951
  if (pretty) html += getIndent(stack.length);
2937
- html += `<${wrapperTag}>`;
2952
+ html += openWrapperTag();
2938
2953
  if (pretty) html += "\n";
2939
2954
  stack.push({ type: listType, indent: currentIndent });
2940
2955
  if (currentIndent >= indent) break;
@@ -2942,7 +2957,7 @@ function handleListOpen(stack, listType, indent, pretty) {
2942
2957
  const current = stack[stack.length - 1];
2943
2958
  if (!current || current.indent < indent) {
2944
2959
  if (pretty) html += getIndent(stack.length);
2945
- html += `<${wrapperTag}>`;
2960
+ html += openWrapperTag();
2946
2961
  if (pretty) html += "\n";
2947
2962
  stack.push({ type: listType, indent });
2948
2963
  }