@scrider/formatter 1.3.6 → 1.4.0

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
@@ -2608,11 +2608,18 @@ function resolveDocumentPresentation(presentation) {
2608
2608
  if (!presentation) return void 0;
2609
2609
  const lineSpacing = typeof presentation.lineSpacing === "number" && presentation.lineSpacing > 0 ? presentation.lineSpacing : void 0;
2610
2610
  const textIndentCm = typeof presentation.textIndentCm === "number" && presentation.textIndentCm > 0 ? presentation.textIndentCm : void 0;
2611
- if (lineSpacing === void 0 && textIndentCm === void 0) return void 0;
2612
- return { lineSpacing, textIndentCm };
2611
+ const listBlockIndentCm = typeof presentation.listBlockIndentCm === "number" && presentation.listBlockIndentCm > 0 ? presentation.listBlockIndentCm : void 0;
2612
+ if (lineSpacing === void 0 && textIndentCm === void 0 && listBlockIndentCm === void 0) {
2613
+ return void 0;
2614
+ }
2615
+ return { lineSpacing, textIndentCm, listBlockIndentCm };
2613
2616
  }
2614
2617
  var LINE_HEIGHT_TAGS = /* @__PURE__ */ new Set(["p", "li", "blockquote"]);
2615
2618
  var TEXT_INDENT_TAGS = /* @__PURE__ */ new Set(["p", "li"]);
2619
+ function documentPresentationListWrapperStyleParts(resolved) {
2620
+ if (!resolved?.listBlockIndentCm) return [];
2621
+ return [`padding-left:calc(1.5em + ${resolved.listBlockIndentCm}cm)`];
2622
+ }
2616
2623
  function documentPresentationStyleParts(tag, resolved) {
2617
2624
  if (!resolved) return [];
2618
2625
  const parts = [];
@@ -2737,7 +2744,13 @@ function deltaToHtml(delta, options = {}) {
2737
2744
  continue;
2738
2745
  }
2739
2746
  if (isList) {
2740
- html += handleListOpen(listStack, listType, indent, pretty);
2747
+ html += handleListOpen(
2748
+ listStack,
2749
+ listType,
2750
+ indent,
2751
+ pretty,
2752
+ resolvedDocumentPresentation
2753
+ );
2741
2754
  if (hierarchicalNumbers && listType === "ordered") {
2742
2755
  if (counters.length > indent + 1) {
2743
2756
  counters = counters.slice(0, indent + 1);
@@ -3016,9 +3029,13 @@ function renderCodeBlock(codeLines, language, embedRenderers, pretty, blockHandl
3016
3029
  </code></pre>`;
3017
3030
  return pretty ? html + "\n" : html;
3018
3031
  }
3019
- function handleListOpen(stack, listType, indent, pretty) {
3032
+ function handleListOpen(stack, listType, indent, pretty, resolvedDocumentPresentation) {
3020
3033
  let html = "";
3021
3034
  const wrapperTag = LIST_WRAPPER_TAGS[listType] || "ul";
3035
+ const openWrapperTag = () => {
3036
+ const styleAttr = stack.length === 0 ? joinStyleParts(documentPresentationListWrapperStyleParts(resolvedDocumentPresentation)) : "";
3037
+ return `<${wrapperTag}${styleAttr}>`;
3038
+ };
3022
3039
  while (stack.length > 0) {
3023
3040
  const last = stack[stack.length - 1];
3024
3041
  if (!last || last.indent <= indent) break;
@@ -3045,7 +3062,7 @@ function handleListOpen(stack, listType, indent, pretty) {
3045
3062
  const currentIndent = last ? last.indent + 1 : 0;
3046
3063
  if (currentIndent > indent) break;
3047
3064
  if (pretty) html += getIndent(stack.length);
3048
- html += `<${wrapperTag}>`;
3065
+ html += openWrapperTag();
3049
3066
  if (pretty) html += "\n";
3050
3067
  stack.push({ type: listType, indent: currentIndent });
3051
3068
  if (currentIndent >= indent) break;
@@ -3053,7 +3070,7 @@ function handleListOpen(stack, listType, indent, pretty) {
3053
3070
  const current = stack[stack.length - 1];
3054
3071
  if (!current || current.indent < indent) {
3055
3072
  if (pretty) html += getIndent(stack.length);
3056
- html += `<${wrapperTag}>`;
3073
+ html += openWrapperTag();
3057
3074
  if (pretty) html += "\n";
3058
3075
  stack.push({ type: listType, indent });
3059
3076
  }