@scrider/formatter 1.10.10 → 1.10.11

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
@@ -93,6 +93,16 @@ interface ScriderDocumentMetadata {
93
93
  textIndentCm?: number;
94
94
  /** Extra left indent in cm on top-level `<ul>`/`<ol>` (shifts marker + text). */
95
95
  listBlockIndentCm?: number;
96
+ /**
97
+ * GFM-style extra left indent for list markers (em of the document size).
98
+ * Default on when omitted. `false` aligns markers with paragraph text.
99
+ */
100
+ listLeftIndent?: boolean;
101
+ /**
102
+ * Extra space above/below a list block (beyond body line-height).
103
+ * Default on when omitted.
104
+ */
105
+ listTopPadding?: boolean;
96
106
  /** Document heading horizontal alignment policy. Presence = policy on. */
97
107
  headingAlign?: 'left' | 'center' | 'right';
98
108
  /** Document heading bold policy. `true` = force bold on `h1`–`h6`. */
package/dist/index.d.ts CHANGED
@@ -93,6 +93,16 @@ interface ScriderDocumentMetadata {
93
93
  textIndentCm?: number;
94
94
  /** Extra left indent in cm on top-level `<ul>`/`<ol>` (shifts marker + text). */
95
95
  listBlockIndentCm?: number;
96
+ /**
97
+ * GFM-style extra left indent for list markers (em of the document size).
98
+ * Default on when omitted. `false` aligns markers with paragraph text.
99
+ */
100
+ listLeftIndent?: boolean;
101
+ /**
102
+ * Extra space above/below a list block (beyond body line-height).
103
+ * Default on when omitted.
104
+ */
105
+ listTopPadding?: boolean;
96
106
  /** Document heading horizontal alignment policy. Presence = policy on. */
97
107
  headingAlign?: 'left' | 'center' | 'right';
98
108
  /** Document heading bold policy. `true` = force bold on `h1`–`h6`. */
package/dist/index.js CHANGED
@@ -4279,6 +4279,7 @@ function htmlToDelta(html, options = {}) {
4279
4279
  if (align) {
4280
4280
  currentBlockAttributes.align = align;
4281
4281
  }
4282
+ applyBlockIndentFromMargin(element);
4282
4283
  if (format.format === "header") {
4283
4284
  const id = element.getAttribute("id");
4284
4285
  if (id) {
@@ -4697,6 +4698,7 @@ function htmlToDelta(html, options = {}) {
4697
4698
  if (align) {
4698
4699
  currentBlockAttributes.align = align;
4699
4700
  }
4701
+ applyBlockIndentFromMargin(element);
4700
4702
  const children2 = element.childNodes;
4701
4703
  const firstChild = children2[0];
4702
4704
  const isBrOnlyParagraph = children2.length === 1 && firstChild !== void 0 && isElement(firstChild) && firstChild.tagName.toLowerCase() === "br" && !firstChild.hasAttribute("data-scrider-embed");
@@ -4713,6 +4715,26 @@ function htmlToDelta(html, options = {}) {
4713
4715
  }
4714
4716
  return null;
4715
4717
  }
4718
+ function parseIndentEm(raw) {
4719
+ if (!raw) return null;
4720
+ const match = raw.trim().match(/^(-?[\d.]+)em$/i);
4721
+ if (!match) return null;
4722
+ const em = Number.parseFloat(match[1]);
4723
+ if (!Number.isFinite(em) || em <= 0) return null;
4724
+ const level = Math.round(em / 2);
4725
+ if (level < 1 || level > 8) return null;
4726
+ return level;
4727
+ }
4728
+ function getIndentFromMarginLeft(element) {
4729
+ const fromAttr = (element.getAttribute?.("style") ?? "").match(/(?:^|;)\s*margin-left:\s*([^;]+)/i)?.[1];
4730
+ const fromStyle = element.style?.getPropertyValue?.("margin-left");
4731
+ return parseIndentEm(fromAttr) ?? parseIndentEm(fromStyle);
4732
+ }
4733
+ function applyBlockIndentFromMargin(element) {
4734
+ if (currentBlockAttributes.list != null) return;
4735
+ const indent = getIndentFromMarginLeft(element);
4736
+ if (indent != null) currentBlockAttributes.indent = indent;
4737
+ }
4716
4738
  const children = fragment.childNodes;
4717
4739
  for (let i = 0; i < children.length; i++) {
4718
4740
  const child = children[i];