@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.cjs CHANGED
@@ -2612,6 +2612,11 @@ function resolveDocumentPresentation(presentation) {
2612
2612
  return { lineSpacing, textIndentCm };
2613
2613
  }
2614
2614
  var LINE_HEIGHT_TAGS = /* @__PURE__ */ new Set(["p", "li", "blockquote"]);
2615
+ var TEXT_INDENT_TAGS = /* @__PURE__ */ new Set(["p"]);
2616
+ function documentPresentationListWrapperStyleParts(resolved) {
2617
+ if (!resolved?.textIndentCm) return [];
2618
+ return [`padding-left:calc(1.5em + ${resolved.textIndentCm}cm)`];
2619
+ }
2615
2620
  function documentPresentationStyleParts(tag, resolved) {
2616
2621
  if (!resolved) return [];
2617
2622
  const parts = [];
@@ -2620,7 +2625,7 @@ function documentPresentationStyleParts(tag, resolved) {
2620
2625
  parts.push(`line-height:${resolved.lineSpacing}`);
2621
2626
  parts.push(`mso-line-height-alt:${pct}%`);
2622
2627
  }
2623
- if (resolved.textIndentCm !== void 0 && tag === "p") {
2628
+ if (resolved.textIndentCm !== void 0 && TEXT_INDENT_TAGS.has(tag)) {
2624
2629
  parts.push(`text-indent:${resolved.textIndentCm}cm`);
2625
2630
  }
2626
2631
  return parts;
@@ -2736,7 +2741,13 @@ function deltaToHtml(delta, options = {}) {
2736
2741
  continue;
2737
2742
  }
2738
2743
  if (isList) {
2739
- html += handleListOpen(listStack, listType, indent, pretty);
2744
+ html += handleListOpen(
2745
+ listStack,
2746
+ listType,
2747
+ indent,
2748
+ pretty,
2749
+ resolvedDocumentPresentation
2750
+ );
2740
2751
  if (hierarchicalNumbers && listType === "ordered") {
2741
2752
  if (counters.length > indent + 1) {
2742
2753
  counters = counters.slice(0, indent + 1);
@@ -3015,9 +3026,13 @@ function renderCodeBlock(codeLines, language, embedRenderers, pretty, blockHandl
3015
3026
  </code></pre>`;
3016
3027
  return pretty ? html + "\n" : html;
3017
3028
  }
3018
- function handleListOpen(stack, listType, indent, pretty) {
3029
+ function handleListOpen(stack, listType, indent, pretty, resolvedDocumentPresentation) {
3019
3030
  let html = "";
3020
3031
  const wrapperTag = LIST_WRAPPER_TAGS[listType] || "ul";
3032
+ const openWrapperTag = () => {
3033
+ const styleAttr = stack.length === 0 ? joinStyleParts(documentPresentationListWrapperStyleParts(resolvedDocumentPresentation)) : "";
3034
+ return `<${wrapperTag}${styleAttr}>`;
3035
+ };
3021
3036
  while (stack.length > 0) {
3022
3037
  const last = stack[stack.length - 1];
3023
3038
  if (!last || last.indent <= indent) break;
@@ -3044,7 +3059,7 @@ function handleListOpen(stack, listType, indent, pretty) {
3044
3059
  const currentIndent = last ? last.indent + 1 : 0;
3045
3060
  if (currentIndent > indent) break;
3046
3061
  if (pretty) html += getIndent(stack.length);
3047
- html += `<${wrapperTag}>`;
3062
+ html += openWrapperTag();
3048
3063
  if (pretty) html += "\n";
3049
3064
  stack.push({ type: listType, indent: currentIndent });
3050
3065
  if (currentIndent >= indent) break;
@@ -3052,7 +3067,7 @@ function handleListOpen(stack, listType, indent, pretty) {
3052
3067
  const current = stack[stack.length - 1];
3053
3068
  if (!current || current.indent < indent) {
3054
3069
  if (pretty) html += getIndent(stack.length);
3055
- html += `<${wrapperTag}>`;
3070
+ html += openWrapperTag();
3056
3071
  if (pretty) html += "\n";
3057
3072
  stack.push({ type: listType, indent });
3058
3073
  }